Changeset 7800
- Timestamp:
- Jun 7, 2010, 1:04:42 PM (15 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/__init__.py
r7796 r7800 29 29 from anuga.shallow_water.shallow_water_domain import Domain 30 30 31 from anuga.abstract_2d_finite_volumes.util import file_function 31 from anuga.abstract_2d_finite_volumes.util import file_function, sww2timeseries 32 32 33 33 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross … … 89 89 #----------------------------- 90 90 from anuga.file_conversion.file_conversion import sww2obj, dat2obj, \ 91 timefile2netcdf, tsh2sww, urs2sww 92 from anuga.file_conversion.urs2nc import urs2nc 91 timefile2netcdf, tsh2sww 92 from anuga.file_conversion.urs2nc import urs2nc 93 from anuga.file_conversion.urs2sww import urs2sww 93 94 from anuga.file_conversion.urs2sts import urs2sts 94 95 from anuga.file_conversion.dem2pts import dem2pts … … 99 100 from anuga.file_conversion.dem2dem import dem2dem 100 101 102 103 #----------------------------- 104 # Mesh API 105 #----------------------------- 106 from anuga.pmesh.mesh_interface import create_mesh_from_regions 101 107 102 108 #----------------------------- -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py
r7780 r7800 1293 1293 assert new == '3*xi+eta + lam' 1294 1294 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 1314 1296 def test_get_revision_number(self): 1315 1297 """test_get_revision_number(self): -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r7772 r7800 149 149 else: 150 150 return format % float(value) 151 152 153 #################################################################################154 # OBSOLETE STUFF155 #################################################################################156 157 # @note TEMP158 def angle(v1, v2):159 """Temporary Interface to new location"""160 161 import anuga.utilities.numerical_tools as NT162 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 TEMP171 def anglediff(v0, v1):172 """Temporary Interface to new location"""173 174 import anuga.utilities.numerical_tools as NT175 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 TEMP183 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 TEMP194 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 TEMP205 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 TEMP216 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 TEMP227 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 TEMP242 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_catcher247 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 256 151 257 152 ## -
trunk/anuga_core/source/anuga/file/netcdf.py
r7776 r7800 46 46 get_all_swwfiles 47 47 from anuga.file.csv_file import load_csv_as_dict 48 from sww _fileimport Read_sww, Write_sww48 from sww import Read_sww, Write_sww 49 49 50 50 from anuga.anuga_exceptions import DataMissingValuesError, \ -
trunk/anuga_core/source/anuga/file_conversion/file_conversion.py
r7776 r7800 316 316 sww.store_connectivity() 317 317 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_files326 # @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 mint331 # @param maxt332 # @param mean_stage333 # @param origin A 3-tuple with geo referenced UTM coordinates334 # @param zscale335 # @param fail_on_NaN336 # @param NaN_filler337 # @param elevation338 # @note Also convert latitude and longitude to UTM. All coordinates are339 # 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 to352 sww format native to abstract_2d_finite_volumes.353 354 Specify only basename_in and read files of the form355 basefilename-z-mux2, basefilename-e-mux2 and356 basefilename-n-mux2 containing relative height,357 x-velocity and y-velocity, respectively.358 359 Also convert latitude and longitude to UTM. All coordinates are360 assumed to be given in the GDA94 datum. The latitude and longitude361 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 referenced369 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, LATITUDE374 which means that latitude is the fastest375 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_in382 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)403 318 404 319 -
trunk/anuga_core/source/anuga/file_conversion/test_urs2sww.py
r7770 r7800 52 52 base_name, files = self.write_mux(lat_long, 53 53 time_step_count, time_step) 54 urs 2sww(base_name, mean_stage=tide, origin =(50,23432,4343))54 urs_ungridded2sww(base_name, mean_stage=tide, origin =(50,23432,4343)) 55 55 56 56 # now I want to check the sww file ... … … 163 163 #Latitude: -21 0 ' 0.00000 '' Longitude: 115 0 ' 0.00000 '' 164 164 165 urs2sww(base_name, mean_stage=-240992.0,165 'hole_points_UTM(base_name, mean_stage=-240992.0, 166 166 hole_points_UTM=[ 292110.784, 7676551.710 ]) 167 167 … … 206 206 #Latitude: -21 0 ' 0.00000 '' Longitude: 115 0 ' 0.00000 '' 207 207 208 urs 2sww(base_name, mean_stage=-240992.0,208 urs_ungridded2sww(base_name, mean_stage=-240992.0, 209 209 hole_points_UTM=[ 292110.784, 7676551.710 ]) 210 210 … … 244 244 base_name, files = self.write_mux(lat_long, 245 245 time_step_count, time_step) 246 urs 2sww(base_name, mean_stage=tide, origin =(50,23432,4343),246 urs_ungridded2sww(base_name, mean_stage=tide, origin =(50,23432,4343), 247 247 mint=101, maxt=500) 248 248 … … 332 332 base_name, files = self.write_mux(lat_long, 333 333 time_step_count, time_step) 334 urs 2sww(base_name, mean_stage=tide, origin =(50,23432,4343),334 urs_ungridded2sww(base_name, mean_stage=tide, origin =(50,23432,4343), 335 335 mint=0, maxt=100000) 336 336 … … 432 432 base_name, files = self.write_mux(lat_long, 433 433 time_step_count, time_step) 434 urs 2sww(base_name, mean_stage=tide,434 urs_ungridded2sww(base_name, mean_stage=tide, 435 435 verbose=self.verbose) 436 436 self.delete_mux(files) … … 496 496 base_name, files = self.write_mux(lat_long, 497 497 time_step_count, time_step) 498 urs 2sww(base_name, mean_stage=tide, origin = geo_reference)498 urs_ungridded2sww(base_name, mean_stage=tide, origin = geo_reference) 499 499 500 500 # now I want to check the sww file ... … … 586 586 base_name, files = self.write_mux(lat_long, 587 587 time_step_count, time_step) 588 urs 2sww(base_name, mean_stage=tide,588 urs_ungridded2sww(base_name, mean_stage=tide, 589 589 verbose=self.verbose) 590 590 -
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 1 import os 2 from struct import pack, unpack 3 import array as p_array 4 import numpy as num 5 6 from anuga.utilities.numerical_tools import ensure_numeric 7 from anuga.caching.caching import myhash 8 9 from anuga.file.netcdf import Write_nc, write_elevation_nc 10 11 12 from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \ 13 NORTH_VELOCITY_LABEL 14 15 10 16 def urs2nc(basename_in='o', basename_out='urs'): 11 17 """Convert the 3 urs files to 4 nc files. -
trunk/anuga_core/source/anuga/file_conversion/urs2sww.py
r7776 r7800 1 import os 1 2 import numpy as num 2 3 from Scientific.IO.NetCDF import NetCDFFile 3 4 4 5 from anuga.file.urs import Read_urs 6 7 from anuga.file_conversion.urs2nc import urs2nc 8 from anuga.file_conversion.ferret2sww import ferret2sww 5 9 6 10 from anuga.coordinate_transforms.redfearn import redfearn, \ … … 40 44 # @note Input filename stem has suffixes '-z-mux', '-e-mux' and '-n-mux' 41 45 # added for relative height, x-velocity and y-velocity respectively. 42 def urs 2sww(basename_in='o', basename_out=None, verbose=False,46 def urs_ungridded2sww(basename_in='o', basename_out=None, verbose=False, 43 47 mint=None, maxt=None, 44 48 mean_stage=0, … … 249 253 return mux_times_start_i, mux_times_fin_i 250 254 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. 279 def 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.