Ignore:
Timestamp:
Jun 7, 2010, 9:38:23 AM (13 years ago)
Author:
sexton
Message:

updates to bunbury scripts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/anuga_1_1/anuga_work/production/bunbury_storm_surge_2009/build_gems_boundary.py

    r7678 r7794  
    1313import sys
    1414# sys.path.append('W:\\sandpits\\lfountain\\anuga_work\\production\\mandurah_storm_surge_2009\\gems_comparison')
    15 sys.path.append('/nas/gemd/georisk_models/inundation/sandpits/lfountain/anuga_work/production/mandurah_storm_surge_2009/gems_comparison')
    16 import project_GEMS_grid
     15#sys.path.append('/nas/gemd/georisk_models/inundation/sandpits/lfountain/anuga_work/production/mandurah_storm_surge_2009/gems_comparison')
     16import project
    1717from Scientific.IO.NetCDF import NetCDFFile
    1818from anuga.coordinate_transforms.geo_reference import Geo_reference, write_NetCDF_georeference
     
    2323state = 'western_australia'
    2424scenario_folder = 'bunbury_storm_surge_scenario_2009'
    25 event = 'case_1' # Baseline TC Alby event
     25event = '20100527_gcom_12min' # Baseline TC Alby event
    2626
    2727ENV_INUNDATIONHOME = 'INUNDATIONHOME'
     
    3535# Define boundary points to extract from master STS file
    3636#--------------------------------------------------------
    37 gems_boundary = numpy.array(read_polygon(project_GEMS_grid.gems_order))
     37gems_boundary = numpy.array(read_polygon(project.gems_order))
     38#gems_boundary = numpy.array(read_polygon(project.gauges))
    3839number_of_points = gems_boundary.shape[0]
     40print 'hello', number_of_points
     41print 'points', gems_boundary
    3942
    4043#---------------------------------------------------------
     
    4245#---------------------------------------------------------
    4346print "Reading master NetCDF file"
    44 infile = NetCDFFile(os.path.join(event_folder, event + '_master.sts'), 'r')
     47infile = NetCDFFile(os.path.join(event_folder, event + '_master_2_1.sts'), 'rl') #rl for large netcdf files
    4548
    4649grid_size = infile.grid_size
     
    6972origin = numpy.array([x_origin[0], y_origin[0]])
    7073index_array_2D = ((gems_boundary - origin)/grid_size).astype(int)
    71 assert index_array_2D[:,0].min() >= 0 and index_array_2D[:,0].max() <= ncols
     74assert index_array_2D[:,0].min() >= 0 and index_array_2D[:,0].max() <= ncols # These test that the boundary points lie within the data area
    7275assert index_array_2D[:,1].min() >= 0 and index_array_2D[:,1].max() <= nrows
    7376
     
    135138    s[i] = stage[i,:]
    136139    xm[i] = xmomentum[i,:]
    137     ym[i] = ymomentum[i,:]
    138  
     140    ym[i] = ymomentum[i,:]
     141
     142#---------------------------------------------------------------------------
     143# Get timeseries values for wave height and components of momentum
     144#---------------------------------------------------------------------------
     145
     146basename = 'sts_gauge_tide'
     147for i in xrange(number_of_points):
     148    out_file = os.path.join(event_folder,
     149                            basename+'_'+str(i)+'.csv')
     150    fid_sts = open(out_file, 'w')
     151    fid_sts.write('time, stage, xmomentum, ymomentum, elevation \n')
     152    for j in xrange(number_of_timesteps):
     153        fid_sts.write('%.6f, %.6f, %.6f, %.6f, %.6f\n'
     154                    % (time[j], stage[j,i], xmomentum[j,i], ymomentum[j,i], elevation[i]))
     155
     156    fid_sts.close()
     157
    139158origin = Geo_reference(refzone, x_origin, y_origin)
    140159geo_ref = write_NetCDF_georeference(origin, fid)
    141160
    142161fid.variables['x'][:] = x
    143 fid.variables['y'][:] = y
     162fid.variables['y'][:] = y  
    144163
    145164fid.close()
     165
     166sys.exit()
     167
     168print 'get timeseries'
     169#-------------------------------------------------------------------------------
     170# Get gauges (timeseries of index points)
     171#-------------------------------------------------------------------------------
     172
     173basename = 'sts_gauge'
     174quantity_names = ['stage', 'xmomentum', 'ymomentum']
     175quantities = {}
     176for i, name in enumerate(quantity_names):
     177    quantities[name] = fid.variables[name][:]
     178
     179
     180for j in range(len(x)):
     181    index = j # permutation[j]
     182    stage = quantities['stage'][:,j]
     183    #print 'hello', j, stage
     184    xmomentum = quantities['xmomentum'][:,j]
     185    ymomentum = quantities['ymomentum'][:,j]
     186
     187    out_file = os.path.join(event_folder,
     188                            basename+'_'+str(index)+'.csv')
     189    fid_sts = open(out_file, 'w')
     190    fid_sts.write('time, stage, xmomentum, ymomentum \n')
     191
     192    #-----------------------------------------------------------------------
     193    # End of the get gauges
     194    #-----------------------------------------------------------------------
     195    for k in range(len(time)-1):
     196        fid_sts.write('%.6f, %.6f, %.6f, %.6f\n'
     197                      % (time[k], stage[k], xmomentum[k], ymomentum[k]))
     198
     199   
Note: See TracChangeset for help on using the changeset viewer.