Changeset 4280


Ignore:
Timestamp:
Feb 26, 2007, 9:50:44 AM (18 years ago)
Author:
duncan
Message:

working on updated urs2sww

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

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

    r4271 r4280  
    7878from anuga.caching.caching import myhash
    7979from anuga.utilities.anuga_exceptions import ANUGAError
    80 from anuga.pmesh.mesh import Mesh
    8180from anuga.shallow_water import Domain
    8281from anuga.abstract_2d_finite_volumes.pmesh2domain import \
     
    44194418
    44204419    """
     4420    #FIXME cache this function!
    44214421   
    44224422    from sets import ImmutableSet
     
    44494449    interpolate any point on the segment.
    44504450    """
     4451    from math import sqrt
    44514452    #print "zone",zone
    44524453    geo_reference = Geo_reference(zone=zone)
     
    44564457    #print "seg_lat_long", seg_lat_long
    44574458    # 1.415 = 2^0.5, rounded up....
    4458     buffer = 1.415 * grid_spacing
     4459    sqrt_2_rounded_up = 1.415
     4460    buffer = sqrt_2_rounded_up * grid_spacing
    44594461   
    44604462    #
     
    44654467    min_long = min(seg_lat_long[0][1], seg_lat_long[1][1]) - buffer
    44664468
    4467     #print "ll_lat", ll_lat
    4468     #print "ll_long", ll_long
    4469     #print "max_lat", max_lat
    4470     #print "max_long", max_long
    4471     #print "min_lat", min_lat
    4472     #print "min_long", min_long
    44734469    first_row = (min_long - ll_long)/grid_spacing
    44744470    # To round up
     
    44794475    last_row_long = int(round(last_row))
    44804476    #print "last_row",last_row _long
    4481 
    44824477   
    44834478    first_row = (min_lat - ll_lat)/grid_spacing
     
    44904485    #print "last_row",last_row_lat
    44914486
     4487    ul_lat = ll_lat + grid_spacing*lat_amount
     4488    ul_lat_close = ul_lat - grid_spacing
     4489    ll_long_close = ll_long + grid_spacing   
     4490    _ , x, y = redfearn(ul_lat, ll_long)   
     4491    _ , _, y_close = redfearn(ul_lat_close, ll_long)   
     4492    _ , x_close, _ = redfearn(ul_lat, ll_long_close)
     4493
     4494   
     4495    max_distance = sqrt_2_rounded_up * max(x-x_close,y - y_close)
    44924496    points_lat_long = []
    44934497    # Create a list of the lat long points to include.
     
    44964500            lat = ll_lat + index_lat*grid_spacing
    44974501            long = ll_long + index_long*grid_spacing
    4498             points_lat_long.append((lat, long)) #must be hashable
     4502
     4503            #filter here to keep good points
     4504            if keep_point(lat, long, seg, max_distance):
     4505                points_lat_long.append((lat, long)) #must be hashable
    44994506    #print "points_lat_long", points_lat_long
    4500     return points_lat_long   
    4501 
     4507
     4508    # Now that we have these points, lets throw ones out that are too far away
     4509    return points_lat_long
     4510
     4511def keep_point(lat, long, seg, max_distance):
     4512    """
     4513    seg is two points, UTM
     4514    """
     4515    from math import sqrt
     4516    _ , x0, y0 = redfearn(lat, long)
     4517    x1 = seg[0][0]
     4518    y1 = seg[0][1]
     4519    x2 = seg[1][0]
     4520    y2 = seg[1][1]
     4521
     4522    x2_1 = x2-x1
     4523    y2_1 = y2-y1
     4524    d = abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1))/sqrt((x2_1)*(x2_1)+(y2_1)*(y2_1))
     4525    if d <= max_distance:
     4526        return True
     4527    else:
     4528        return False
     4529   
    45024530    #### CONVERTING UNGRIDDED URS DATA TO AN SWW FILE ####
    45034531def urs_ungridded2sww_link(basename_in='o', basename_out=None, verbose=False,
     
    45224550            origin = None,
    45234551            zscale=1,
    4524             fail_on_NaN=True,
    4525             NaN_filler=0):
     4552            fail_on_NaN=True):
    45264553    """
    45274554    parameters not used!
    4528     NaN_filler
    45294555    origin
    45304556    #mint=None, maxt=None,
    4531     """
    4532     # Convert to utm
    4533    
     4557    """   
     4558    from anuga.pmesh.mesh import Mesh
     4559
    45344560    files_in = [basename_in+'-z-mux',
    45354561                basename_in+'-e-mux',
     
    45394565    # instanciate urs_points of the three mux files.
    45404566    mux = {}
    4541     quality_slices = {}
     4567    #quality_slices = {}
    45424568    for quantity, file in map(None, quantities, files_in):
    45434569        mux[quantity] = Urs_points(file)
    4544         quality_slices[quantity] = []
    4545         for slice in mux[quantity]:
    4546             quality_slices[quantity].append(slice)
    4547        
     4570        #quality_slices[quantity] = []
     4571        #for slice in mux[quantity]:
     4572        #    quality_slices[quantity].append(slice)
    45484573       
    45494574    # FIXME: check that the depth is the same. (hashing)
     
    45604585    #print "zone", zone
    45614586
    4562     elevation = a_mux.lonlatdep[:,0] * -1 #
     4587    elevation = a_mux.lonlatdep[:,2] * -1 #
    45634588   
    45644589    # grid ( create a mesh from the selected points)
     4590    # This mesh has a problem.  Triangles are streched over ungridded areas.
     4591    #  If these areas could be described as holes in pmesh, that would be great
     4592   
    45654593    mesh = Mesh()
    45664594    mesh.add_vertices(points_utm)
     
    45704598
    45714599    #mesh.export_mesh_file(basename_in + '.tsh')
    4572 
     4600   
    45734601    times = []
    45744602    for i in range(a_mux.time_step_count):
     
    45934621    write_sww_header(outfile, times, len(volumes), len(points_utm))
    45944622    write_sww_triangulation(outfile, points_utm, volumes,
    4595                             elevation, zone,  verbose=verbose)
    4596 
    4597     write_sww_time_slice(outfile, quality_slices['HA'],
    4598                          quality_slices['UA'], quality_slices['VA'],
    4599                          elevation,
    4600                          mean_stage=mean_stage, zscale=zscale,
    4601                          verbose=verbose)
     4623                            elevation, zone,  origin=origin, verbose=verbose)
     4624    j = 0
     4625    # Read in a time slice from each mux file and write it to the sww file
     4626    for HA, UA, VA in map(None, mux['HA'], mux['UA'], mux['VA']):           
     4627        write_sww_time_slice(outfile, HA, UA, VA,  elevation, j,
     4628                              mean_stage=mean_stage, zscale=zscale,
     4629                              verbose=verbose)
     4630        j += 1
     4631    outfile.close()
    46024632    #
    46034633    # Do some conversions while writing the sww file
    4604 
    4605 
    46064634
    46074635def write_sww_header(outfile, times, number_of_volumes, number_of_points ):
     
    46594687                           ('number_of_timesteps',
    46604688                            'number_of_points'))
    4661 
    4662 class Urs_points:
    4663     """
    4664     Read the info in URS mux files.
    4665 
    4666     for the quantities heres a correlation between the file names and
    4667     what they mean;
    4668     z-mux is height above sea level, m
    4669     e-mux is velocity is Eastern direction, m/s
    4670     n-mux is velocity is Northern direction, m/s
    4671 
    4672    
    4673     """
    4674     def __init__(self,urs_file):
    4675         self.iterated = False
    4676         columns = 3 # long, lat , depth
    4677         mux_file = open(urs_file, 'rb')
    4678        
    4679         # Number of points/stations
    4680         (self.points_num,)= unpack('i',mux_file.read(4))
    4681        
    4682         # nt, int - Number of time steps
    4683         (self.time_step_count,)= unpack('i',mux_file.read(4))
    4684 
    4685         #dt, float - time step, seconds
    4686         (self.time_step,) = unpack('f', mux_file.read(4))
    4687    
    4688         msg = "Bad data in the urs file."
    4689         if self.points_num < 0:
    4690             mux_file.close()
    4691             raise ANUGAError, msg
    4692         if self.time_step_count < 0:
    4693             mux_file.close()
    4694             raise ANUGAError, msg
    4695         if self.time_step < 0:
    4696             mux_file.close()
    4697             raise ANUGAError, msg
    4698 
    4699         # the depth is in meters, and it is the distance from the ocean
    4700         # to the sea bottom.
    4701         lonlatdep = p_array.array('f')
    4702         lonlatdep.read(mux_file, columns * self.points_num)
    4703         lonlatdep = array(lonlatdep, typecode=Float)   
    4704         lonlatdep = reshape(lonlatdep, (self.points_num, columns))
    4705         #print 'lonlatdep',lonlatdep
    4706         self.lonlatdep = lonlatdep
    4707        
    4708         self.mux_file = mux_file
    4709         # check this array
    4710 
    4711     def __iter__(self):
    4712         """
    4713         iterate over quantity data which is with respect to time.
    4714 
    4715         Note: You can only interate once over an object
    4716        
    4717         returns quantity infomation for each time slice
    4718         """
    4719         msg =  "You can only interate once over a urs file."
    4720         assert not self.iterated, msg
    4721         self.time_step = 0
    4722         self.iterated = True
    4723         return self
    4724    
    4725     def next(self):
    4726         if self.time_step_count == self.time_step:
    4727             self.close()
    4728             raise StopIteration
    4729         #Read in a time slice  from mux file 
    4730         hz_p_array = p_array.array('f')
    4731         hz_p_array.read(self.mux_file, self.points_num)
    4732         hz_p = array(hz_p_array, typecode=Float)
    4733         self.time_step += 1
    4734        
    4735         return hz_p
    4736 
    4737     def close(self):
    4738         self.mux_file.close()
     4689   
     4690    outfile.variables['time'][:] = times   
    47394691
    47404692
    47414693def write_sww_triangulation(outfile, points_utm, volumes,
    4742                             elevation, zone, verbose=False):
    4743 
    4744     number_of_points = len(points_utm)
    4745     #Store
    4746     x = zeros(number_of_points, Float)  #Easting
    4747     y = zeros(number_of_points, Float)  #Northing
    4748 
     4694                            elevation, zone, origin=None, verbose=False):
     4695
     4696    number_of_points = len(points_utm)   
    47494697    volumes = array(volumes)
    47504698
    4751     geo_ref = Geo_reference(zone,min(x),min(y))
     4699    if origin is not None:
     4700        if isinstance(origin, Geo_reference):
     4701            geo_ref = origin
     4702        else:
     4703            geo_ref = apply(Geo_reference,origin)
     4704    else:
     4705        geo_ref = Geo_reference(zone,min(points_utm[:,0]),min(points_utm[:,1]))
     4706    #geo_ref = Geo_reference(zone,0,0)
    47524707    geo_ref.write_NetCDF(outfile)
    47534708
     
    47734728
    47744729    #z = resize(bath_grid,outfile.variables['z'][:].shape)
    4775     outfile.variables['x'][:] = x - geo_ref.get_xllcorner()
    4776     outfile.variables['y'][:] = y - geo_ref.get_yllcorner()
     4730    outfile.variables['x'][:] = points_utm[:,0] - geo_ref.get_xllcorner()
     4731    outfile.variables['y'][:] = points_utm[:,1] - geo_ref.get_yllcorner()
    47774732    outfile.variables['z'][:] = elevation
    47784733    outfile.variables['elevation'][:] = elevation  #FIXME HACK
     
    47824737    # FIXME: Don't store the whole speeds and stage in  memory.
    47834738    # block it?
    4784 def write_sww_time_slice(outfile, has, uas, vas, elevation,
     4739def write_sww_time_slices(outfile, has, uas, vas, elevation,
    47854740                         mean_stage=0, zscale=1,
    47864741                         verbose=False):   
     
    47924747    if verbose: print 'Converting quantities'
    47934748    n = len(has)
    4794     j = 0
    4795    
     4749    j=0
    47964750    for ha, ua, va in map(None, has, uas, vas):
    47974751        if verbose and j%((n+10)/10)==0: print '  Doing %d of %d' %(j, n)
     
    48024756        ymomentum[j] = va*h
    48034757        j += 1
    4804     outfile.close()
    4805    
     4758
     4759 
     4760def write_sww_time_slice(outfile, ha, ua, va, elevation, slice_index,
     4761                         mean_stage=0, zscale=1,
     4762                         verbose=False):   
     4763    #Time stepping
     4764    stage = outfile.variables['stage']
     4765    xmomentum = outfile.variables['xmomentum']
     4766    ymomentum = outfile.variables['ymomentum']
     4767
     4768    if verbose: print 'Converting quantities'
     4769   
     4770    w = zscale*ha + mean_stage
     4771    stage[slice_index] = w
     4772    h = w - elevation
     4773    xmomentum[slice_index] = ua*h
     4774    ymomentum[slice_index] = va*h
     4775       
     4776class Urs_points:
     4777    """
     4778    Read the info in URS mux files.
     4779
     4780    for the quantities heres a correlation between the file names and
     4781    what they mean;
     4782    z-mux is height above sea level, m
     4783    e-mux is velocity is Eastern direction, m/s
     4784    n-mux is velocity is Northern direction, m/s   
     4785    """
     4786    def __init__(self,urs_file):
     4787        self.iterated = False
     4788        columns = 3 # long, lat , depth
     4789        mux_file = open(urs_file, 'rb')
     4790       
     4791        # Number of points/stations
     4792        (self.points_num,)= unpack('i',mux_file.read(4))
     4793       
     4794        # nt, int - Number of time steps
     4795        (self.time_step_count,)= unpack('i',mux_file.read(4))
     4796        #print "self.time_step_count", self.time_step_count
     4797        #dt, float - time step, seconds
     4798        (self.time_step,) = unpack('f', mux_file.read(4))
     4799        #print "self.time_step", self.time_step
     4800        msg = "Bad data in the urs file."
     4801        if self.points_num < 0:
     4802            mux_file.close()
     4803            raise ANUGAError, msg
     4804        if self.time_step_count < 0:
     4805            mux_file.close()
     4806            raise ANUGAError, msg
     4807        if self.time_step < 0:
     4808            mux_file.close()
     4809            raise ANUGAError, msg
     4810
     4811        # the depth is in meters, and it is the distance from the ocean
     4812        # to the sea bottom.
     4813        lonlatdep = p_array.array('f')
     4814        lonlatdep.read(mux_file, columns * self.points_num)
     4815        lonlatdep = array(lonlatdep, typecode=Float)   
     4816        lonlatdep = reshape(lonlatdep, (self.points_num, columns))
     4817        #print 'lonlatdep',lonlatdep
     4818        self.lonlatdep = lonlatdep
     4819       
     4820        self.mux_file = mux_file
     4821        # check this array
     4822
     4823    def __iter__(self):
     4824        """
     4825        iterate over quantity data which is with respect to time.
     4826
     4827        Note: You can only interate once over an object
     4828       
     4829        returns quantity infomation for each time slice
     4830        """
     4831        msg =  "You can only interate once over a urs file."
     4832        assert not self.iterated, msg
     4833        self.iter_time_step = 0
     4834        self.iterated = True
     4835        return self
     4836   
     4837    def next(self):
     4838        if self.time_step_count == self.iter_time_step:
     4839            self.close()
     4840            raise StopIteration
     4841        #Read in a time slice  from mux file 
     4842        hz_p_array = p_array.array('f')
     4843        hz_p_array.read(self.mux_file, self.points_num)
     4844        hz_p = array(hz_p_array, typecode=Float)
     4845        self.iter_time_step += 1
     4846       
     4847        return hz_p
     4848
     4849    def close(self):
     4850        self.mux_file.close()
     4851
    48064852    #### END URS UNGRIDDED 2 SWW ###
    48074853
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4271 r4280  
    52215221        time_step_count = 2
    52225222        time_step = 400
     5223        tide = 9000000
    52235224        base_name, files = self.write_mux(lat_long,
    52245225                                          time_step_count, time_step)
    5225         urs_ungridded2sww(base_name)
    5226    
    5227        
     5226        urs_ungridded2sww(base_name, mean_stage=tide)
     5227       
     5228        # now I want to check the sww file ...
     5229        sww_file = base_name + '.sww'
     5230       
     5231        #Let's interigate the sww file
     5232        # Note, the sww info is not gridded.  It is point data.
     5233        fid = NetCDFFile(sww_file)
     5234       
     5235        # Make x and y absolute
     5236        x = fid.variables['x'][:]
     5237        y = fid.variables['y'][:]
     5238        geo_reference = Geo_reference(NetCDFObject=fid)
     5239        points = geo_reference.get_absolute(map(None, x, y))
     5240        points = ensure_numeric(points)
     5241        x = points[:,0]
     5242        y = points[:,1]
     5243       
     5244        #Check that first coordinate is correctly represented       
     5245        #Work out the UTM coordinates for first point
     5246        zone, e, n = redfearn(lat_long[0][0], lat_long[0][1])
     5247        assert allclose([x[0],y[0]], [e,n])
     5248
     5249        #Check the time vector
     5250        times = fid.variables['time'][:]
     5251       
     5252        times_actual = []
     5253        for i in range(time_step_count):
     5254            times_actual.append(time_step * i)
     5255       
     5256        assert allclose(ensure_numeric(times),
     5257                        ensure_numeric(times_actual))
     5258       
     5259        #Check first value
     5260        stage = fid.variables['stage'][:]
     5261        xmomentum = fid.variables['xmomentum'][:]
     5262        ymomentum = fid.variables['ymomentum'][:]
     5263        elevation = fid.variables['elevation'][:]
     5264        assert allclose(stage[0,0], e +tide)  #Meters
     5265
     5266        #Check the momentums - ua
     5267        #momentum = velocity*(stage-elevation)
     5268        #momentum = velocity*(stage+elevation)
     5269        # -(-elevation) since elevation is inverted in mux files
     5270        # = n*(e+tide+n) based on how I'm writing these files
     5271        answer = n*(e+tide+n)
     5272        actual = xmomentum[0,0]
     5273        assert allclose(answer, actual)  #Meters
     5274
     5275        # check the stage values, first time step.
     5276        # These arrays are equal since the Easting values were used as
     5277        # the stage
     5278        assert allclose(stage[0], x +tide)  #Meters
     5279        # check the elevation values.
     5280        # -ve since urs measures depth, sww meshers height,
     5281        # these arrays are equal since the northing values were used as
     5282        # the elevation
     5283        assert allclose(-elevation, y)  #Meters
     5284       
     5285        fid.close()
     5286        self.delete_mux(files)
     5287        os.remove(sww_file)
     5288 
     5289    def test_urs_ungridded2swwII (self):
     5290       
     5291        #Zone:   50   
     5292        #Easting:  240992.578  Northing: 7620442.472
     5293        #Latitude:   -21  30 ' 0.00000 ''  Longitude: 114  30 ' 0.00000 ''
     5294        lat_long = [[-21.5,114.5],[-21,114.5],[-21,115]]
     5295        time_step_count = 2
     5296        time_step = 400
     5297        tide = 9000000
     5298        geo_reference = Geo_reference(50, 3434543,34534543)
     5299        base_name, files = self.write_mux(lat_long,
     5300                                          time_step_count, time_step)
     5301        urs_ungridded2sww(base_name, mean_stage=tide, origin = geo_reference)
     5302       
     5303        # now I want to check the sww file ...
     5304        sww_file = base_name + '.sww'
     5305       
     5306        #Let's interigate the sww file
     5307        # Note, the sww info is not gridded.  It is point data.
     5308        fid = NetCDFFile(sww_file)
     5309       
     5310        # Make x and y absolute
     5311        x = fid.variables['x'][:]
     5312        y = fid.variables['y'][:]
     5313        geo_reference = Geo_reference(NetCDFObject=fid)
     5314        points = geo_reference.get_absolute(map(None, x, y))
     5315        points = ensure_numeric(points)
     5316        x = points[:,0]
     5317        y = points[:,1]
     5318       
     5319        #Check that first coordinate is correctly represented       
     5320        #Work out the UTM coordinates for first point
     5321        zone, e, n = redfearn(lat_long[0][0], lat_long[0][1])
     5322        assert allclose([x[0],y[0]], [e,n])
     5323
     5324        #Check the time vector
     5325        times = fid.variables['time'][:]
     5326       
     5327        times_actual = []
     5328        for i in range(time_step_count):
     5329            times_actual.append(time_step * i)
     5330       
     5331        assert allclose(ensure_numeric(times),
     5332                        ensure_numeric(times_actual))
     5333       
     5334        #Check first value
     5335        stage = fid.variables['stage'][:]
     5336        xmomentum = fid.variables['xmomentum'][:]
     5337        ymomentum = fid.variables['ymomentum'][:]
     5338        elevation = fid.variables['elevation'][:]
     5339        assert allclose(stage[0,0], e +tide)  #Meters
     5340
     5341        #Check the momentums - ua
     5342        #momentum = velocity*(stage-elevation)
     5343        #momentum = velocity*(stage+elevation)
     5344        # -(-elevation) since elevation is inverted in mux files
     5345        # = n*(e+tide+n) based on how I'm writing these files
     5346        answer = n*(e+tide+n)
     5347        actual = xmomentum[0,0]
     5348        assert allclose(answer, actual)  #Meters
     5349
     5350        # check the stage values, first time step.
     5351        # These arrays are equal since the Easting values were used as
     5352        # the stage
     5353        assert allclose(stage[0], x +tide)  #Meters
     5354        # check the elevation values.
     5355        # -ve since urs measures depth, sww meshers height,
     5356        # these arrays are equal since the northing values were used as
     5357        # the elevation
     5358        assert allclose(-elevation, y)  #Meters
     5359       
     5360        fid.close()
     5361        self.delete_mux(files)
     5362        #os.remove(sww_file)
     5363 
     5364    def test_urs_ungridded2swwIII (self):
     5365       
     5366        #Zone:   50   
     5367        #Easting:  240992.578  Northing: 7620442.472
     5368        #Latitude:   -21  30 ' 0.00000 ''  Longitude: 114  30 ' 0.00000 ''
     5369        lat_long = [[-21.5,114.5],[-21,114.5],[-21,115]]
     5370        time_step_count = 2
     5371        time_step = 400
     5372        tide = 9000000
     5373        base_name, files = self.write_mux(lat_long,
     5374                                          time_step_count, time_step)
     5375        urs_ungridded2sww(base_name, mean_stage=tide, origin =(50,23432,4343))
     5376       
     5377        # now I want to check the sww file ...
     5378        sww_file = base_name + '.sww'
     5379       
     5380        #Let's interigate the sww file
     5381        # Note, the sww info is not gridded.  It is point data.
     5382        fid = NetCDFFile(sww_file)
     5383       
     5384        # Make x and y absolute
     5385        x = fid.variables['x'][:]
     5386        y = fid.variables['y'][:]
     5387        geo_reference = Geo_reference(NetCDFObject=fid)
     5388        points = geo_reference.get_absolute(map(None, x, y))
     5389        points = ensure_numeric(points)
     5390        x = points[:,0]
     5391        y = points[:,1]
     5392       
     5393        #Check that first coordinate is correctly represented       
     5394        #Work out the UTM coordinates for first point
     5395        zone, e, n = redfearn(lat_long[0][0], lat_long[0][1])
     5396        assert allclose([x[0],y[0]], [e,n])
     5397
     5398        #Check the time vector
     5399        times = fid.variables['time'][:]
     5400       
     5401        times_actual = []
     5402        for i in range(time_step_count):
     5403            times_actual.append(time_step * i)
     5404       
     5405        assert allclose(ensure_numeric(times),
     5406                        ensure_numeric(times_actual))
     5407       
     5408        #Check first value
     5409        stage = fid.variables['stage'][:]
     5410        xmomentum = fid.variables['xmomentum'][:]
     5411        ymomentum = fid.variables['ymomentum'][:]
     5412        elevation = fid.variables['elevation'][:]
     5413        assert allclose(stage[0,0], e +tide)  #Meters
     5414
     5415        #Check the momentums - ua
     5416        #momentum = velocity*(stage-elevation)
     5417        #momentum = velocity*(stage+elevation)
     5418        # -(-elevation) since elevation is inverted in mux files
     5419        # = n*(e+tide+n) based on how I'm writing these files
     5420        answer = n*(e+tide+n)
     5421        actual = xmomentum[0,0]
     5422        assert allclose(answer, actual)  #Meters
     5423
     5424        # check the stage values, first time step.
     5425        # These arrays are equal since the Easting values were used as
     5426        # the stage
     5427        assert allclose(stage[0], x +tide)  #Meters
     5428        # check the elevation values.
     5429        # -ve since urs measures depth, sww meshers height,
     5430        # these arrays are equal since the northing values were used as
     5431        # the elevation
     5432        assert allclose(-elevation, y)  #Meters
     5433       
     5434        fid.close()
     5435        self.delete_mux(files)
     5436        os.remove(sww_file)
     5437       
     5438    def test_URS_points_needed_and_urs_ungridded2sww(self):
     5439        # This doesn't actually check anything
     5440        # 
     5441        ll_lat = -21.5
     5442        ll_long = 114.5
     5443        grid_spacing = 1./60.
     5444        lat_amount = 30
     5445        long_amount = 30
     5446        time_step_count = 2
     5447        time_step = 400
     5448        tide = -200000
     5449
     5450        boundary_polygon = [[250000,7660000],[280000,7660000],
     5451                             [280000,7630000],[250000,7630000]]
     5452        geo=URS_points_needed(boundary_polygon,
     5453                              ll_lat, ll_long, grid_spacing,
     5454                              lat_amount, long_amount)
     5455        lat_long = geo.get_data_points(as_lat_long=True)
     5456        base_name, files = self.write_mux(lat_long,
     5457                                          time_step_count, time_step)
     5458        urs_ungridded2sww(base_name, mean_stage=tide)
     5459        self.delete_mux(files)
     5460        os.remove( base_name + '.sww')
     5461       
     5462    def visual_test_URS_points_needed_and_urs_ungridded2sww(self):
     5463       
     5464        ll_lat = -21.5
     5465        ll_long = 114.5
     5466        grid_spacing = 1./60.
     5467        lat_amount = 30
     5468        long_amount = 30
     5469        time_step_count = 2
     5470        time_step = 400
     5471        tide = -200000
     5472
     5473        boundary_polygon = [[250000,7660000],[270000,7650000],
     5474                             [280000,7630000],[250000,7630000]]
     5475        geo=URS_points_needed(boundary_polygon,
     5476                              ll_lat, ll_long, grid_spacing,
     5477                              lat_amount, long_amount)
     5478        lat_long = geo.get_data_points(as_lat_long=True)
     5479        base_name, files = self.write_mux(lat_long,
     5480                                          time_step_count, time_step)
     5481        urs_ungridded2sww(base_name, mean_stage=tide)
     5482        self.delete_mux(files)
     5483        #os.remove( base_name + '.sww')
    52285484#-------------------------------------------------------------
    52295485if __name__ == "__main__":
    52305486    #suite = unittest.makeSuite(Test_Data_Manager,'test_URS_points_needed')
    5231     #suite = unittest.makeSuite(Test_Data_Manager,'dave_test_URS_poinneeded')
    5232     #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_')
     5487    #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded2swwII')
     5488    #suite = unittest.makeSuite(Test_Data_Manager,'visual_test_URS_points_needed_and_urs_ungridded2sww')
    52335489    suite = unittest.makeSuite(Test_Data_Manager,'test')
    52345490    runner = unittest.TextTestRunner()
Note: See TracChangeset for help on using the changeset viewer.