Changeset 7800


Ignore:
Timestamp:
Jun 7, 2010, 1:04:42 PM (10 years ago)
Author:
hudson
Message:

urs2sww has an extra urs_ungridded2sww function.

Location:
trunk/anuga_core/source/anuga
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/__init__.py

    r7796 r7800  
    2929from anuga.shallow_water.shallow_water_domain import Domain
    3030
    31 from anuga.abstract_2d_finite_volumes.util import file_function
     31from anuga.abstract_2d_finite_volumes.util import file_function, sww2timeseries
    3232
    3333from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
     
    8989#-----------------------------
    9090from anuga.file_conversion.file_conversion import sww2obj, dat2obj, \
    91                     timefile2netcdf, tsh2sww, urs2sww
    92 from anuga.file_conversion.urs2nc import urs2nc 
     91                    timefile2netcdf, tsh2sww
     92from anuga.file_conversion.urs2nc import urs2nc
     93from anuga.file_conversion.urs2sww import urs2sww 
    9394from anuga.file_conversion.urs2sts import urs2sts
    9495from anuga.file_conversion.dem2pts import dem2pts                   
     
    99100from anuga.file_conversion.dem2dem import dem2dem
    100101
     102
     103#-----------------------------
     104# Mesh API
     105#-----------------------------
     106from anuga.pmesh.mesh_interface import create_mesh_from_regions
    101107
    102108#-----------------------------
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r7780 r7800  
    12931293        assert new == '3*xi+eta + lam'
    12941294                         
    1295 
    1296 
    1297     def test_point_on_line_obsolete(self):
    1298         """Test that obsolete call issues appropriate warning"""
    1299 
    1300         #Turn warning into an exception
    1301         import warnings
    1302         warnings.filterwarnings('error')
    1303 
    1304         try:
    1305             assert point_on_line( 0, 0.5, 0,1, 0,0 )
    1306         except DeprecationWarning:
    1307             pass
    1308         else:
    1309             msg = 'point_on_line should have issued a DeprecationWarning'
    1310             raise Exception(msg)   
    1311 
    1312         warnings.resetwarnings()
    1313    
     1295   
    13141296    def test_get_revision_number(self):
    13151297        """test_get_revision_number(self):
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r7772 r7800  
    149149        else:
    150150            return format % float(value)
    151 
    152 
    153 #################################################################################
    154 # OBSOLETE STUFF
    155 #################################################################################
    156 
    157 # @note TEMP
    158 def angle(v1, v2):
    159     """Temporary Interface to new location"""
    160 
    161     import anuga.utilities.numerical_tools as NT   
    162    
    163     msg = 'angle has moved from util.py.  '
    164     msg += 'Please use "from anuga.utilities.numerical_tools import angle"'
    165     warn(msg, DeprecationWarning)
    166 
    167     return NT.angle(v1, v2)
    168 
    169    
    170 # @note TEMP
    171 def anglediff(v0, v1):
    172     """Temporary Interface to new location"""
    173 
    174     import anuga.utilities.numerical_tools as NT
    175    
    176     msg = 'anglediff has moved from util.py.  '
    177     msg += 'Please use "from anuga.utilities.numerical_tools import anglediff"'
    178     warn(msg, DeprecationWarning)
    179 
    180     return NT.anglediff(v0, v1)   
    181 
    182 # @note TEMP
    183 def point_on_line(*args, **kwargs):
    184     """Temporary Interface to new location"""
    185 
    186     msg = 'point_on_line has moved from util.py.  '
    187     msg += 'Please use "from anuga.geometry.polygon import point_on_line"'
    188     warn(msg, DeprecationWarning)
    189 
    190     return utilities.geometry.point_on_line(*args, **kwargs)   
    191 
    192    
    193 # @note TEMP
    194 def inside_polygon(*args, **kwargs):
    195     """Temporary Interface to new location"""
    196 
    197     log.critical('inside_polygon has moved from util.py.')
    198     log.critical('Please use '
    199                  '"from anuga.utilities.polygon import inside_polygon"')
    200 
    201     return geometry.polygon.inside_polygon(*args, **kwargs)   
    202 
    203    
    204 # @note TEMP
    205 def outside_polygon(*args, **kwargs):
    206     """Temporary Interface to new location"""
    207 
    208     log.critical('outside_polygon has moved from util.py.')
    209     log.critical('Please use '
    210                  '"from anuga.geometry.polygon import outside_polygon"')
    211 
    212     return geometry.geometry.outside_polygon(*args, **kwargs)   
    213 
    214    
    215 # @note TEMP
    216 def read_polygon(*args, **kwargs):
    217     """Temporary Interface to new location"""
    218 
    219     log.critical('read_polygon has moved from util.py.')
    220     log.critical('Please use '
    221                  '"from anuga.geometry.polygon import read_polygon"')
    222 
    223     return geometry.geometry.read_polygon(*args, **kwargs)   
    224 
    225 
    226 # @note TEMP
    227 def populate_polygon(*args, **kwargs):
    228     """Temporary Interface to new location"""
    229 
    230     log.critical('populate_polygon has moved from util.py.')
    231     log.critical('Please use '
    232                  '"from anuga.utilities.polygon import populate_polygon"')
    233 
    234     return utilities.geometry.populate_polygon(*args, **kwargs)   
    235 
    236 
    237 #################################################################################
    238 # End of obsolete stuff ?
    239 #################################################################################
    240 
    241 # @note TEMP
    242 def start_screen_catcher(dir_name, myid='', numprocs='', extra_info='',
    243                          verbose=False):
    244     """Temporary Interface to new location"""
    245     from anuga.shallow_water.data_manager import start_screen_catcher \
    246          as dm_start_screen_catcher
    247 
    248     log.critical('start_screen_catcher has moved from util.py.')
    249     log.critical('Please use "from anuga.shallow_water.data_manager import '
    250                  'start_screen_catcher"')
    251    
    252     return dm_start_screen_catcher(dir_name, myid='', numprocs='',
    253                                    extra_info='', verbose=False)
    254 
    255 
    256151
    257152##
  • trunk/anuga_core/source/anuga/file/netcdf.py

    r7776 r7800  
    4646                        get_all_swwfiles
    4747from anuga.file.csv_file import load_csv_as_dict
    48 from sww_file import Read_sww, Write_sww
     48from sww import Read_sww, Write_sww
    4949
    5050from anuga.anuga_exceptions import DataMissingValuesError, \
  • trunk/anuga_core/source/anuga/file_conversion/file_conversion.py

    r7776 r7800  
    316316    sww.store_connectivity()
    317317    sww.store_timestep()
    318 
    319 
    320 ##
    321 # @brief Convert URS file to SWW file.
    322 # @param basename_in Stem of the input filename.
    323 # @param basename_out Stem of the output filename.
    324 # @param verbose True if this function is to be verbose.
    325 # @param remove_nc_files
    326 # @param minlat Sets extent of area to be used.  If not supplied, full extent.
    327 # @param maxlat Sets extent of area to be used.  If not supplied, full extent.
    328 # @param minlon Sets extent of area to be used.  If not supplied, full extent.
    329 # @param maxlon Sets extent of area to be used.  If not supplied, full extent.
    330 # @param mint
    331 # @param maxt
    332 # @param mean_stage
    333 # @param origin A 3-tuple with geo referenced UTM coordinates
    334 # @param zscale
    335 # @param fail_on_NaN
    336 # @param NaN_filler
    337 # @param elevation
    338 # @note Also convert latitude and longitude to UTM. All coordinates are
    339 #       assumed to be given in the GDA94 datum.
    340 def urs2sww(basename_in='o', basename_out=None, verbose=False,
    341             remove_nc_files=True,
    342             minlat=None, maxlat=None,
    343             minlon=None, maxlon=None,
    344             mint=None, maxt=None,
    345             mean_stage=0,
    346             origin=None,
    347             zscale=1,
    348             fail_on_NaN=True,
    349             NaN_filler=0):
    350     """Convert a URS file to an SWW file.
    351     Convert URS C binary format for wave propagation to
    352     sww format native to abstract_2d_finite_volumes.
    353 
    354     Specify only basename_in and read files of the form
    355     basefilename-z-mux2, basefilename-e-mux2 and
    356     basefilename-n-mux2 containing relative height,
    357     x-velocity and y-velocity, respectively.
    358 
    359     Also convert latitude and longitude to UTM. All coordinates are
    360     assumed to be given in the GDA94 datum. The latitude and longitude
    361     information is for  a grid.
    362 
    363     min's and max's: If omitted - full extend is used.
    364     To include a value min may equal it, while max must exceed it.
    365     Lat and lon are assumed to be in decimal degrees.
    366     NOTE: minlon is the most east boundary.
    367 
    368     origin is a 3-tuple with geo referenced
    369     UTM coordinates (zone, easting, northing)
    370     It will be the origin of the sww file. This shouldn't be used,
    371     since all of anuga should be able to handle an arbitary origin.
    372 
    373     URS C binary format has data orgainised as TIME, LONGITUDE, LATITUDE
    374     which means that latitude is the fastest
    375     varying dimension (row major order, so to speak)
    376 
    377     In URS C binary the latitudes and longitudes are in assending order.
    378     """
    379 
    380     if basename_out == None:
    381         basename_out = basename_in
    382 
    383     files_out = urs2nc(basename_in, basename_out)
    384 
    385     ferret2sww(basename_out,
    386                minlat=minlat,
    387                maxlat=maxlat,
    388                minlon=minlon,
    389                maxlon=maxlon,
    390                mint=mint,
    391                maxt=maxt,
    392                mean_stage=mean_stage,
    393                origin=origin,
    394                zscale=zscale,
    395                fail_on_NaN=fail_on_NaN,
    396                NaN_filler=NaN_filler,
    397                inverted_bathymetry=True,
    398                verbose=verbose)
    399    
    400     if remove_nc_files:
    401         for file_out in files_out:
    402             os.remove(file_out)
    403318
    404319
  • trunk/anuga_core/source/anuga/file_conversion/test_urs2sww.py

    r7770 r7800  
    5252        base_name, files = self.write_mux(lat_long,
    5353                                          time_step_count, time_step)
    54         urs2sww(base_name, mean_stage=tide, origin =(50,23432,4343))
     54        urs_ungridded2sww(base_name, mean_stage=tide, origin =(50,23432,4343))
    5555       
    5656        # now I want to check the sww file ...
     
    163163        #Latitude:   -21  0 ' 0.00000 ''  Longitude: 115  0 ' 0.00000 ''
    164164
    165         urs2sww(base_name, mean_stage=-240992.0,
     165        'hole_points_UTM(base_name, mean_stage=-240992.0,
    166166                          hole_points_UTM=[ 292110.784, 7676551.710 ])
    167167       
     
    206206        #Latitude:   -21  0 ' 0.00000 ''  Longitude: 115  0 ' 0.00000 ''
    207207
    208         urs2sww(base_name, mean_stage=-240992.0,
     208        urs_ungridded2sww(base_name, mean_stage=-240992.0,
    209209                          hole_points_UTM=[ 292110.784, 7676551.710 ])
    210210       
     
    244244        base_name, files = self.write_mux(lat_long,
    245245                                          time_step_count, time_step)
    246         urs2sww(base_name, mean_stage=tide, origin =(50,23432,4343),
     246        urs_ungridded2sww(base_name, mean_stage=tide, origin =(50,23432,4343),
    247247                          mint=101, maxt=500)
    248248       
     
    332332        base_name, files = self.write_mux(lat_long,
    333333                                          time_step_count, time_step)
    334         urs2sww(base_name, mean_stage=tide, origin =(50,23432,4343),
     334        urs_ungridded2sww(base_name, mean_stage=tide, origin =(50,23432,4343),
    335335                          mint=0, maxt=100000)
    336336       
     
    432432        base_name, files = self.write_mux(lat_long,
    433433                                          time_step_count, time_step)
    434         urs2sww(base_name, mean_stage=tide,
     434        urs_ungridded2sww(base_name, mean_stage=tide,
    435435                          verbose=self.verbose)
    436436        self.delete_mux(files)
     
    496496        base_name, files = self.write_mux(lat_long,
    497497                                          time_step_count, time_step)
    498         urs2sww(base_name, mean_stage=tide, origin = geo_reference)
     498        urs_ungridded2sww(base_name, mean_stage=tide, origin = geo_reference)
    499499       
    500500        # now I want to check the sww file ...
     
    586586        base_name, files = self.write_mux(lat_long,
    587587                                          time_step_count, time_step)
    588         urs2sww(base_name, mean_stage=tide,
     588        urs_ungridded2sww(base_name, mean_stage=tide,
    589589                          verbose=self.verbose)
    590590       
  • trunk/anuga_core/source/anuga/file_conversion/urs2nc.py

    r7776 r7800  
    1 
    2 ##
    3 # @brief Convert 3 URS files back to 4 NC files.
    4 # @param basename_in Stem of the input filenames.
    5 # @param basename_outStem of the output filenames.
    6 # @note The name of the urs file names must be:
    7 #          [basename_in]-z-mux
    8 #          [basename_in]-e-mux
    9 #          [basename_in]-n-mux
     1import os
     2from struct import pack, unpack
     3import array as p_array
     4import numpy as num
     5
     6from anuga.utilities.numerical_tools import ensure_numeric   
     7from anuga.caching.caching import myhash
     8
     9from anuga.file.netcdf import Write_nc, write_elevation_nc
     10
     11
     12from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
     13                            NORTH_VELOCITY_LABEL
     14
     15
    1016def urs2nc(basename_in='o', basename_out='urs'):
    1117    """Convert the 3 urs files to 4 nc files.
  • trunk/anuga_core/source/anuga/file_conversion/urs2sww.py

    r7776 r7800  
     1import os
    12import numpy as num
    23from Scientific.IO.NetCDF import NetCDFFile
    34
    45from anuga.file.urs import Read_urs
     6
     7from anuga.file_conversion.urs2nc import urs2nc
     8from anuga.file_conversion.ferret2sww import ferret2sww
    59
    610from anuga.coordinate_transforms.redfearn import redfearn, \
     
    4044# @note Input filename stem has suffixes '-z-mux', '-e-mux' and '-n-mux'
    4145#       added for relative height, x-velocity and y-velocity respectively.
    42 def urs2sww(basename_in='o', basename_out=None, verbose=False,
     46def urs_ungridded2sww(basename_in='o', basename_out=None, verbose=False,
    4347                      mint=None, maxt=None,
    4448                      mean_stage=0,
     
    249253    return mux_times_start_i, mux_times_fin_i
    250254
     255
     256
     257
     258
     259##
     260# @brief Convert URS file to SWW file.
     261# @param basename_in Stem of the input filename.
     262# @param basename_out Stem of the output filename.
     263# @param verbose True if this function is to be verbose.
     264# @param remove_nc_files
     265# @param minlat Sets extent of area to be used.  If not supplied, full extent.
     266# @param maxlat Sets extent of area to be used.  If not supplied, full extent.
     267# @param minlon Sets extent of area to be used.  If not supplied, full extent.
     268# @param maxlon Sets extent of area to be used.  If not supplied, full extent.
     269# @param mint
     270# @param maxt
     271# @param mean_stage
     272# @param origin A 3-tuple with geo referenced UTM coordinates
     273# @param zscale
     274# @param fail_on_NaN
     275# @param NaN_filler
     276# @param elevation
     277# @note Also convert latitude and longitude to UTM. All coordinates are
     278#       assumed to be given in the GDA94 datum.
     279def urs2sww(basename_in='o', basename_out=None, verbose=False,
     280            remove_nc_files=True,
     281            minlat=None, maxlat=None,
     282            minlon=None, maxlon=None,
     283            mint=None, maxt=None,
     284            mean_stage=0,
     285            origin=None,
     286            zscale=1,
     287            fail_on_NaN=True,
     288            NaN_filler=0):
     289    """Convert a URS file to an SWW file.
     290    Convert URS C binary format for wave propagation to
     291    sww format native to abstract_2d_finite_volumes.
     292
     293    Specify only basename_in and read files of the form
     294    basefilename-z-mux2, basefilename-e-mux2 and
     295    basefilename-n-mux2 containing relative height,
     296    x-velocity and y-velocity, respectively.
     297
     298    Also convert latitude and longitude to UTM. All coordinates are
     299    assumed to be given in the GDA94 datum. The latitude and longitude
     300    information is for  a grid.
     301
     302    min's and max's: If omitted - full extend is used.
     303    To include a value min may equal it, while max must exceed it.
     304    Lat and lon are assumed to be in decimal degrees.
     305    NOTE: minlon is the most east boundary.
     306
     307    origin is a 3-tuple with geo referenced
     308    UTM coordinates (zone, easting, northing)
     309    It will be the origin of the sww file. This shouldn't be used,
     310    since all of anuga should be able to handle an arbitary origin.
     311
     312    URS C binary format has data orgainised as TIME, LONGITUDE, LATITUDE
     313    which means that latitude is the fastest
     314    varying dimension (row major order, so to speak)
     315
     316    In URS C binary the latitudes and longitudes are in assending order.
     317    """
     318
     319    if basename_out == None:
     320        basename_out = basename_in
     321
     322    files_out = urs2nc(basename_in, basename_out)
     323
     324    ferret2sww(basename_out,
     325               minlat=minlat,
     326               maxlat=maxlat,
     327               minlon=minlon,
     328               maxlon=maxlon,
     329               mint=mint,
     330               maxt=maxt,
     331               mean_stage=mean_stage,
     332               origin=origin,
     333               zscale=zscale,
     334               fail_on_NaN=fail_on_NaN,
     335               NaN_filler=NaN_filler,
     336               inverted_bathymetry=True,
     337               verbose=verbose)
     338   
     339    if remove_nc_files:
     340        for file_out in files_out:
     341            os.remove(file_out)
     342
Note: See TracChangeset for help on using the changeset viewer.