Changeset 6086


Ignore:
Timestamp:
Dec 19, 2008, 10:38:08 AM (15 years ago)
Author:
rwilson
Message:

Changes to handle large files when Scientific.IO.NetCDF provides the feature.

Location:
anuga_core/source/anuga
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r6072 r6086  
    18341834if __name__ == "__main__":
    18351835    suite = unittest.makeSuite(Test_Util,'test')
    1836 #    suite = unittest.makeSuite(Test_Util,'test_remove_lone_verts')
     1836#    suite = unittest.makeSuite(Test_Util,'test_sww2csv_gauges')
    18371837#    runner = unittest.TextTestRunner(verbosity=2)
    18381838    runner = unittest.TextTestRunner(verbosity=1)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r6072 r6086  
    2525from anuga.utilities.system_tools import get_revision_number
    2626from anuga.utilities.system_tools import store_version_info
     27
     28from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    2729
    2830
     
    272274    if verbose: print 'Reading', filename
    273275
    274     fid = NetCDFFile(filename, 'r')
     276    fid = NetCDFFile(filename, netcdf_mode_r)
    275277
    276278    if type(quantity_names) == types.StringType:
  • anuga_core/source/anuga/config.py

    r5961 r6086  
    22"""
    33
    4 #--------------------
     4################################################################################
    55# Numerical constants
    6 #--------------------
    7 epsilon = 1.0e-12 # Smallest number - used for safe division
    8 max_float = 1.0e36 # Largest number - used to initialise (max, min) ranges
    9 default_smoothing_parameter = 0.001 # Default alpha for penalised
    10                                     # least squares fitting
    11                                    
    12 single_precision = 1.0e-6           # Smallest single precision number
     6################################################################################
     7
     8epsilon = 1.0e-12                    # Smallest number - used for safe division
     9max_float = 1.0e36                   # Largest number - used to initialise
     10                                     # (max, min) ranges
     11default_smoothing_parameter = 0.001  # Default alpha for penalised
     12                                     # least squares fitting
     13single_precision = 1.0e-6            # Smallest single precision number
    1314velocity_protection = 1.0e-6                                     
    1415
    15 #-------------------------------------------
    16 # Standard filenames, directories and system
    17 # parameters used by ANUGA
    18 #-------------------------------------------
     16################################################################################
     17# Standard filenames, directories and system parameters used by ANUGA
     18################################################################################
     19
    1920pmesh_filename = '.\\pmesh'
    2021version_filename = 'stored_version_info.py'
     
    2829major_revision = '1.0beta'
    2930
    30 
    31 #-------------------
     31################################################################################
    3232# Physical constants
    33 #-------------------
     33################################################################################
     34
    3435manning = 0.03  # Manning's friction coefficient
    3536#g = 9.80665    # Gravity - FIXME reinstate this and fix unit tests.
     
    3839#The 'official' average is 9.80665
    3940
    40 eta_w = 3.0e-3 #Wind stress coefficient
    41 rho_a = 1.2e-3 #Atmospheric density
    42 rho_w = 1023   #Fluid density [kg/m^3] (rho_w = 1023 for salt water)
    43 
    44 
    45 #-----------------------------------------------------
     41eta_w = 3.0e-3 # Wind stress coefficient
     42rho_a = 1.2e-3 # Atmospheric density
     43rho_w = 1023   # Fluid density [kg/m^3] (rho_w = 1023 for salt water)
     44
     45################################################################################
    4646# Limiters - used with linear reconstruction of vertex
    4747# values from centroid values
    48 #-----------------------------------------------------
     48################################################################################
    4949
    5050# Betas [0;1] control the allowed steepness of gradient for second order
     
    6363beta_vh_dry = 0.2
    6464
    65 
    6665# Alpha_balance controls how limiters are balanced between deep and shallow.
    67 # A large value will favour the deep water limiters, allowing the a closer hug to the coastline.
    68 # This will minimise 'creep' but at the same time cause smaller time steps
     66# A large value will favour the deep water limiters, allowing the a closer hug
     67# to the coastline.  This will minimise 'creep' but at the same time cause
     68# smaller time steps
    6969# Range:
    70 
    7170alpha_balance = 2.0
    7271
     
    8584# This option is good with tight_slope_limiters, especially for large domains.
    8685use_centroid_velocities = True
    87 
    8886       
    8987# FIXME (Ole) Maybe get rid of order altogether and use beta_w
     
    9189default_order = 1
    9290
    93 
    94 #-------------
     91################################################################################
    9592# Timestepping
    96 #-------------
     93################################################################################
    9794
    9895CFL = 1.0  # CFL condition assigned to domain.CFL - controls timestep size
    9996     
    10097# Choose type of timestepping,
     98#timestepping_method = 'rk2'   # 2nd Order TVD scheme
    10199timestepping_method = 'euler' # 1st order euler
    102 #timestepping_method = 'rk2'   # 2nd Order TVD scheme
    103100
    104101# rk2 is a little more stable than euler, so rk2 timestepping
     
    109106beta_rk2   = 1.6
    110107
    111 
    112 
    113108# Option to search for signatures where isolated triangles are
    114109# responsible for a small global timestep.
     
    116111# overall computation.
    117112# This facility is experimental.
    118 
    119113# protect_against_isolated_degenerate_timesteps = False
    120114protect_against_isolated_degenerate_timesteps = False
    121115
    122 
    123116min_timestep = 1.0e-6 # Minimal timestep accepted in ANUGA
    124117max_timestep = 1.0e+3
    125 max_smallsteps = 50  # Max number of degenerate steps allowed b4 trying first order
    126 
    127 #Perhaps minimal timestep could be based on the geometry as follows:
    128 #Define maximal possible speed in open water v_max, e.g. 500m/s (soundspeed?)
    129 #Then work out minimal internal distance in mesh r_min and set
    130 #min_timestep = r_min/v_max
    131 #
    132 #Max speeds are calculated in the flux function as
    133 #
    134 #lambda = v +/- sqrt(gh)
     118max_smallsteps = 50   # Max number of degenerate steps allowed b4
     119                      # trying first order
     120
     121# Perhaps minimal timestep could be based on the geometry as follows:
     122# Define maximal possible speed in open water v_max, e.g. 500m/s (soundspeed?)
     123# Then work out minimal internal distance in mesh r_min and set
     124# min_timestep = r_min/v_max
     125#
     126# Max speeds are calculated in the flux function as
     127#
     128# lambda = v +/- sqrt(gh)
    135129#
    136130# so with 500 m/s, h ~ 500^2/g = 2500 m well out of the domain of the
    137131# shallow water wave equation
    138132#
    139 #The actual soundspeed can be as high as 1530m/s
    140 #(see http://staff.washington.edu/aganse/public.projects/clustering/clustering.html),
    141 #but that would only happen with h>225000m in this equation. Why ?
    142 #The maximal speed we specify is really related to the max speed
    143 #of surface pertubation
    144 #
    145 #v_max = 100 #For use in domain_ext.c
    146 #sound_speed = 500
    147 
    148 
    149 #---------------------------------------------------
     133# The actual soundspeed can be as high as 1530m/s
     134# (see http://staff.washington.edu/aganse/public.projects/clustering/clustering.html),
     135# but that would only happen with h>225000m in this equation. Why ?
     136# The maximal speed we specify is really related to the max speed
     137# of surface pertubation
     138#
     139# v_max = 100 #For use in domain_ext.c
     140# sound_speed = 500
     141
     142################################################################################
    150143# Ranges specific to the shallow water wave equation
    151 # These control maximal and minimal values of
    152 # quantities
    153 #---------------------------------------------------
     144# These control maximal and minimal values of quantities
     145################################################################################
    154146
    155147# Water depth below which it is considered to be 0 in the model
     
    163155maximum_allowed_speed = 0.0 # Maximal particle speed of water
    164156#maximum_allowed_speed = 1.0 # Maximal particle speed of water
    165                             # Too large (100) creates 'flopping' water
    166                             # Too small (0) creates 'creep'
     157                             # Too large (100) creates 'flopping' water
     158                             # Too small (0) creates 'creep'
    167159                           
    168160maximum_froude_number = 100.0 # To be used in limiters.
    169161
    170 
    171 #------------------------------------------------------------
     162################################################################################
    172163# Performance parameters used to invoke various optimisations
    173 #------------------------------------------------------------
     164################################################################################
    174165
    175166use_extensions = True # Use C-extensions
    176 use_psyco = True # Use psyco optimisations
     167use_psyco = True      # Use psyco optimisations
    177168
    178169optimise_dry_cells = True # Exclude dry and still cells from flux computation
    179170optimised_gradient_limiter = True # Use hardwired gradient limiter
    180 use_edge_limiter = False # The edge limiter is better, but most runs have been using vertex limiting. Validations passed with this one True 9th May 2008, but many unit tests need backward compatibility flag set FIXME(Ole).
     171use_edge_limiter = False  # The edge limiter is better, but most runs have been
     172                          # using vertex limiting. Validations passed with this
     173                          # one True 9th May 2008, but many unit tests need
     174                          # backward compatibility flag set FIXME(Ole).
    181175
    182176points_file_block_line_size = 500 # Number of lines read in from a points file
    183177                                  # when blocking
    184178
    185 
    186 
    187 
    188 
    189 
    190    
     179################################################################################
     180# Dynamically-defined constants.
     181################################################################################
     182
     183# Determine if we can read/write large NetCDF files
     184
     185netcdf_mode_w = 'w'
     186netcdf_mode_a = 'a'
     187netcdf_mode_r = 'r'
     188
     189try:
     190    import tempfile
     191    from Scientific.IO.NetCDF import NetCDFFile
     192
     193    fname = tempfile.mktemp()
     194    fid = NetCDFFile(fname, netcdf_mode_w)
     195    fid.close()
     196    netcdf_mode_w = 'wl'
     197#    log('Using NetCDF large file mode')
     198except IOError:
     199    pass
     200
  • anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py

    r4663 r6086  
    88from geo_reference import *
    99from Numeric import allclose,array
     10from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    1011
    1112
     
    3233        file_name = tempfile.mktemp(".geo_referenceTest")
    3334       
    34         out_file = NetCDFFile(file_name, 'w')
     35        out_file = NetCDFFile(file_name, netcdf_mode_w)
    3536        g.write_NetCDF(out_file)
    3637        out_file.close()
    3738       
    38         in_file = NetCDFFile(file_name, 'r')
     39        in_file = NetCDFFile(file_name, netcdf_mode_r)
    3940        new_g = Geo_reference(NetCDFObject=in_file)
    4041        in_file.close()
     
    4950        file_name = tempfile.mktemp(".geo_referenceTest")
    5051       
    51         outfile = NetCDFFile(file_name, 'w')
     52        outfile = NetCDFFile(file_name, netcdf_mode_w)
    5253        outfile.xllcorner = g.get_xllcorner()
    5354        outfile.yllcorner =  g.get_yllcorner()
     
    5556        outfile.close()
    5657       
    57         in_file = NetCDFFile(file_name, 'r')
     58        in_file = NetCDFFile(file_name, netcdf_mode_r)
    5859        new_g = Geo_reference(NetCDFObject=in_file)
    5960        in_file.close()
  • anuga_core/source/anuga/fit_interpolate/interpolate.py

    r6073 r6086  
    4040from anuga.fit_interpolate.general_fit_interpolate import FitInterpolate
    4141from anuga.abstract_2d_finite_volumes.util import file_function
     42from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    4243
    4344# Interpolation specific exceptions
     
    13111312    stdout = sys.stdout
    13121313    sys.stdout = fd
    1313     fid = NetCDFFile(file_name, 'r')
     1314    fid = NetCDFFile(file_name, netcdf_mode_r)
    13141315    sys.stdout = stdout
    13151316    fd.close()
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r6081 r6086  
    2121from anuga.utilities.anuga_exceptions import ANUGAError
    2222from anuga.config import points_file_block_line_size as MAX_READ_LINES
    23 
     23from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    2424
    2525DEFAULT_ATTRIBUTE = 'elevation'
     
    793793
    794794            # Throws prints to screen if file not present
    795             self.fid = NetCDFFile(self.file_name, 'r')
     795            self.fid = NetCDFFile(self.file_name, netcdf_mode_r)
    796796
    797797            (self.blocking_georef,
     
    10021002
    10031003    # Throws prints to screen if file not present
    1004     fid = NetCDFFile(file_name, 'r')
     1004    fid = NetCDFFile(file_name, netcdf_mode_r)
    10051005
    10061006    pointlist = array(fid.variables['points'])
     
    12531253
    12541254    # NetCDF file definition
    1255     outfile = NetCDFFile(file_name, 'w')
     1255    outfile = NetCDFFile(file_name, netcdf_mode_w)
    12561256
    12571257    # Create new file
  • anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r5730 r6086  
    1414from anuga.utilities.anuga_exceptions import ANUGAError
    1515from anuga.utilities.system_tools import get_host_name
     16from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    1617
    1718class Test_Geospatial_data(unittest.TestCase):
     
    11311132        fileName = tempfile.mktemp(".pts")
    11321133        # NetCDF file definition
    1133         outfile = NetCDFFile(fileName, 'w')
     1134        outfile = NetCDFFile(fileName, netcdf_mode_w)
    11341135       
    11351136        # dimension definitions
     
    12881289        FN = 'test_points.pts'
    12891290        # NetCDF file definition
    1290         outfile = NetCDFFile(FN, 'w')
     1291        outfile = NetCDFFile(FN, netcdf_mode_w)
    12911292       
    12921293        # dimension definitions
     
    13291330        FN = 'test_points.pts'
    13301331        # NetCDF file definition
    1331         outfile = NetCDFFile(FN, 'w')
     1332        outfile = NetCDFFile(FN, netcdf_mode_w)
    13321333
    13331334        # Make up an arbitrary georef
  • anuga_core/source/anuga/load_mesh/loadASCII.py

    r6074 r6086  
    6666
    6767from Scientific.IO.NetCDF import NetCDFFile
     68from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
     69
    6870
    6971import exceptions
     
    682684    # NetCDF file definition
    683685    try:
    684         outfile = NetCDFFile(file_name, 'w')
     686        outfile = NetCDFFile(file_name, netcdf_mode_w)
    685687    except IOError:
    686688        msg = 'File %s could not be created' % file_name
     
    844846
    845847    #throws prints to screen if file not present
    846     fid = NetCDFFile(file_name, 'r')
     848    fid = NetCDFFile(file_name, netcdf_mode_r)
    847849    mesh = {}
    848850
  • anuga_core/source/anuga/shallow_water/benchmark_sww2dem.py

    r4894 r6086  
    3434from anuga.fit_interpolate.interpolate import benchmark_interpolate
    3535from anuga.shallow_water.data_manager import Write_sww, export_grid
     36from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
     37
    3638
    3739def mem_usage():
     
    105107       
    106108    # NetCDF file definition
    107     fid = NetCDFFile(sww_fileName, 'w')
     109    fid = NetCDFFile(sww_fileName, netcdf_mode_w)
    108110    sww = Write_sww()
    109111    sww.store_header(fid, 0,
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r6080 r6086  
    7878from anuga.config import minimum_storable_height as \
    7979     default_minimum_storable_height
     80from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    8081from anuga.config import max_float
    8182from anuga.utilities.numerical_tools import ensure_numeric,  mean
     
    300301    # @param extension
    301302    # @param mode The mode of the underlying file.
    302     def __init__(self, domain, extension, mode='w'):
    303         assert mode in ['r', 'w', 'a'], \
     303    def __init__(self, domain, extension, mode=netcdf_mode_w):
     304        assert mode[0] in ['r', 'w', 'a'], \
    304305               "Mode %s must be either:\n" % mode + \
    305306               "   'w' (write)\n" + \
     
    341342    # @param max_size ??
    342343    # @param recursion ??
    343     # @note Prepare the undelying data file if mode is 'w'.
    344     def __init__(self, domain, mode='w', max_size=2000000000, recursion=False):
     344    # @note Prepare the underlying data file if mode starts with 'w'.
     345    def __init__(self, domain, mode=netcdf_mode_w, max_size=2000000000, recursion=False):
    345346        from Scientific.IO.NetCDF import NetCDFFile
    346347        from Numeric import Int, Float, Float32
     
    363364        # NetCDF file definition
    364365        fid = NetCDFFile(self.filename, mode)
    365         if mode == 'w':
     366        if mode[0] == 'w':
    366367            description = 'Output from anuga.abstract_2d_finite_volumes ' \
    367368                          'suitable for plotting'
     
    429430
    430431        # append to the NetCDF file
    431         fid = NetCDFFile(self.filename, 'a')
    432 
    433         # Get the variables
    434         x = fid.variables['x']
    435         y = fid.variables['y']
    436         z = fid.variables['elevation']
    437         volumes = fid.variables['volumes']
     432        fid = NetCDFFile(self.filename, netcdf_mode_a)
     433
     434#        # Get the variables
     435#        x = fid.variables['x']
     436#        y = fid.variables['y']
     437#        z = fid.variables['elevation']
     438#        volumes = fid.variables['volumes']
    438439
    439440        # Get X, Y and bed elevation Z
     
    445446        self.writer.store_triangulation(fid,
    446447                                        points,
    447                                         V.astype(volumes.typecode()),
     448#                                        V.astype(volumes.typecode()),
     449                                        V.astype(Float32),
    448450                                        Z,
    449451                                        points_georeference=\
     
    475477        while not file_open and retries < 10:
    476478            try:
    477                 fid = NetCDFFile(self.filename, 'a') # Open existing file
     479                fid = NetCDFFile(self.filename, netcdf_mode_a) # Open existing file
    478480            except IOError:
    479481                # This could happen if someone was reading the file.
     
    623625    # @param domain ??
    624626    # @param mode Mode of underlying data file (default WRITE).
    625     def __init__(self, domain, mode='w'):
     627    def __init__(self, domain, mode=netcdf_mode_w):
    626628        from Scientific.IO.NetCDF import NetCDFFile
    627629        from Numeric import Int, Float, Float
     
    633635        # NetCDF file definition
    634636        fid = NetCDFFile(self.filename, mode)
    635         if mode == 'w':
     637        if mode[0] == 'w':
    636638            #Create new file
    637639            fid.institution = 'Geoscience Australia'
     
    683685
    684686        #Get NetCDF
    685         fid = NetCDFFile(self.filename, 'a')
     687        fid = NetCDFFile(self.filename, netcdf_mode_a)
    686688
    687689        # Get the variables
     
    718720        while not file_open and retries < 10:
    719721            try:
    720                 fid = NetCDFFile(self.filename, 'a')
     722                fid = NetCDFFile(self.filename, netcdf_mode_a)
    721723            except IOError:
    722724                #This could happen if someone was reading the file.
     
    11341136    FN = create_filename('.', basefilename, 'sww', size)
    11351137    print 'Reading from ', FN
    1136     fid = NetCDFFile(FN, 'r')  #Open existing file for read
     1138    fid = NetCDFFile(FN, netcdf_mode_r)  #Open existing file for read
    11371139
    11381140    # Get the variables
     
    12571259
    12581260    # Get NetCDF
    1259     infile = NetCDFFile(filename1, 'r')  #Open existing file for read
    1260     outfile = NetCDFFile(filename2, 'w')  #Open new file
     1261    infile = NetCDFFile(filename1, netcdf_mode_r)  #Open existing file for read
     1262    outfile = NetCDFFile(filename2, netcdf_mode_w)  #Open new file
    12611263
    12621264    # Copy dimensions
     
    13031305# @return A class instance of required domain and mode.
    13041306#Get data objects
    1305 def get_dataobject(domain, mode='w'):
     1307def get_dataobject(domain, mode=netcdf_mode_w):
    13061308    """Return instance of class of given format using filename
    13071309    """
     
    13891391
    13901392    # Get NetCDF
    1391     infile = NetCDFFile(root + '.dem', 'r')
     1393    infile = NetCDFFile(root + '.dem', netcdf_mode_r)
    13921394
    13931395    if verbose: print 'Reading DEM from %s' %(root + '.dem')
     
    14191421
    14201422    # NetCDF file definition
    1421     outfile = NetCDFFile(ptsname, 'w')
     1423    outfile = NetCDFFile(ptsname, netcdf_mode_w)
    14221424
    14231425    # Create new file
     
    27002702
    27012703    # NetCDF file definition
    2702     fid = NetCDFFile(netcdfname, 'w')
     2704    fid = NetCDFFile(netcdfname, netcdf_mode_w)
    27032705
    27042706    #Create new file
     
    28292831    if verbose: print 'Reading files %s_*.nc' % basename_in
    28302832
    2831     file_h = NetCDFFile(basename_in + '_ha.nc', 'r') # Wave amplitude (cm)
    2832     file_u = NetCDFFile(basename_in + '_ua.nc', 'r') # Velocity (x) (cm/s)
    2833     file_v = NetCDFFile(basename_in + '_va.nc', 'r') # Velocity (y) (cm/s)
    2834     file_e = NetCDFFile(basename_in + '_e.nc', 'r')  # Elevation (z) (m)
     2833    file_h = NetCDFFile(basename_in + '_ha.nc', netcdf_mode_r) # Wave amplitude (cm)
     2834    file_u = NetCDFFile(basename_in + '_ua.nc', netcdf_mode_r) # Velocity (x) (cm/s)
     2835    file_v = NetCDFFile(basename_in + '_va.nc', netcdf_mode_r) # Velocity (y) (cm/s)
     2836    file_e = NetCDFFile(basename_in + '_e.nc', netcdf_mode_r)  # Elevation (z) (m)
    28352837
    28362838    if basename_out is None:
     
    30333035
    30343036    # NetCDF file definition
    3035     outfile = NetCDFFile(swwname, 'w')
     3037    outfile = NetCDFFile(swwname, netcdf_mode_w)
    30363038
    30373039    description = 'Converted from Ferret files: %s, %s, %s, %s' \
     
    32633265    from Scientific.IO.NetCDF import NetCDFFile
    32643266
    3265     fid = NetCDFFile(filename + '.tms', 'w')
     3267    fid = NetCDFFile(filename + '.tms', netcdf_mode_w)
    32663268
    32673269    fid.institution = 'Geoscience Australia'
     
    33123314
    33133315    #Get NetCDF
    3314     fid = NetCDFFile(file_name, 'r')
     3316    fid = NetCDFFile(file_name, netcdf_mode_r)
    33153317
    33163318    # Get the variables
     
    33553357    if verbose: print 'Reading from ', filename
    33563358
    3357     fid = NetCDFFile(filename, 'r')    # Open existing file for read
     3359    fid = NetCDFFile(filename, netcdf_mode_r)    # Open existing file for read
    33583360    time = fid.variables['time']       # Timesteps
    33593361    if t is None:
     
    36473649
    36483650    #Open existing netcdf file to read
    3649     infile = NetCDFFile(inname, 'r')
     3651    infile = NetCDFFile(inname, netcdf_mode_r)
    36503652
    36513653    if verbose: print 'Reading DEM from %s' % inname
     
    36843686
    36853687    #Open netcdf file for output
    3686     outfile = NetCDFFile(outname, 'w')
     3688    outfile = NetCDFFile(outname, netcdf_mode_w)
    36873689
    36883690    #Create new file
     
    39253927
    39263928    # NetCDF file definition
    3927     outfile = NetCDFFile(sww_file, 'w')
     3929    outfile = NetCDFFile(sww_file, netcdf_mode_w)
    39283930
    39293931    #Create new file
     
    42764278
    42774279        # NetCDF file definition
    4278         self.outfile = NetCDFFile(file_name, 'w')
     4280        self.outfile = NetCDFFile(file_name, netcdf_mode_w)
    42794281        outfile = self.outfile
    42804282
     
    45574559
    45584560    # NetCDF file definition
    4559     outfile = NetCDFFile(file_out, 'w')
     4561    outfile = NetCDFFile(file_out, netcdf_mode_w)
    45604562
    45614563    #Create new file
     
    51365138    if verbose: print 'Output to ', swwname
    51375139
    5138     outfile = NetCDFFile(swwname, 'w')
     5140    outfile = NetCDFFile(swwname, netcdf_mode_w)
    51395141
    51405142    # For a different way of doing this, check out tsh2sww
     
    55285530
    55295531    # NetCDF file definition
    5530     outfile = NetCDFFile(stsname, 'w')
     5532    outfile = NetCDFFile(stsname, netcdf_mode_w)
    55315533
    55325534    description = 'Converted from URS mux2 files: %s' % basename_in
     
    56285630
    56295631    try:
    5630         fid = NetCDFFile(stsname + '.sts', 'r')
     5632        fid = NetCDFFile(stsname + '.sts', netcdf_mode_r)
    56315633    except:
    56325634        msg = 'Cannot open %s' % stsname + '.sts'
     
    67186720    if verbose: print 'Reading from ', filename
    67196721
    6720     fid = NetCDFFile(filename, 'r')    # Open existing file for read
     6722    fid = NetCDFFile(filename, netcdf_mode_r)    # Open existing file for read
    67216723    time = fid.variables['time'][:]    # Time vector
    67226724    time += fid.starttime[0]
  • anuga_core/source/anuga/shallow_water/most2nc.py

    r6058 r6086  
    99import sys
    1010from Scientific.IO.NetCDF import NetCDFFile
     11from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    1112
    1213
     
    7576    if verbose: print 'writing results'
    7677
    77     out_file = NetCDFFile(output_file,'w')
     78    out_file = NetCDFFile(output_file, netcdf_mode_w)
    7879
    7980    out_file.createDimension(long_name,nx)
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r6055 r6086  
    108108from anuga.config import use_edge_limiter
    109109from anuga.config import use_centroid_velocities
     110from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    110111
    111112from anuga.fit_interpolate.interpolate import Modeltime_too_late, Modeltime_too_early
     
    625626
    626627        # Initialise writer
    627         self.writer = get_dataobject(self, mode = 'w')
     628        self.writer = get_dataobject(self, mode=netcdf_mode_w)
    628629
    629630        # Store vertices and connectivity
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r6010 r6086  
    2222from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees
    2323from anuga.abstract_2d_finite_volumes.util import file_function
    24 
    2524from anuga.utilities.system_tools import get_pathname_from_package
     25from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    2626
    2727# This is needed to run the tests of local functions
     
    3232from anuga.geospatial_data.geospatial_data import Geospatial_data
    3333
     34
    3435class Test_Data_Manager(unittest.TestCase):
    3536    # Class variable
     
    4243        import time
    4344        from mesh_factory import rectangular
    44 
    4545       
    4646        self.verbose = Test_Data_Manager.verbose
     
    105105
    106106        for ext in ['_ha.nc', '_ua.nc', '_va.nc', '_e.nc']:
    107             fid = NetCDFFile(self.test_MOST_file + ext, 'w')
     107            fid = NetCDFFile(self.test_MOST_file + ext, netcdf_mode_w)
    108108
    109109            fid.createDimension(long_name,nx)
     
    180180        sww.store_connectivity()
    181181
    182         fid = NetCDFFile(sww.filename, 'r')  #Open existing file for append
     182        fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
    183183
    184184        # Get the variables
     
    214214        #Check contents
    215215        #Get NetCDF
    216         fid = NetCDFFile(sww.filename, 'r')  #Open existing file for append
     216        fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
    217217
    218218        # Get the variables
     
    247247           
    248248        # Get NetCDF
    249         fid = NetCDFFile(sww.filename, 'r') # Open existing file for append
     249        fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append
    250250
    251251        # Get the variables
     
    326326           
    327327        # Get NetCDF
    328         fid = NetCDFFile(sww.filename, 'r') # Open existing file for append
     328        fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append
    329329
    330330        # Get the variables
     
    372372        #Check contents
    373373        #Get NetCDF
    374         fid = NetCDFFile(sww.filename, 'r')  #Open existing file for append
     374        fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
    375375
    376376        # Get the variables
     
    413413        #Check contents
    414414        #Get NetCDF
    415         fid = NetCDFFile(sww.filename, 'r')  #Open existing file for append
     415        fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
    416416
    417417
     
    465465        #Check contents
    466466        #Get NetCDF
    467         fid = NetCDFFile(sww.filename, 'r')  #Open existing file for append
     467        fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
    468468
    469469        # Get the variables
     
    522522        #Check contents
    523523        #Get NetCDF
    524         fid = NetCDFFile(sww.filename, 'r')
     524        fid = NetCDFFile(sww.filename, inetcdf_mode_r)
    525525
    526526        # Get the variables
     
    586586
    587587            #Get NetCDF
    588             fid = NetCDFFile(self.domain.writer.filename, 'r')
     588            fid = NetCDFFile(self.domain.writer.filename, netcdf_mode_r)
    589589            stage_file = fid.variables['stage']
    590590           
     
    627627        #Check contents
    628628        #Get NetCDF
    629         fid = NetCDFFile(sww.filename, 'r')
     629        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    630630
    631631
     
    677677        #Check contents
    678678        #Get NetCDF
    679         fid = NetCDFFile(sww.filename, 'r')
     679        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    680680
    681681        # Get the variables
     
    787787        #Check contents
    788788        #Get NetCDF
    789         fid = NetCDFFile(root+'.pts', 'r')
     789        fid = NetCDFFile(root+'.pts', netcdf_mode_r)
    790790
    791791        # Get the variables
     
    908908        #Check contents
    909909        #Get NetCDF
    910         fid = NetCDFFile(root+'.pts', 'r')
     910        fid = NetCDFFile(root+'.pts', netcdf_mode_r)
    911911
    912912        # Get the variables
     
    10391039        #Check contents
    10401040        #Get NetCDF
    1041         fid = NetCDFFile(root+'.pts', 'r')
     1041        fid = NetCDFFile(root+'.pts', netcdf_mode_r)
    10421042
    10431043        # Get the variables
     
    11801180        #Check contents
    11811181        #Get NetCDF
    1182         fid = NetCDFFile(root+'.pts', 'r')
     1182        fid = NetCDFFile(root+'.pts', netcdf_mode_r)
    11831183
    11841184        # Get the variables
     
    12661266        #Get NetCDF
    12671267
    1268         fid = NetCDFFile(sww.filename, 'r')
     1268        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    12691269
    12701270        # Get the variables
     
    14601460        #Get NetCDF
    14611461
    1462         fid = NetCDFFile(sww.filename, 'r')
     1462        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    14631463
    14641464        # Get the variables
     
    15421542        #Get NetCDF
    15431543
    1544         fid = NetCDFFile(sww.filename, 'r')
     1544        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    15451545
    15461546        # Get the variables
     
    16811681        #Get NetCDF
    16821682
    1683         fid = NetCDFFile(sww.filename, 'r')
     1683        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    16841684
    16851685        # Get the variables
     
    18281828        #Get NetCDF
    18291829
    1830         fid = NetCDFFile(sww.filename, 'r')
     1830        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    18311831
    18321832        # Get the variables
     
    19911991        #Get NetCDF
    19921992
    1993         fid = NetCDFFile(sww.filename, 'r')
     1993        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    19941994
    19951995        # Get the variables
     
    21822182        #Get NetCDF
    21832183
    2184         fid = NetCDFFile(sww.filename, 'r')
     2184        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    21852185
    21862186        # Get the variables
     
    23302330        #Get NetCDF
    23312331
    2332         fid = NetCDFFile(sww.filename, 'r')
     2332        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    23332333
    23342334        # Get the variables
     
    24432443        #Get NetCDF
    24442444
    2445         fid = NetCDFFile(sww.filename, 'r')
     2445        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    24462446
    24472447        # Get the variables
     
    25932593        #Get NetCDF
    25942594
    2595         fid = NetCDFFile(swwfile, 'r')
     2595        fid = NetCDFFile(swwfile, netcdf_mode_r)
    25962596
    25972597        # Get the variables
     
    27042704        #Get NetCDF
    27052705
    2706         fid = NetCDFFile(sww.filename, 'r')
     2706        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    27072707
    27082708        # Get the variables
     
    28002800
    28012801        # Check contents in NetCDF
    2802         fid = NetCDFFile(sww.filename, 'r')
     2802        fid = NetCDFFile(sww.filename, netcdf_mode_r)
    28032803
    28042804        # Get the variables
     
    31743174        from anuga.coordinate_transforms.redfearn import redfearn
    31753175        import os
    3176         fid1 = NetCDFFile('test_ha.nc','w')
    3177         fid2 = NetCDFFile('test_ua.nc','w')
    3178         fid3 = NetCDFFile('test_va.nc','w')
    3179         fid4 = NetCDFFile('test_e.nc','w')
     3176        fid1 = NetCDFFile('test_ha.nc',netcdf_mode_w)
     3177        fid2 = NetCDFFile('test_ua.nc',netcdf_mode_w)
     3178        fid3 = NetCDFFile('test_va.nc',netcdf_mode_w)
     3179        fid4 = NetCDFFile('test_e.nc',netcdf_mode_w)
    31803180
    31813181        h1_list = [150.66667,150.83334,151.]
     
    32623262        fid4.sync(); fid4.close()
    32633263
    3264         fid1 = NetCDFFile('test_ha.nc','r')
    3265         fid2 = NetCDFFile('test_e.nc','r')
    3266         fid3 = NetCDFFile('test_va.nc','r')
     3264        fid1 = NetCDFFile('test_ha.nc',netcdf_mode_r)
     3265        fid2 = NetCDFFile('test_e.nc',netcdf_mode_r)
     3266        fid3 = NetCDFFile('test_va.nc',netcdf_mode_r)
    32673267
    32683268
     
    33343334        from anuga.coordinate_transforms.redfearn import redfearn
    33353335        import os
    3336         fid1 = NetCDFFile('test_ha.nc','w')
    3337         fid2 = NetCDFFile('test_ua.nc','w')
    3338         fid3 = NetCDFFile('test_va.nc','w')
    3339         fid4 = NetCDFFile('test_e.nc','w')
     3336        fid1 = NetCDFFile('test_ha.nc',netcdf_mode_w)
     3337        fid2 = NetCDFFile('test_ua.nc',netcdf_mode_w)
     3338        fid3 = NetCDFFile('test_va.nc',netcdf_mode_w)
     3339        fid4 = NetCDFFile('test_e.nc',netcdf_mode_w)
    33403340
    33413341        h1_list = [150.66667,150.83334,151.]
     
    34263426        fid4.sync(); fid4.close()
    34273427
    3428         fid1 = NetCDFFile('test_ha.nc','r')
    3429         fid2 = NetCDFFile('test_e.nc','r')
    3430         fid3 = NetCDFFile('test_va.nc','r')
     3428        fid1 = NetCDFFile('test_ha.nc',netcdf_mode_r)
     3429        fid2 = NetCDFFile('test_e.nc',netcdf_mode_r)
     3430        fid3 = NetCDFFile('test_va.nc',netcdf_mode_r)
    34313431
    34323432
     
    34913491
    34923492        #Read output file 'small.sww'
    3493         #fid = NetCDFFile('small.sww', 'r')
     3493        #fid = NetCDFFile('small.sww', netcdf_mode_r)
    34943494        fid = NetCDFFile(self.test_MOST_file + '.sww')
    34953495
     
    39693969
    39703970        filename = root + '.dem'
    3971         fid = NetCDFFile(filename, 'w')
     3971        fid = NetCDFFile(filename, netcdf_mode_w)
    39723972
    39733973        fid.institution = 'Geoscience Australia'
     
    40264026
    40274027        #Open decimated NetCDF file
    4028         fid = NetCDFFile(root + '_100.dem', 'r')
     4028        fid = NetCDFFile(root + '_100.dem', netcdf_mode_r)
    40294029
    40304030        # Get decimated elevation
     
    40524052
    40534053        filename = root + '.dem'
    4054         fid = NetCDFFile(filename, 'w')
     4054        fid = NetCDFFile(filename, netcdf_mode_w)
    40554055
    40564056        fid.institution = 'Geoscience Australia'
     
    41214121
    41224122        #Open decimated NetCDF file
    4123         fid = NetCDFFile(root + '_100.dem', 'r')
     4123        fid = NetCDFFile(root + '_100.dem', netcdf_mode_r)
    41244124
    41254125        # Get decimated elevation
     
    43044304        # check the sww file
    43054305
    4306         fid = NetCDFFile(sww_file, 'r')    #Open existing file for read
     4306        fid = NetCDFFile(sww_file, netcdf_mode_r)    #Open existing file for read
    43074307        x = fid.variables['x'][:]
    43084308        y = fid.variables['y'][:]
     
    46144614        # check the sww file
    46154615
    4616         fid = NetCDFFile(sww_file, 'r')    #Open existing file for read
     4616        fid = NetCDFFile(sww_file, netcdf_mode_r)    #Open existing file for read
    46174617        x = fid.variables['x'][:]
    46184618        y = fid.variables['y'][:]
     
    48084808        # check the sww file
    48094809
    4810         fid = NetCDFFile(sww_file, 'r')    #Open existing file for read
     4810        fid = NetCDFFile(sww_file, netcdf_mode_r)    #Open existing file for read
    48114811        x = fid.variables['x'][:]
    48124812        y = fid.variables['y'][:]
     
    71187118
    71197119            # Read in sts file for this source file
    7120             fid = NetCDFFile(sts_name_out+'.sts', 'r') # Open existing file for read
     7120            fid = NetCDFFile(sts_name_out+'.sts', netcdf_mode_r) # Open existing file for read
    71217121            x = fid.variables['x'][:]+fid.xllcorner    # x-coordinates of vertices
    71227122            y = fid.variables['y'][:]+fid.yllcorner    # y-coordinates of vertices
     
    72747274       
    72757275        # read in sts file for combined source
    7276         fid = NetCDFFile(sts_name_out+'.sts', 'r')    #Open existing file for read
     7276        fid = NetCDFFile(sts_name_out+'.sts', netcdf_mode_r)    #Open existing file for read
    72777277        x = fid.variables['x'][:]+fid.xllcorner   #x-coordinates of vertices
    72787278        y = fid.variables['y'][:]+fid.yllcorner   #y-coordinates of vertices
     
    1000710007       
    1000810008        filename = tempfile.mktemp("_data_manager.sww")
    10009         outfile = NetCDFFile(filename, "w")
     10009        outfile = NetCDFFile(filename, netcdf_mode_w)
    1001010010        points_utm = array([[0.,0.],[1.,1.], [0.,1.]])
    1001110011        volumes = (0,1,2)
     
    1003910039       
    1004010040        filename = tempfile.mktemp("_data_manager.sww")
    10041         outfile = NetCDFFile(filename, "w")
     10041        outfile = NetCDFFile(filename, netcdf_mode_w)
    1004210042        points_utm = array([[0.,0.],[1.,1.], [0.,1.]])
    1004310043        volumes = (0,1,2)
     
    1007410074       
    1007510075        filename = tempfile.mktemp("_data_manager.sww")
    10076         outfile = NetCDFFile(filename, "w")
     10076        outfile = NetCDFFile(filename, netcdf_mode_w)
    1007710077        points_utm = array([[0.,0.],[1.,1.], [0.,1.]])
    1007810078        volumes = (0,1,2)
     
    1011310113       
    1011410114        filename = tempfile.mktemp("_data_manager.sww")
    10115         outfile = NetCDFFile(filename, "w")
     10115        outfile = NetCDFFile(filename, netcdf_mode_w)
    1011610116        points_utm = array([[0.,0.],[1.,1.], [0.,1.]])
    1011710117        volumes = (0,1,2)
     
    1014910149       
    1015010150        filename = tempfile.mktemp("_data_manager.sww")
    10151         outfile = NetCDFFile(filename, "w")
     10151        outfile = NetCDFFile(filename, netcdf_mode_w)
    1015210152        points_utm = array([[0.,0.],[1.,1.], [0.,1.]])
    1015310153        volumes = (0,1,2)
     
    1047210472
    1047310473        # Check that mimimum_storable_height works
    10474         fid = NetCDFFile(swwfile, 'r') # Open existing file
     10474        fid = NetCDFFile(swwfile, netcdf_mode_r) # Open existing file
    1047510475       
    1047610476        stage = fid.variables['stage'][:]
     
    1104911049
    1105011050    suite = unittest.makeSuite(Test_Data_Manager,'test')
    11051     #suite = unittest.makeSuite(Test_Data_Manager,'test_file_boundary_stsI_beyond_model_time')
     11051#    suite = unittest.makeSuite(Test_Data_Manager,'test_export_gridIII')
    1105211052    #suite = unittest.makeSuite(Test_Data_Manager,'test_file_boundary_stsIV_sinewave_ordering')
    1105311053    #suite = unittest.makeSuite(Test_Data_Manager,'test_get_flow_through_cross_section_with_geo')
  • anuga_core/source/anuga/shallow_water/test_most2nc.py

    r3567 r6086  
    11import unittest
    22from Numeric import allclose, asarray
     3from Scientific.IO.NetCDF import NetCDFFile
    34import most2nc
    4 from Scientific.IO.NetCDF import NetCDFFile
    55import os
    66
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r6051 r6086  
    66
    77from anuga.config import g, epsilon
     8from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    89from Numeric import allclose, alltrue, array, zeros, ones, Float, take
    910from anuga.utilities.numerical_tools import mean
     
    61886189
    61896190            #Get NetCDF
    6190             fid = NetCDFFile(domain.writer.filename, 'r')
     6191            fid = NetCDFFile(domain.writer.filename, netcdf_mode_r)
    61916192            stage_file = fid.variables['stage']
    61926193           
  • anuga_core/source/anuga/shallow_water/test_system.py

    r5878 r6086  
    1616from anuga.pmesh.mesh import Mesh
    1717from anuga.abstract_2d_finite_volumes.pmesh2domain import pmesh_instance_to_domain_instance
    18 
     18from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    1919
    2020
     
    114114
    115115        # do an assertion on the time of the produced sww file
    116         fid = NetCDFFile(filename, 'r')    #Open existing file for read
     116        fid = NetCDFFile(filename, netcdf_mode_r)    #Open existing file for read
    117117        times = fid.variables['time'][:]
    118118        #print "times", times
     
    165165
    166166        # do an assertion on the time of the produced sww file
    167         fid = NetCDFFile(filename, 'r')    #Open existing file for read
     167        fid = NetCDFFile(filename, netcdf_mode_r)    #Open existing file for read
    168168        times = fid.variables['time'][:]
    169169        stage = fid.variables['stage'][:]
  • anuga_core/source/anuga/test_all.py

    r4978 r6086  
    2020exclude_files = []
    2121
    22 #if sys.platform != 'win32': 
     22#if sys.platform != 'win32':
    2323#    exclude_files.append('test_advection.py') #Weave doesn't work on Linux
    24 
    2524# Exclude test_advection on all platforms for the time being. See ticket:205
    2625#exclude_files.append('test_advection.py') #Weave doesn't work on Linux
    2726
     27# Directories that should not be searched for test files.
    2828
    29 # Directories that should not be searched for test files.   
    30 exclude_dirs = ['pypar_dist', #Special requirements
     29exclude_dirs = ['pypar_dist',                        #Special requirements
    3130                'props', 'wcprops', 'prop-base', 'text-base', '.svn', #Svn
    3231                'tmp']
    33 
    3432
    3533print "The following directories will be skipped over;"
     
    3836print ""
    3937
     38
    4039def get_test_files(path):
    41 
    42 
    4340    try:
    4441        files = os.listdir(path)
     
    5350    path_files = []
    5451    for file in files:
    55 
    5652        absolute_filename = path + os.sep + file
    5753
    5854        #sys.path.append('pmesh')
    5955        if os.path.isdir(absolute_filename):
    60             sys.path.append(file) #FIXME: May cause name conflicts between pyvolution\mesh.py and pmesh\mesh.py on some systems
     56            # FIXME: May cause name conflicts between pyvolution\mesh.py and
     57            #        pmesh\mesh.py on some systems
     58            sys.path.append(file)
    6159            path_files.append(file)
    62             print  file + ',',
    63             more_test_files, more_path_files =\
    64                              get_test_files(absolute_filename)
    65            
     60            print file + ',',
     61            more_test_files, more_path_files = \
     62                    get_test_files(absolute_filename)
    6663            test_files += more_test_files
    6764            path_files += more_path_files
     
    7067        else:
    7168            pass
    72        
     69
    7370    return test_files, path_files
    74 
    7571
    7672
     
    8379
    8480    files.sort() # Ensure same order on all platforms
    85    
     81
    8682    print
    8783    print
     
    8985    print
    9086    print 'Files tested;'
    91     #print_files = []
    9287    for file in files:
    93         #print_files += file + ' '
    9488        print file + ',',
    9589    print
     
    9892        for file in exclude_files:
    9993            print 'WARNING: File '+ file + ' to be excluded from testing'
    100             try:   
     94            try:
    10195                files.remove(file)
    10296            except ValueError, e:
    103                 msg = 'File "%s" was not found in test suite.\n' %file
    104                 msg += 'Original error is "%s"\n' %e
    105                 msg += 'Perhaps it should be removed from exclude list?' 
     97                msg = 'File "%s" was not found in test suite.\n' % file
     98                msg += 'Original error is "%s"\n' % e
     99                msg += 'Perhaps it should be removed from exclude list?'
    106100                raise Exception, msg
    107101
     
    109103    moduleNames = map(filenameToModuleName, files)
    110104    modules = map(__import__, moduleNames)
    111    
     105
    112106    # Fix up the system path
    113107    for file in path_files:
    114108        sys.path.remove(file)
    115        
     109
    116110    load = unittest.defaultTestLoader.loadTestsFromModule
    117111    testCaseClasses = map(load, modules)
    118112
    119    
    120113    if test_verbose is True:
    121114        # Test the code by setting verbose to True.
     
    128121                    # these are the test functions
    129122                    try:
    130                         # Calls class method set_verbose in the test case classes
    131                         # print 'Tests', tests._tests[0]
    132                         # print 'Type', type(tests._tests[0])                       
     123                        # Calls class method set_verbose in test case classes
    133124                        tests._tests[0].set_verbose()
    134125                    except:
    135                         pass # No all classes have set_verbose
     126                        pass                # No all classes have set_verbose
    136127    return unittest.TestSuite(testCaseClasses)
     128
    137129
    138130def check_anuga_import():
     
    143135        print "Python cannot import ANUGA module."
    144136        print "Check you have followed all steps of its installation."
    145         import sys; sys.exit()
     137        import sys
     138        sys.exit()
    146139
    147    
     140
    148141if __name__ == '__main__':
    149142    check_anuga_import()
     143
    150144    if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V':
    151145        test_verbose = True
    152         saveout = sys.stdout   
     146        saveout = sys.stdout
    153147        filename = ".temp"
    154148        fid = open(filename, 'w')
    155149        sys.stdout = fid
    156150    else:
    157         test_verbose = False       
     151        test_verbose = False
    158152    suite = regressionTest(test_verbose)
    159153    runner = unittest.TextTestRunner() #verbosity=2
    160154    runner.run(suite)
    161    
     155
    162156    # Cleaning up
    163157    if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V':
    164         sys.stdout = saveout 
     158        sys.stdout = saveout
    165159        #fid.close() # This was causing an error in windows
    166160        #os.remove(filename)
  • anuga_core/source/anuga/utilities/test_system_tools.py

    r5897 r6086  
    66import zlib
    77from os.path import join, split, sep
     8from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    89
    910
     
    8586            # First file
    8687            filename1 = mktemp(suffix='.nc', dir='.')
    87             fid = NetCDFFile(filename1, 'w')
     88            fid = NetCDFFile(filename1, netcdf_mode_w)
    8889            fid.createDimension('two', 2)
    8990            fid.createVariable('test_array', Float,
     
    9495            # Second file
    9596            filename2 = mktemp(suffix='.nc', dir='.')
    96             fid = NetCDFFile(filename2, 'w')
     97            fid = NetCDFFile(filename2, netcdf_mode_w)
    9798            fid.createDimension('two', 2)
    9899            fid.createVariable('test_array', Float,
Note: See TracChangeset for help on using the changeset viewer.