Ignore:
Timestamp:
Feb 10, 2009, 11:11:04 AM (16 years ago)
Author:
rwilson
Message:

Initial commit of numpy changes. Still a long way to go.

Location:
branches/numpy
Files:
1 deleted
17 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/shallow_water/benchmark_sww2dem.py

    r6162 r6304  
    2525
    2626from Scientific.IO.NetCDF import NetCDFFile
    27 import Numeric as num
     27import numpy as num
    2828
    2929from anuga.fit_interpolate.interpolate import Interpolate
     
    101101    sww_fileName = tempfile.mktemp(".sww" )
    102102    # sww_fileName = "aa.sww"
    103     elevation = num.array(range(len(mesh_dict["vertices"])), num.Int)      #array default#
     103    elevation = num.array(range(len(mesh_dict["vertices"])), num.int)      #array default#
    104104    stage = elevation
    105105    ymomentum = elevation
     
    111111    sww.store_header(fid, 0,
    112112               len(mesh_dict['triangles']),
    113                len(mesh_dict["vertices"]),sww_precision=num.Float)
     113               len(mesh_dict["vertices"]),sww_precision=num.float)
    114114    sww.store_triangulation(fid,
    115115                      mesh_dict["vertices"], mesh_dict['triangles'],
  • branches/numpy/anuga/shallow_water/data_manager.py

    r6224 r6304  
    6161from os import sep, path, remove, mkdir, access, F_OK, W_OK, getcwd
    6262
    63 import Numeric as num
     63import numpy as num
    6464
    6565from Scientific.IO.NetCDF import NetCDFFile
     
    7676     default_minimum_storable_height
    7777from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
     78from anuga.config import netcdf_float, netcdf_float32, netcdf_int
    7879from anuga.config import max_float
    7980from anuga.utilities.numerical_tools import ensure_numeric,  mean
     
    343344        from Scientific.IO.NetCDF import NetCDFFile
    344345
    345         self.precision = num.Float32 #Use single precision for quantities
     346        self.precision = netcdf_float32 #Use single precision for quantities
    346347        self.recursion = recursion
    347348        self.mode = mode
     
    438439
    439440        # store the connectivity data
    440         points = num.concatenate( (X[:,num.NewAxis],Y[:,num.NewAxis]), axis=1 )
     441        points = num.concatenate( (X[:,num.newaxis],Y[:,num.newaxis]), axis=1 )
    441442        self.writer.store_triangulation(fid,
    442443                                        points,
    443 #                                        V.astype(volumes.typecode()),
    444                                         V.astype(num.Float32),
     444                                        V.astype(num.float32),
    445445                                        Z,
    446446                                        points_georeference=\
     
    561561                # Define a zero vector of same size and type as A
    562562                # for use with momenta
    563                 null = num.zeros(num.size(A), A.typecode())
     563                null = num.zeros(num.size(A), A.dtype.char) #??#
    564564
    565565                # Get xmomentum where depth exceeds minimum_storable_height
     
    622622        from Scientific.IO.NetCDF import NetCDFFile
    623623
    624         self.precision = num.Float #Use full precision
     624        self.precision = netcdf_float #Use full precision
    625625
    626626        Data_format.__init__(self, domain, 'sww', mode)
     
    650650
    651651
    652             fid.createVariable('volumes', num.Int, ('number_of_volumes',
    653                                                     'number_of_vertices'))
     652            fid.createVariable('volumes', netcdf_int, ('number_of_volumes',
     653                                                       'number_of_vertices'))
    654654
    655655            fid.createVariable('time', self.precision, ('number_of_timesteps',))
     
    13041304
    13051305    M = size  #Number of lines
    1306     xx = num.zeros((M,3), num.Float)
    1307     yy = num.zeros((M,3), num.Float)
    1308     zz = num.zeros((M,3), num.Float)
     1306    xx = num.zeros((M,3), num.float)
     1307    yy = num.zeros((M,3), num.float)
     1308    zz = num.zeros((M,3), num.float)
    13091309
    13101310    for i in range(M):
     
    13491349
    13501350    M = len(lines)  #Number of lines
    1351     x = num.zeros((M,3), num.Float)
    1352     y = num.zeros((M,3), num.Float)
    1353     z = num.zeros((M,3), num.Float)
     1351    x = num.zeros((M,3), num.float)
     1352    y = num.zeros((M,3), num.float)
     1353    z = num.zeros((M,3), num.float)
    13541354
    13551355    for i, line in enumerate(lines):
     
    14091409# @param step Timestep stride.
    14101410def filter_netcdf(filename1, filename2, first=0, last=None, step=1):
    1411     """Read netcdf filename1, pick timesteps first:step:last and save to
     1411    """Filter data file, selecting timesteps first:step:last.
     1412   
     1413    Read netcdf filename1, pick timesteps first:step:last and save to
    14121414    nettcdf file filename2
    14131415    """
     
    14261428    for name in infile.variables:
    14271429        var = infile.variables[name]
    1428         outfile.createVariable(name, var.typecode(), var.dimensions)
     1430        outfile.createVariable(name, var.dtype.char, var.dimensions)    #??#
    14291431
    14301432    # Copy the static variables
     
    14991501    Convert to NetCDF pts format which is
    15001502
    1501     points:  (Nx2) Float array
    1502     elevation: N Float array
     1503    points:  (Nx2) float array
     1504    elevation: N float array
    15031505    """
    15041506
     
    16581660
    16591661    # Variable definitions
    1660     outfile.createVariable('points', num.Float, ('number_of_points',
    1661                                                  'number_of_dimensions'))
    1662     outfile.createVariable('elevation', num.Float, ('number_of_points',))
     1662    outfile.createVariable('points', netcdf_float, ('number_of_points',
     1663                                                    'number_of_dimensions'))
     1664    outfile.createVariable('elevation', netcdf_float, ('number_of_points',))
    16631665
    16641666    # Get handles to the variables
     
    16841686            newcols = lenv              # ncols_in_bounding_box
    16851687
    1686         telev = num.zeros(newcols, num.Float)
    1687         tpoints = num.zeros((newcols, 2), num.Float)
     1688        telev = num.zeros(newcols, num.float)
     1689        tpoints = num.zeros((newcols, 2), num.float)
    16881690
    16891691        local_index = 0
     
    18011803    Convert to NetCDF pts format which is
    18021804
    1803     points:  (Nx2) Float array
    1804     elevation: N Float array
     1805    points:  (Nx2) float array
     1806    elevation: N float array
    18051807    """
    18061808
     
    22452247        # Comment out for reduced memory consumption
    22462248        for name in ['stage', 'xmomentum', 'ymomentum']:
    2247             q = fid.variables[name][:].flat
     2249            q = fid.variables[name][:].flatten()
    22482250            if timestep is not None:
    22492251                q = q[timestep*len(x):(timestep+1)*len(x)]
    22502252            if verbose: print '    %s in [%f, %f]' %(name, min(q), max(q))
    22512253        for name in ['elevation']:
    2252             q = fid.variables[name][:].flat
     2254            q = fid.variables[name][:].flatten()
    22532255            if verbose: print '    %s in [%f, %f]' %(name, min(q), max(q))
    22542256
     
    22562258    if verbose: print 'Processing quantity %s' %quantity
    22572259
    2258     # Turn NetCDF objects into Numeric arrays
     2260    # Turn NetCDF objects into numeric arrays
    22592261    try:
    22602262        q = fid.variables[quantity][:]
     
    22692271        #q has a time component, must be reduced alongthe temporal dimension
    22702272        if verbose: print 'Reducing quantity %s' %quantity
    2271         q_reduced = num.zeros(number_of_points, num.Float)
     2273        q_reduced = num.zeros(number_of_points, num.float)
    22722274
    22732275        if timestep is not None:
     
    23292331    y = y + yllcorner - newyllcorner
    23302332
    2331     vertex_points = num.concatenate ((x[:,num.NewAxis], y[:,num.NewAxis]), axis=1)
     2333    vertex_points = num.concatenate ((x[:,num.newaxis], y[:,num.newaxis]), axis=1)
    23322334    assert len(vertex_points.shape) == 2
    23332335
    2334     grid_points = num.zeros ((ncols*nrows, 2), num.Float)
     2336    grid_points = num.zeros ((ncols*nrows, 2), num.float)
    23352337
    23362338    for i in xrange(nrows):
     
    23592361    #Interpolate using quantity values
    23602362    if verbose: print 'Interpolating'
    2361     grid_values = interp.interpolate(q, grid_points).flat
     2363    grid_values = interp.interpolate(q, grid_points).flatten()
    23622364
    23632365    if verbose:
    2364         print 'Interpolated values are in [%f, %f]' %(min(grid_values),
    2365                                                       max(grid_values))
     2366        print 'Interpolated values are in [%f, %f]' %(min(grid_values.flat),
     2367                                                      max(grid_values.flat))
    23662368
    23672369    #Assign NODATA_value to all points outside bounding polygon (from interpolation mesh)
     
    26312633    if verbose: print 'Processing quantity %s' % quantity
    26322634
    2633     # Turn NetCDF objects into Numeric arrays
     2635    # Turn NetCDF objects into numeric arrays
    26342636    quantity_dict = {}
    26352637    for name in fid.variables.keys():
     
    26442646        if verbose: print 'Reducing quantity %s' % quantity
    26452647
    2646         q_reduced = num.zeros(number_of_points, num.Float)
     2648        q_reduced = num.zeros(number_of_points, num.float)
    26472649        for k in range(number_of_points):
    26482650            q_reduced[k] = reduction(q[:,k])
     
    26582660
    26592661    # Create grid and update xll/yll corner and x,y
    2660     vertex_points = num.concatenate((x[:, num.NewAxis], y[:, num.NewAxis]), axis=1)
     2662    vertex_points = num.concatenate((x[:, num.newaxis], y[:, num.newaxis]), axis=1)
    26612663    assert len(vertex_points.shape) == 2
    26622664
     
    26672669    # Interpolate using quantity values
    26682670    if verbose: print 'Interpolating'
    2669     interpolated_values = interp.interpolate(q, data_points).flat
     2671    interpolated_values = interp.interpolate(q, data_points).flatten
    26702672
    26712673    if verbose:
    2672         print 'Interpolated values are in [%f, %f]' % (min(interpolated_values),
    2673                                                        max(interpolated_values))
     2674        print 'Interpolated values are in [%f, %f]' \
     2675              % (min(interpolated_values.flat), max(interpolated_values.flat))
    26742676
    26752677    # Assign NODATA_value to all points outside bounding polygon
     
    28782880
    28792881    # variable definitions
    2880     fid.createVariable('elevation', num.Float, ('number_of_rows',
    2881                                                 'number_of_columns'))
     2882    fid.createVariable('elevation', netcdf_float, ('number_of_rows',
     2883                                                   'number_of_columns'))
    28822884
    28832885    # Get handles to the variables
     
    29592961    from Scientific.IO.NetCDF import NetCDFFile
    29602962
    2961     precision = num.Float
     2963    precision = num.float
    29622964
    29632965    msg = 'Must use latitudes and longitudes for minlat, maxlon etc'
     
    30783080    #        elevations = file_e.variables['ELEVATION'][kmin:kmax, lmin:lmax]
    30793081    #    elif latitudes2[0]==latitudes[-1] and latitudes2[-1]==latitudes[0]:
    3080     #        from Numeric import asarray
     3082    #        from numpy import asarray
    30813083    #        elevations=elevations.tolist()
    30823084    #        elevations.reverse()
    30833085    #        elevations=asarray(elevations)
    30843086    #    else:
    3085     #        from Numeric import asarray
     3087    #        from numpy import asarray
    30863088    #        elevations=elevations.tolist()
    30873089    #        elevations.reverse()
     
    31953197    sww.store_header(outfile, times, number_of_volumes,
    31963198                     number_of_points, description=description,
    3197                      verbose=verbose, sww_precision=num.Float)
     3199                     verbose=verbose, sww_precision=netcdf_float)
    31983200
    31993201    # Store
    32003202    from anuga.coordinate_transforms.redfearn import redfearn
    3201     x = num.zeros(number_of_points, num.Float)  #Easting
    3202     y = num.zeros(number_of_points, num.Float)  #Northing
     3203    x = num.zeros(number_of_points, num.float)  #Easting
     3204    y = num.zeros(number_of_points, num.float)  #Northing
    32033205
    32043206    if verbose: print 'Making triangular grid'
     
    32343236            volumes.append([v4,v3,v2]) #Lower element
    32353237
    3236     volumes = num.array(volumes, num.Int)      #array default#
     3238    volumes = num.array(volumes)
    32373239
    32383240    if origin is None:
     
    32553257    outfile.variables['z'][:] = z             #FIXME HACK for bacwards compat.
    32563258    outfile.variables['elevation'][:] = z
    3257     outfile.variables['volumes'][:] = volumes.astype(num.Int32) #For Opteron 64
     3259    outfile.variables['volumes'][:] = volumes.astype(num.int32) #For Opteron 64
    32583260
    32593261    #Time stepping
     
    33873389    d = len(q)
    33883390
    3389     T = num.zeros(N, num.Float)       # Time
    3390     Q = num.zeros((N, d), num.Float)  # Values
     3391    T = num.zeros(N, num.float)       # Time
     3392    Q = num.zeros((N, d), num.float)  # Values
    33913393
    33923394    for i, line in enumerate(lines):
     
    34243426    fid.createDimension('number_of_timesteps', len(T))
    34253427
    3426     fid.createVariable('time', num.Float, ('number_of_timesteps',))
     3428    fid.createVariable('time', netcdf_float, ('number_of_timesteps',))
    34273429
    34283430    fid.variables['time'][:] = T
     
    34343436            name = 'Attribute%d' % i
    34353437
    3436         fid.createVariable(name, num.Float, ('number_of_timesteps',))
     3438        fid.createVariable(name, netcdf_float, ('number_of_timesteps',))
    34373439        fid.variables[name][:] = Q[:,i]
    34383440
     
    35053507    time_interp = get_time_interp(time,t)
    35063508
    3507     # Get the variables as Numeric arrays
     3509    # Get the variables as numeric arrays
    35083510    x = fid.variables['x'][:]                   # x-coordinates of vertices
    35093511    y = fid.variables['y'][:]                   # y-coordinates of vertices
     
    35183520    # FIXME (Ole): Something like this might be better:
    35193521    #                 concatenate((x, y), axis=1)
    3520     # or              concatenate((x[:,num.NewAxis], x[:,num.NewAxis]), axis=1)
     3522    # or              concatenate((x[:,num.newaxis], x[:,num.newaxis]), axis=1)
    35213523
    35223524    conserved_quantities = []
     
    37063708# @param boundary
    37073709def weed(coordinates, volumes, boundary=None):
    3708     if type(coordinates) == num.ArrayType:
     3710    if isinstance(coordinates, num.ndarray):
    37093711        coordinates = coordinates.tolist()
    3710     if type(volumes) == num.ArrayType:
     3712    if isinstance(volumes, num.ndarray):
    37113713        volumes = volumes.tolist()
    37123714
     
    38543856
    38553857    # variable definition
    3856     outfile.createVariable('elevation', num.Float, ('number_of_points',))
     3858    outfile.createVariable('elevation', netcdf_float, ('number_of_points',))
    38573859
    38583860    # Get handle to the variable
     
    38673869
    38683870        lower_index = global_index
    3869         telev = num.zeros(ncols_new, num.Float)
     3871        telev = num.zeros(ncols_new, num.float)
    38703872        local_index = 0
    38713873        trow = i * cellsize_ratio
     
    39953997    from anuga.coordinate_transforms.redfearn import redfearn
    39963998
    3997     precision = num.Float # So if we want to change the precision its done here
     3999    precision = netcdf_float # So if we want to change the precision its done here
    39984000
    39994001    # go in to the bath dir and load the only file,
     
    40964098    #################################
    40974099
    4098     outfile.createVariable('volumes', num.Int, ('number_of_volumes',
    4099                                                 'number_of_vertices'))
     4100    outfile.createVariable('volumes', netcdf_int, ('number_of_volumes',
     4101                                                   'number_of_vertices'))
    41004102
    41014103    outfile.createVariable('time', precision, ('number_of_timesteps',))
     
    41134115    from anuga.coordinate_transforms.redfearn import redfearn
    41144116
    4115     x = num.zeros(number_of_points, num.Float)  #Easting
    4116     y = num.zeros(number_of_points, num.Float)  #Northing
     4117    x = num.zeros(number_of_points, num.float)  #Easting
     4118    y = num.zeros(number_of_points, num.float)  #Northing
    41174119
    41184120    if verbose: print 'Making triangular grid'
     
    41504152            volumes.append([v4,v2,v3]) #Lower element
    41514153
    4152     volumes = num.array(volumes, num.Int)      #array default#
     4154    volumes = num.array(volumes)
    41534155
    41544156    geo_ref = Geo_reference(refzone, min(x), min(y))
     
    41754177    outfile.variables['z'][:] = z
    41764178    outfile.variables['elevation'][:] = z
    4177     outfile.variables['volumes'][:] = volumes.astype(num.Int32) # On Opteron 64
     4179    outfile.variables['volumes'][:] = volumes.astype(num.int32) # On Opteron 64
    41784180
    41794181    stage = outfile.variables['stage']
     
    43674369lat_name = 'LAT'
    43684370time_name = 'TIME'
    4369 precision = num.Float # So if we want to change the precision its done here
     4371precision = netcdf_float # So if we want to change the precision its done here
    43704372
    43714373##
     
    46484650    lonlatdep = p_array.array('f')
    46494651    lonlatdep.read(mux_file, columns * points_num)
    4650     lonlatdep = num.array(lonlatdep, typecode=num.Float)
     4652    lonlatdep = num.array(lonlatdep, dtype=num.float)
    46514653    lonlatdep = num.reshape(lonlatdep, (points_num, columns))
    46524654
     
    46554657    lon_sorted.sort()
    46564658
    4657     if not lon == lon_sorted:
     4659    if not num.alltrue(lon == lon_sorted):
    46584660        msg = "Longitudes in mux file are not in ascending order"
    46594661        raise IOError, msg
     
    46614663    lat_sorted = list(lat)
    46624664    lat_sorted.sort()
    4663 
    4664 # UNUSED?
    4665 ##    if not lat == lat_sorted:
    4666 ##        msg = "Latitudes in mux file are not in ascending order"
    46674665
    46684666    nc_file = Write_nc(quantity,
     
    46774675        hz_p_array = p_array.array('f')
    46784676        hz_p_array.read(mux_file, points_num)
    4679         hz_p = num.array(hz_p_array, typecode=num.Float)
     4677        hz_p = num.array(hz_p_array, dtype=num.float)
    46804678        hz_p = num.reshape(hz_p, (len(lon), len(lat)))
    46814679        hz_p = num.transpose(hz_p)  # mux has lat varying fastest, nc has long v.f.
     
    47754773    QUANTITY = 2
    47764774
    4777     long_lat_dep = ensure_numeric(long_lat_dep, num.Float)
     4775    long_lat_dep = ensure_numeric(long_lat_dep, num.float)
    47784776
    47794777    num_points = long_lat_dep.shape[0]
     
    48134811    # FIXME - make this faster/do this a better way
    48144812    # use numeric transpose, after reshaping the quantity vector
    4815     quantity = num.zeros(num_points, num.Float)
     4813    quantity = num.zeros(num_points, num.float)
    48164814
    48174815    for lat_i, _ in enumerate(lat):
     
    52665264
    52675265    points_utm=ensure_numeric(points_utm)
    5268     assert ensure_numeric(mesh_dic['generatedpointlist']) \
    5269            == ensure_numeric(points_utm)
     5266    assert num.alltrue(ensure_numeric(mesh_dic['generatedpointlist'])
     5267                       == ensure_numeric(points_utm))
    52705268
    52715269    volumes = mesh_dic['generatedtrianglelist']
     
    52855283    sww = Write_sww()
    52865284    sww.store_header(outfile, times, len(volumes), len(points_utm),
    5287                      verbose=verbose, sww_precision=num.Float)
     5285                     verbose=verbose, sww_precision=netcdf_float)
    52885286    outfile.mean_stage = mean_stage
    52895287    outfile.zscale = zscale
     
    53095307                                 xmomentum=xmomentum,
    53105308                                 ymomentum=ymomentum,
    5311                                  sww_precision=num.Float)
     5309                                 sww_precision=num.float)
    53125310        j += 1
    53135311
     
    53565354    numSrc = len(filenames)
    53575355
    5358     file_params = -1 * num.ones(3, num.Float)                    # [nsta,dt,nt]
     5356    file_params = -1 * num.ones(3, num.float)                    # [nsta,dt,nt]
    53595357
    53605358    # Convert verbose to int C flag
     
    53655363
    53665364    if weights is None:
    5367         weights = num.ones(numSrc)
     5365        weights = num.ones(numSrc, num.int)     #array default#
    53685366
    53695367    if permutation is None:
    5370         permutation = ensure_numeric([], num.Float)
     5368        permutation = ensure_numeric([], num.float)
    53715369
    53725370    # Call underlying C implementation urs2sts_ext.c
     
    54165414
    54175415    times = dt * num.arange(parameters_index)
    5418     latitudes = num.zeros(number_of_selected_stations, num.Float)
    5419     longitudes = num.zeros(number_of_selected_stations, num.Float)
    5420     elevation = num.zeros(number_of_selected_stations, num.Float)
    5421     quantity = num.zeros((number_of_selected_stations, parameters_index), num.Float)
     5416    latitudes = num.zeros(number_of_selected_stations, num.float)
     5417    longitudes = num.zeros(number_of_selected_stations, num.float)
     5418    elevation = num.zeros(number_of_selected_stations, num.float)
     5419    quantity = num.zeros((number_of_selected_stations, parameters_index), num.float)
    54225420
    54235421    starttime = 1e16
     
    55435541    if weights is None:
    55445542        # Default is equal weighting
    5545         weights = num.ones(numSrc, num.Float) / numSrc
     5543        weights = num.ones(numSrc, num.float) / numSrc
    55465544    else:
    55475545        weights = ensure_numeric(weights)
     
    56655663    # 0 to number_of_points-1
    56665664    if permutation is None:
    5667         permutation = num.arange(number_of_points, typecode=num.Int)
     5665        permutation = num.arange(number_of_points, dtype=num.int)
    56685666
    56695667    # NetCDF file definition
     
    56795677                     description=description,
    56805678                     verbose=verbose,
    5681                      sts_precision=num.Float)
     5679                     sts_precision=netcdf_float)
    56825680
    56835681    # Store
    56845682    from anuga.coordinate_transforms.redfearn import redfearn
    56855683
    5686     x = num.zeros(number_of_points, num.Float)  # Easting
    5687     y = num.zeros(number_of_points, num.Float)  # Northing
     5684    x = num.zeros(number_of_points, num.float)  # Easting
     5685    y = num.zeros(number_of_points, num.float)  # Northing
    56885686
    56895687    # Check zone boundaries
     
    57165714
    57175715    elevation = num.resize(elevation, outfile.variables['elevation'][:].shape)
    5718     outfile.variables['permutation'][:] = permutation.astype(num.Int32) # Opteron 64
     5716    outfile.variables['permutation'][:] = permutation.astype(num.int32) # Opteron 64
    57195717    outfile.variables['x'][:] = x - geo_ref.get_xllcorner()
    57205718    outfile.variables['y'][:] = y - geo_ref.get_yllcorner()
     
    58215819    # @param smoothing True if smoothing is to be used.
    58225820    # @param order
    5823     # @param sww_precision Data type of the quantitiy to be written (Float32)
     5821    # @param sww_precision Data type of the quantitiy written (netcdf constant)
    58245822    # @param verbose True if this function is to be verbose.
    58255823    # @note If 'times' is a list, the info will be made relative.
     
    58325830                     smoothing=True,
    58335831                     order=1,
    5834                      sww_precision=num.Float32,
     5832                     sww_precision=netcdf_float32,
    58355833                     verbose=False):
    58365834        """Write an SWW file header.
     
    58655863        # This is being used to seperate one number from a list.
    58665864        # what it is actually doing is sorting lists from numeric arrays.
    5867         if type(times) is list or type(times) is num.ArrayType:
     5865        if type(times) is list or isinstance(times, num.ndarray):
    58685866            number_of_times = len(times)
    58695867            times = ensure_numeric(times)
     
    59145912        outfile.createVariable('z', sww_precision, ('number_of_points',))
    59155913
    5916         outfile.createVariable('volumes', num.Int, ('number_of_volumes',
    5917                                                     'number_of_vertices'))
     5914        outfile.createVariable('volumes', netcdf_int, ('number_of_volumes',
     5915                                                       'number_of_vertices'))
    59185916
    59195917        # Doing sww_precision instead of Float gives cast errors.
    5920         outfile.createVariable('time', num.Float,
     5918        outfile.createVariable('time', netcdf_float,
    59215919                               ('number_of_timesteps',))
    59225920
     
    59325930            #outfile.variables[q+Write_sww.RANGE][1] = -max_float # Max
    59335931
    5934         if type(times) is list or type(times) is num.ArrayType:
     5932        if type(times) is list or isinstance(times, num.ndarray):
    59355933            outfile.variables['time'][:] = times    #Store time relative
    59365934
     
    60356033        outfile.variables['z'][:] = elevation
    60366034        outfile.variables['elevation'][:] = elevation  #FIXME HACK
    6037         outfile.variables['volumes'][:] = volumes.astype(num.Int32) #On Opteron 64
     6035        outfile.variables['volumes'][:] = volumes.astype(num.int32) #On Opteron 64
    60386036
    60396037        q = 'elevation'
     
    60516049    # @param verbose True if this function is to be verbose.
    60526050    # @param **quant
    6053     def store_quantities(self, outfile, sww_precision=num.Float32,
     6051    def store_quantities(self, outfile, sww_precision=num.float32,
    60546052                         slice_index=None, time=None,
    60556053                         verbose=False, **quant):
     
    62366234    # @param number_of_points The number of URS gauge sites.
    62376235    # @param description Description string to write into the STS file.
    6238     # @param sts_precision Format of data to write (default Float32).
     6236    # @param sts_precision Format of data to write (netcdf constant ONLY).
    62396237    # @param verbose True if this function is to be verbose.
    62406238    # @note If 'times' is a list, the info will be made relative.
     
    62446242                     number_of_points,
    62456243                     description='Converted from URS mux2 format',
    6246                      sts_precision=num.Float32,
     6244                     sts_precision=netcdf_float32,
    62476245                     verbose=False):
    62486246        """
     
    62676265        # This is being used to seperate one number from a list.
    62686266        # what it is actually doing is sorting lists from numeric arrays.
    6269         if type(times) is list or type(times) is num.ArrayType:
     6267        if type(times) is list or isinstance(times, num.ndarray):
    62706268            number_of_times = len(times)
    62716269            times = ensure_numeric(times)
     
    62876285
    62886286        # Variable definitions
    6289         outfile.createVariable('permutation', num.Int, ('number_of_points',))
     6287        outfile.createVariable('permutation', netcdf_int, ('number_of_points',))
    62906288        outfile.createVariable('x', sts_precision, ('number_of_points',))
    62916289        outfile.createVariable('y', sts_precision, ('number_of_points',))
     
    63026300
    63036301        # Doing sts_precision instead of Float gives cast errors.
    6304         outfile.createVariable('time', num.Float, ('number_of_timesteps',))
     6302        outfile.createVariable('time', netcdf_float, ('number_of_timesteps',))
    63056303
    63066304        for q in Write_sts.sts_quantities:
     
    63146312            outfile.variables[q + Write_sts.RANGE][1] = -max_float # Max
    63156313
    6316         if type(times) is list or type(times) is num.ArrayType:
     6314        if type(times) is list or isinstance(times, num.ndarray):
    63176315            outfile.variables['time'][:] = times    #Store time relative
    63186316
     
    64236421    # @param verboseTrue if this function is to be verbose.
    64246422    # @param **quant Extra keyword args.
    6425     def store_quantities(self, outfile, sts_precision=num.Float32,
     6423    def store_quantities(self, outfile, sts_precision=num.float32,
    64266424                         slice_index=None, time=None,
    64276425                         verbose=False, **quant):
     
    65146512        lonlatdep = p_array.array('f')
    65156513        lonlatdep.read(mux_file, columns * self.points_num)
    6516         lonlatdep = num.array(lonlatdep, typecode=num.Float)
     6514        lonlatdep = num.array(lonlatdep, dtype=num.float)
    65176515        lonlatdep = num.reshape(lonlatdep, (self.points_num, columns))
    65186516        self.lonlatdep = lonlatdep
     
    65506548        hz_p_array = p_array.array('f')
    65516549        hz_p_array.read(self.mux_file, self.points_num)
    6552         hz_p = num.array(hz_p_array, typecode=num.Float)
     6550        hz_p = num.array(hz_p_array, dtype=num.float)
    65536551        self.iter_time_step += 1
    65546552
     
    66956693    # array to store data, number in there is to allow float...
    66966694    # i'm sure there is a better way!
    6697     data = num.array([], typecode=num.Float)
     6695    data = num.array([], dtype=num.float)
    66986696    data = num.resize(data, ((len(lines)-1), len(header_fields)))
    66996697
     
    68616859    time += fid.starttime[0]
    68626860
    6863     # Get the variables as Numeric arrays
     6861    # Get the variables as numeric arrays
    68646862    x = fid.variables['x'][:]                   # x-coordinates of nodes
    68656863    y = fid.variables['y'][:]                   # y-coordinates of nodes
     
    68706868
    68716869    # Mesh (nodes (Mx2), triangles (Nx3))
    6872     nodes = num.concatenate((x[:,num.NewAxis], y[:,num.NewAxis]), axis=1)
     6870    nodes = num.concatenate((x[:,num.newaxis], y[:,num.newaxis]), axis=1)
    68736871    triangles = fid.variables['volumes'][:]
    68746872
     
    72937291
    72947292        # Get the relevant quantities (Convert from single precison)
    7295         elevation = num.array(fid.variables['elevation'][:], num.Float)
    7296         stage = num.array(fid.variables['stage'][:], num.Float)
     7293        elevation = num.array(fid.variables['elevation'][:], num.float)
     7294        stage = num.array(fid.variables['stage'][:], num.float)
    72977295
    72987296        # Here's where one could convert nodal information to centroid
     
    73117309            # and call it here
    73127310
    7313             points = num.concatenate((x[:,num.NewAxis], y[:,num.NewAxis]), axis=1)
     7311            points = num.concatenate((x[:,num.newaxis], y[:,num.newaxis]), axis=1)
    73147312
    73157313            point_indices = inside_polygon(points, polygon)
  • branches/numpy/anuga/shallow_water/eq_test.py

    r6162 r6304  
    6666   
    6767from anuga.abstract_2d_finite_volumes.util import file_function
    68 import Numeric as num
     68import numpy as num
    6969from pylab import plot, ion, hold,savefig
    7070
     
    7575
    7676y = 10000
    77 points=num.array([[0]*2]*max, num.Int)      #array default#
     77points=num.array([[0]*2]*max)
    7878print points
    7979half_max_skip=(max*skip)/2
     
    8787number_points = profile_lenght/interval
    8888y = 10000
    89 points=num.array([[0]*2]*number_points, num.Int)      #array default#
     89points=num.array([[0]*2]*number_points)
    9090print points
    9191half_profile=profile_lenght/2
  • branches/numpy/anuga/shallow_water/eqf_v2.py

    r4436 r6304  
    2626"""
    2727
     28import numpy as num
     29
     30
    2831def earthquake_tsunami(length, width, strike, depth, \
    2932                       dip, x0=0.0, y0=0.0, slip=1.0, rake=90.,\
     
    110113
    111114        from math import sin, cos, radians, exp, cosh
    112         from Numeric import zeros, Float
    113115        #from okada import okadatest
    114116
     
    142144        #z1 = okada(xr,yr,depth,length,width,dip,rake,slip)
    143145
    144         z2 = zeros(N, Float)
     146        z2 = num.zeros(N, num.float)
    145147        alp = 0.5
    146148        disl3 = 0.0
     
    182184        """                                                                   
    183185       
    184         from Numeric import zeros, Float
    185         U = zeros(9, Float)
    186         DU = zeros(9, Float)
     186        U = num.zeros(9, num.float)
     187        DU = num.zeros(9, num.float)
    187188       
    188189        F0 = 0.0
  • branches/numpy/anuga/shallow_water/shallow_water_domain.py

    r6190 r6304  
    8080# $LastChangedBy$
    8181
    82 import Numeric as num
     82import numpy as num
    8383
    8484from anuga.abstract_2d_finite_volumes.neighbour_mesh import segment_midpoints
     
    10811081        self.normals = domain.normals
    10821082
    1083         self.conserved_quantities = num.zeros(3, num.Float)
     1083        self.conserved_quantities = num.zeros(3, num.float)
    10841084
    10851085    def __repr__(self):
     
    15011501    if callable(f):
    15021502        N = 3
    1503         x = num.ones(3, num.Float)
    1504         y = num.ones(3, num.Float)
     1503        x = num.ones(3, num.float)
     1504        y = num.ones(3, num.float)
    15051505        try:
    15061506            q = f(1.0, x=x, y=y)
     
    15111511
    15121512        try:
    1513             q = num.array(q, num.Float)
     1513            q = num.array(q, num.float)
    15141514        except:
    15151515            msg = 'Return value from vector function %s could ' %f
    1516             msg += 'not be converted into a Numeric array of floats.\n'
     1516            msg += 'not be converted into a numeric array of floats.\n'
    15171517            msg += 'Specified function should return either list or array.'
    15181518            raise msg
     
    15201520        # Is this really what we want?
    15211521        msg = 'Return vector from function %s ' %f
    1522         msg += 'must have same lenght as input vectors'
     1522        msg += 'must have same length as input vectors'
     1523        msg += ' (type(q)=%s' % type(q)
    15231524        assert len(q) == N, msg
    15241525
     
    16221623
    16231624            try:
    1624                 s_vec = self.speed * num.ones(N, num.Float)
     1625                s_vec = self.speed * num.ones(N, num.float)
    16251626            except:
    16261627                msg = 'Speed must be either callable or a scalar: %s' %self.s
     
    16351636
    16361637            try:
    1637                 phi_vec = self.phi * num.ones(N, num.Float)
     1638                phi_vec = self.phi * num.ones(N, num.float)
    16381639            except:
    16391640                msg = 'Angle must be either callable or a scalar: %s' %self.phi
     
    17121713                 quantity_name,
    17131714                 rate=0.0,
    1714                 center=None, radius=None,
     1715                center=None, radius=None,
    17151716                 polygon=None,
    17161717                 default_rate=None,
     
    17751776                assert is_inside_polygon(point, bounding_polygon), msg
    17761777
    1777        
    17781778        if polygon is not None:
    17791779
     
    18351835           
    18361836        # Check and store default_rate
    1837         msg = 'Keyword argument default_rate must be either None '
    1838         msg += 'or a function of time.\n I got %s' %(str(default_rate))
     1837        msg = 'Keyword argument default_rate must be either None '
     1838        msg += 'or a function of time.\n I got %s' %(str(default_rate))
    18391839        assert default_rate is None or \
    18401840               type(default_rate) in [IntType, FloatType] or \
     
    19201920       
    19211921        """
    1922         if callable(self.rate):
    1923             rate = self.rate(t)
    1924         else:
    1925             rate = self.rate
     1922        if callable(self.rate):
     1923            rate = self.rate(t)
     1924        else:
     1925            rate = self.rate
    19261926
    19271927        return rate
     
    19641964   
    19651965    Used for implementing Rainfall over the entire domain.
    1966        
    1967         Current Limited to only One Gauge..
    1968        
    1969         Need to add Spatial Varying Capability
    1970         (This module came from copying and amending the Inflow Code)
     1966       
     1967        Current Limited to only One Gauge..
     1968       
     1969        Need to add Spatial Varying Capability
     1970        (This module came from copying and amending the Inflow Code)
    19711971   
    19721972    Rainfall(rain)
     
    19741974    domain   
    19751975    rain [mm/s]:  Total rain rate over the specified domain. 
    1976                   NOTE: Raingauge Data needs to reflect the time step.
    1977                   IE: if Gauge is mm read at a time step, then the input
     1976                  NOTE: Raingauge Data needs to reflect the time step.
     1977                  IE: if Gauge is mm read at a time step, then the input
    19781978                  here is as mm/(timeStep) so 10mm in 5minutes becomes
    19791979                  10/(5x60) = 0.0333mm/s.
    1980        
    1981        
     1980
    19821981                  This parameter can be either a constant or a
    19831982                  function of time. Positive values indicate inflow,
     
    19921991    Examples
    19931992    How to put them in a run File...
    1994        
     1993
    19951994    #------------------------------------------------------------------------
    19961995    # Setup specialised forcing terms
     
    20092008    def __init__(self,
    20102009                 domain,
    2011                 rate=0.0,
    2012                 center=None, radius=None,
     2010                rate=0.0,
     2011                center=None, radius=None,
    20132012                 polygon=None,
    20142013                 default_rate=None,                 
     
    20712070    # The outflow area is 0.07**2*pi=0.0154 m^2
    20722071    # This corresponds to a rate of change of 0.003/0.0154 = 0.2 m/s
    2073     #                                    
     2072    #         
    20742073    Inflow((0.7, 0.4), 0.07, -0.003)
    20752074
     
    20982097    def __init__(self,
    20992098                 domain,
    2100                 rate=0.0,
    2101                 center=None, radius=None,
     2099                rate=0.0,
     2100                center=None, radius=None,
    21022101                 polygon=None,
    21032102                 default_rate=None,
     
    21232122        """
    21242123
    2125         if callable(self.rate):
    2126             _rate = self.rate(t)/self.exchange_area
    2127         else:
    2128             _rate = self.rate/self.exchange_area
     2124        if callable(self.rate):
     2125            _rate = self.rate(t)/self.exchange_area
     2126        else:
     2127            _rate = self.rate/self.exchange_area
    21292128
    21302129        return _rate
  • branches/numpy/anuga/shallow_water/shallow_water_ext.c

    r5967 r6304  
    1515
    1616#include "Python.h"
    17 #include "Numeric/arrayobject.h"
     17#include "numpy/arrayobject.h"
    1818#include "math.h"
    1919#include <stdio.h>
  • branches/numpy/anuga/shallow_water/smf.py

    r6157 r6304  
    4747"""
    4848
    49 import Numeric as num
     49import numpy as num
    5050
    5151
     
    388388
    389389        from math import sin, cos, radians, exp, cosh
    390 #        from Numeric import zeros, Float
    391390
    392391        #ensure vectors x and y have the same length
     
    416415        yr = ((x-x0) * sina + (y-y0) * cosa) + y0
    417416
    418         z = num.zeros(N, num.Float)
     417        z = num.zeros(N, num.float)
    419418        maxz = 0.0
    420419        minz = 0.0
  • branches/numpy/anuga/shallow_water/test_all.py

    r3691 r6304  
    7878if __name__ == '__main__':   
    7979    suite = regressionTest()
    80     runner = unittest.TextTestRunner() #(verbosity=2)
     80    runner = unittest.TextTestRunner() #verbosity=2)
    8181    runner.run(suite)
  • branches/numpy/anuga/shallow_water/test_data_manager.py

    r6224 r6304  
    77import unittest
    88import copy
    9 import Numeric as num
     9import numpy as num
    1010               
    1111from anuga.utilities.numerical_tools import mean
     
    2525from anuga.utilities.system_tools import get_pathname_from_package
    2626from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
     27from anuga.config import netcdf_float
    2728
    2829# This is needed to run the tests of local functions
     
    6768        #Initial condition - with jumps
    6869        bed = domain.quantities['elevation'].vertex_values
    69         stage = num.zeros(bed.shape, num.Float)
     70        stage = num.zeros(bed.shape, num.float)
    7071
    7172        h = 0.3
     
    109110
    110111            fid.createDimension(long_name,nx)
    111             fid.createVariable(long_name,'d',(long_name,))
     112            fid.createVariable(long_name,netcdf_float,(long_name,))
    112113            fid.variables[long_name].point_spacing='uneven'
    113114            fid.variables[long_name].units='degrees_east'
     
    115116
    116117            fid.createDimension(lat_name,ny)
    117             fid.createVariable(lat_name,'d',(lat_name,))
     118            fid.createVariable(lat_name,netcdf_float,(lat_name,))
    118119            fid.variables[lat_name].point_spacing='uneven'
    119120            fid.variables[lat_name].units='degrees_north'
     
    121122
    122123            fid.createDimension('TIME',six)
    123             fid.createVariable('TIME','d',('TIME',))
     124            fid.createVariable('TIME',netcdf_float,('TIME',))
    124125            fid.variables['TIME'].point_spacing='uneven'
    125126            fid.variables['TIME'].units='seconds'
     
    129130            name = ext[1:3].upper()
    130131            if name == 'E.': name = 'ELEVATION'
    131             fid.createVariable(name,'d',('TIME', lat_name, long_name))
     132            fid.createVariable(name,netcdf_float,('TIME', lat_name, long_name))
    132133            fid.variables[name].units='CENTIMETERS'
    133134            fid.variables[name].missing_value=-1.e+034
     
    189190        V = fid.variables['volumes']
    190191
    191         assert num.allclose (x[:], self.X.flat)
    192         assert num.allclose (y[:], self.Y.flat)
    193         assert num.allclose (z[:], self.F.flat)
     192        assert num.allclose (x[:], self.X.flatten())
     193        assert num.allclose (y[:], self.Y.flatten())
     194        assert num.allclose (z[:], self.F.flatten())
    194195
    195196        P = len(self.domain)
     
    521522        #Check contents
    522523        #Get NetCDF
    523         fid = NetCDFFile(sww.filename, inetcdf_mode_r)
     524        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    524525
    525526        # Get the variables
     
    589590            if t == 0.0:
    590591                assert num.allclose(stage, self.initial_stage)
    591                 assert num.allclose(stage_file[:], stage.flat)
     592                assert num.allclose(stage_file[:], stage.flatten())
    592593            else:
    593594                assert not num.allclose(stage, self.initial_stage)
    594                 assert not num.allclose(stage_file[:], stage.flat)
     595                assert not num.allclose(stage_file[:], stage.flatten())
    595596
    596597            fid.close()
     
    855856        xvec = range(10)
    856857        #z = range(100)
    857         z = num.zeros(100)
     858        z = num.zeros(100, num.int)     #array default#
    858859        NODATA_value = -9999
    859860        count = -1
     
    914915
    915916        #create new reference points
    916         newz = num.zeros(19)
     917        newz = num.zeros(19, num.int)       #array default#
    917918        newz[0:2] = ref_elevation[32:34]
    918919        newz[2:5] = ref_elevation[35:38]
     
    985986        xvec = range(10)
    986987        #z = range(100)
    987         z = num.zeros(100)
     988        z = num.zeros(100, num.int)     #array default#
    988989        NODATA_value = -9999
    989990        count = -1
     
    10441045
    10451046        #create new reference points
    1046         newz = num.zeros(14)
     1047        newz = num.zeros(14, num.int)       #array default#
    10471048        newz[0:2] = ref_elevation[32:34]
    10481049        newz[2:5] = ref_elevation[35:38]
     
    25432544
    25442545        bed = domain.quantities['elevation'].vertex_values
    2545         stage = num.zeros(bed.shape, num.Float)
     2546        stage = num.zeros(bed.shape, num.float)
    25462547
    25472548        h = 0.3
     
    27932794
    27942795        # Invoke interpolation for vertex points       
    2795         points = num.concatenate( (x[:,num.NewAxis],y[:,num.NewAxis]), axis=1 )
     2796        points = num.concatenate( (x[:,num.newaxis],y[:,num.newaxis]), axis=1 )
    27962797        sww2pts(self.domain.get_name(),
    27972798                quantity = 'elevation',
     
    31713172        for fid in [fid1,fid2,fid3]:
    31723173            fid.createDimension(long_name,nx)
    3173             fid.createVariable(long_name,'d',(long_name,))
     3174            fid.createVariable(long_name,netcdf_float,(long_name,))
    31743175            fid.variables[long_name].point_spacing='uneven'
    31753176            fid.variables[long_name].units='degrees_east'
     
    31773178
    31783179            fid.createDimension(lat_name,ny)
    3179             fid.createVariable(lat_name,'d',(lat_name,))
     3180            fid.createVariable(lat_name,netcdf_float,(lat_name,))
    31803181            fid.variables[lat_name].point_spacing='uneven'
    31813182            fid.variables[lat_name].units='degrees_north'
     
    31833184
    31843185            fid.createDimension(time_name,2)
    3185             fid.createVariable(time_name,'d',(time_name,))
     3186            fid.createVariable(time_name,netcdf_float,(time_name,))
    31863187            fid.variables[time_name].point_spacing='uneven'
    31873188            fid.variables[time_name].units='seconds'
     
    31923193        for fid in [fid4]:
    31933194            fid.createDimension(long_name,nx)
    3194             fid.createVariable(long_name,'d',(long_name,))
     3195            fid.createVariable(long_name,netcdf_float,(long_name,))
    31953196            fid.variables[long_name].point_spacing='uneven'
    31963197            fid.variables[long_name].units='degrees_east'
     
    31983199
    31993200            fid.createDimension(lat_name,ny)
    3200             fid.createVariable(lat_name,'d',(lat_name,))
     3201            fid.createVariable(lat_name,netcdf_float,(lat_name,))
    32013202            fid.variables[lat_name].point_spacing='uneven'
    32023203            fid.variables[lat_name].units='degrees_north'
     
    32223223
    32233224        for fid in [fid1,fid2,fid3]:
    3224           fid.createVariable(name[fid],'d',(time_name,lat_name,long_name))
     3225          fid.createVariable(name[fid],netcdf_float,(time_name,lat_name,long_name))
    32253226          fid.variables[name[fid]].point_spacing='uneven'
    32263227          fid.variables[name[fid]].units=units[fid]
     
    32303231
    32313232        for fid in [fid4]:
    3232             fid.createVariable(name[fid],'d',(lat_name,long_name))
     3233            fid.createVariable(name[fid],netcdf_float,(lat_name,long_name))
    32333234            fid.variables[name[fid]].point_spacing='uneven'
    32343235            fid.variables[name[fid]].units=units[fid]
     
    33353336        for fid in [fid1,fid2,fid3]:
    33363337            fid.createDimension(long_name,nx)
    3337             fid.createVariable(long_name,'d',(long_name,))
     3338            fid.createVariable(long_name,netcdf_float,(long_name,))
    33383339            fid.variables[long_name].point_spacing='uneven'
    33393340            fid.variables[long_name].units='degrees_east'
     
    33413342
    33423343            fid.createDimension(lat_name,ny)
    3343             fid.createVariable(lat_name,'d',(lat_name,))
     3344            fid.createVariable(lat_name,netcdf_float,(lat_name,))
    33443345            fid.variables[lat_name].point_spacing='uneven'
    33453346            fid.variables[lat_name].units='degrees_north'
     
    33473348
    33483349            fid.createDimension(time_name,2)
    3349             fid.createVariable(time_name,'d',(time_name,))
     3350            fid.createVariable(time_name,netcdf_float,(time_name,))
    33503351            fid.variables[time_name].point_spacing='uneven'
    33513352            fid.variables[time_name].units='seconds'
     
    33563357        for fid in [fid4]:
    33573358            fid.createDimension(long_name,nx)
    3358             fid.createVariable(long_name,'d',(long_name,))
     3359            fid.createVariable(long_name,netcdf_float,(long_name,))
    33593360            fid.variables[long_name].point_spacing='uneven'
    33603361            fid.variables[long_name].units='degrees_east'
     
    33623363
    33633364            fid.createDimension(lat_name,ny)
    3364             fid.createVariable(lat_name,'d',(lat_name,))
     3365            fid.createVariable(lat_name,netcdf_float,(lat_name,))
    33653366            fid.variables[lat_name].point_spacing='uneven'
    33663367            fid.variables[lat_name].units='degrees_north'
     
    33863387
    33873388        for fid in [fid1,fid2,fid3]:
    3388           fid.createVariable(name[fid],'d',(time_name,lat_name,long_name))
     3389          fid.createVariable(name[fid],netcdf_float,(time_name,lat_name,long_name))
    33893390          fid.variables[name[fid]].point_spacing='uneven'
    33903391          fid.variables[name[fid]].units=units[fid]
     
    33943395
    33953396        for fid in [fid4]:
    3396             fid.createVariable(name[fid],'d',(lat_name,long_name))
     3397            fid.createVariable(name[fid],netcdf_float,(lat_name,long_name))
    33973398            fid.variables[name[fid]].point_spacing='uneven'
    33983399            fid.variables[name[fid]].units=units[fid]
     
    39663967        fid.createDimension('number_of_points', nrows*ncols)
    39673968
    3968         fid.createVariable('elevation', num.Float, ('number_of_points',))
     3969        fid.createVariable('elevation', netcdf_float, ('number_of_points',))
    39693970
    39703971        elevation = fid.variables['elevation']
     
    39933994
    39943995        #generate a stencil for computing the decimated values
    3995         stencil = num.ones((3,3), num.Float) / 9.0
     3996        stencil = num.ones((3,3), num.float) / 9.0
    39963997
    39973998        decimate_dem(root, stencil=stencil, cellsize_new=100)
     
    40494050        fid.createDimension('number_of_points', nrows*ncols)
    40504051
    4051         fid.createVariable('elevation', num.Float, ('number_of_points',))
     4052        fid.createVariable('elevation', netcdf_float, ('number_of_points',))
    40524053
    40534054        elevation = fid.variables['elevation']
     
    40874088
    40884089        #generate a stencil for computing the decimated values
    4089         stencil = num.ones((3,3), num.Float) / 9.0
     4090        stencil = num.ones((3,3), num.float) / 9.0
    40904091
    40914092        decimate_dem(root, stencil=stencil, cellsize_new=100)
     
    49504951
    49514952        ## 7th test
    4952         m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]], num.Int)      #array default#
     4953        m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]])
    49534954        kmin, kmax, lmin, lmax = data_manager._get_min_max_indexes(
    49544955            latitudes,longitudes,
     
    49634964        #print "longitudes_news",longitudes_news
    49644965
    4965         self.failUnless(latitudes_new == [2, 1] and \
    4966                         longitudes_news == [10, 20],
    4967                          'failed')
    4968 
    4969         self.failUnless(m2d == [[5,6],[9,10]],
    4970                          'failed')
     4966        self.failUnless(num.alltrue(latitudes_new == [2, 1]) and
     4967                        num.alltrue(longitudes_news == [10, 20]),
     4968                        'failed')
     4969
     4970        self.failUnless(num.alltrue(m2d == [[5,6],[9,10]]), 'failed')
    49714971
    49724972    def test_get_min_max_indexes_lat_ascending(self):
     
    50105010        longitudes = [148,149,150,151]
    50115011
    5012         m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]], num.Int)      #array default#
     5012        m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]])
    50135013
    50145014        # k - lat
     
    50315031        #print "longitudes_new",longitudes_new
    50325032
    5033         self.failUnless(latitudes_new == [-30, -35, -40] and \
     5033        self.failUnless(latitudes_new == [-30, -35, -40] and
    50345034                        longitudes_new == [148, 149,150],
    5035                          'failed')
    5036         self.failUnless(m2d == [[0,1,2],[4,5,6],[8,9,10]],
    5037                          'failed')
     5035                        'failed')
     5036        self.failUnless(num.alltrue(m2d == [[0,1,2],[4,5,6],[8,9,10]]),
     5037                        'failed')
    50385038
    50395039    def test_get_min_max_indexes3(self):
     
    54775477            quantities_init[i] = ensure_numeric(quantities_init[i])
    54785478            #print "HA_init", HA_init
    5479             q_time = num.zeros((time_step_count, points_num), num.Float)
     5479            q_time = num.zeros((time_step_count, points_num), num.float)
    54805480            for time in range(time_step_count):
    54815481                q_time[time,:] = quantities_init[i] #* time * 4
     
    55615561            quantities_init[i] = ensure_numeric(quantities_init[i])
    55625562            #print "HA_init", HA_init
    5563             q_time = num.zeros((time_step_count, points_num), num.Float)
     5563            q_time = num.zeros((time_step_count, points_num), num.float)
    55645564            for time in range(time_step_count):
    55655565                q_time[time,:] = quantities_init[i] #* time * 4
     
    60176017            if ha is None:
    60186018                this_ha = e
    6019                 quantities_init[0].append(num.ones(time_step_count,num.Float)*this_ha) # HA
     6019                quantities_init[0].append(num.ones(time_step_count,num.float)*this_ha) # HA
    60206020            else:
    60216021                quantities_init[0].append(ha[i])
    60226022            if ua is None:
    60236023                this_ua = n
    6024                 quantities_init[1].append(num.ones(time_step_count,num.Float)*this_ua) # UA
     6024                quantities_init[1].append(num.ones(time_step_count,num.float)*this_ua) # UA
    60256025            else:
    60266026                quantities_init[1].append(ua[i])
    60276027            if va is None:
    60286028                this_va = e
    6029                 quantities_init[2].append(num.ones(time_step_count,num.Float)*this_va) #
     6029                quantities_init[2].append(num.ones(time_step_count,num.float)*this_va) #
    60306030            else:
    60316031                quantities_init[2].append(va[i])           
     
    60376037        files = []       
    60386038        for i, q in enumerate(quantities):
    6039             q_time = num.zeros((time_step_count, points_num), num.Float)
     6039            q_time = num.zeros((time_step_count, points_num), num.float)
    60406040            quantities_init[i] = ensure_numeric(quantities_init[i])
    60416041            for time in range(time_step_count):
     
    61066106        lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)]
    61076107        n=len(lat_long_points)
    6108         first_tstep=num.ones(n,num.Int)
    6109         last_tstep=time_step_count*num.ones(n,num.Int)
    6110         depth=20*num.ones(n,num.Float)
    6111         ha=2*num.ones((n,time_step_count),num.Float)
    6112         ua=5*num.ones((n,time_step_count),num.Float)
    6113         va=-10*num.ones((n,time_step_count),num.Float)
     6108        first_tstep=num.ones(n,num.int)
     6109        last_tstep=time_step_count*num.ones(n,num.int)
     6110        depth=20*num.ones(n,num.float)
     6111        ha=2*num.ones((n,time_step_count),num.float)
     6112        ua=5*num.ones((n,time_step_count),num.float)
     6113        va=-10*num.ones((n,time_step_count),num.float)
    61146114        #-ve added to take into account mux file format where south is positive.
    61156115        base_name, files = self.write_mux2(lat_long_points,
     
    61216121                                      va=va)
    61226122
    6123         weights=num.ones(1, num.Float)
     6123        weights=num.ones(1, num.float)
    61246124        #ensure that files are indeed mux2 files
    61256125        times, latitudes, longitudes, elevation, stage, starttime = read_mux2_py([files[0]],weights)
     
    61616161        lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)]
    61626162        n=len(lat_long_points)
    6163         first_tstep=num.ones(n,num.Int)
    6164         last_tstep=(time_step_count)*num.ones(n,num.Int)
    6165         depth=20*num.ones(n,num.Float)
    6166         ha=2*num.ones((n,time_step_count),num.Float)
     6163        first_tstep=num.ones(n,num.int)
     6164        last_tstep=(time_step_count)*num.ones(n,num.int)
     6165        depth=20*num.ones(n,num.float)
     6166        ha=2*num.ones((n,time_step_count),num.float)
    61676167        ha[0]=num.arange(0,time_step_count)+1
    61686168        ha[1]=time_step_count-num.arange(1,time_step_count+1)
     
    61706170        ha[2]=num.arange(2*time_step_count,3*time_step_count)
    61716171        ha[3]=num.arange(3*time_step_count,4*time_step_count)
    6172         ua=5*num.ones((n,time_step_count),num.Float)
    6173         va=-10*num.ones((n,time_step_count),num.Float)
     6172        ua=5*num.ones((n,time_step_count),num.float)
     6173        va=-10*num.ones((n,time_step_count),num.float)
    61746174        #-ve added to take into account mux file format where south is positive.
    61756175        base_name, files = self.write_mux2(lat_long_points,
     
    61816181                                      va=va)
    61826182
    6183         weights=num.ones(1, num.Float)
     6183        weights=num.ones(1, num.float)
    61846184        #ensure that files are indeed mux2 files
    61856185        times, latitudes, longitudes, elevation, stage,starttime=read_mux2_py([files[0]],weights)
     
    62196219        lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)]
    62206220        n=len(lat_long_points)
    6221         first_tstep=num.ones(n,num.Int)
     6221        first_tstep=num.ones(n,num.int)
    62226222        first_tstep[0]+=1
    62236223        first_tstep[2]+=1
    6224         last_tstep=(time_step_count)*num.ones(n,num.Int)
     6224        last_tstep=(time_step_count)*num.ones(n,num.int)
    62256225        last_tstep[0]-=1
    62266226
    6227         depth=20*num.ones(n,num.Float)
    6228         ha=2*num.ones((n,time_step_count),num.Float)
     6227        depth=20*num.ones(n,num.float)
     6228        ha=2*num.ones((n,time_step_count),num.float)
    62296229        ha[0]=num.arange(0,time_step_count)
    62306230        ha[1]=num.arange(time_step_count,2*time_step_count)
    62316231        ha[2]=num.arange(2*time_step_count,3*time_step_count)
    62326232        ha[3]=num.arange(3*time_step_count,4*time_step_count)
    6233         ua=5*num.ones((n,time_step_count),num.Float)
    6234         va=-10*num.ones((n,time_step_count),num.Float)
     6233        ua=5*num.ones((n,time_step_count),num.float)
     6234        va=-10*num.ones((n,time_step_count),num.float)
    62356235        #-ve added to take into account mux file format where south is positive.
    62366236        base_name, files = self.write_mux2(lat_long_points,
     
    62426242                                      va=va)
    62436243
    6244         weights=num.ones(1, num.Float)
     6244        weights=num.ones(1, num.float)
    62456245        #ensure that files are indeed mux2 files
    62466246        times, latitudes, longitudes, elevation, stage, starttime=read_mux2_py([files[0]],weights)
     
    63086308       
    63096309        # Create different timeseries starting and ending at different times
    6310         first_tstep=num.ones(n, num.Int)
     6310        first_tstep=num.ones(n, num.int)
    63116311        first_tstep[0]+=2   # Point 0 starts at 2
    63126312        first_tstep[1]+=4   # Point 1 starts at 4       
    63136313        first_tstep[2]+=3   # Point 2 starts at 3
    63146314       
    6315         last_tstep=(time_step_count)*num.ones(n,num.Int)
     6315        last_tstep=(time_step_count)*num.ones(n,num.int)
    63166316        last_tstep[0]-=1    # Point 0 ends 1 step early
    63176317        last_tstep[1]-=2    # Point 1 ends 2 steps early               
     
    63196319       
    63206320        # Create varying elevation data (positive values for seafloor)
    6321         gauge_depth=20*num.ones(n,num.Float)
     6321        gauge_depth=20*num.ones(n,num.float)
    63226322        for i in range(n):
    63236323            gauge_depth[i] += i**2
    63246324           
    63256325        # Create data to be written to first mux file       
    6326         ha0=2*num.ones((n,time_step_count),num.Float)
     6326        ha0=2*num.ones((n,time_step_count),num.float)
    63276327        ha0[0]=num.arange(0,time_step_count)
    63286328        ha0[1]=num.arange(time_step_count,2*time_step_count)
    63296329        ha0[2]=num.arange(2*time_step_count,3*time_step_count)
    63306330        ha0[3]=num.arange(3*time_step_count,4*time_step_count)
    6331         ua0=5*num.ones((n,time_step_count),num.Float)
    6332         va0=-10*num.ones((n,time_step_count),num.Float)
     6331        ua0=5*num.ones((n,time_step_count),num.float)
     6332        va0=-10*num.ones((n,time_step_count),num.float)
    63336333
    63346334        # Ensure data used to write mux file to be zero when gauges are
     
    63696369        # For each quantity read the associated list of source mux2 file with
    63706370        # extention associated with that quantity
    6371         file_params=-1*num.ones(3,num.Float) #[nsta,dt,nt]
     6371        file_params=-1*num.ones(3,num.float) #[nsta,dt,nt]
    63726372        OFFSET = 5
    63736373
     
    64146414       
    64156415        # Create different timeseries starting and ending at different times
    6416         first_tstep=num.ones(n,num.Int)
     6416        first_tstep=num.ones(n,num.int)
    64176417        first_tstep[0]+=2   # Point 0 starts at 2
    64186418        first_tstep[1]+=4   # Point 1 starts at 4       
    64196419        first_tstep[2]+=3   # Point 2 starts at 3
    64206420       
    6421         last_tstep=(time_step_count)*num.ones(n,num.Int)
     6421        last_tstep=(time_step_count)*num.ones(n,num.int)
    64226422        last_tstep[0]-=1    # Point 0 ends 1 step early
    64236423        last_tstep[1]-=2    # Point 1 ends 2 steps early               
     
    64256425       
    64266426        # Create varying elevation data (positive values for seafloor)
    6427         gauge_depth=20*num.ones(n,num.Float)
     6427        gauge_depth=20*num.ones(n,num.float)
    64286428        for i in range(n):
    64296429            gauge_depth[i] += i**2
    64306430           
    64316431        # Create data to be written to second mux file       
    6432         ha1=num.ones((n,time_step_count),num.Float)
     6432        ha1=num.ones((n,time_step_count),num.float)
    64336433        ha1[0]=num.sin(times_ref)
    64346434        ha1[1]=2*num.sin(times_ref - 3)
     
    64376437        ha1[4]=num.sin(2*times_ref-0.7)
    64386438               
    6439         ua1=num.zeros((n,time_step_count),num.Float)
     6439        ua1=num.zeros((n,time_step_count),num.float)
    64406440        ua1[0]=3*num.cos(times_ref)       
    64416441        ua1[1]=2*num.sin(times_ref-0.7)   
     
    64436443        ua1[4]=2*num.ones(time_step_count)
    64446444       
    6445         va1=num.zeros((n,time_step_count),num.Float)
     6445        va1=num.zeros((n,time_step_count),num.float)
    64466446        va1[0]=2*num.cos(times_ref-0.87)       
    64476447        va1[1]=3*num.ones(time_step_count)
     
    65166516            if ha is None:
    65176517                this_ha = e
    6518                 quantities_init[0].append(num.ones(time_step_count,num.Float)*this_ha) # HA
     6518                quantities_init[0].append(num.ones(time_step_count,num.float)*this_ha) # HA
    65196519            else:
    65206520                quantities_init[0].append(ha[i])
    65216521            if ua is None:
    65226522                this_ua = n
    6523                 quantities_init[1].append(num.ones(time_step_count,num.Float)*this_ua) # UA
     6523                quantities_init[1].append(num.ones(time_step_count,num.float)*this_ua) # UA
    65246524            else:
    65256525                quantities_init[1].append(ua[i])
    65266526            if va is None:
    65276527                this_va = e
    6528                 quantities_init[2].append(num.ones(time_step_count,num.Float)*this_va) #
     6528                quantities_init[2].append(num.ones(time_step_count,num.float)*this_va) #
    65296529            else:
    65306530                quantities_init[2].append(va[i])
     
    65346534            #print i, q
    65356535           
    6536             q_time = num.zeros((time_step_count, points_num), num.Float)
     6536            q_time = num.zeros((time_step_count, points_num), num.float)
    65376537            quantities_init[i] = ensure_numeric(quantities_init[i])
    65386538            for time in range(time_step_count):
     
    66206620        # For each quantity read the associated list of source mux2 file with
    66216621        # extention associated with that quantity
    6622         file_params=-1*num.ones(3,num.Float) # [nsta,dt,nt]
     6622        file_params=-1*num.ones(3,num.float) # [nsta,dt,nt]
    66236623        OFFSET = 5
    66246624
     
    66396639            parameters_index = data.shape[1]-OFFSET         
    66406640                 
    6641             quantity=num.zeros((number_of_selected_stations, parameters_index), num.Float)
     6641            quantity=num.zeros((number_of_selected_stations, parameters_index), num.float)
    66426642           
    66436643           
     
    66746674        lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)]
    66756675        n=len(lat_long_points)
    6676         first_tstep=num.ones(n,num.Int)
     6676        first_tstep=num.ones(n,num.int)
    66776677        first_tstep[0]+=1
    66786678        first_tstep[2]+=1
    6679         last_tstep=(time_step_count)*num.ones(n,num.Int)
     6679        last_tstep=(time_step_count)*num.ones(n,num.int)
    66806680        last_tstep[0]-=1
    66816681
    6682         gauge_depth=20*num.ones(n,num.Float)
    6683         ha=2*num.ones((n,time_step_count),num.Float)
     6682        gauge_depth=20*num.ones(n,num.float)
     6683        ha=2*num.ones((n,time_step_count),num.float)
    66846684        ha[0]=num.arange(0,time_step_count)
    66856685        ha[1]=num.arange(time_step_count,2*time_step_count)
    66866686        ha[2]=num.arange(2*time_step_count,3*time_step_count)
    66876687        ha[3]=num.arange(3*time_step_count,4*time_step_count)
    6688         ua=5*num.ones((n,time_step_count),num.Float)
    6689         va=-10*num.ones((n,time_step_count),num.Float)
     6688        ua=5*num.ones((n,time_step_count),num.float)
     6689        va=-10*num.ones((n,time_step_count),num.float)
    66906690
    66916691        base_name, files = self.write_mux2(lat_long_points,
     
    67606760        #momentum = velocity_ua *(stage+depth)
    67616761
    6762         depth=num.zeros((len(lat_long_points),time_step_count),num.Float)
     6762        depth=num.zeros((len(lat_long_points),time_step_count),num.float)
    67636763        for i in range(len(lat_long_points)):
    67646764            depth[i]=gauge_depth[i]+tide+ha[i]
     
    67896789        lat_long_points =[(-21.,114.5),(-21.,113.5),(-21.,114.), (-21.,115.)]
    67906790        n=len(lat_long_points)
    6791         first_tstep=num.ones(n,num.Int)
     6791        first_tstep=num.ones(n,num.int)
    67926792        first_tstep[0]+=1
    67936793        first_tstep[2]+=1
    6794         last_tstep=(time_step_count)*num.ones(n,num.Int)
     6794        last_tstep=(time_step_count)*num.ones(n,num.int)
    67956795        last_tstep[0]-=1
    67966796
    6797         gauge_depth=20*num.ones(n,num.Float)
    6798         ha=2*num.ones((n,time_step_count),num.Float)
     6797        gauge_depth=20*num.ones(n,num.float)
     6798        ha=2*num.ones((n,time_step_count),num.float)
    67996799        ha[0]=num.arange(0,time_step_count)
    68006800        ha[1]=num.arange(time_step_count,2*time_step_count)
    68016801        ha[2]=num.arange(2*time_step_count,3*time_step_count)
    68026802        ha[3]=num.arange(3*time_step_count,4*time_step_count)
    6803         ua=5*num.ones((n,time_step_count),num.Float)
    6804         va=-10*num.ones((n,time_step_count),num.Float)
     6803        ua=5*num.ones((n,time_step_count),num.float)
     6804        va=-10*num.ones((n,time_step_count),num.float)
    68056805
    68066806        base_name, files = self.write_mux2(lat_long_points,
     
    68516851        lat_long_points =[(-21.,113.5),(-21.,114.5),(-21.,114.), (-21.,115.)]
    68526852        n=len(lat_long_points)
    6853         first_tstep=num.ones(n,num.Int)
     6853        first_tstep=num.ones(n,num.int)
    68546854        first_tstep[0]+=1
    68556855        first_tstep[2]+=1
    6856         last_tstep=(time_step_count)*num.ones(n,num.Int)
     6856        last_tstep=(time_step_count)*num.ones(n,num.int)
    68576857        last_tstep[0]-=1
    68586858
    6859         gauge_depth=20*num.ones(n,num.Float)
    6860         ha=2*num.ones((n,time_step_count),num.Float)
     6859        gauge_depth=20*num.ones(n,num.float)
     6860        ha=2*num.ones((n,time_step_count),num.float)
    68616861        ha[0]=num.arange(0,time_step_count)
    68626862        ha[1]=num.arange(time_step_count,2*time_step_count)
    68636863        ha[2]=num.arange(2*time_step_count,3*time_step_count)
    68646864        ha[3]=num.arange(3*time_step_count,4*time_step_count)
    6865         ua=5*num.ones((n,time_step_count),num.Float)
    6866         va=-10*num.ones((n,time_step_count),num.Float)
     6865        ua=5*num.ones((n,time_step_count),num.float)
     6866        va=-10*num.ones((n,time_step_count),num.float)
    68676867
    68686868        base_name, files = self.write_mux2(lat_long_points,
     
    69146914        lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)]
    69156915        n=len(lat_long_points)
    6916         first_tstep=num.ones(n,num.Int)
     6916        first_tstep=num.ones(n,num.int)
    69176917        first_tstep[0]+=1
    69186918        first_tstep[2]+=1
    6919         last_tstep=(time_step_count)*num.ones(n,num.Int)
     6919        last_tstep=(time_step_count)*num.ones(n,num.int)
    69206920        last_tstep[0]-=1
    69216921
    6922         gauge_depth=20*num.ones(n,num.Float)
    6923         ha=2*num.ones((n,time_step_count),num.Float)
     6922        gauge_depth=20*num.ones(n,num.float)
     6923        ha=2*num.ones((n,time_step_count),num.float)
    69246924        ha[0]=num.arange(0,time_step_count)
    69256925        ha[1]=num.arange(time_step_count,2*time_step_count)
    69266926        ha[2]=num.arange(2*time_step_count,3*time_step_count)
    69276927        ha[3]=num.arange(3*time_step_count,4*time_step_count)
    6928         ua=5*num.ones((n,time_step_count),num.Float)
    6929         va=-10*num.ones((n,time_step_count),num.Float)
     6928        ua=5*num.ones((n,time_step_count),num.float)
     6929        va=-10*num.ones((n,time_step_count),num.float)
    69306930
    69316931        # Create two identical mux files to be combined by urs2sts
     
    70167016        #momentum = velocity_ua *(stage+depth)
    70177017
    7018         depth=num.zeros((len(lat_long_points),time_step_count),num.Float)
     7018        depth=num.zeros((len(lat_long_points),time_step_count),num.float)
    70197019        for i in range(len(lat_long_points)):
    70207020            depth[i]=gauge_depth[i]+tide+2.0*ha[i]
     
    73867386        lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)]
    73877387        n=len(lat_long_points)
    7388         first_tstep=num.ones(n,num.Int)
     7388        first_tstep=num.ones(n,num.int)
    73897389        first_tstep[0]+=1
    73907390        first_tstep[2]+=1
    7391         last_tstep=(time_step_count)*num.ones(n,num.Int)
     7391        last_tstep=(time_step_count)*num.ones(n,num.int)
    73927392        last_tstep[0]-=1
    73937393
    7394         gauge_depth=20*num.ones(n,num.Float)
    7395         ha=2*num.ones((n,time_step_count),num.Float)
     7394        gauge_depth=20*num.ones(n,num.float)
     7395        ha=2*num.ones((n,time_step_count),num.float)
    73967396        ha[0]=num.arange(0,time_step_count)
    73977397        ha[1]=num.arange(time_step_count,2*time_step_count)
    73987398        ha[2]=num.arange(2*time_step_count,3*time_step_count)
    73997399        ha[3]=num.arange(3*time_step_count,4*time_step_count)
    7400         ua=5*num.ones((n,time_step_count),num.Float)
    7401         va=-10*num.ones((n,time_step_count),num.Float)
     7400        ua=5*num.ones((n,time_step_count),num.float)
     7401        va=-10*num.ones((n,time_step_count),num.float)
    74027402
    74037403        # Create two identical mux files to be combined by urs2sts
     
    75307530        #momentum = velocity_ua *(stage+depth)
    75317531
    7532         depth=num.zeros((len(lat_long_points),time_step_count),num.Float)
     7532        depth=num.zeros((len(lat_long_points),time_step_count),num.float)
    75337533        for i in range(len(lat_long_points)):
    75347534            depth[i]=gauge_depth[i]+tide+2.0*ha[i]
     
    75737573        lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)]
    75747574        n=len(lat_long_points)
    7575         first_tstep=num.ones(n,num.Int)
     7575        first_tstep=num.ones(n,num.int)
    75767576        first_tstep[0]+=1
    75777577        first_tstep[2]+=1
    7578         last_tstep=(time_step_count)*num.ones(n,num.Int)
     7578        last_tstep=(time_step_count)*num.ones(n,num.int)
    75797579        last_tstep[0]-=1
    75807580
    7581         gauge_depth=20*num.ones(n,num.Float)
    7582         ha=2*num.ones((n,time_step_count),num.Float)
     7581        gauge_depth=20*num.ones(n,num.float)
     7582        ha=2*num.ones((n,time_step_count),num.float)
    75837583        ha[0]=num.arange(0,time_step_count)
    75847584        ha[1]=num.arange(time_step_count,2*time_step_count)
    75857585        ha[2]=num.arange(2*time_step_count,3*time_step_count)
    75867586        ha[3]=num.arange(3*time_step_count,4*time_step_count)
    7587         ua=5*num.ones((n,time_step_count),num.Float)
    7588         va=-10*num.ones((n,time_step_count),num.Float)
     7587        ua=5*num.ones((n,time_step_count),num.float)
     7588        va=-10*num.ones((n,time_step_count),num.float)
    75897589
    75907590        # Create two identical mux files to be combined by urs2sts
     
    76697669       
    76707670        # Create different timeseries starting and ending at different times
    7671         first_tstep=num.ones(n,num.Int)
     7671        first_tstep=num.ones(n,num.int)
    76727672        first_tstep[0]+=2   # Point 0 starts at 2
    76737673        first_tstep[1]+=4   # Point 1 starts at 4       
    76747674        first_tstep[2]+=3   # Point 2 starts at 3
    76757675       
    7676         last_tstep=(time_step_count)*num.ones(n,num.Int)
     7676        last_tstep=(time_step_count)*num.ones(n,num.int)
    76777677        last_tstep[0]-=1    # Point 0 ends 1 step early
    76787678        last_tstep[1]-=2    # Point 1 ends 2 steps early               
     
    76877687       
    76887688        # Create varying elevation data (positive values for seafloor)
    7689         gauge_depth=20*num.ones(n,num.Float)
     7689        gauge_depth=20*num.ones(n,num.float)
    76907690        for i in range(n):
    76917691            gauge_depth[i] += i**2
     
    76947694       
    76957695        # Create data to be written to first mux file       
    7696         ha0=2*num.ones((n,time_step_count),num.Float)
     7696        ha0=2*num.ones((n,time_step_count),num.float)
    76977697        ha0[0]=num.arange(0,time_step_count)
    76987698        ha0[1]=num.arange(time_step_count,2*time_step_count)
    76997699        ha0[2]=num.arange(2*time_step_count,3*time_step_count)
    77007700        ha0[3]=num.arange(3*time_step_count,4*time_step_count)
    7701         ua0=5*num.ones((n,time_step_count),num.Float)
    7702         va0=-10*num.ones((n,time_step_count),num.Float)
     7701        ua0=5*num.ones((n,time_step_count),num.float)
     7702        va0=-10*num.ones((n,time_step_count),num.float)
    77037703
    77047704        # Ensure data used to write mux file to be zero when gauges are
     
    77317731                                             
    77327732        # Create data to be written to second mux file       
    7733         ha1=num.ones((n,time_step_count),num.Float)
     7733        ha1=num.ones((n,time_step_count),num.float)
    77347734        ha1[0]=num.sin(times_ref)
    77357735        ha1[1]=2*num.sin(times_ref - 3)
     
    77387738        ha1[4]=num.sin(2*times_ref-0.7)
    77397739               
    7740         ua1=num.zeros((n,time_step_count),num.Float)
     7740        ua1=num.zeros((n,time_step_count),num.float)
    77417741        ua1[0]=3*num.cos(times_ref)       
    77427742        ua1[1]=2*num.sin(times_ref-0.7)   
     
    77447744        ua1[4]=2*num.ones(time_step_count)
    77457745       
    7746         va1=num.zeros((n,time_step_count),num.Float)
     7746        va1=num.zeros((n,time_step_count),num.float)
    77477747        va1[0]=2*num.cos(times_ref-0.87)       
    7748         va1[1]=3*num.ones(time_step_count)
     7748        va1[1]=3*num.ones(time_step_count, num.int)       #array default#
    77497749        va1[3]=2*num.sin(times_ref-0.71)       
    77507750       
     
    78737873        #momentum = velocity_ua *(stage+depth)
    78747874
    7875         depth_ref = num.zeros((len(permutation), time_step_count), num.Float)
     7875        depth_ref = num.zeros((len(permutation), time_step_count), num.float)
    78767876        for i in range(len(permutation)):
    78777877            depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i]
     
    79867986        #momentum = velocity_ua *(stage+depth)
    79877987
    7988         depth_ref = num.zeros((len(permutation), time_step_count), num.Float)
     7988        depth_ref = num.zeros((len(permutation), time_step_count), num.float)
    79897989        for i in range(len(permutation)):
    79907990            depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i]
     
    80928092        #momentum = velocity_ua *(stage+depth)
    80938093
    8094         depth_ref = num.zeros((len(permutation), time_step_count), num.Float)
     8094        depth_ref = num.zeros((len(permutation), time_step_count), num.float)
    80958095        for i in range(len(permutation)):
    80968096            depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i]
     
    81618161        lat_long_points =bounding_polygon[0:3]
    81628162        n=len(lat_long_points)
    8163         first_tstep=num.ones(n,num.Int)
    8164         last_tstep=(time_step_count)*num.ones(n,num.Int)
     8163        first_tstep=num.ones(n,num.int)
     8164        last_tstep=(time_step_count)*num.ones(n,num.int)
    81658165
    81668166        h = 20       
     
    81688168        u = 10
    81698169        v = -10
    8170         gauge_depth=h*num.ones(n,num.Float)
    8171         ha=w*num.ones((n,time_step_count),num.Float)
    8172         ua=u*num.ones((n,time_step_count),num.Float)
    8173         va=v*num.ones((n,time_step_count),num.Float)
     8170        gauge_depth=h*num.ones(n,num.float)
     8171        ha=w*num.ones((n,time_step_count),num.float)
     8172        ua=u*num.ones((n,time_step_count),num.float)
     8173        va=v*num.ones((n,time_step_count),num.float)
    81748174        base_name, files = self.write_mux2(lat_long_points,
    81758175                                           time_step_count, time_step,
     
    82248224        finaltime=time_step*(time_step_count-1)
    82258225        yieldstep=time_step
    8226         temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.Float)
     8226        temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.float)
    82278227
    82288228        for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep,
     
    82508250
    82518251        domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br})
    8252         temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.Float)
     8252        temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.float)
    82538253
    82548254        for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep,
     
    83058305        lat_long_points = bounding_polygon[0:3]
    83068306        n=len(lat_long_points)
    8307         first_tstep=num.ones(n,num.Int)
    8308         last_tstep=(time_step_count)*num.ones(n,num.Int)
     8307        first_tstep=num.ones(n,num.int)
     8308        last_tstep=(time_step_count)*num.ones(n,num.int)
    83098309
    83108310        h = 20       
     
    83128312        u = 10
    83138313        v = -10
    8314         gauge_depth=h*num.ones(n,num.Float)
    8315         ha=w*num.ones((n,time_step_count),num.Float)
    8316         ua=u*num.ones((n,time_step_count),num.Float)
    8317         va=v*num.ones((n,time_step_count),num.Float)
     8314        gauge_depth=h*num.ones(n,num.float)
     8315        ha=w*num.ones((n,time_step_count),num.float)
     8316        ua=u*num.ones((n,time_step_count),num.float)
     8317        va=v*num.ones((n,time_step_count),num.float)
    83188318        base_name, files = self.write_mux2(lat_long_points,
    83198319                                           time_step_count, time_step,
     
    83778377        finaltime = data_finaltime + 10 # Let model time exceed available data
    83788378        yieldstep = time_step
    8379         temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num.Float)
     8379        temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num.float)
    83808380
    83818381        for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep,
     
    84098409
    84108410        domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br})
    8411         temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.Float)
     8411        temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.float)
    84128412
    84138413        for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep,
     
    84638463        lat_long_points = bounding_polygon[0:3]
    84648464        n=len(lat_long_points)
    8465         first_tstep=num.ones(n,num.Int)
    8466         last_tstep=(time_step_count)*num.ones(n,num.Int)
     8465        first_tstep=num.ones(n,num.int)
     8466        last_tstep=(time_step_count)*num.ones(n,num.int)
    84678467
    84688468        h = 20       
     
    84708470        u = 10
    84718471        v = -10
    8472         gauge_depth=h*num.ones(n,num.Float)
    8473         ha=w*num.ones((n,time_step_count),num.Float)
    8474         ua=u*num.ones((n,time_step_count),num.Float)
    8475         va=v*num.ones((n,time_step_count),num.Float)
     8472        gauge_depth=h*num.ones(n,num.float)
     8473        ha=w*num.ones((n,time_step_count),num.float)
     8474        ua=u*num.ones((n,time_step_count),num.float)
     8475        va=v*num.ones((n,time_step_count),num.float)
    84768476        base_name, files = self.write_mux2(lat_long_points,
    84778477                                           time_step_count, time_step,
     
    85388538        finaltime = data_finaltime + 10 # Let model time exceed available data
    85398539        yieldstep = time_step
    8540         temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num.Float)
     8540        temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num.float)
    85418541
    85428542        for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep,
     
    85828582        lat_long_points.insert(0,[6.0,97.01])
    85838583        n=len(lat_long_points)
    8584         first_tstep=num.ones(n,num.Int)
    8585         last_tstep=(time_step_count)*num.ones(n,num.Int)
    8586         gauge_depth=20*num.ones(n,num.Float)
    8587         ha=2*num.ones((n,time_step_count),num.Float)
    8588         ua=10*num.ones((n,time_step_count),num.Float)
    8589         va=-10*num.ones((n,time_step_count),num.Float)
     8584        first_tstep=num.ones(n,num.int)
     8585        last_tstep=(time_step_count)*num.ones(n,num.int)
     8586        gauge_depth=20*num.ones(n,num.float)
     8587        ha=2*num.ones((n,time_step_count),num.float)
     8588        ua=10*num.ones((n,time_step_count),num.float)
     8589        va=-10*num.ones((n,time_step_count),num.float)
    85908590        base_name, files = self.write_mux2(lat_long_points,
    85918591                                           time_step_count,
     
    86298629        finaltime=time_step*(time_step_count-1)
    86308630        yieldstep=time_step
    8631         temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.Float)
     8631        temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.float)
    86328632       
    86338633        for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep,
     
    86418641        Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide])
    86428642        domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br})
    8643         temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.Float)
     8643        temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.float)
    86448644
    86458645        for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep,
     
    86888688        time_step = 2
    86898689        n=len(lat_long_points)
    8690         first_tstep=num.ones(n,num.Int)
    8691         last_tstep=(time_step_count)*num.ones(n,num.Int)
    8692         gauge_depth=20*num.ones(n,num.Float)
    8693         ha=2*num.ones((n,time_step_count),num.Float)
    8694         ua=10*num.ones((n,time_step_count),num.Float)
    8695         va=-10*num.ones((n,time_step_count),num.Float)
     8690        first_tstep=num.ones(n,num.int)
     8691        last_tstep=(time_step_count)*num.ones(n,num.int)
     8692        gauge_depth=20*num.ones(n,num.float)
     8693        ha=2*num.ones((n,time_step_count),num.float)
     8694        ua=10*num.ones((n,time_step_count),num.float)
     8695        va=-10*num.ones((n,time_step_count),num.float)
    86968696        base_name, files = self.write_mux2(lat_long_points,
    86978697                                           time_step_count,
     
    87798779        finaltime=time_step*(time_step_count-1)
    87808780        yieldstep=time_step
    8781         temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.Float)
     8781        temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.float)
    87828782   
    87838783        for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep,
     
    87928792        Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide])
    87938793        domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br})
    8794         temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.Float)
     8794        temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.float)
    87958795       
    87968796        for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep,
     
    88548854       
    88558855        n=len(lat_long_points)
    8856         first_tstep=num.ones(n,num.Int)
    8857         last_tstep=(time_step_count)*num.ones(n,num.Int)
    8858        
    8859         gauge_depth=20*num.ones(n,num.Float)
    8860        
    8861         ha1=num.ones((n,time_step_count),num.Float)
    8862         ua1=3.*num.ones((n,time_step_count),num.Float)
    8863         va1=2.*num.ones((n,time_step_count),num.Float)
     8856        first_tstep=num.ones(n,num.int)
     8857        last_tstep=(time_step_count)*num.ones(n,num.int)
     8858       
     8859        gauge_depth=20*num.ones(n,num.float)
     8860       
     8861        ha1=num.ones((n,time_step_count),num.float)
     8862        ua1=3.*num.ones((n,time_step_count),num.float)
     8863        va1=2.*num.ones((n,time_step_count),num.float)
    88648864        for i in range(n):
    88658865            ha1[i]=num.sin(times_ref)
     
    89768976        finaltime=time_step*(time_step_count-1)
    89778977        yieldstep=time_step
    8978         temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.Float)
     8978        temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.float)
    89798979   
    89808980        for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep,
     
    89918991        domain_time.set_boundary({'ocean': Bw,'otherocean': Br})
    89928992       
    8993         temp_time=num.zeros(int(finaltime/yieldstep)+1,num.Float)
     8993        temp_time=num.zeros(int(finaltime/yieldstep)+1,num.float)
    89948994        for i, t in enumerate(domain_time.evolve(yieldstep=yieldstep,
    89958995                                                   finaltime=finaltime,
     
    90509050       
    90519051        n=len(lat_long_points)
    9052         first_tstep=num.ones(n,num.Int)
    9053         last_tstep=(time_step_count)*num.ones(n,num.Int)
    9054        
    9055         gauge_depth=20*num.ones(n,num.Float)
    9056        
    9057         ha1=num.ones((n,time_step_count),num.Float)
    9058         ua1=3.*num.ones((n,time_step_count),num.Float)
    9059         va1=2.*num.ones((n,time_step_count),num.Float)
     9052        first_tstep=num.ones(n,num.int)
     9053        last_tstep=(time_step_count)*num.ones(n,num.int)
     9054       
     9055        gauge_depth=20*num.ones(n,num.float)
     9056       
     9057        ha1=num.ones((n,time_step_count),num.float)
     9058        ua1=3.*num.ones((n,time_step_count),num.float)
     9059        va1=2.*num.ones((n,time_step_count),num.float)
    90609060        for i in range(n):
    90619061            ha1[i]=num.sin(times_ref)
     
    1012710127        sww.store_header(outfile, times, number_of_volumes,
    1012810128                         number_of_points, description='fully sick testing',
    10129                          verbose=self.verbose,sww_precision=num.Float)
     10129                         verbose=self.verbose,sww_precision=netcdf_float)
    1013010130        sww.store_triangulation(outfile, points_utm, volumes,
    1013110131                                elevation,  new_origin=new_origin,
     
    1015910159        sww.store_header(outfile, times, number_of_volumes,
    1016010160                         number_of_points, description='fully sick testing',
    10161                          verbose=self.verbose,sww_precision=num.Float)
     10161                         verbose=self.verbose,sww_precision=netcdf_float)
    1016210162        sww.store_triangulation(outfile, points_utm, volumes,
    1016310163                                elevation,  new_origin=new_origin,
     
    1019510195        sww.store_header(outfile, times, number_of_volumes,
    1019610196                         number_of_points, description='fully sick testing',
    10197                          verbose=self.verbose,sww_precision=num.Float)
     10197                         verbose=self.verbose,sww_precision=netcdf_float)
    1019810198        sww.store_triangulation(outfile, points_utm, volumes,
    1019910199                                elevation,  new_origin=new_origin,
     
    1023410234        sww.store_header(outfile, times, number_of_volumes,
    1023510235                         number_of_points, description='fully sick testing',
    10236                          verbose=self.verbose,sww_precision=num.Float)
     10236                         verbose=self.verbose,sww_precision=netcdf_float)
    1023710237        sww.store_triangulation(outfile, points_utm, volumes,
    1023810238                                elevation,  new_origin=new_origin,
     
    1027010270        sww.store_header(outfile, times, number_of_volumes,
    1027110271                         number_of_points, description='fully sick testing',
    10272                          verbose=self.verbose,sww_precision=num.Float)
     10272                         verbose=self.verbose,sww_precision=netcdf_float)
    1027310273        sww.store_triangulation(outfile, points_utm, volumes,
    1027410274                                elevation,  new_origin=new_origin,
     
    1062910629
    1063010630        # Check runup restricted to a polygon
    10631         p = num.array([[50,1], [99,1], [99,49], [50,49]], num.Int) + num.array([E, N], num.Int)      #array default#
     10631        p = num.array([[50,1], [99,1], [99,49], [50,49]]) + num.array([E, N])
    1063210632
    1063310633        runup = get_maximum_inundation_elevation(swwfile, polygon=p)
  • branches/numpy/anuga/shallow_water/test_eq.py

    r6157 r6304  
    11import unittest
    2 import Numeric as num
     2import numpy as num
    33from eqf import earthquake_tsunami, Okada_func
    44
  • branches/numpy/anuga/shallow_water/test_most2nc.py

    r6157 r6304  
    11import unittest
    2 import Numeric as num
     2import numpy as num
    33from Scientific.IO.NetCDF import NetCDFFile
    44import most2nc
  • branches/numpy/anuga/shallow_water/test_shallow_water_domain.py

    r6244 r6304  
    77from anuga.config import g, epsilon
    88from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    9 import Numeric as num
     9import numpy as num
    1010from anuga.utilities.numerical_tools import mean
    1111from anuga.utilities.polygon import is_inside_polygon
     
    3737        assert N == len(y)
    3838
    39         z = num.zeros(N, num.Float)
     39        z = num.zeros(N, num.float)
    4040        for i in range(N):
    4141            z[i] = -x[i]/2  #General slope
     
    142142        assert N == len(y)
    143143
    144         z = num.zeros(N, num.Float)
     144        z = num.zeros(N, num.float)
    145145        for i in range(N):
    146146            z[i] = -x[i]  #General slope
     
    195195def scalar_func(t,x,y):
    196196    """Function that returns a scalar.
    197     Used to test error message when Numeric array is expected
     197    Used to test error message when numeric array is expected
    198198    """
    199199
     
    254254        #Check error check
    255255        try:
    256             rotate(r, num.array([1,1,1], num.Int))      #array default#
     256            rotate(r, num.array([1,1,1]))
    257257        except:
    258258            pass
     
    263263    # Individual flux tests
    264264    def test_flux_zero_case(self):
    265         ql = num.zeros( 3, num.Float )
    266         qr = num.zeros( 3, num.Float )
    267         normal = num.zeros( 2, num.Float )
    268         edgeflux = num.zeros( 3, num.Float )
     265        ql = num.zeros( 3, num.float )
     266        qr = num.zeros( 3, num.float )
     267        normal = num.zeros( 2, num.float )
     268        edgeflux = num.zeros( 3, num.float )
    269269        zl = zr = 0.
    270270        H0 = 0.0
     
    281281        ql = num.array([w, 0, 0])
    282282        qr = num.array([w, 0, 0])
    283         edgeflux = num.zeros(3, num.Float)       
     283        edgeflux = num.zeros(3, num.float)       
    284284        zl = zr = 0.
    285285        h = w - (zl+zr)/2
     
    312312        qr = num.array([-0.2, 2, 3])
    313313        zl = zr = -0.5
    314         edgeflux = num.zeros(3, num.Float)               
     314        edgeflux = num.zeros(3, num.float)               
    315315
    316316        H0 = 0.0
     
    329329        zl = zr = -0.375
    330330
    331         edgeflux = num.zeros(3, num.Float)               
     331        edgeflux = num.zeros(3, num.float)               
    332332        H0 = 0.0
    333333        max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0)       
     
    343343        zl = zr = -0.375
    344344
    345         edgeflux = num.zeros(3, num.Float)               
     345        edgeflux = num.zeros(3, num.float)               
    346346        H0 = 0.0
    347347        max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0)       
     
    357357        zl = zr = -0.375
    358358
    359         edgeflux = num.zeros(3, num.Float)               
     359        edgeflux = num.zeros(3, num.float)               
    360360        H0 = 0.0
    361361        max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0)               
     
    433433            assert domain.quantities.has_key(name)
    434434
    435 
    436         assert domain.get_conserved_quantities(0, edge=1) == 0.
     435        assert num.alltrue(domain.get_conserved_quantities(0, edge=1) == 0.)
    437436
    438437
     
    709708        zl=zr=0. # Assume flat bed
    710709
    711         edgeflux = num.zeros(3, num.Float)       
    712         edgeflux0 = num.zeros(3, num.Float)
    713         edgeflux1 = num.zeros(3, num.Float)
    714         edgeflux2 = num.zeros(3, num.Float)                               
     710        edgeflux = num.zeros(3, num.float)       
     711        edgeflux0 = num.zeros(3, num.float)
     712        edgeflux1 = num.zeros(3, num.float)
     713        edgeflux2 = num.zeros(3, num.float)                               
    715714        H0 = 0.0       
    716715
     
    797796        zl=zr=0. #Assume flat bed
    798797
    799         edgeflux = num.zeros(3, num.Float)       
    800         edgeflux0 = num.zeros(3, num.Float)
    801         edgeflux1 = num.zeros(3, num.Float)
    802         edgeflux2 = num.zeros(3, num.Float)                               
     798        edgeflux = num.zeros(3, num.float)       
     799        edgeflux0 = num.zeros(3, num.float)
     800        edgeflux1 = num.zeros(3, num.float)
     801        edgeflux2 = num.zeros(3, num.float)                               
    803802        H0 = 0.0       
    804803       
     
    905904
    906905        zl=zr=0 #Assume flat zero bed
    907         edgeflux = num.zeros(3, num.Float)       
    908         edgeflux0 = num.zeros(3, num.Float)
    909         edgeflux1 = num.zeros(3, num.Float)
    910         edgeflux2 = num.zeros(3, num.Float)                               
     906        edgeflux = num.zeros(3, num.float)       
     907        edgeflux0 = num.zeros(3, num.float)
     908        edgeflux1 = num.zeros(3, num.float)
     909        edgeflux2 = num.zeros(3, num.float)                               
    911910        H0 = 0.0       
    912911       
    913912
    914         domain.set_quantity('elevation', zl*num.ones( (4,3) ))
     913        domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default#
    915914
    916915
     
    988987
    989988        zl=zr=-3.75 #Assume constant bed (must be less than stage)
    990         domain.set_quantity('elevation', zl*num.ones( (4,3) ))
    991 
    992 
    993         edgeflux = num.zeros(3, num.Float)       
    994         edgeflux0 = num.zeros(3, num.Float)
    995         edgeflux1 = num.zeros(3, num.Float)
    996         edgeflux2 = num.zeros(3, num.Float)                               
     989        domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default#
     990
     991
     992        edgeflux = num.zeros(3, num.float)       
     993        edgeflux0 = num.zeros(3, num.float)
     994        edgeflux1 = num.zeros(3, num.float)
     995        edgeflux2 = num.zeros(3, num.float)                               
    997996        H0 = 0.0       
    998997       
     
    10711070
    10721071        zl=zr=4  #Too large
    1073         domain.set_quantity('elevation', zl*num.ones( (4,3) ))
     1072        domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default#
    10741073        domain.set_quantity('stage', [[val0, val0-1, val0-2],
    10751074                                      [val1, val1+1, val1],
     
    11051104
    11061105        zl=zr=5
    1107         domain.set_quantity('elevation', zl*num.ones( (4,3) ))
     1106        domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default#
    11081107        domain.set_quantity('stage', [[val0, val0-1, val0-2],
    11091108                                      [val1, val1+1, val1],
     
    26212620    def test_time_dependent_rainfall_using_starttime(self):
    26222621   
    2623         rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.Float)   
     2622        rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.float)   
    26242623
    26252624        a = [0.0, 0.0]
     
    26922691
    26932692       
    2694         rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.Float)
     2693        rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.float)
    26952694        rainfall_poly += [x0, y0]
    26962695
     
    31423141
    31433142        zl=zr=-3.75 #Assume constant bed (must be less than stage)
    3144         domain.set_quantity('elevation', zl*num.ones( (4,3) ))
     3143        domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default#
    31453144        domain.set_quantity('stage', [[val0, val0-1, val0-2],
    31463145                                      [val1, val1+1, val1],
     
    45604559            if V:
    45614560                #Set centroids as if system had been evolved
    4562                 L = num.zeros(2*N*N, num.Float)
     4561                L = num.zeros(2*N*N, num.float)
    45634562                L[:32] = [7.21205592e-003, 5.35214298e-002, 1.00910824e-002,
    45644563                          5.35439433e-002, 1.00910824e-002, 5.35439433e-002,
     
    45734572                          0.00000000e+000, 5.57305948e-005]
    45744573
    4575                 X = num.zeros(2*N*N, num.Float)
     4574                X = num.zeros(2*N*N, num.float)
    45764575                X[:32] = [6.48351607e-003, 3.68571894e-002, 8.50733285e-003,
    45774576                          3.68731327e-002, 8.50733285e-003, 3.68731327e-002,
     
    45864585                          0.00000000e+000, 4.57662812e-005]
    45874586
    4588                 Y = num.zeros(2*N*N, num.Float)
     4587                Y = num.zeros(2*N*N, num.float)
    45894588                Y[:32]=[-1.39463104e-003, 6.15600298e-004, -6.03637382e-004,
    45904589                        6.18272251e-004, -6.03637382e-004, 6.18272251e-004,
     
    56915690
    56925691        #print points[0], points[5], points[10], points[15]
    5693         assert num.allclose( num.take(points, [0,5,10,15]),
    5694                              [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]])
     5692        msg = ('value was %s,\nshould be [[0,0], [1.0/3, 1.0/3], '
     5693               '[2.0/3, 2.0/3], [1,1]]' % str(num.take(points, [0,5,10,15])))
     5694        assert num.allclose(num.take(points, [0,5,10,15]),
     5695                            [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg
    56955696
    56965697
     
    58725873
    58735874        #print points[0], points[5], points[10], points[15]
    5874         assert num.allclose( num.take(points, [0,5,10,15]),
    5875                              [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]])
     5875        msg = ('values was %s,\nshould be [[0,0], [1.0/3, 1.0/3], '
     5876               '[2.0/3, 2.0/3], [1,1]]' % str(num.take(points, [0,5,10,15])))
     5877        assert num.allclose(num.take(points, [0,5,10,15]),
     5878                            [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg
    58765879
    58775880
     
    60456048
    60466049        #print points[0], points[5], points[10], points[15]
    6047         assert num.allclose( num.take(points, [0,5,10,15]),
    6048                              [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]])
     6050        msg = ('value was %s,\nshould be [[0,0], [1.0/3, 1.0/3], '
     6051               '[2.0/3, 2.0/3], [1,1]]' % str(num.take(points, [0,5,10,15])))
     6052        assert num.allclose(num.take(points, [0,5,10,15]),
     6053                            [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg
     6054
    60496055
    60506056
     
    62376243
    62386244        bed = domain.quantities['elevation'].vertex_values
    6239         stage = num.zeros(bed.shape, num.Float)
     6245        stage = num.zeros(bed.shape, num.float)
    62406246
    62416247        h = 0.3
  • branches/numpy/anuga/shallow_water/test_smf.py

    r6157 r6304  
    11import unittest
    2 import Numeric as num
     2import numpy as num
    33from smf import slide_tsunami, slump_tsunami, Double_gaussian
    44
  • branches/numpy/anuga/shallow_water/test_system.py

    r6157 r6304  
    99
    1010from Scientific.IO.NetCDF import NetCDFFile
    11 import Numeric as num
     11import numpy as num
    1212
    1313from anuga.shallow_water import Domain
     
    3434        20       13.9773
    3535        """
     36
    3637        tide = 5
    3738        boundary_filename = tempfile.mktemp(".sww")
     
    8586        boundary_filename = self.create_sww_boundary(boundary_starttime)
    8687        filename = tempfile.mktemp(".sww")
    87         #print "filename",filename
    8888        dir, base = os.path.split(filename)
    8989        senario_name = base[:-4]
  • branches/numpy/anuga/shallow_water/test_tsunami_okada.py

    r6157 r6304  
    11import unittest
    2 import Numeric as num
     2import numpy as num
    33from tsunami_okada import earthquake_tsunami,Okada_func
    44
  • branches/numpy/anuga/shallow_water/tsunami_okada.py

    r6157 r6304  
    3030"""
    3131
    32 import Numeric as num
     32import numpy as num
    3333
    3434
     
    4545    zrec=zrec0.get_vertex_values(xy=True)
    4646   
    47     x0= num.zeros(ns,num.Float)
    48     y0= num.zeros(ns,num.Float)
     47    x0= num.zeros(ns,num.float)
     48    y0= num.zeros(ns,num.float)
    4949    if ns ==1:
    5050        x0[0]=xi
     
    151151        zrec=self.zrec
    152152        #initialization
    153         disp0=num.zeros(3,num.Float)
    154         strain0=num.zeros(6,num.Float)
    155         tilt0 = num.zeros(2,num.Float)
    156         dislocations=num.zeros(ns,num.Float)
    157         depths=num.zeros(ns,num.Float)
    158         strikes= num.zeros(ns,num.Float)
    159         lengths= num.zeros(ns,num.Float)
    160         slips= num.zeros(ns,num.Float)
    161         rakes= num.zeros(ns,num.Float)
    162         widths= num.zeros(ns,num.Float)
    163         dips= num.zeros(ns,num.Float)
    164         strikes= num.zeros(ns,num.Float)
    165         strikes= num.zeros(ns,num.Float)
    166         strain = num.zeros((N,6),num.Float)
    167         disp = num.zeros((N,3),num.Float)
    168         tilt = num.zeros((N,2),num.Float)
    169         xs =num.zeros(ns,num.Float)
    170         ys =num.zeros(ns,num.Float)
     153        disp0=num.zeros(3,num.float)
     154        strain0=num.zeros(6,num.float)
     155        tilt0 = num.zeros(2,num.float)
     156        dislocations=num.zeros(ns,num.float)
     157        depths=num.zeros(ns,num.float)
     158        strikes= num.zeros(ns,num.float)
     159        lengths= num.zeros(ns,num.float)
     160        slips= num.zeros(ns,num.float)
     161        rakes= num.zeros(ns,num.float)
     162        widths= num.zeros(ns,num.float)
     163        dips= num.zeros(ns,num.float)
     164        strikes= num.zeros(ns,num.float)
     165        strikes= num.zeros(ns,num.float)
     166        strain = num.zeros((N,6),num.float)
     167        disp = num.zeros((N,3),num.float)
     168        tilt = num.zeros((N,2),num.float)
     169        xs =num.zeros(ns,num.float)
     170        ys =num.zeros(ns,num.float)
    171171        z=[]
    172172        if ns==1:
     
    378378         
    379379          F0=0.0                                                   
    380           U=num.zeros((12,1),num.Float)
    381           DUA=num.zeros((12,1),num.Float)
    382           DUB=num.zeros((12,1),num.Float)
    383           DUC=num.zeros((12,1),num.Float)
     380          U=num.zeros((12,1),num.float)
     381          DUA=num.zeros((12,1),num.float)
     382          DUB=num.zeros((12,1),num.float)
     383          DUC=num.zeros((12,1),num.float)
    384384         
    385385         
     
    526526       WZ=self.WZ
    527527
    528        DUA=num.zeros((12,1),num.Float)
    529        DU=num.zeros((12,1),num.Float)
    530        U=num.zeros((12,1),num.Float)
     528       DUA=num.zeros((12,1),num.float)
     529       DU=num.zeros((12,1),num.float)
     530       U=num.zeros((12,1),num.float)
    531531#-----                                                               
    532532       for I in range(0,12):                                                   
     
    636636#      DATA PI2/6.283185307179586D0/
    637637       
    638         DUB=num.zeros((12,1),num.Float)
    639         DU=num.zeros((12,1),num.Float)
    640         U=num.zeros((12,1),num.Float)
     638        DUB=num.zeros((12,1),num.float)
     639        DU=num.zeros((12,1),num.float)
     640        U=num.zeros((12,1),num.float)
    641641       
    642642        F0=0.0
     
    811811       
    812812
    813       DUC=num.zeros((12,1),num.Float)
    814       DU=num.zeros((12,1),num.Float)
    815       U=num.zeros((12,1),num.Float)
     813      DUC=num.zeros((12,1),num.float)
     814      DU=num.zeros((12,1),num.float)
     815      U=num.zeros((12,1),num.float)
    816816             
    817817      F0=0.0
     
    10051005      EPS=0.000001
    10061006       
    1007       XI=num.zeros(2,num.Float)
    1008       ET=num.zeros(2,num.Float)
    1009       KXI=num.zeros(2,num.Float)
    1010       KET=num.zeros(2,num.Float)
    1011       U=num.zeros(12,num.Float)
    1012       DU=num.zeros(12,num.Float)
    1013       DUA=num.zeros(12,num.Float)
    1014       DUB=num.zeros(12,num.Float)
    1015       DUC=num.zeros(12,num.Float)
     1007      XI=num.zeros(2,num.float)
     1008      ET=num.zeros(2,num.float)
     1009      KXI=num.zeros(2,num.float)
     1010      KET=num.zeros(2,num.float)
     1011      U=num.zeros(12,num.float)
     1012      DU=num.zeros(12,num.float)
     1013      DUA=num.zeros(12,num.float)
     1014      DUB=num.zeros(12,num.float)
     1015      DUC=num.zeros(12,num.float)
    10161016
    10171017#-----                                                                 
     
    12111211
    12121212
    1213       U=num.zeros(12,num.Float)
    1214       DU=num.zeros(12,num.Float)
    1215       DUA=num.zeros(12,num.Float)
     1213      U=num.zeros(12,num.float)
     1214      DU=num.zeros(12,num.float)
     1215      DUA=num.zeros(12,num.float)
    12161216      F0 =0.0
    12171217      F2=2.0
     
    13421342#      DATA  F0,F1,F2,PI2/0.D0,1.D0,2.D0,6.283185307179586D0/
    13431343
    1344       DUB=num.zeros(12,num.Float)
    1345       DU=num.zeros(12,num.Float)
    1346       U=num.zeros(12,num.Float)
     1344      DUB=num.zeros(12,num.float)
     1345      DU=num.zeros(12,num.float)
     1346      U=num.zeros(12,num.float)
    13471347     
    13481348      F0=0.0
     
    15071507 #     DATA F0,F1,F2,F3,PI2/0.D0,1.D0,2.D0,3.D0,6.283185307179586D0/
    15081508
    1509       DUC=num.zeros(12,num.Float)
    1510       DU=num.zeros(12,num.Float)
    1511       U=num.zeros(12,num.Float)
     1509      DUC=num.zeros(12,num.float)
     1510      DU=num.zeros(12,num.float)
     1511      U=num.zeros(12,num.float)
    15121512     
    15131513      F0=0.0
  • branches/numpy/anuga/shallow_water/urs_ext.c

    r5972 r6304  
    55
    66#include "Python.h"
    7 #include "Numeric/arrayobject.h"
     7#include "numpy/arrayobject.h"
    88#include "structure.h"
    99#include "math.h"
Note: See TracChangeset for help on using the changeset viewer.