Ignore:
Timestamp:
Nov 18, 2005, 2:39:35 PM (19 years ago)
Author:
duncan
Message:

remove bug in gippsland converter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/data_manager.py

    r2035 r2038  
    33553355    latitudes = [bath_metadata['yllcorner']+y*bath_metadata['cellsize'] \
    33563356                 for y in range(number_of_latitudes)]
    3357 
     3357   
     3358     # reverse order of lat, so the fist lat represents the first grid row
     3359    latitudes.reverse()
     3360   
     3361    #print "latitudes - before get_min_max_indexes",latitudes
    33583362    kmin, kmax, lmin, lmax = get_min_max_indexes(latitudes,longitudes,
    33593363                                                 minlat=minlat, maxlat=maxlat,
    33603364                                                 minlon=minlon, maxlon=maxlon)
    3361     #print "latitudes", latitudes
    3362     #print "********************"
    3363     #print "kmin",kmin
    3364     #print "kmax",kmax
    3365     #print "lmin",lmin
    3366     #print "lmax",lmax
    3367     #print "bath_grid",bath_grid
     3365   
     3366
    33683367    bath_grid = bath_grid[kmin:kmax,lmin:lmax]
    33693368    #print "bath_grid",bath_grid
     
    33773376    latitudes = latitudes[kmin:kmax]
    33783377    longitudes = longitudes[lmin:lmax]
    3379 
    3380      # reverse order of lat, so the fist lat represents the first grid row
    3381     latitudes.reverse()
    3382    
     3378    number_of_latitudes = len(latitudes)
     3379    number_of_longitudes = len(longitudes)
     3380
     3381
    33833382    #Work out the times
    33843383    if len(elevation_files) > 1:
     
    35303529        _, v_momentum_grid =  _read_asc(vcur_dir + os.sep + vcur_files[j])
    35313530
     3531        #print "elevation_grid",elevation_grid
    35323532        #cut matrix to desired size
    35333533        elevation_grid = elevation_grid[kmin:kmax,lmin:lmax]
    35343534        u_momentum_grid = u_momentum_grid[kmin:kmax,lmin:lmax]
    35353535        v_momentum_grid = v_momentum_grid[kmin:kmax,lmin:lmax]
     3536        #print "elevation_grid",elevation_grid
    35363537        # handle missing values
    35373538        missing = (elevation_grid == elevation_meta['NODATA_value'])
     
    35503551        for k in range(number_of_latitudes):      #Y direction
    35513552            for l in range(number_of_longitudes): #X direction
    3552                 #w = zscale*amplitudes[j,k,l]/100 + mean_stage
    35533553                w = zscale*elevation_grid[k,l] + mean_stage
    35543554                stage[j,i] = w
     
    35633563                        minlon=None, maxlon=None):
    35643564    """
    3565     return max, min indexes of the lat and long arrays to cover the area
     3565    return max, min indexes (for slicing) of the lat and long arrays to cover the area
    35663566    specified with min/max lat/long
    35673567
     
    35713571    has a section outside of the latitudes/longitudes area.)
    35723572
    3573     assume latitudess & longitudes are sorted, from low to high
    3574     """
    3575 
    3576    
    3577   #Cut out a smaller extent.
     3573    assume latitudess & longitudes are sorted,
     3574    long - from low to high (west to east, eg 148 - 151)
     3575    lat - from high to low (north to south, eg -35 - -38)
     3576    """
     3577
     3578    # reverse order of lat, so it's in ascending order
     3579    latitudes.reverse()
     3580    largest_lat_index = len(latitudes)-1
     3581    #Cut out a smaller extent.
    35783582    if minlat == None:
    3579         lat_min_index =0
     3583        lat_min_index = 0
    35803584    else:
    35813585        lat_min_index = searchsorted(latitudes, minlat)-1
    35823586        if lat_min_index <0:
    3583             lat_min_index =0
     3587            lat_min_index = 0
    35843588           
    35853589
    35863590    if maxlat == None:
    3587         lat_max_index = len(latitudes)
     3591        lat_max_index = largest_lat_index #len(latitudes)
    35883592    else:
    3589         lat_max_index = searchsorted(latitudes, maxlat)+1
     3593        lat_max_index = searchsorted(latitudes, maxlat)
     3594        if lat_max_index > largest_lat_index:
     3595            lat_max_index = largest_lat_index
     3596       
    35903597    if minlon == None:
    35913598        lon_min_index = 0
     
    35983605        lon_max_index = len(longitudes)
    35993606    else:
    3600         lon_max_index = searchsorted(longitudes, maxlon)+1
    3601 
     3607        lon_max_index = searchsorted(longitudes, maxlon)
     3608
     3609    #Take into account that the latitude list was reversed
     3610    latitudes.reverse() # Python passes by reference, need to swap back
     3611    lat_min_index, lat_max_index = largest_lat_index - lat_max_index , \
     3612                                   largest_lat_index - lat_min_index
     3613    lat_max_index = lat_max_index + 1 # taking into account how slicing works
     3614    lon_max_index = lon_max_index + 1 # taking into account how slicing works
     3615   
    36023616    return lat_min_index, lat_max_index, lon_min_index, lon_max_index
    36033617       
Note: See TracChangeset for help on using the changeset viewer.