Changeset 7922


Ignore:
Timestamp:
Aug 5, 2010, 8:20:47 PM (14 years ago)
Author:
mungkasi
Message:

Modifying codes so that arrays are compatible with numpy instead of Numeric.

Location:
trunk/anuga_work/development/sudi/sw_1d
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/sudi/sw_1d/avalanche/A_velocity/shallow_water_domain_avalanche.py

    r7914 r7922  
    668668    import sys
    669669    from Numeric import Float
    670     from numpy import zeros
     670    from numpy import array, zeros
    671671    from config import epsilon, h0
    672672
     
    719719
    720720    for i in range(N):                                         
    721         if h_V[i] <= 0.0:
    722             h_V[i] = 0.0
     721        if min(h_V[i]) <= 0.0:
     722            h_V[i] = array([0.0, 0.0])
    723723            stage_V[i] = bed_V[i]
    724             xmom_V[i] = 0.0
     724            xmom_V[i] = array([0.0, 0.0])
    725725   
    726726    u_V[:]  = xmom_V/(h_V + h0/h_V)   
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/cg/analytical_prescription.py

    r7837 r7922  
    4545
    4646def prescribe(x,t):
    47     from Numeric import array, zeros, Float
     47    from Numeric import Float
     48    from numpy import array, zeros
    4849    q_shore = shore(t)
    4950    q = zeros(2,Float)
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/cg/domain.py

    r7837 r7922  
    2424        """
    2525
    26         from Numeric import array, zeros, Float, Int
    27 
     26        from Numeric import Float, Int
     27        from numpy import array, zeros
    2828        from config import timestepping_method
    2929        from config import CFL
     
    175175          self.vertexlist is built
    176176        """
    177         from Numeric import array
     177        from numpy import array
    178178
    179179        vertexlist = [None]*len(self.coordinates)
     
    322322            self.element_tag is defined
    323323        """
    324         from Numeric import array, Int
     324        from Numeric import Int
     325        from numpy import array
    325326
    326327        if tagged_elements is None:
     
    393394
    394395        if obj is True:
    395             from Numeric import concatenate, reshape
     396            from numpy import concatenate, reshape
    396397            V = self.vertices
    397398            N = V.shape[0]
     
    412413        """
    413414
    414         from Numeric import zeros, Float
     415        from Numeric import Float
     416        from numpy import zeros
    415417        q = zeros( len(self.conserved_quantities), Float)
    416418        for i, name in enumerate(self.conserved_quantities):
     
    436438        """
    437439
    438         from Numeric import zeros, Float
     440        from Numeric import Float
     441        from numpy import zeros
    439442        q = zeros( len(self.evolved_quantities), Float)
    440443
     
    10781081        """
    10791082        import copy
    1080         from Numeric import zeros,Float
     1083        from Numeric import Float
     1084        from numpy import zeros
    10811085
    10821086        N = self.number_of_elements
     
    11361140        """
    11371141        import copy
    1138         from Numeric import zeros,Float
     1142        from Numeric import Float
     1143        from numpy import zeros
    11391144
    11401145        N = self.number_of_elements
     
    13541359        """
    13551360
    1356         from Numeric import ones, sum, equal, Float
     1361        from Numeric import Float
     1362        from numpy import ones, sum, equal       
    13571363
    13581364        N = self.number_of_elements
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/cg/domain_cg.py

    r7837 r7922  
    218218    """
    219219
    220     from Numeric import zeros, Float
     220    from Numeric import Float
     221    from numpy import zeros
    221222
    222223    assert len(q) == 3,\
     
    266267    from config import g, epsilon, h0
    267268    from math import sqrt
    268     from Numeric import array
     269    from numpy import array
    269270
    270271    #Align momentums with x-axis
     
    336337def compute_timestep(domain):
    337338    import sys
    338     from Numeric import zeros, Float
     339    from Numeric import Float
     340    from numpy import zeros
    339341
    340342    N = domain.number_of_elements
     
    398400def compute_fluxes_C_wellbalanced(domain):
    399401    import sys
    400     from Numeric import zeros, Float
     402    from Numeric import Float
     403    from numpy import zeros
    401404   
    402405    N = domain.number_of_elements
     
    506509
    507510    import sys
    508     from Numeric import zeros, Float
     511    from Numeric import Float
     512    from numpy import zeros
    509513    from config import epsilon, h0, h_min
    510514
     
    600604    """
    601605
    602     from Numeric import zeros, Float
     606    from Numeric import Float
     607    from numpy import zeros
    603608
    604609    N = domain.number_of_elements
     
    767772
    768773    from util import gradient
    769     from Numeric import zeros, Float, array, sum
     774    from Numeric import Float
     775    from numpy import zeros, array, sum
    770776
    771777    xmom = domain.quantities['xmomentum'].explicit_update
     
    865871    """
    866872
    867     from Numeric import ones, Float, array
     873    from Numeric import Float
     874    from numpy import ones, array   
    868875
    869876
     
    947954
    948955        from config import rho_a, rho_w, eta_w
    949         from Numeric import array, Float
     956        from Numeric import Float
     957        from numpy import array
    950958
    951959        if len(args) == 2:
     
    978986
    979987        from math import pi, cos, sin, sqrt
    980         from Numeric import Float, ones, ArrayType
     988        from Numeric import Float
     989        from numpy import ones, ArrayType       
    981990
    982991        xmom_update = domain.quantities['xmomentum'].explicit_update
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/cg/generic_boundary_conditions.py

    r7837 r7922  
    4343        self.velocity = domain.quantities['velocity'].vertex_values
    4444
    45         from Numeric import zeros, Float
     45        from Numeric import Float
     46        from numpy import zeros
    4647        self.evolved_quantities = zeros(5, Float)
    4748
     
    103104            raise msg
    104105
    105         from Numeric import array, Float
     106        from Numeric import Float
     107        from numpy import array
    106108        self.conserved_quantities=array(conserved_quantities).astype(Float)
    107109
     
    132134
    133135
    134         from Numeric import array, Float
     136        from Numeric import Float
     137        from numpy import array
    135138        try:
    136139            q = array(q).astype(Float)
     
    173176    def __init__(self, filename, domain):
    174177        import time
    175         from Numeric import array
     178        from numpy import array
    176179        from config import time_format
    177180        from util import File_function
     
    223226    def __init__(self, filename, domain, verbose = False):
    224227        import time
    225         from Numeric import array, zeros, Float
     228        from Numeric import Float
     229        from numpy import array, zeros
    226230        from config import time_format
    227231        from util import file_function
     
    421425    def __init__(self, domain = None, filename = None):
    422426        import time
    423         from Numeric import array
     427        from numpy import array
    424428        from config import time_format
    425429
     
    479483
    480484    def read_time_boundary(self):
    481         from Numeric import zeros, Float, alltrue
     485        from Numeric import Float
     486        from numpy import zeros, alltrue       
    482487        from config import time_format
    483488        import time
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/cg/parameter.py

    r7837 r7922  
    22from scipy import pi, sqrt, linspace, pi, sin, cos
    33from config import g
    4 from Numeric import zeros, Float
     4from Numeric import Float
     5from numpy import zeros
    56from rootsearch import *
    67from bisect import *
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/cg/quantity.py

    r7837 r7922  
    2424
    2525        from domain import Domain
    26         from Numeric import array, zeros, Float
     26        from Numeric import Float
     27        from numpy import array, zeros
    2728
    2829        msg = 'First argument in Quantity.__init__ '
     
    6061
    6162
    62         from Numeric import zeros, Float
     63        from Numeric import Float
     64        from numpy import zeros
    6365       
    6466        #Allocate space for boundary values
     
    194196        """
    195197
    196         from Numeric import array, Float
     198        from Numeric import Float
     199        from numpy import zeros
    197200
    198201        values = array(values).astype(Float)
     
    237240
    238241        """
    239         from Numeric import take
     242        from numpy import take
    240243
    241244        if location not in ['vertices', 'centroids', 'unique vertices']:
     
    310313        """
    311314
    312         from Numeric import concatenate, zeros, Float, Int, array, reshape
     315        from Numeric import Float, Int
     316        from numpy import concatenate, zeros, array, reshape       
    313317
    314318
     
    402406        """
    403407
    404         from Numeric import sum, equal, ones, Float
     408        from Numeric import Float
     409        from numpy import sum, equal, ones
    405410
    406411        N = self.centroid_values.shape[0]
     
    427432        #print 'compute_gradient'
    428433
    429         from Numeric import array, zeros, Float
     434        from Numeric import Float
     435        from numpy import array, zeros
    430436
    431437        N = self.centroid_values.shape[0]
     
    518524        #print 'compute_minmod_gradients'
    519525       
    520         from Numeric import array, zeros, Float,sign
     526        from Numeric import Float,sign
     527        from numpy import array, zeros
    521528       
    522529        def xmin(a,b):
     
    712719        vertex values are updated
    713720        """
    714         from Numeric import zeros, Float
     721        from Numeric import Float
     722        from numpy import zeros
    715723
    716724        N = self.domain.number_of_elements
     
    763771    def limit_range(self):
    764772        import sys
    765         from Numeric import zeros, Float
     773        from Numeric import Float
     774        from numpy import zeros
    766775        from util import minmod, minmod_kurganov, maxmod, vanleer, vanalbada
    767776        limiter = self.domain.limiter
     
    822831
    823832        import sys
    824         from Numeric import zeros, Float
     833        from Numeric import Float
     834        from numpy import zeros
    825835        from util import minmod, minmod_kurganov, maxmod, vanleer
    826836
     
    950960    #from domain import Domain
    951961    from domain_cg import Domain   
    952     from Numeric import arange
     962    from numpy import arange
    953963   
    954964    points1 = [0.0, 1.0, 2.0, 3.0]
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/cg/run-discrepancy.py

    r7837 r7922  
    44from rootsearch import *
    55from bisect import *
    6 from Numeric import zeros,Float,dot
     6from Numeric import Float
     7from numpy import zeros,dot
    78from gaussPivot import *
    89from config import g
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/cg/run-program.py

    r7837 r7922  
    11from scipy import sin, cos, sqrt, linspace, pi, dot
    2 from Numeric import zeros, Float, array
     2from Numeric import Float
     3from numpy import zeros, array
    34from gaussPivot import *
    45from analytical_prescription import *
     
    134135
    135136waktu = 10.0     #3.0*60.0
    136 WAKTU = 12690.0  #20.0*Tp  #Note: Tp=15.0*60.0
     137WAKTU = 10.0#12690.0  #20.0*Tp  #Note: Tp=15.0*60.0
    137138yieldstep = finaltime = waktu
    138139t0 = time.time()
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/cg/util.py

    r7837 r7922  
    44
    55def mean(x):
    6     from Numeric import sum
     6    from numpy import sum
    77    return sum(x)/len(x)
    88
     
    142142
    143143def analytic_cannal(C,t):
    144     from Numeric import zeros, Float,sqrt,sin,cos
     144    from Numeric import Float,sqrt,sin,cos
     145    from numpy import zeros
    145146
    146147   
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/johns/analytical_prescription.py

    r7837 r7922  
    2727
    2828def prescribe(x,t):
    29     from Numeric import array, zeros, Float
     29    from Numeric import Float
     30    from numpy import array, zeros
    3031    if x<1.0:
    3132        q = zeros(2,Float)
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/johns/domain.py

    r7837 r7922  
    2424        """
    2525
    26         from Numeric import array, zeros, Float, Int
     26        from Numeric import Float, Int
     27        from numpy import array, zeros
    2728
    2829        from config import timestepping_method
     
    175176          self.vertexlist is built
    176177        """
    177         from Numeric import array
     178        from numpy import array
    178179
    179180        vertexlist = [None]*len(self.coordinates)
     
    322323            self.element_tag is defined
    323324        """
    324         from Numeric import array, Int
     325        from Numeric import Int
     326        from numpy import array
    325327
    326328        if tagged_elements is None:
     
    393395
    394396        if obj is True:
    395             from Numeric import concatenate, reshape
     397            from numpy import concatenate, reshape
    396398            V = self.vertices
    397399            N = V.shape[0]
     
    412414        """
    413415
    414         from Numeric import zeros, Float
     416        from Numeric import Float
     417        from numpy import zeros       
    415418        q = zeros( len(self.conserved_quantities), Float)
    416419        for i, name in enumerate(self.conserved_quantities):
     
    436439        """
    437440
    438         from Numeric import zeros, Float
     441        from Numeric import Float
     442        from numpy import zeros   
    439443        q = zeros( len(self.evolved_quantities), Float)
    440444
     
    10781082        """
    10791083        import copy
    1080         from Numeric import zeros,Float
     1084        from Numeric import Float
     1085        from numpy import zeros   
    10811086
    10821087        N = self.number_of_elements
     
    11361141        """
    11371142        import copy
    1138         from Numeric import zeros,Float
     1143        from Numeric import Float
     1144        from numpy import zeros   
    11391145
    11401146        N = self.number_of_elements
     
    13351341        """
    13361342
    1337         from Numeric import ones, sum, equal, Float
     1343        from Numeric import Float
     1344        from numpy import ones, sum, equal
    13381345
    13391346        N = self.number_of_elements
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/johns/domain_johns.py

    r7837 r7922  
    218218    """
    219219
    220     from Numeric import zeros, Float
     220    from Numeric import Float
     221    from numpy import zeros
    221222
    222223    assert len(q) == 3,\
     
    266267    from config import g, epsilon, h0
    267268    from math import sqrt
    268     from Numeric import array
     269    from numpy import array
    269270
    270271    #Align momentums with x-axis
     
    336337def compute_timestep(domain):
    337338    import sys
    338     from Numeric import zeros, Float
     339    from Numeric import Float
     340    from numpy import zeros
    339341
    340342    N = domain.number_of_elements
     
    398400def compute_fluxes_C_wellbalanced(domain):
    399401    import sys
    400     from Numeric import zeros, Float
     402    from Numeric import Float
     403    from numpy import zeros
    401404   
    402405    N = domain.number_of_elements
     
    506509
    507510    import sys
    508     from Numeric import zeros, Float
     511    from Numeric import Float
     512    from numpy import zeros
    509513    from config import epsilon, h0, h_min
    510514
     
    600604    """
    601605
    602     from Numeric import zeros, Float
     606    from Numeric import Float
     607    from numpy import zeros
    603608
    604609    N = domain.number_of_elements
     
    767772
    768773    from util import gradient
    769     from Numeric import zeros, Float, array, sum
     774    from Numeric import Float
     775    from numpy import zeros, array, sum   
    770776
    771777    xmom = domain.quantities['xmomentum'].explicit_update
     
    865871    """
    866872
    867     from Numeric import ones, Float, array
     873    from Numeric import Float
     874    from numpy import ones, array   
    868875
    869876
     
    947954
    948955        from config import rho_a, rho_w, eta_w
    949         from Numeric import array, Float
     956        from Numeric import Float
     957        from numpy import array
    950958
    951959        if len(args) == 2:
     
    978986
    979987        from math import pi, cos, sin, sqrt
    980         from Numeric import Float, ones, ArrayType
     988        from Numeric import Float, ArrayType
     989        from numpy import ones
    981990
    982991        xmom_update = domain.quantities['xmomentum'].explicit_update
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/johns/generic_boundary_conditions.py

    r7837 r7922  
    4343        self.velocity = domain.quantities['velocity'].vertex_values
    4444
    45         from Numeric import zeros, Float
     45        from Numeric import Float
     46        from numpy import zeros
    4647        self.evolved_quantities = zeros(5, Float)
    4748
     
    103104            raise msg
    104105
    105         from Numeric import array, Float
     106        from Numeric import Float
     107        from numpy import array             
    106108        self.conserved_quantities=array(conserved_quantities).astype(Float)
    107109
     
    132134
    133135
    134         from Numeric import array, Float
     136        from Numeric import Float
     137        from numpy import array       
    135138        try:
    136139            q = array(q).astype(Float)
     
    173176    def __init__(self, filename, domain):
    174177        import time
    175         from Numeric import array
     178        from numpy import array
    176179        from config import time_format
    177180        from util import File_function
     
    223226    def __init__(self, filename, domain, verbose = False):
    224227        import time
    225         from Numeric import array, zeros, Float
     228        from Numeric import Float
     229        from numpy import array, zeros
    226230        from config import time_format
    227231        from util import file_function
     
    421425    def __init__(self, domain = None, filename = None):
    422426        import time
    423         from Numeric import array
     427        from numpy import array
    424428        from config import time_format
    425429
     
    479483
    480484    def read_time_boundary(self):
    481         from Numeric import zeros, Float, alltrue
     485        from Numeric import Float
     486        from numpy import zeros, alltrue       
    482487        from config import time_format
    483488        import time
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/johns/parameter.py

    r7837 r7922  
    22from scipy import pi, sqrt, linspace, pi, sin, cos
    33from config import g
    4 from Numeric import zeros, Float
     4from Numeric import Float
     5from numpy import zeros
    56from rootsearch import *
    67from bisect import *
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/johns/quantity.py

    r7837 r7922  
    2424
    2525        from domain import Domain
    26         from Numeric import array, zeros, Float
     26        from Numeric import Float
     27        from numpy import array, zeros
    2728
    2829        msg = 'First argument in Quantity.__init__ '
     
    6061
    6162
    62         from Numeric import zeros, Float
     63        from Numeric import Float
     64        from numpy import zeros
    6365       
    6466        #Allocate space for boundary values
     
    194196        """
    195197
    196         from Numeric import array, Float
     198        from Numeric import Float
     199        from numpy import array
    197200
    198201        values = array(values).astype(Float)
     
    237240
    238241        """
    239         from Numeric import take
     242        from numpy import take
    240243
    241244        if location not in ['vertices', 'centroids', 'unique vertices']:
     
    310313        """
    311314
    312         from Numeric import concatenate, zeros, Float, Int, array, reshape
     315        from Numeric import Float, Int
     316        from numpy import concatenate, zeros, array, reshape       
    313317
    314318
     
    402406        """
    403407
    404         from Numeric import sum, equal, ones, Float
     408        from Numeric import Float
     409        from numpy import sum, equal, ones
    405410
    406411        N = self.centroid_values.shape[0]
     
    427432        #print 'compute_gradient'
    428433
    429         from Numeric import array, zeros, Float
     434        from Numeric import Float
     435        from numpy import array, zeros
    430436
    431437        N = self.centroid_values.shape[0]
     
    518524        #print 'compute_minmod_gradients'
    519525       
    520         from Numeric import array, zeros, Float,sign
     526        from Numeric import Float,sign
     527        from numpy import array, zeros
    521528       
    522529        def xmin(a,b):
     
    712719        vertex values are updated
    713720        """
    714         from Numeric import zeros, Float
     721        from Numeric import Float
     722        from numpy import zeros
    715723
    716724        N = self.domain.number_of_elements
     
    763771    def limit_range(self):
    764772        import sys
    765         from Numeric import zeros, Float
     773        from Numeric import Float
     774        from numpy import zeros
    766775        from util import minmod, minmod_kurganov, maxmod, vanleer, vanalbada
    767776        limiter = self.domain.limiter
     
    822831
    823832        import sys
    824         from Numeric import zeros, Float
     833        from Numeric import Float
     834        from numpy import zeros
    825835        from util import minmod, minmod_kurganov, maxmod, vanleer
    826836
     
    947957    #from domain import Domain
    948958    from domain_johns import Domain   
    949     from Numeric import arange
     959    from numpy import arange
    950960   
    951961    points1 = [0.0, 1.0, 2.0, 3.0]
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/johns/run-discrepancy.py

    r7837 r7922  
    44from rootsearch import *
    55from bisect import *
    6 from Numeric import zeros,Float,dot
     6from Numeric import Float
     7from numpy import zeros,dot
    78from gaussPivot import *
    89from config import g
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/johns/run-program.py

    r7837 r7922  
    11from scipy import sin, cos, sqrt, linspace, pi, dot
    2 from Numeric import zeros, Float, array
     2from Numeric import Float
     3from numpy import zeros,array
    34from gaussPivot import *
    45from analytical_prescription import *
     
    134135
    135136waktu = 10.0     #3.0*60.0
    136 WAKTU = 12690.0  #Note: Tp=15.0*60.0
     137WAKTU = 10.0#12690.0  #Note: Tp=15.0*60.0
    137138yieldstep = finaltime = waktu
    138139t0 = time.time()
  • trunk/anuga_work/development/sudi/sw_1d/periodic_waves/johns/util.py

    r7837 r7922  
    44
    55def mean(x):
    6     from Numeric import sum
     6    from numpy import sum
    77    return sum(x)/len(x)
    88
     
    142142
    143143def analytic_cannal(C,t):
    144     from Numeric import zeros, Float,sqrt,sin,cos
     144    from Numeric import Float,sqrt,sin,cos
     145    from numpy import zeros
    145146
    146147   
Note: See TracChangeset for help on using the changeset viewer.