Changeset 8780


Ignore:
Timestamp:
Mar 27, 2013, 8:04:00 PM (12 years ago)
Author:
steve
Message:

Some changes to allow netcdf4 use

Location:
trunk/anuga_core/source
Files:
55 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/file_function.py

    r8718 r8780  
    1616
    1717from anuga.geospatial_data.geospatial_data import ensure_absolute
    18 from Scientific.IO.NetCDF import NetCDFFile
     18from anuga.file.netcdf import NetCDFFile
    1919from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    2020from anuga.utilities.numerical_tools import ensure_numeric
     
    297297    # Get first timestep
    298298    try:
    299         starttime = fid.starttime
     299        starttime = float(fid.starttime)
    300300    except ValueError:
    301301        msg = 'Could not read starttime from file %s' % filename
    302302        raise Exception(msg)
     303
    303304
    304305    # Get variables
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/gauge.py

    r8718 r8780  
    163163                if value.strip()=='elevation':elevation=j
    164164        else:
     165            #points.append([float(row[easting]),float(row[northing])])
    165166            points.append([float(row[easting]),float(row[northing])])
    166167            point_name.append(row[name])
     
    170171       
    171172    points_array = ensure_absolute(points_array)
     173
     174    #print 'points_array', points_array
    172175
    173176    dir_name, base = os.path.split(sww_file)   
     
    223226
    224227        if quake_offset_time is None:
    225             quake_offset_time = callable_sww.starttime[0]
     228            quake_offset_time = callable_sww.starttime
    226229
    227230        for point_i, point in enumerate(points_array):
     
    241244                        points_writer = writer(file(dir_name + sep + gauge_file
    242245                                                    + point_name[point_i] + '.csv', "ab"))
     246
    243247
    244248                    points_list = [quake_time, quake_time/3600.] +  _quantities2csv(quantities, point_quantities, callable_sww.centroids, point_i)
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_gauge.py

    r8718 r8780  
    99import anuga
    1010#from anuga.abstract_2d_finite_volumes.util import *
    11 from anuga.abstract_2d_finite_volumes.gauge import *
     11from anuga.abstract_2d_finite_volumes.gauge import sww2csv_gauges
    1212from anuga.config import epsilon
    1313
     
    9494       
    9595       
    96     def test_sww2csv(self):
     96    def test_sww2csv_0(self):
    9797
    9898        """Most of this test was copied from test_interpolate
     
    109109        points = [[5.0,1.],[0.5,2.]]
    110110
    111         points_file = tempfile.mktemp(".csv")
     111        points_file = tempfile.mktemp(".csv") 
    112112#        points_file = 'test_point.csv'
    113113        file_id = open(points_file,"w")
     
    155155        point1_handle.close()
    156156        point2_handle.close()
    157         os.remove(points_file)
    158         os.remove(point1_filename)
    159         os.remove(point2_filename)
     157        #os.remove(points_file)
     158        #os.remove(point1_filename)
     159        #os.remove(point2_filename)
    160160
    161161
     
    544544
    545545if __name__ == "__main__":
    546     suite = unittest.makeSuite(Test_Gauge, 'test')
     546    suite = unittest.makeSuite(Test_Gauge, 'test_')
    547547#    runner = unittest.TextTestRunner(verbosity=2)
    548548    runner = unittest.TextTestRunner(verbosity=1)
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r8599 r8780  
    173173
    174174        #Now read data from sww and check
    175         from Scientific.IO.NetCDF import NetCDFFile
     175        from anuga.file.netcdf import NetCDFFile
    176176        filename = domain1.get_name() + '.sww'
    177177        fid = NetCDFFile(filename)
     
    375375
    376376        #Now read data from sww and check
    377         from Scientific.IO.NetCDF import NetCDFFile
     377        from anuga.file.netcdf import NetCDFFile
    378378        filename = domain1.get_name() + '.sww'
    379379        fid = NetCDFFile(filename)
  • trunk/anuga_core/source/anuga/config.py

    r8745 r8780  
    228228s = """
    229229import os, tempfile
    230 from Scientific.IO.NetCDF import NetCDFFile
     230from anuga.file.netcdf import NetCDFFile
    231231
    232232filename = tempfile.mktemp('.nc')
     
    237237"""
    238238
     239"""
    239240# Need to run in a separate process due an
    240241# error with older versions of Scientific.IO
     
    265266        #netcdf_mode_w = 'w'   # Old style NetCDF used by OSG viewer
    266267
    267 
     268"""
  • trunk/anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py

    r8125 r8780  
    3030       
    3131    def test_read_write_NetCDF(self):
    32         from Scientific.IO.NetCDF import NetCDFFile
     32        from anuga.file.netcdf import NetCDFFile
    3333        g = Geo_reference(56,1.9,1.9)
    3434        file_name = tempfile.mktemp(".geo_referenceTest")
     
    4747    def test_read_NetCDFI(self):
    4848        # test if read_NetCDF
    49         from Scientific.IO.NetCDF import NetCDFFile
     49        from anuga.file.netcdf import NetCDFFile
    5050        g = Geo_reference(56,1.9,1.9)
    5151        file_name = tempfile.mktemp(".geo_referenceTest")
     
    6565       
    6666    def test_read_write_ASCII(self):
    67         from Scientific.IO.NetCDF import NetCDFFile
     67        from anuga.file.netcdf import NetCDFFile
    6868        g = Geo_reference(56,1.9,1.9)
    6969        file_name = tempfile.mktemp(".geo_referenceTest")
     
    8080   
    8181    def test_read_write_ASCII2(self):
    82         from Scientific.IO.NetCDF import NetCDFFile
     82        from anuga.file.netcdf import NetCDFFile
    8383        g = Geo_reference(56,1.9,1.9)
    8484        file_name = tempfile.mktemp(".geo_referenceTest")
     
    9595       
    9696    def test_read_write_ASCII3(self):
    97         from Scientific.IO.NetCDF import NetCDFFile
     97        from anuga.file.netcdf import NetCDFFile
    9898        g = Geo_reference(56,1.9,1.9)
    9999        file_name = tempfile.mktemp(".geo_referenceTest")
     
    498498
    499499    def test_read_write_ASCII_test_and_fail(self):
    500         from Scientific.IO.NetCDF import NetCDFFile
     500        from anuga.file.netcdf import NetCDFFile
    501501
    502502        # This is to test a fail
     
    631631        '''
    632632
    633         from Scientific.IO.NetCDF import NetCDFFile
     633        from anuga.file.netcdf import NetCDFFile
    634634
    635635        # ensure that basic instance attributes are correct
  • trunk/anuga_core/source/anuga/file/netcdf.py

    r8145 r8780  
    33
    44import numpy as num
    5 
    6 from Scientific.IO.NetCDF import NetCDFFile
    75
    86from anuga.coordinate_transforms.redfearn import \
     
    2220time_name = 'TIME'
    2321precision = netcdf_float # So if we want to change the precision its done here
     22
     23
     24
     25def NetCDFFile(file_name, netcdf_mode=netcdf_mode_r):
     26    """Wrapper to isolate changes of the netcdf libray.
     27
     28    In theory we should be able to change over to NetCDF4 via this
     29    wrapper, by ensuring the interface to the NetCDF library isthe same as the
     30    the old Scientific.IO.NetCDF library.
     31
     32    There is a difference between extracting dimensions. We have used the following
     33    to cover netcdf4 and scientific python
     34
     35    try: # works with netcdf4
     36        number_of_timesteps = len(fid.dimensions['number_of_timesteps'])
     37        number_of_points = len(fid.dimensions['number_of_points'])
     38    except: # works with scientific.io.netcdf
     39        number_of_timesteps = fid.dimensions['number_of_timesteps']
     40        number_of_points = fid.dimensions['number_of_points']
     41   
     42    """
     43
     44    #from Scientific.IO.NetCDF import NetCDFFile
     45    #return NetCDFFile(file_name, netcdf_mode)
     46
     47    from netCDF4 import Dataset
     48    return Dataset(file_name, netcdf_mode, format='NETCDF3_64BIT')
     49
     50    #return Dataset(file_name, netcdf_mode, format='NETCDF3_CLASSIC')
     51
     52
     53    # COMMENT SR; Can't use scipy.io.netcdf as we can't append to
     54    # a file as of 2013/03/26
     55    #from scipy.io.netcdf import netcdf_file
     56    #return netcdf_file(file_name, netcdf_mode, version=2)
     57
     58
     59
    2460
    2561class Write_nc:
  • trunk/anuga_core/source/anuga/file/sts.py

    r8143 r8780  
    11import numpy as num
    22import anuga.utilities.log as log
    3 from Scientific.IO.NetCDF import NetCDFFile
     3from anuga.file.netcdf import NetCDFFile
    44
    55from anuga.config import max_float
     
    275275        raise IOError(msg)
    276276
    277     xllcorner = fid.xllcorner[0]
    278     yllcorner = fid.yllcorner[0]
     277    xllcorner = fid.xllcorner
     278    yllcorner = fid.yllcorner
    279279
    280280    #Points stored in sts file are normalised to [xllcorner,yllcorner] but
  • trunk/anuga_core/source/anuga/file/sww.py

    r8757 r8780  
    1717from anuga.utilities.numerical_tools import ensure_numeric
    1818import anuga.utilities.log as log
    19 from Scientific.IO.NetCDF import NetCDFFile
     19from anuga.file.netcdf import NetCDFFile
    2020
    2121from sts import Write_sts
     
    6767    def __init__(self, domain,
    6868                 mode=netcdf_mode_w, max_size=2000000000, recursion=False):
    69         from Scientific.IO.NetCDF import NetCDFFile
    7069
    7170        self.precision = netcdf_float32 # Use single precision for quantities
     
    103102        fid = NetCDFFile(self.filename, mode)
    104103        if mode[0] == 'w':
    105             description = 'Output from anuga.file.sww' \
     104            description = 'Output from anuga.file.sww ' \
    106105                          'suitable for plotting'
    107106                         
     
    165164        # stores both connectivity (triangulation) and static quantities
    166165       
    167         from Scientific.IO.NetCDF import NetCDFFile
    168166
    169167        domain = self.domain
     
    211209        """
    212210
    213         from Scientific.IO.NetCDF import NetCDFFile
    214211        import types
    215212        from time import sleep
     
    566563        outfile.createVariable('y', sww_precision, ('number_of_points',))
    567564
    568         outfile.createVariable('volumes', netcdf_int, ('number_of_volumes',
     565        outfile.createVariable('volumes', netcdf_int , ('number_of_volumes',
    569566                                                       'number_of_vertices'))
    570567
     
    588585
    589586
     587        outfile.sync()
     588
     589
    590590
    591591    def store_triangulation(self,
     
    639639
    640640        number_of_points = len(points_utm)
    641         volumes = num.array(volumes)
     641        volumes = num.array(volumes,num.int32).reshape(-1,3)
     642
     643
    642644        points_utm = num.array(points_utm)
    643645
     
    668670        y =  points[:,1]
    669671
    670         x = x.astype(netcdf_float32)
    671         y = y.astype(netcdf_float32)
     672        #x = x.astype(netcdf_float32)
     673        #y = y.astype(netcdf_float32)
    672674       
    673675
     
    688690        outfile.variables['x'][:] = x #- geo_ref.get_xllcorner()
    689691        outfile.variables['y'][:] = y #- geo_ref.get_yllcorner()
    690         outfile.variables['volumes'][:] = volumes.astype(num.int32) #On Opteron 64
     692
     693
     694        msg = 'Mismatch between shape of volumes array and (number_of_volumes , 3)'
     695        assert volumes.shape == outfile.variables['volumes'].shape, msg
     696
     697        outfile.variables['volumes'][:] = volumes
     698
     699        outfile.sync()
    691700
    692701
     
    733742
    734743        outfile.variables['tri_full_flag'][:] = tri_full_flag.astype(num.int32)
     744
     745
     746        outfile.sync()
    735747
    736748
     
    782794
    783795                   
    784                    
     796        outfile.sync()
    785797       
    786798       
     
    851863                    outfile.variables[q + Write_sww.RANGE][1] = q_values_max
    852864
     865
     866        outfile.sync()
     867
     868       
     869
    853870    def verbose_quantities(self, outfile):
    854871        log.critical('------------------------------------------------')
     
    873890    """
    874891
    875     from Scientific.IO.NetCDF import NetCDFFile
    876892
    877893    #Get NetCDF
     
    903919    """
    904920   
    905     from Scientific.IO.NetCDF import NetCDFFile
    906921    from anuga.shallow_water.shallow_water_domain import Domain
    907922
     
    920935    x = fid.variables['x'][:]                   # x-coordinates of vertices
    921936    y = fid.variables['y'][:]                   # y-coordinates of vertices
    922     elevation = fid.variables['elevation']      # Elevation
    923     stage = fid.variables['stage']              # Water level
    924     xmomentum = fid.variables['xmomentum']      # Momentum in the x-direction
    925     ymomentum = fid.variables['ymomentum']      # Momentum in the y-direction
    926 
    927     starttime = fid.starttime[0]
     937    #elevation = fid.variables['elevation']      # Elevation
     938    #stage = fid.variables['stage']              # Water level
     939    #xmomentum = fid.variables['xmomentum']      # Momentum in the x-direction
     940    #ymomentum = fid.variables['ymomentum']      # Momentum in the y-direction
     941
     942    starttime = fid.starttime
     943    #starttime = fid.starttime[0]
    928944    volumes = fid.variables['volumes'][:]       # Connectivity
    929945    coordinates = num.transpose(num.asarray([x.tolist(), y.tolist()]))
     
    10781094
    10791095    import types
    1080     from Scientific.IO.NetCDF import NetCDFFile
    10811096    from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
    10821097
     
    10851100    fid = NetCDFFile(filename, netcdf_mode_r)    # Open existing file for read
    10861101    time = fid.variables['time'][:]    # Time vector
    1087     time += fid.starttime[0]
     1102    #time += fid.starttime[0]
     1103    time += fid.starttime
    10881104
    10891105    # Get the variables as numeric arrays
    10901106    x = fid.variables['x'][:]                   # x-coordinates of nodes
    10911107    y = fid.variables['y'][:]                   # y-coordinates of nodes
     1108
     1109
    10921110    elevation = fid.variables['elevation'][:]   # Elevation
    10931111    stage = fid.variables['stage'][:]           # Water level
     
    10951113    ymomentum = fid.variables['ymomentum'][:]   # Momentum in the y-direction
    10961114
     1115
     1116
    10971117    # Mesh (nodes (Mx2), triangles (Nx3))
    10981118    nodes = num.concatenate((x[:,num.newaxis], y[:,num.newaxis]), axis=1)
    1099     triangles = fid.variables['volumes'][:]
     1119    triangles = fid.variables['volumes']
    11001120
    11011121    # Get geo_reference
  • trunk/anuga_core/source/anuga/file/test_mux.py

    r8249 r8780  
    44import os
    55from struct import pack, unpack
    6 from Scientific.IO.NetCDF import NetCDFFile
     6from anuga.file.netcdf import NetCDFFile
    77
    88from anuga.utilities.numerical_tools import ensure_numeric
  • trunk/anuga_core/source/anuga/file/test_sww.py

    r8488 r8780  
    1010from sww import load_sww_as_domain, weed, get_mesh_and_quantities_from_file, \
    1111                Write_sww
    12 from Scientific.IO.NetCDF import NetCDFFile
     12from anuga.file.netcdf import NetCDFFile
    1313
    1414from anuga.config import netcdf_mode_w, netcdf_float
     
    184184       
    185185        import time, os
    186         from Scientific.IO.NetCDF import NetCDFFile
    187186
    188187        # Setup
     
    199198                        geo_reference = Geo_reference(56,308500,6189000))
    200199
    201         domain.set_name('flowtest')
     200        domain.set_name('test_get_mesh_and_quantities_from_sww_file')
    202201        swwfile = domain.get_name() + '.sww'
    203202        domain.set_datadir('.')
     
    247246           
    248247        # Cleanup
    249         os.remove(swwfile)
     248        #os.remove(swwfile)
    250249       
    251250       
     
    277276        filename = tempfile.mktemp("_data_manager.sww")
    278277        outfile = NetCDFFile(filename, netcdf_mode_w)
    279         points_utm = num.array([[0.,0.],[1.,1.], [0.,1.]])
    280         volumes = (0,1,2)
     278        points_utm = num.array([[0.,0.],[1.,1.],[0.,1.]])
     279        volumes = [[0,1,2]]
    281280        elevation = [0,1,2]
    282281        new_origin = None
     
    312311        outfile = NetCDFFile(filename, netcdf_mode_w)
    313312        points_utm = num.array([[0.,0.],[1.,1.], [0.,1.]])
    314         volumes = (0,1,2)
     313        volumes = [[0,1,2]]
    315314        elevation = [0,1,2]
    316315        new_origin = None
     
    349348        outfile = NetCDFFile(filename, netcdf_mode_w)
    350349        points_utm = num.array([[0.,0.],[1.,1.], [0.,1.]])
    351         volumes = (0,1,2)
     350        volumes = [[0,1,2]]
    352351        elevation = [0,1,2]
    353352        new_origin = None
     
    388387        outfile = NetCDFFile(filename, netcdf_mode_w)
    389388        points_utm = num.array([[0.,0.],[1.,1.], [0.,1.]])
    390         volumes = (0,1,2)
     389        volumes = [[0,1,2]]
    391390        elevation = [0,1,2]
    392391        new_origin = None
     
    424423        outfile = NetCDFFile(filename, netcdf_mode_w)
    425424        points_utm = num.array([[0.,0.],[1.,1.], [0.,1.]])
    426         volumes = (0,1,2)
     425        volumes = [[0,1,2]]
    427426        elevation = [0,1,2]
    428427        new_origin = Geo_reference(56, 1, 1)
  • trunk/anuga_core/source/anuga/file_conversion/asc2dem.py

    r8404 r8780  
    6464
    6565    import os
    66     from Scientific.IO.NetCDF import NetCDFFile
     66    from anuga.file.netcdf import NetCDFFile
    6767
    6868    root = name_in[:-4]
  • trunk/anuga_core/source/anuga/file_conversion/csv2sts.py

    r7858 r8780  
    5757import getopt
    5858from anuga.utilities import log
    59 from Scientific.IO.NetCDF import NetCDFFile
     59from anuga.file.netcdf import NetCDFFile
    6060from anuga.file.csv_file import load_csv_as_dict
    6161from anuga.config import netcdf_mode_w, netcdf_float
     
    9898        fid.createVariable(col, netcdf_float, ('number_of_timesteps',))
    9999       
    100         fid.variables[col].assignValue(timeseries_data[col])
     100        fid.variables[col][:] = timeseries_data[col]
    101101
    102102    fid.close()
  • trunk/anuga_core/source/anuga/file_conversion/dem2dem.py

    r7814 r8780  
    2424
    2525    import os
    26     from Scientific.IO.NetCDF import NetCDFFile
     26    from anuga.file.netcdf import NetCDFFile
    2727
    2828    if name_in[-4:] != '.dem':
     
    3838
    3939    # Read metadata (convert from numpy.int32 to int where appropriate)
    40     ncols = int(infile.ncols[0])
    41     nrows = int(infile.nrows[0])
    42     xllcorner = infile.xllcorner[0]
    43     yllcorner = infile.yllcorner[0]
    44     cellsize = int(infile.cellsize[0])
    45     NODATA_value = int(infile.NODATA_value[0])
    46     zone = int(infile.zone[0])
    47     false_easting = infile.false_easting[0]
    48     false_northing = infile.false_northing[0]
     40    ncols = int(infile.ncols)
     41    nrows = int(infile.nrows)
     42    xllcorner = infile.xllcorner
     43    yllcorner = infile.yllcorner
     44    cellsize = int(infile.cellsize)
     45    NODATA_value = int(infile.NODATA_value)
     46    zone = int(infile.zone)
     47    false_easting = infile.false_easting
     48    false_northing = infile.false_northing
    4949    projection = infile.projection
    5050    datum = infile.datum
  • trunk/anuga_core/source/anuga/file_conversion/dem2pts.py

    r8740 r8780  
    6464
    6565    import os
    66     from Scientific.IO.NetCDF import NetCDFFile
     66    from anuga.file.netcdf import NetCDFFile
    6767
    6868    root = name_in[:-4]
     
    8686    if verbose: log.critical('Reading DEM from %s' % (name_in))
    8787
    88     ncols = infile.ncols[0]
    89     nrows = infile.nrows[0]
    90     xllcorner = infile.xllcorner[0]  # Easting of lower left corner
    91     yllcorner = infile.yllcorner[0]  # Northing of lower left corner
    92     cellsize = infile.cellsize[0]
    93     NODATA_value = infile.NODATA_value[0]
     88    ncols = infile.ncols
     89    nrows = infile.nrows
     90    xllcorner = infile.xllcorner  # Easting of lower left corner
     91    yllcorner = infile.yllcorner  # Northing of lower left corner
     92    cellsize = infile.cellsize
     93    NODATA_value = infile.NODATA_value
    9494    dem_elevation = infile.variables['elevation']
    9595
    96     zone = infile.zone[0]
    97     false_easting = infile.false_easting[0]
    98     false_northing = infile.false_northing[0]
     96    zone = infile.zone
     97    false_easting = infile.false_easting
     98    false_northing = infile.false_northing
    9999
    100100    # Text strings
  • trunk/anuga_core/source/anuga/file_conversion/esri2sww.py

    r7814 r8780  
    3737    """
    3838
    39     from Scientific.IO.NetCDF import NetCDFFile
     39    from anuga.file.netcdf import NetCDFFile
    4040
    4141    from anuga.coordinate_transforms.redfearn import redfearn
  • trunk/anuga_core/source/anuga/file_conversion/ferret2sww.py

    r7814 r8780  
    6060    """
    6161
    62     from Scientific.IO.NetCDF import NetCDFFile
     62    from anuga.file.netcdf import NetCDFFile
    6363
    6464    _assert_lat_long(minlat, maxlat, minlon, maxlon)
     
    176176
    177177    # Get missing values
    178     nan_ha = file_h.variables['HA'].missing_value[0]
    179     nan_ua = file_u.variables['UA'].missing_value[0]
    180     nan_va = file_v.variables['VA'].missing_value[0]
     178    nan_ha = file_h.variables['HA'].missing_value
     179    nan_ua = file_u.variables['UA'].missing_value
     180    nan_va = file_v.variables['VA'].missing_value
    181181    if hasattr(file_e.variables[zname],'missing_value'):
    182         nan_e  = file_e.variables[zname].missing_value[0]
     182        nan_e  = file_e.variables[zname].missing_value
    183183    else:
    184184        nan_e = None
  • trunk/anuga_core/source/anuga/file_conversion/file_conversion.py

    r8757 r8780  
    88
    99#non ANUGA imports
    10 from Scientific.IO.NetCDF import NetCDFFile
     10from anuga.file.netcdf import NetCDFFile
    1111import numpy as num
    1212import os.path
     
    3939    """
    4040
    41     from Scientific.IO.NetCDF import NetCDFFile
    42 
    4341    if filename[-4:] != '.sww':
    4442        raise IOError('Output file %s should be of type .sww.' % sww_file)
     
    186184
    187185    #Create NetCDF file
    188     from Scientific.IO.NetCDF import NetCDFFile
    189 
    190186    fid = NetCDFFile(file_out, netcdf_mode_w)
    191187
  • trunk/anuga_core/source/anuga/file_conversion/sdf2pts.py

    r8150 r8780  
    9292
    9393    import os
    94     from Scientific.IO.NetCDF import NetCDFFile
     94    from anuga.file.netcdf import NetCDFFile
    9595
    9696    if name_in[-4:] != '.sdf':
  • trunk/anuga_core/source/anuga/file_conversion/sts2sww_mesh.py

    r8121 r8780  
    11import os
    22import numpy as num
    3 from Scientific.IO.NetCDF import NetCDFFile
     3from anuga.file.netcdf import NetCDFFile
    44import pylab as P
    55
     
    3737    x_origin = infile.xllcorner
    3838    y_origin = infile.yllcorner
    39     origin = num.array([x_origin[0], y_origin[0]])
     39    origin = num.array([x_origin, y_origin])
    4040    x = infile.variables['x'][:]
    4141    y = infile.variables['y'][:]
  • trunk/anuga_core/source/anuga/file_conversion/sww2array.py

    r8690 r8780  
    100100
    101101
    102     from Scientific.IO.NetCDF import NetCDFFile
     102    from anuga.file.netcdf import NetCDFFile
    103103    fid = NetCDFFile(name_in)
    104104
  • trunk/anuga_core/source/anuga/file_conversion/sww2dem.py

    r8634 r8780  
    131131        log.critical('Output directory is %s' % name_out)
    132132
    133     from Scientific.IO.NetCDF import NetCDFFile
     133    from anuga.file.netcdf import NetCDFFile
    134134    fid = NetCDFFile(name_in)
    135135
     
    143143        times = fid.variables['time'][:]
    144144
    145     number_of_timesteps = fid.dimensions['number_of_timesteps']
    146     number_of_points = fid.dimensions['number_of_points']
     145    try: # works with netcdf4
     146        number_of_timesteps = len(fid.dimensions['number_of_timesteps'])
     147        number_of_points = len(fid.dimensions['number_of_points'])
     148    except: #works with scientific.io.netcdf
     149        number_of_timesteps = fid.dimensions['number_of_timesteps']
     150        number_of_points = fid.dimensions['number_of_points']
     151
     152
    147153
    148154    if origin is None:
     
    216222
    217223    # Create result array and start filling, block by block.
     224
     225
    218226    result = num.zeros(number_of_points, num.float)
    219227
  • trunk/anuga_core/source/anuga/file_conversion/sww2dem_new.py

    r8626 r8780  
    132132        log.critical('Output directory is %s' % name_out)
    133133
    134     from Scientific.IO.NetCDF import NetCDFFile
     134    from anuga.file.netcdf import NetCDFFile
    135135    fid = NetCDFFile(name_in)
    136136
  • trunk/anuga_core/source/anuga/file_conversion/sww2pts.py

    r8149 r8780  
    5656    # Read sww file
    5757    if verbose: log.critical('Reading from %s' % name_in)
    58     from Scientific.IO.NetCDF import NetCDFFile
     58    from anuga.file.netcdf import NetCDFFile
    5959    fid = NetCDFFile(name_in)
    6060
     
    6464    volumes = fid.variables['volumes'][:]
    6565
    66     number_of_timesteps = fid.dimensions['number_of_timesteps']
    67     number_of_points = fid.dimensions['number_of_points']
     66
     67    try: # works with netcdf4
     68        number_of_timesteps = len(fid.dimensions['number_of_timesteps'])
     69        number_of_points = len(fid.dimensions['number_of_points'])
     70    except: #works with scientific.io.netcdf
     71        number_of_timesteps = fid.dimensions['number_of_timesteps']
     72        number_of_points = fid.dimensions['number_of_points']
     73
     74       
    6875    if origin is None:
    6976        # Get geo_reference
  • trunk/anuga_core/source/anuga/file_conversion/test_2pts.py

    r7814 r8780  
    2929
    3030        import time, os
    31         from Scientific.IO.NetCDF import NetCDFFile
     31        from anuga.file.netcdf import NetCDFFile
    3232
    3333        #Write test asc file
     
    160160
    161161        import time, os
    162         from Scientific.IO.NetCDF import NetCDFFile
     162        from anuga.file.netcdf import NetCDFFile
    163163        # Used for points that lie outside mesh
    164164        NODATA_value = 1758323
  • trunk/anuga_core/source/anuga/file_conversion/test_csv2sts.py

    r7864 r8780  
    44import unittest
    55import numpy as num
    6 from Scientific.IO.NetCDF import NetCDFFile
     6from anuga.file.netcdf import NetCDFFile
    77
    88# ANUGA modules
  • trunk/anuga_core/source/anuga/file_conversion/test_dem2dem.py

    r7814 r8780  
    3939
    4040        import os
    41         from Scientific.IO.NetCDF import NetCDFFile
     41        from anuga.file.netcdf import NetCDFFile
    4242
    4343        #Write test dem file
     
    121121
    122122        import os
    123         from Scientific.IO.NetCDF import NetCDFFile
     123        from anuga.file.netcdf import NetCDFFile
    124124
    125125        # Write test dem file
  • trunk/anuga_core/source/anuga/file_conversion/test_dem2pts.py

    r8707 r8780  
    88from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a, \
    99                            netcdf_float
     10
     11from anuga.file.netcdf import NetCDFFile
    1012
    1113from dem2pts import dem2pts
     
    2426
    2527        import time, os
    26         from Scientific.IO.NetCDF import NetCDFFile
     28
    2729
    2830        #Write test asc file
     
    9395
    9496        #Check values
    95         assert fid.xllcorner[0] == 2002.0
    96         assert fid.yllcorner[0] == 3003.0
     97        assert fid.xllcorner == 2002.0
     98        assert fid.yllcorner == 3003.0
    9799
    98100        #create new reference points
     
    136138
    137139        import time, os
    138         from Scientific.IO.NetCDF import NetCDFFile
    139140
    140141        #Write test asc file
     
    211212
    212213        #Check values
    213         assert fid.xllcorner[0] == 2002.0
    214         assert fid.yllcorner[0] == 3003.0
     214        assert fid.xllcorner == 2002.0
     215        assert fid.yllcorner == 3003.0
    215216
    216217        #create new reference points
     
    264265
    265266        import time, os
    266         from Scientific.IO.NetCDF import NetCDFFile
    267267
    268268        #Write test asc file
     
    339339
    340340        #Check values
    341         assert fid.xllcorner[0] == 2002.0
    342         assert fid.yllcorner[0] == 3003.0
     341        assert fid.xllcorner == 2002.0
     342        assert fid.yllcorner == 3003.0
    343343
    344344        #create new reference points
  • trunk/anuga_core/source/anuga/file_conversion/test_file_conversion.py

    r8757 r8780  
    1111from anuga.file_conversion.urs2nc import lon_lat2grid
    1212from anuga.config import netcdf_float, epsilon, g
    13 from Scientific.IO.NetCDF import NetCDFFile
     13from anuga.file.netcdf import NetCDFFile
    1414
    1515from anuga.file_conversion.file_conversion import tsh2sww
     
    108108            fid.variables[long_name].point_spacing='uneven'
    109109            fid.variables[long_name].units='degrees_east'
    110             fid.variables[long_name].assignValue(longitudes)
     110            fid.variables[long_name][:] = longitudes
    111111
    112112            fid.createDimension(lat_name,ny)
     
    114114            fid.variables[lat_name].point_spacing='uneven'
    115115            fid.variables[lat_name].units='degrees_north'
    116             fid.variables[lat_name].assignValue(latitudes)
     116            fid.variables[lat_name][:] = latitudes
    117117
    118118            fid.createDimension('TIME',six)
     
    120120            fid.variables['TIME'].point_spacing='uneven'
    121121            fid.variables['TIME'].units='seconds'
    122             fid.variables['TIME'].assignValue([0.0, 0.1, 0.6, 1.1, 1.6, 2.1])
     122            fid.variables['TIME'][:] = [0.0, 0.1, 0.6, 1.1, 1.6, 2.1]
    123123
    124124
     
    129129            fid.variables[name].missing_value=-1.e+034
    130130
    131             fid.variables[name].assignValue([[[0.3400644, 0, -46.63519, -6.50198],
     131            fid.variables[name][:] = [[[0.3400644, 0, -46.63519, -6.50198],
    132132                                              [-0.1214216, 0, 0, 0],
    133133                                              [0, 0, 0, 0],
     
    152152                                              [-0.1209405, 0.0009771062, 0.02527271, 2.617787e-005],
    153153                                              [0.0004811212, 0.0009622425, 0.0009599366, 8.152277e-007],
    154                                               [0, 0.0004811212, 0.0004811212, 0]]])
     154                                              [0, 0.0004811212, 0.0004811212, 0]]]
    155155
    156156
     
    170170        ferret format (lat/lon) to sww format (UTM)
    171171        """
    172         from Scientific.IO.NetCDF import NetCDFFile
    173172        import os, sys
    174173
     
    236235        """Test that zscale workse
    237236        """
    238         from Scientific.IO.NetCDF import NetCDFFile
    239237        import os, sys
    240238
     
    326324        ferret format (lat/lon) to sww format (UTM)
    327325        """
    328         from Scientific.IO.NetCDF import NetCDFFile
    329326
    330327        #The test file has
     
    469466        """Elevation included
    470467        """
    471         from Scientific.IO.NetCDF import NetCDFFile
    472468
    473469        #The test file has
     
    506502            fid.variables[long_name].point_spacing='uneven'
    507503            fid.variables[long_name].units='degrees_east'
    508             fid.variables[long_name].assignValue(h1_list)
     504            fid.variables[long_name][:] = h1_list
    509505
    510506            fid.createDimension(lat_name,ny)
     
    512508            fid.variables[lat_name].point_spacing='uneven'
    513509            fid.variables[lat_name].units='degrees_north'
    514             fid.variables[lat_name].assignValue(h2_list)
     510            fid.variables[lat_name][:] = h2_list
    515511
    516512            fid.createDimension(time_name,2)
     
    518514            fid.variables[time_name].point_spacing='uneven'
    519515            fid.variables[time_name].units='seconds'
    520             fid.variables[time_name].assignValue([0.,1.])
     516            fid.variables[time_name][:] = [0.,1.]
    521517            #if fid == fid3: break
    522518
     
    527523            fid.variables[long_name].point_spacing='uneven'
    528524            fid.variables[long_name].units='degrees_east'
    529             fid.variables[long_name].assignValue(h1_list)
     525            fid.variables[long_name][:] = h1_list
    530526
    531527            fid.createDimension(lat_name,ny)
     
    533529            fid.variables[lat_name].point_spacing='uneven'
    534530            fid.variables[lat_name].units='degrees_north'
    535             fid.variables[lat_name].assignValue(h2_list)
     531            fid.variables[lat_name][:] = h2_list
    536532
    537533        name = {}
     
    557553          fid.variables[name[fid]].point_spacing='uneven'
    558554          fid.variables[name[fid]].units=units[fid]
    559           fid.variables[name[fid]].assignValue(values[fid])
     555          fid.variables[name[fid]][:] = values[fid]
    560556          fid.variables[name[fid]].missing_value = -99999999.
    561557          #if fid == fid3: break
     
    565561            fid.variables[name[fid]].point_spacing='uneven'
    566562            fid.variables[name[fid]].units=units[fid]
    567             fid.variables[name[fid]].assignValue(values[fid])
     563            fid.variables[name[fid]][:] = values[fid]
    568564            fid.variables[name[fid]].missing_value = -99999999.
    569565
     
    629625        in files produced by ferret as opposed to MOST
    630626        """
    631         from Scientific.IO.NetCDF import NetCDFFile
    632627
    633628        #The test file has
     
    670665            fid.variables[long_name].point_spacing='uneven'
    671666            fid.variables[long_name].units='degrees_east'
    672             fid.variables[long_name].assignValue(h1_list)
     667            fid.variables[long_name][:] = h1_list
    673668
    674669            fid.createDimension(lat_name,ny)
     
    676671            fid.variables[lat_name].point_spacing='uneven'
    677672            fid.variables[lat_name].units='degrees_north'
    678             fid.variables[lat_name].assignValue(h2_list)
     673            fid.variables[lat_name][:] = h2_list
    679674
    680675            fid.createDimension(time_name,2)
     
    682677            fid.variables[time_name].point_spacing='uneven'
    683678            fid.variables[time_name].units='seconds'
    684             fid.variables[time_name].assignValue([0.,1.])
     679            fid.variables[time_name][:] = [0.,1.]
    685680            #if fid == fid3: break
    686681
     
    691686            fid.variables[long_name].point_spacing='uneven'
    692687            fid.variables[long_name].units='degrees_east'
    693             fid.variables[long_name].assignValue(h1_list)
     688            fid.variables[long_name][:] = h1_list
    694689
    695690            fid.createDimension(lat_name,ny)
     
    697692            fid.variables[lat_name].point_spacing='uneven'
    698693            fid.variables[lat_name].units='degrees_north'
    699             fid.variables[lat_name].assignValue(h2_list)
     694            fid.variables[lat_name][:] = h2_list
    700695
    701696        name = {}
     
    721716          fid.variables[name[fid]].point_spacing='uneven'
    722717          fid.variables[name[fid]].units=units[fid]
    723           fid.variables[name[fid]].assignValue(values[fid])
     718          fid.variables[name[fid]][:] = values[fid]
    724719          fid.variables[name[fid]].missing_value = -99999999.
    725720          #if fid == fid3: break
     
    729724            fid.variables[name[fid]].point_spacing='uneven'
    730725            fid.variables[name[fid]].units=units[fid]
    731             fid.variables[name[fid]].assignValue(values[fid])
     726            fid.variables[name[fid]][:] = values[fid]
    732727            fid.variables[name[fid]].missing_value = -99999999.
    733728
     
    791786
    792787    def test_ferret2sww_nz_origin(self):
    793         from Scientific.IO.NetCDF import NetCDFFile
    794788        from anuga.coordinate_transforms.redfearn import redfearn
    795789
     
    850844
    851845        import time, os
    852         from Scientific.IO.NetCDF import NetCDFFile
     846
    853847
    854848        self.domain.set_name('datatest' + str(id(self)))
  • trunk/anuga_core/source/anuga/file_conversion/test_sww2dem.py

    r8634 r8780  
    55from anuga.shallow_water.shallow_water_domain import Domain
    66from anuga.config import netcdf_mode_r
     7from anuga.file.netcdf import NetCDFFile
    78
    89from anuga.coordinate_transforms.geo_reference import Geo_reference, \
     
    8586
    8687        import time, os
    87         from Scientific.IO.NetCDF import NetCDFFile
    8888
    8989        # Setup
     
    124124       
    125125        # Check georeferencig: zone, xllcorner and yllcorner
    126         assert fid.zone[0] == 56
    127         assert fid.xllcorner[0] == 308500
    128         assert fid.yllcorner[0] == 6189000
     126        assert fid.zone == 56
     127        assert fid.xllcorner == 308500
     128        assert fid.yllcorner == 6189000
    129129               
    130130
     
    300300
    301301        import time, os
    302         from Scientific.IO.NetCDF import NetCDFFile
    303302
    304303        #Create basic mesh (100m x 100m)
     
    466465
    467466        import time, os
    468         from Scientific.IO.NetCDF import NetCDFFile
    469467
    470468        #Setup
     
    660658
    661659        import time, os
    662         from Scientific.IO.NetCDF import NetCDFFile
    663660
    664661        #Setup
     
    825822
    826823        import time, os
    827         from Scientific.IO.NetCDF import NetCDFFile
    828824
    829825        #Setup
     
    933929
    934930        import time, os
    935         from Scientific.IO.NetCDF import NetCDFFile
    936931
    937932        #Setup
     
    10381033
    10391034        import time, os
    1040         from Scientific.IO.NetCDF import NetCDFFile
    10411035
    10421036        #Setup
     
    11521146
    11531147        import time, os
    1154         from Scientific.IO.NetCDF import NetCDFFile
    11551148
    11561149        #Setup mesh not coinciding with rectangle.
     
    12981291
    12991292        import time, os
    1300         from Scientific.IO.NetCDF import NetCDFFile
    13011293
    13021294
     
    13961388
    13971389        import time, os
    1398         from Scientific.IO.NetCDF import NetCDFFile
    13991390
    14001391        base_name = 'tegp'
     
    15271518
    15281519        import time, os
    1529         from Scientific.IO.NetCDF import NetCDFFile
    15301520
    15311521        try:
     
    16111601
    16121602        import time, os
    1613         from Scientific.IO.NetCDF import NetCDFFile
    16141603
    16151604        try:
     
    17471736
    17481737        import time, os
    1749         from Scientific.IO.NetCDF import NetCDFFile
    17501738
    17511739        try:
  • trunk/anuga_core/source/anuga/file_conversion/test_urs2sts.py

    r8690 r8780  
    44import os
    55import sys
    6 from Scientific.IO.NetCDF import NetCDFFile
     6from anuga.file.netcdf import NetCDFFile
    77
    88from anuga.utilities.system_tools import get_pathname_from_package
     
    276276            #print k, time_start_z[k,:]
    277277            starttime = min(time_start_z[k, :])
    278             sts_starttime = fid.starttime[0]
     278            sts_starttime = fid.starttime
    279279            msg = 'sts starttime for source %d was %f. Should have been %f'\
    280280                %(source_number, sts_starttime, starttime)
     
    440440        # across all stations (for this source)
    441441        starttime = min(time_start_z[:])
    442         sts_starttime = fid.starttime[0]
     442        sts_starttime = fid.starttime
    443443        msg = 'sts starttime was %f. Should have been %f'\
    444444            %(sts_starttime, starttime)
     
    20312031        # Check the time vector
    20322032        times = fid.variables['time'][:]
    2033         starttime = fid.starttime[0]
     2033        starttime = fid.starttime
    20342034        #print times
    20352035        #print starttime
  • trunk/anuga_core/source/anuga/file_conversion/test_urs2sww.py

    r7805 r8780  
    11
    22# External modules
    3 from Scientific.IO.NetCDF import NetCDFFile
     3from anuga.file.netcdf import NetCDFFile
    44import sys
    55import unittest
  • trunk/anuga_core/source/anuga/file_conversion/urs2sts.py

    r8149 r8780  
    6868
    6969    import os
    70     from Scientific.IO.NetCDF import NetCDFFile
     70    from anuga.file.netcdf import NetCDFFile
    7171    from operator import __and__
    7272
  • trunk/anuga_core/source/anuga/file_conversion/urs2sww.py

    r8149 r8780  
    11import os
    22import numpy as num
    3 from Scientific.IO.NetCDF import NetCDFFile
     3from anuga.file.netcdf import NetCDFFile
    44
    55from anuga.file.urs import Read_urs
  • trunk/anuga_core/source/anuga/fit_interpolate/test_interpolate.py

    r8709 r8780  
    1313import csv
    1414
    15 from Scientific.IO.NetCDF import NetCDFFile
     15from anuga.file.netcdf import NetCDFFile
    1616
    1717import numpy as num
  • trunk/anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r8592 r8780  
    1212import copy
    1313
    14 from Scientific.IO.NetCDF import NetCDFFile
     14from anuga.file.netcdf import NetCDFFile
    1515import numpy as num
    1616from numpy.random import randint, seed
     
    10491049        geo_reference = None
    10501050
    1051     return geo_reference, keys, fid.dimensions['number_of_points']
     1051    try: # netcdf4
     1052        number_of_points = len(fid.dimensions['number_of_points'])
     1053    except: #scientific python
     1054        number_of_points = fid.dimensions['number_of_points']
     1055       
     1056    return geo_reference, keys, number_of_points
    10521057
    10531058
  • trunk/anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r8124 r8780  
    10421042
    10431043    def test_loadpts(self):
    1044         from Scientific.IO.NetCDF import NetCDFFile
     1044        from anuga.file.netcdf import NetCDFFile
    10451045
    10461046        fileName = tempfile.mktemp('.pts')
     
    12001200
    12011201    def test_create_from_pts_file(self):
    1202         from Scientific.IO.NetCDF import NetCDFFile
     1202        from anuga.file.netcdf import NetCDFFile
    12031203
    12041204        # NetCDF file definition
     
    12401240        '''Test if Geospatial data is correctly instantiated from a pts file.'''
    12411241
    1242         from Scientific.IO.NetCDF import NetCDFFile
     1242        from anuga.file.netcdf import NetCDFFile
    12431243
    12441244        # NetCDF file definition
  • trunk/anuga_core/source/anuga/load_mesh/loadASCII.py

    r8694 r8780  
    6969import anuga.utilities.log as log
    7070
    71 from Scientific.IO.NetCDF import NetCDFFile
     71from anuga.file.netcdf import NetCDFFile
    7272
    7373import numpy as num
  • trunk/anuga_core/source/anuga/shallow_water/forcing.py

    r8420 r8780  
    2020from warnings import warn
    2121import numpy as num
    22 from Scientific.IO.NetCDF import NetCDFFile
     22from anuga.file.netcdf import NetCDFFile
    2323from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    2424from copy import copy
  • trunk/anuga_core/source/anuga/shallow_water/most2nc.py

    r8124 r8780  
    88
    99import sys
    10 from Scientific.IO.NetCDF import NetCDFFile
     10from anuga.file.netcdf import NetCDFFile
    1111from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    1212import anuga.utilities.log as log
     
    8686    out_file.variables[long_name].point_spacing='uneven'
    8787    out_file.variables[long_name].units='degrees_east'
    88     out_file.variables[long_name].assignValue(h1_list)
     88    out_file.variables[long_name][:] = h1_list
    8989
    9090    out_file.createDimension(lat_name,ny)
     
    9292    out_file.variables[lat_name].point_spacing='uneven'
    9393    out_file.variables[lat_name].units='degrees_north'
    94     out_file.variables[lat_name].assignValue(h2_list)
     94    out_file.variables[lat_name][:] = h2_list
    9595
    9696    out_file.createVariable(elev_name,'d',(lat_name,long_name))
    9797    out_file.variables[elev_name].point_spacing='uneven'
    9898    out_file.variables[elev_name].units='meters'
    99     out_file.variables[elev_name].assignValue(depth_list)
     99    out_file.variables[elev_name][:] = depth_list
    100100
    101101    out_file.close()
  • trunk/anuga_core/source/anuga/shallow_water/sww_interrogate.py

    r8124 r8780  
    323323    from anuga.geometry.polygon import inside_polygon
    324324    from anuga.config import minimum_allowed_height
    325     from Scientific.IO.NetCDF import NetCDFFile
     325    from anuga.file.netcdf import NetCDFFile
    326326
    327327    dir, base = os.path.split(filename)
  • trunk/anuga_core/source/anuga/shallow_water/test_data_manager.py

    r8690 r8780  
    1818from struct import pack, unpack
    1919
    20 from Scientific.IO.NetCDF import NetCDFFile
     20from anuga.file.netcdf import NetCDFFile
    2121
    2222
     
    142142            fid.variables[long_name].point_spacing='uneven'
    143143            fid.variables[long_name].units='degrees_east'
    144             fid.variables[long_name].assignValue(longitudes)
     144            fid.variables[long_name][:] = longitudes
    145145
    146146            fid.createDimension(lat_name,ny)
     
    148148            fid.variables[lat_name].point_spacing='uneven'
    149149            fid.variables[lat_name].units='degrees_north'
    150             fid.variables[lat_name].assignValue(latitudes)
     150            fid.variables[lat_name][:] = latitudes
    151151
    152152            fid.createDimension('TIME',six)
     
    154154            fid.variables['TIME'].point_spacing='uneven'
    155155            fid.variables['TIME'].units='seconds'
    156             fid.variables['TIME'].assignValue([0.0, 0.1, 0.6, 1.1, 1.6, 2.1])
     156            fid.variables['TIME'][:] = [0.0, 0.1, 0.6, 1.1, 1.6, 2.1]
    157157
    158158
     
    163163            fid.variables[name].missing_value=-1.e+034
    164164
    165             fid.variables[name].assignValue([[[0.3400644, 0, -46.63519, -6.50198],
     165            fid.variables[name][:] = [[[0.3400644, 0, -46.63519, -6.50198],
    166166                                              [-0.1214216, 0, 0, 0],
    167167                                              [0, 0, 0, 0],
     
    186186                                              [-0.1209405, 0.0009771062, 0.02527271, 2.617787e-005],
    187187                                              [0.0004811212, 0.0009622425, 0.0009599366, 8.152277e-007],
    188                                               [0, 0.0004811212, 0.0004811212, 0]]])
     188                                              [0, 0.0004811212, 0.0004811212, 0]]]
    189189
    190190
     
    495495
    496496        import time, os
    497         from Scientific.IO.NetCDF import NetCDFFile
    498497
    499498        self.domain.set_name('datatest' + str(id(self)))
     
    549548
    550549        import time, os, config
    551         from Scientific.IO.NetCDF import NetCDFFile
    552550
    553551        self.domain.set_name('synctest')
     
    596594
    597595        import time, os
    598         from Scientific.IO.NetCDF import NetCDFFile
    599596
    600597        self.domain.set_name('datatest' + str(id(self)))
  • trunk/anuga_core/source/anuga/shallow_water/test_loadsave.py

    r7841 r8780  
    66import tempfile
    77
    8 from Scientific.IO.NetCDF import NetCDFFile
     8from anuga.file.netcdf import NetCDFFile
    99from anuga.file.sww import extent_sww
    1010
  • trunk/anuga_core/source/anuga/shallow_water/test_most2nc.py

    r7276 r8780  
    11import unittest
    22import numpy as num
    3 from Scientific.IO.NetCDF import NetCDFFile
     3from anuga.file.netcdf import NetCDFFile
    44import most2nc
    55import os
  • trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r8690 r8780  
    66import tempfile
    77
    8 from Scientific.IO.NetCDF import NetCDFFile
     8from anuga.file.netcdf import NetCDFFile
    99from anuga.file.sww import extent_sww
    1010
     
    18251825
    18261826        import time, os
    1827         from Scientific.IO.NetCDF import NetCDFFile
    18281827        from mesh_factory import rectangular
    18291828
     
    19161915
    19171916        import time, os
    1918         from Scientific.IO.NetCDF import NetCDFFile
    19191917        from mesh_factory import rectangular
    19201918
     
    60396037
    60406038        # Read results for specific timesteps t=1 and t=2
    6041         from Scientific.IO.NetCDF import NetCDFFile
    60426039        fid = NetCDFFile(domain1.get_name() + '.sww')
    60436040
     
    62126209
    62136210        # Read results for specific timesteps t=1 and t=2
    6214         from Scientific.IO.NetCDF import NetCDFFile
    62156211        fid = NetCDFFile(domain1.get_name() + '.sww')
    62166212
     
    63886384
    63896385        # Read results for specific timesteps t=1 and t=2
    6390         from Scientific.IO.NetCDF import NetCDFFile
    63916386        fid = NetCDFFile(domain1.get_name() + '.sww')
    63926387
     
    75847579           
    75857580        # Check that quantities have been stored correctly   
    7586         from Scientific.IO.NetCDF import NetCDFFile
    75877581        sww_file = domain.get_name() + '.sww'
    75887582        fid = NetCDFFile(sww_file)
  • trunk/anuga_core/source/anuga/shallow_water/test_sww_interrogate.py

    r8404 r8780  
    4040
    4141        import time, os
    42         from Scientific.IO.NetCDF import NetCDFFile
     42        from anuga.file.netcdf import NetCDFFile
    4343
    4444        #Setup
     
    200200
    201201        import time, os
    202         from Scientific.IO.NetCDF import NetCDFFile
     202        from anuga.file.netcdf import NetCDFFile
    203203
    204204        # Setup
     
    326326
    327327        import time, os
    328         from Scientific.IO.NetCDF import NetCDFFile
     328        from anuga.file.netcdf import NetCDFFile
    329329
    330330        # Setup
     
    428428
    429429        import time, os
    430         from Scientific.IO.NetCDF import NetCDFFile
     430        from anuga.file.netcdf import NetCDFFile
    431431
    432432        # Setup
  • trunk/anuga_core/source/anuga/shallow_water/test_system.py

    r8486 r8780  
    66import os
    77
    8 from Scientific.IO.NetCDF import NetCDFFile
     8from anuga.file.netcdf import NetCDFFile
    99import numpy as num
    1010
  • trunk/anuga_core/source/anuga/utilities/plot_utils.py

    r8591 r8780  
    3636
    3737"""
    38 from Scientific.IO.NetCDF import NetCDFFile
     38from anuga.file.netcdf import NetCDFFile
    3939import numpy
    4040
  • trunk/anuga_core/source/anuga/utilities/sww_merge.py

    r8760 r8780  
    66from anuga.utilities.numerical_tools import ensure_numeric
    77
    8 from Scientific.IO.NetCDF import NetCDFFile
     8from anuga.file.netcdf import NetCDFFile
    99from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    1010from anuga.config import netcdf_float, netcdf_float32, netcdf_int
     
    2626    fid = NetCDFFile(swwfiles[0], netcdf_mode_r)
    2727
    28     number_of_volumes = fid.dimensions['number_of_volumes']
    29     number_of_points =  fid.dimensions['number_of_points']
     28    try: # works with netcdf4
     29        number_of_volumes = len(fid.dimensions['number_of_volumes'])
     30        number_of_points = len(fid.dimensions['number_of_points'])
     31    except: # works with scientific.io.netcdf
     32        number_of_volumes = len(fid.dimensions['number_of_volumes'])
     33        number_of_points = fid.dimensions['number_of_points']
    3034
    3135    fid.close()
     
    111115                out_tris.append(verts)
    112116
    113         num_pts = fid.dimensions['number_of_points']
     117
     118
     119        try: # works with netcdf4
     120            num_pts = len(fid.dimensions['number_of_points'])
     121        except: # works with scientific.io.netcdf
     122            num_pts = fid.dimensions['number_of_points']
     123
    114124        tri_offset += num_pts
    115125       
  • trunk/anuga_core/source/anuga/utilities/test_system_tools.py

    r8146 r8780  
    99import os
    1010from os.path import join, split, sep
    11 from Scientific.IO.NetCDF import NetCDFFile
     11from anuga.file.netcdf import NetCDFFile
    1212from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    1313from anuga.config import netcdf_float, netcdf_char, netcdf_int
     
    8282
    8383        try:
    84             from Scientific.IO.NetCDF import NetCDFFile
     84            from anuga.file.netcdf import NetCDFFile
    8585        except ImportError:
    8686            # This code is also used by EQRM which does not require NetCDF
  • trunk/anuga_core/source/anuga/visualiser/offline.py

    r7452 r8780  
    11#from Numeric import array, Float, ravel, zeros
    22import numpy as num
    3 from Scientific.IO.NetCDF import NetCDFFile
     3from anuga.file.netcdf import NetCDFFile
    44from Tkinter import Button, E, Tk, W, Label, StringVar, Scale, HORIZONTAL
    55from visualiser import Visualiser
  • trunk/anuga_core/source/anuga/visualiser_new/sww_visualiser.py

    r4621 r8780  
    11from Numeric import array, Float
    2 from Scientific.IO.NetCDF import NetCDFFile
     2from anuga.file.netcdf import NetCDFFile
    33from visualiser import Visualiser
    44from vtk import vtkCellArray
  • trunk/anuga_core/source/anuga_parallel/test_parallel_file_boundary.py

    r8757 r8780  
    2424import tempfile
    2525from struct import pack, unpack
    26 from Scientific.IO.NetCDF import NetCDFFile
     26from anuga.file.netcdf import NetCDFFile
    2727import copy
    2828
  • trunk/anuga_core/source/anuga_validation_tests/Case_studies/Okushiri/compare_timeseries_with_measures.py

    r8676 r8780  
    99
    1010import numpy as num
    11 from Scientific.IO.NetCDF import NetCDFFile
     11from anuga.file.netcdf import NetCDFFile
    1212
    1313import project
  • trunk/anuga_core/source/anuga_validation_tests/Case_studies/Okushiri/create_okushiri.py

    r8756 r8780  
    107107    """
    108108
    109     from Scientific.IO.NetCDF import NetCDFFile
     109    from anuga.file.netcdf import NetCDFFile
    110110
    111111    print 'Creating', filename
Note: See TracChangeset for help on using the changeset viewer.