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

urs2sww has an extra urs_ungridded2sww function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.