Changeset 7602


Ignore:
Timestamp:
Jan 6, 2010, 9:23:10 PM (15 years ago)
Author:
ole
Message:

Removed obsolete variable 'z' from sww file format and verified tests and validations.
This commits ANUGA to the new viewer http://www.ausposdevelop.com.au/trac/anuga_viewer and closes ticket:342

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r7574 r7602  
    702702        fin = NetCDFFile(self.source, 'r')
    703703       
    704         for q in filter(lambda n:n != 'x' and n != 'y' and n != 'z' and n != 'time' and n != 'volumes' and \
     704        for q in filter(lambda n:n != 'x' and n != 'y' and n != 'time' and n != 'volumes' and \
    705705                        '_range' not in n, \
    706706                        fin.variables.keys()):
     
    34133413
    34143414    #FIXME use the Write_sww instance(sww) to write this info
    3415     z = num.resize(z, outfile.variables['z'][:].shape)
     3415    z = num.resize(z, outfile.variables['elevation'][:].shape)
    34163416    outfile.variables['x'][:] = x - geo_ref.get_xllcorner()
    34173417    outfile.variables['y'][:] = y - geo_ref.get_yllcorner()
    3418     outfile.variables['z'][:] = z             #FIXME HACK for bacwards compat.
     3418    #outfile.variables['z'][:] = z             #FIXME HACK for bacwards compat.
    34193419    outfile.variables['elevation'][:] = z
    34203420    outfile.variables['volumes'][:] = volumes.astype(num.int32) #For Opteron 64
     
    37073707    other_quantities.remove('x')
    37083708    other_quantities.remove('y')
    3709     other_quantities.remove('z')
     3709    #other_quantities.remove('z')
    37103710    other_quantities.remove('volumes')
    37113711    try:
     
    42644264
    42654265    #FIXME: Backwards compatibility
    4266     outfile.createVariable('z', precision, ('number_of_points',))
     4266    #outfile.createVariable('z', precision, ('number_of_points',))
    42674267    #################################
    42684268
     
    43394339        log.critical('geo_ref: ', geo_ref)
    43404340
    4341     z = num.resize(bath_grid,outfile.variables['z'][:].shape)
     4341    z = num.resize(bath_grid,outfile.variables['elevation'][:].shape)
    43424342    outfile.variables['x'][:] = x - geo_ref.get_xllcorner()
    43434343    outfile.variables['y'][:] = y - geo_ref.get_yllcorner()
    4344 # FIXME (Ole): Remove once viewer has been recompiled and changed
    4345 #              to use elevation instead of z
    4346     outfile.variables['z'][:] = z
     4344    # FIXME (Ole): Remove once viewer has been recompiled and changed
     4345    #              to use elevation instead of z
     4346    #outfile.variables['z'][:] = z
    43474347    outfile.variables['elevation'][:] = z
    43484348    outfile.variables['volumes'][:] = volumes.astype(num.int32) # On Opteron 64
     
    60996099            outfile.variables[q+Write_sww.RANGE][1] = -max_float # Max
    61006100
    6101         if 'elevation' in self.static_quantities:   
    6102             # FIXME: Backwards compat - get rid of z once old view has retired
    6103             outfile.createVariable('z', sww_precision,
    6104                                    ('number_of_points',))
     6101        #if 'elevation' in self.static_quantities:   
     6102        #    # FIXME: Backwards compat - get rid of z once old view has retired
     6103        #    outfile.createVariable('z', sww_precision,
     6104        #                           ('number_of_points',))
    61056105                               
    61066106        for q in self.dynamic_quantities:
     
    62676267                   
    62686268        # FIXME: Hack for backwards compatibility with old viewer
    6269         if 'elevation' in self.static_quantities:
    6270             outfile.variables['z'][:] = outfile.variables['elevation'][:]
     6269        #if 'elevation' in self.static_quantities:
     6270        #    outfile.variables['z'][:] = outfile.variables['elevation'][:]
    62716271
    62726272                   
     
    66386638        geo_ref.write_NetCDF(outfile)
    66396639
    6640         x =  points[:,0]
    6641         y =  points[:,1]
    6642         z = outfile.variables['z'][:]
     6640        x = points[:,0]
     6641        y = points[:,1]
     6642        z = outfile.variables['elevation'][:]
    66436643
    66446644        if verbose:
     
    66556655            log.critical('------------------------------------------------')
    66566656
    6657         #z = resize(bath_grid,outfile.variables['z'][:].shape)
     6657        z = resize(bath_grid,outfile.variables['elevation'][:].shape)
    66586658        outfile.variables['x'][:] = points[:,0] #- geo_ref.get_xllcorner()
    66596659        outfile.variables['y'][:] = points[:,1] #- geo_ref.get_yllcorner()
    6660         outfile.variables['z'][:] = elevation
     6660        #outfile.variables['z'][:] = elevation
    66616661        outfile.variables['elevation'][:] = elevation  #FIXME HACK4
    66626662
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r7520 r7602  
    182182        sww.store_connectivity()
    183183
    184         fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
     184        fid = NetCDFFile(sww.filename, netcdf_mode_r)  # Open existing file for append
    185185
    186186        # Get the variables
     
    214214        sww.store_connectivity()
    215215
    216         #Check contents
    217         #Get NetCDF
    218         fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
     216        # Check contents
     217        # Get NetCDF
     218        fid = NetCDFFile(sww.filename, netcdf_mode_r)  # Open existing file for append
    219219
    220220        # Get the variables
     
    383383        sww.store_connectivity()
    384384
    385         #Check contents
    386         #Get NetCDF
    387         fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
     385        # Check contents
     386        # Get NetCDF
     387        fid = NetCDFFile(sww.filename, netcdf_mode_r)  # Open existing file for append
    388388
    389389        # Get the variables
     
    424424        sww.store_timestep()
    425425
    426         #Check contents
    427         #Get NetCDF
    428         fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
     426        # Check contents
     427        # Get NetCDF
     428        fid = NetCDFFile(sww.filename, netcdf_mode_r)  # Open existing file for append
    429429
    430430
     
    475475
    476476
    477         #Check contents
    478         #Get NetCDF
    479         fid = NetCDFFile(sww.filename, netcdf_mode_r)  #Open existing file for append
     477        # Check contents
     478        # Get NetCDF
     479        fid = NetCDFFile(sww.filename, netcdf_mode_r)  # Open existing file for append
    480480
    481481        # Get the variables
     
    23712371
    23722372
    2373         #Export to ascii/prj files
     2373        # Export to ascii/prj files
    23742374        sww2dem(domain.get_name(),
    23752375                quantity = 'elevation',
     
    23862386
    23872387
    2388         #Check prj (meta data)
     2388        # Check prj (meta data)
    23892389        prjid = open(prjfile)
    23902390        lines = prjid.readlines()
     
    42204220                         (228+229+230+246+247+248+264+265+266) / 9.0]
    42214221
    4222         #generate a stencil for computing the decimated values
     4222        # generate a stencil for computing the decimated values
    42234223        stencil = num.ones((3,3), num.float) / 9.0
    42244224
    42254225        decimate_dem(root, stencil=stencil, cellsize_new=100)
    42264226
    4227         #Open decimated NetCDF file
     4227        # Open decimated NetCDF file
    42284228        fid = NetCDFFile(root + '_100.dem', netcdf_mode_r)
    42294229
     
    42314231        elevation = fid.variables['elevation']
    42324232
    4233         #Check values
     4233        # Check values
    42344234        assert num.allclose(elevation, ref_elevation)
    42354235
    4236         #Cleanup
     4236        # Cleanup
    42374237        fid.close()
    42384238
     
    42474247        from Scientific.IO.NetCDF import NetCDFFile
    42484248
    4249         #Write test dem file
     4249        # Write test dem file
    42504250        root = 'decdemtest'
    42514251
     
    42814281        elevation = fid.variables['elevation']
    42824282
    4283         #generate initial elevation values
     4283        # Generate initial elevation values
    42844284        elevation_tmp = (num.arange(nrows*ncols))
    4285         #add some NODATA values
     4285
     4286        # Add some NODATA values
    42864287        elevation_tmp[0]   = NODATA_value
    42874288        elevation_tmp[95]  = NODATA_value
     
    42964297        fid.close()
    42974298
    4298         #generate the elevation values expected in the decimated file
     4299        # Generate the elevation values expected in the decimated file
    42994300        ref_elevation = [NODATA_value,
    43004301                         (  4+  5+  6+ 22+ 23+ 24+ 40+ 41+ 42) / 9.0,
     
    43144315                         (228+229+230+246+247+248+264+265+266) / 9.0]
    43154316
    4316         #generate a stencil for computing the decimated values
     4317        # Generate a stencil for computing the decimated values
    43174318        stencil = num.ones((3,3), num.float) / 9.0
    43184319
    43194320        decimate_dem(root, stencil=stencil, cellsize_new=100)
    43204321
    4321         #Open decimated NetCDF file
     4322        # Open decimated NetCDF file
    43224323        fid = NetCDFFile(root + '_100.dem', netcdf_mode_r)
    43234324
     
    43254326        elevation = fid.variables['elevation']
    43264327
    4327         #Check values
     4328        # Check values
    43284329        assert num.allclose(elevation, ref_elevation)
    43294330
    4330         #Cleanup
     4331        # Cleanup
    43314332        fid.close()
    43324333
     
    45014502        # check the sww file
    45024503
    4503         fid = NetCDFFile(sww_file, netcdf_mode_r)    #Open existing file for read
     4504        fid = NetCDFFile(sww_file, netcdf_mode_r)    # Open existing file for read
    45044505        x = fid.variables['x'][:]
    45054506        y = fid.variables['y'][:]
    4506         z = fid.variables['z'][:]
     4507        z = fid.variables['elevation'][:]
    45074508        stage = fid.variables['stage'][:]
    45084509        xmomentum = fid.variables['xmomentum'][:]
     
    48114812        # check the sww file
    48124813
    4813         fid = NetCDFFile(sww_file, netcdf_mode_r)    #Open existing file for read
     4814        fid = NetCDFFile(sww_file, netcdf_mode_r)    # Open existing file for read
    48144815        x = fid.variables['x'][:]
    48154816        y = fid.variables['y'][:]
    4816         z = fid.variables['z'][:]
     4817        z = fid.variables['elevation'][:]
    48174818        stage = fid.variables['stage'][:]
    48184819        xmomentum = fid.variables['xmomentum'][:]
     
    50055006        # check the sww file
    50065007
    5007         fid = NetCDFFile(sww_file, netcdf_mode_r)    #Open existing file for read
     5008        fid = NetCDFFile(sww_file, netcdf_mode_r)    # Open existing file for read
    50085009        x = fid.variables['x'][:]
    50095010        y = fid.variables['y'][:]
    5010         z = fid.variables['z'][:]
     5011        z = fid.variables['elevation'][:]
    50115012        stage = fid.variables['stage'][:]
    50125013        xmomentum = fid.variables['xmomentum'][:]
     
    77577758       
    77587759        # read in sts file for combined source
    7759         fid = NetCDFFile(sts_name_out+'.sts', netcdf_mode_r)    #Open existing file for read
    7760         x = fid.variables['x'][:]+fid.xllcorner   #x-coordinates of vertices
    7761         y = fid.variables['y'][:]+fid.yllcorner   #y-coordinates of vertices
     7760        fid = NetCDFFile(sts_name_out+'.sts', netcdf_mode_r)    # Open existing file for read
     7761        x = fid.variables['x'][:]+fid.xllcorner   # x-coordinates of vertices
     7762        y = fid.variables['y'][:]+fid.yllcorner   # y-coordinates of vertices
    77627763        elevation = fid.variables['elevation'][:]
    77637764        time=fid.variables['time'][:]+fid.starttime
     
    77717772        assert num.allclose(stored_permutation, permutation), msg       
    77727773
    7773         # get quantity data from sts file
     7774        # Get quantity data from sts file
    77747775        quantity_names=['stage','xmomentum','ymomentum']
    77757776        quantities = {}
Note: See TracChangeset for help on using the changeset viewer.