Ignore:
Timestamp:
Jun 2, 2010, 5:17:47 PM (13 years ago)
Author:
hudson
Message:

Broke up data_manager into more modules - some failing tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/file_conversion/urs2sww.py

    r7758 r7770  
     1import numpy as num
     2from Scientific.IO.NetCDF import NetCDFFile
     3
     4from anuga.file.urs import Read_urs
     5
     6from anuga.coordinate_transforms.redfearn import redfearn, \
     7     convert_from_latlon_to_utm
     8
     9from anuga.geospatial_data.geospatial_data import ensure_absolute, \
     10                                                    Geospatial_data
     11
     12from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
     13                            NORTH_VELOCITY_LABEL
     14                           
     15from anuga.utilities.numerical_tools import ensure_numeric                           
     16
     17from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a, \
     18                            netcdf_float
     19
     20from sww_file import Read_sww, Write_sww
     21
     22
    123################################################################################
    224# CONVERTING UNGRIDDED URS DATA TO AN SWW FILE
    325################################################################################
    4 
    5 WAVEHEIGHT_MUX_LABEL = '-z-mux'
    6 EAST_VELOCITY_LABEL =  '-e-mux'
    7 NORTH_VELOCITY_LABEL =  '-n-mux'
    826
    927##
     
    95113    mux = {}
    96114    for quantity, file in map(None, quantities, files_in):
    97         mux[quantity] = Urs_points(file)
     115        mux[quantity] = Read_urs(file)
    98116
    99117    # Could check that the depth is the same. (hashing)
     
    143161    for i in range(a_mux.time_step_count):
    144162        mux_times.append(a_mux.time_step * i)
    145     (mux_times_start_i, mux_times_fin_i) = mux2sww_time(mux_times, mint, maxt)
     163    (mux_times_start_i, mux_times_fin_i) = read_time_from_mux(mux_times, mint, maxt)
    146164    times = mux_times[mux_times_start_i:mux_times_fin_i]
    147165
     
    209227
    210228    # Do some conversions while writing the sww file
     229
     230
     231def read_time_from_mux(mux_times, mint, maxt):
     232    """
     233        Read a list of mux times.
     234        Return start and finish times which lie within the passed time period.
     235    """
     236
     237    if mint == None:
     238        mux_times_start_i = 0
     239    else:
     240        mux_times_start_i = num.searchsorted(mux_times, mint)
     241
     242    if maxt == None:
     243        mux_times_fin_i = len(mux_times)
     244    else:
     245        maxt += 0.5 # so if you specify a time where there is
     246                    # data that time will be included
     247        mux_times_fin_i = num.searchsorted(mux_times, maxt)
     248
     249    return mux_times_start_i, mux_times_fin_i
     250
Note: See TracChangeset for help on using the changeset viewer.