Changeset 4862


Ignore:
Timestamp:
Nov 28, 2007, 4:52:47 PM (16 years ago)
Author:
duncan
Message:

ticket:#224

Files:
3 edited

Legend:

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

    r4850 r4862  
    7070from Numeric import concatenate, array, Float, Int, Int32, resize, sometrue, \
    7171     searchsorted, zeros, allclose, around, reshape, transpose, sort, \
    72      NewAxis, ArrayType, compress, take, arange, argmax, alltrue,shape,Float
     72     NewAxis, ArrayType, compress, take, arange, argmax, alltrue,shape,Float32
    7373
    7474import string
     
    337337                                     description=description,
    338338                                     smoothing=domain.smooth,
    339                                      order=domain.default_order)
     339                                     order=domain.default_order,
     340                                     sww_precision=self.precision)
    340341
    341342            # Extra optional information
     
    542543                self.writer.store_quantities(fid,
    543544                                             time=self.domain.time,
    544                                              precision=self.precision,
     545                                             sww_precision=self.precision,
    545546                                             stage=stage,
    546547                                             xmomentum=xmomentum,
     
    28982899    # Create new file
    28992900    starttime = times[0]
     2901   
    29002902    sww = Write_sww()
    29012903    sww.store_header(outfile, times, number_of_volumes,
    29022904                     number_of_points, description=description,
    2903                      verbose=verbose)
     2905                     verbose=verbose,sww_precision=Float)
    29042906
    29052907    # Store
     
    29572959    #FIXME: z should be obtained from MOST and passed in here
    29582960
     2961    #FIXME use the Write_sww instance(sww) to write this info
    29592962    from Numeric import resize
    29602963    z = resize(z,outfile.variables['z'][:].shape)
     
    47424745    sww = Write_sww()
    47434746    sww.store_header(outfile, times, len(volumes), len(points_utm),
    4744                      verbose=verbose)
     4747                     verbose=verbose,sww_precision=Float)
    47454748    outfile.mean_stage = mean_stage
    47464749    outfile.zscale = zscale
     
    47644767                                 stage=stage,
    47654768                                 xmomentum=xmomentum,
    4766                                  ymomentum=ymomentum)
     4769                                 ymomentum=ymomentum,
     4770                                 sww_precision=Float)
    47674771        j += 1
    47684772    if verbose: sww.verbose_quantities(outfile)
     
    48184822                     description='Converted from XXX',
    48194823                     smoothing=True,
    4820                      order=1, verbose=False):
     4824                     order=1,
     4825                     sww_precision=Float32,
     4826                     verbose=False):
    48214827        """
    48224828        outfile - the name of the file that will be written
     
    48854891
    48864892        # variable definitions
    4887         outfile.createVariable('x', precision, ('number_of_points',))
    4888         outfile.createVariable('y', precision, ('number_of_points',))
    4889         outfile.createVariable('elevation', precision, ('number_of_points',))
     4893        outfile.createVariable('x', sww_precision, ('number_of_points',))
     4894        outfile.createVariable('y', sww_precision, ('number_of_points',))
     4895        outfile.createVariable('elevation', sww_precision, ('number_of_points',))
    48904896        q = 'elevation'
    4891         outfile.createVariable(q+Write_sww.RANGE, precision,
     4897        outfile.createVariable(q+Write_sww.RANGE, sww_precision,
    48924898                               ('numbers_in_range',))
    48934899
     
    48954901        # Initialise ranges with small and large sentinels.
    48964902        # If this was in pure Python we could have used None sensibly
    4897         outfile.variables[q+Write_sww.RANGE][0] = max_float  # Min              
     4903        outfile.variables[q+Write_sww.RANGE][0] = max_float  # Min
    48984904        outfile.variables[q+Write_sww.RANGE][1] = -max_float # Max
    48994905
    49004906        # FIXME: Backwards compatibility
    4901         outfile.createVariable('z', precision, ('number_of_points',))
     4907        outfile.createVariable('z', sww_precision, ('number_of_points',))
    49024908        #################################
    49034909
    49044910        outfile.createVariable('volumes', Int, ('number_of_volumes',
    49054911                                                'number_of_vertices'))
    4906 
    4907         outfile.createVariable('time', precision,
     4912        # Doing sww_precision instead of Float gives cast errors.
     4913        outfile.createVariable('time', Float,
    49084914                               ('number_of_timesteps',))
    49094915       
    49104916        for q in Write_sww.sww_quantities:
    4911             outfile.createVariable(q, precision,
     4917            outfile.createVariable(q, sww_precision,
    49124918                                   ('number_of_timesteps',
    49134919                                    'number_of_points')) 
    4914             outfile.createVariable(q+Write_sww.RANGE, precision,
     4920            outfile.createVariable(q+Write_sww.RANGE, sww_precision,
    49154921                                   ('numbers_in_range',))
    49164922
    49174923            # Initialise ranges with small and large sentinels.
    49184924            # If this was in pure Python we could have used None sensibly
    4919             outfile.variables[q+Write_sww.RANGE][0] = max_float  # Min               
     4925            outfile.variables[q+Write_sww.RANGE][0] = max_float  # Min
    49204926            outfile.variables[q+Write_sww.RANGE][1] = -max_float # Max
    49214927           
     
    50165022           
    50175023        #z = resize(bath_grid,outfile.variables['z'][:].shape)
     5024        #print "points[:,0]", points[:,0]
    50185025        outfile.variables['x'][:] = points[:,0] #- geo_ref.get_xllcorner()
    50195026        outfile.variables['y'][:] = points[:,1] #- geo_ref.get_yllcorner()
     
    50285035
    50295036
    5030     def store_quantities(self, outfile, precision=Float,
     5037    def store_quantities(self, outfile, sww_precision=Float32,
    50315038                         slice_index=None, time=None,
    50325039                         verbose=False, **quant):
     
    50645071            else:
    50655072                q_values = quant[q]
    5066                 outfile.variables[q][slice_index] = q_values.astype(precision)
     5073                outfile.variables[q][slice_index] = \
     5074                                q_values.astype(sww_precision)
    50675075
    50685076                # This updates the _range values
     
    57135721                runup_index = argmax(wet_elevation)
    57145722                runup = max(wet_elevation)
    5715                 assert wet_elevation[runup_index] == runup # Must always be True
     5723                assert wet_elevation[runup_index] == runup # Must be True
     5724            #print "runup", runup
     5725            #print "maximal_runup", maximal_runup
     5726           
    57165727            if runup > maximal_runup:
    57175728                maximal_runup = runup      # This works even if maximal_runups is None
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4805 r4862  
    67706770        sww.store_header(outfile, times, number_of_volumes,
    67716771                         number_of_points, description='fully sick testing',
    6772                          verbose=self.verbose)
     6772                         verbose=self.verbose,sww_precision=Float)
    67736773        sww.store_triangulation(outfile, points_utm, volumes,
    67746774                                elevation,  new_origin=new_origin,
     
    68026802        sww.store_header(outfile, times, number_of_volumes,
    68036803                         number_of_points, description='fully sick testing',
    6804                          verbose=self.verbose)
     6804                         verbose=self.verbose,sww_precision=Float)
    68056805        sww.store_triangulation(outfile, points_utm, volumes,
    68066806                                elevation,  new_origin=new_origin,
    6807                                 verbose=self.verbose)       
     6807                                verbose=self.verbose)
    68086808        outfile.close()
    68096809        fid = NetCDFFile(filename)
     
    68386838        sww.store_header(outfile, times, number_of_volumes,
    68396839                         number_of_points, description='fully sick testing',
    6840                          verbose=self.verbose)
     6840                         verbose=self.verbose,sww_precision=Float)
    68416841        sww.store_triangulation(outfile, points_utm, volumes,
    68426842                                elevation,  new_origin=new_origin,
    6843                                 verbose=self.verbose)       
     6843                                verbose=self.verbose)
    68446844        outfile.close()
    68456845        fid = NetCDFFile(filename)
     
    68776877        sww.store_header(outfile, times, number_of_volumes,
    68786878                         number_of_points, description='fully sick testing',
    6879                          verbose=self.verbose)
     6879                         verbose=self.verbose,sww_precision=Float)
    68806880        sww.store_triangulation(outfile, points_utm, volumes,
    68816881                                elevation,  new_origin=new_origin,
     
    69136913        sww.store_header(outfile, times, number_of_volumes,
    69146914                         number_of_points, description='fully sick testing',
    6915                          verbose=self.verbose)
     6915                         verbose=self.verbose,sww_precision=Float)
    69166916        sww.store_triangulation(outfile, points_utm, volumes,
    69176917                                elevation,  new_origin=new_origin,
     
    73277327#-------------------------------------------------------------
    73287328if __name__ == "__main__":
    7329     #suite = unittest.makeSuite(Test_Data_Manager,'test_get_maximum_inundation')
    73307329    #suite = unittest.makeSuite(Test_Data_Manager,'test_sww_header')
    7331     #suite = unittest.makeSuite(Test_Data_Manager,'test_export_grid_parallel')
    73327330    suite = unittest.makeSuite(Test_Data_Manager,'test')
    7333     #suite = unittest.makeSuite(Test_Data_Manager,'test_sww_extrema')
     7331    #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded_holeII')
     7332    #suite = unittest.makeSuite(Test_Data_Manager,'test_sww_range')
    73347333
    73357334   
  • anuga_work/development/cairns_demo/runcairns.py

    r4861 r4862  
    139139domain.set_quantity('elevation',
    140140                    filename=dem_name + '.pts',
    141                     use_cache=True,
     141                    use_cache=False,
    142142                    verbose=True,
    143143                    alpha=0.1)
Note: See TracChangeset for help on using the changeset viewer.