Ignore:
Timestamp:
Feb 18, 2005, 6:12:32 PM (20 years ago)
Author:
ole
Message:

Tested ferret2sww and fixed swapping of axes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/data_manager.py

    r928 r930  
    10961096               minlon = None, maxlon =None,
    10971097               mint = None, maxt = None, mean_stage = 0,
    1098                origin = (0,0,0,0,0)):
     1098               origin = None):
    10991099    """Convert 'Ferret' NetCDF format for wave propagation to
    11001100    sww format native to pyvolution.
     
    11101110    To include a value min may equal it, while max must exceed it.
    11111111
    1112     origin is a 3-tuple with geo referenced
    1113     UTM coordinates (zone, easting, northing) 
     1112    origin is a 5-tuple with geo referenced
     1113    UTM coordinates (zone, easting, northing, false_easting, false_northing)
     1114
     1115    nc format has values organised as HA[TIME, LATITUDE, LONGITUDE]
     1116    which means that longitude is the fastest
     1117    varying dimension (row major order, so to speak)
     1118
     1119    ferret2sww uses grid points as vertices in a triangular grid
     1120    counting vertices from lower left corner upwards, then right
    11141121    """
    11151122
     
    11611168    else:
    11621169        lmax = searchsorted(longitudes, maxlon)           
    1163        
     1170
     1171    times = times[jmin:jmax]       
    11641172    latitudes = latitudes[kmin:kmax]
    11651173    longitudes = longitudes[lmin:lmax]
    1166     times = times[jmin:jmax]
     1174
    11671175
    11681176    if verbose: print 'cropping'
     
    11711179    yspeed = file_v.variables['VA'][jmin:jmax, kmin:kmax, lmin:lmax]   
    11721180
     1181    number_of_times = times.shape[0]
    11731182    number_of_latitudes = latitudes.shape[0]
    11741183    number_of_longitudes = longitudes.shape[0]
    11751184
     1185    assert amplitudes.shape[0] == number_of_times
     1186    assert amplitudes.shape[1] == number_of_latitudes
     1187    assert amplitudes.shape[2] == number_of_longitudes         
    11761188
    11771189    #print times
     
    12541266
    12551267    #Check zone boundaries
    1256     refzone, _, _ = redfearn(latitudes[0],longitudes[0],
    1257                              false_easting=origin[3],
    1258                              false_northing=origin[4])
    1259    
     1268    if origin is None:
     1269        refzone, _, _ = redfearn(latitudes[0],longitudes[0])
     1270    else:   
     1271        refzone, _, _ = redfearn(latitudes[0],longitudes[0],
     1272                                 false_easting=origin[3],
     1273                                 false_northing=origin[4])
     1274       
    12601275                             
    12611276
    12621277    vertices = {}
    1263     for l, lon in enumerate(longitudes):   
    1264         for k, lat in enumerate(latitudes):
     1278    for k, lat in enumerate(latitudes):   
     1279        for l, lon in enumerate(longitudes):   
     1280
    12651281            vertices[l,k] = i
    1266            
    1267             zone, easting, northing = redfearn(lat,lon,
    1268                                                false_easting=origin[3],
    1269                                                false_northing=origin[4])
     1282
     1283            if origin is None:
     1284                zone, easting, northing = redfearn(lat,lon)               
     1285            else:   
     1286                zone, easting, northing = redfearn(lat,lon,
     1287                                                   false_easting=origin[3],
     1288                                                   false_northing=origin[4])
    12701289
    12711290            msg = 'Zone boundary crossed at longitude =', lon
     
    13191338    for j in range(len(times)):
    13201339        i = 0
    1321         for l in range(number_of_longitudes):   
    1322             for k in range(number_of_latitudes):
     1340        for k in range(number_of_latitudes):
     1341            for l in range(number_of_longitudes):                   
    13231342                h = amplitudes[j,k,l]/100 + mean_stage
    13241343                stage[j,i] = h
Note: See TracChangeset for help on using the changeset viewer.