Changeset 1102


Ignore:
Timestamp:
Mar 17, 2005, 7:12:46 PM (20 years ago)
Author:
ole
Message:

Work on file boundary (cyclone)

Location:
inundation/ga/storm_surge/pyvolution
Files:
4 edited

Legend:

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

    r1090 r1102  
    11831183               minlon = None, maxlon = None,
    11841184               mint = None, maxt = None, mean_stage = 0,
    1185                origin = None, zscale = 1,
     1185               origin = None, zscale = 1,
     1186               fail_on_NaN = True,
     1187               NaN_filler = 0,
    11861188               elevation = -100): #FIXME: Bathymetry should be obtained
    11871189                                  #from MOST somehow.
     
    12771279    uspeed = file_u.variables['UA'][jmin:jmax, kmin:kmax, lmin:lmax] #Lon
    12781280    vspeed = file_v.variables['VA'][jmin:jmax, kmin:kmax, lmin:lmax] #Lat
     1281
     1282    #Get missing values
     1283    nan_ha = file_h.variables['HA'].missing_value[0]
     1284    nan_ua = file_u.variables['UA'].missing_value[0]
     1285    nan_va = file_v.variables['VA'].missing_value[0]
     1286
     1287   
     1288    #Cleanup
     1289    from Numeric import sometrue
     1290   
     1291    missing = (amplitudes == nan_ha)
     1292    if sometrue (missing):
     1293        if fail_on_NaN:
     1294            msg = 'NetCDFFile %s contains missing values'\
     1295                  %(basename_in+'_ha.nc')
     1296            raise msg
     1297        else:
     1298            amplitudes = amplitudes*(missing==0) + missing*NaN_filler
     1299
     1300    missing = (uspeed == nan_ua)
     1301    if sometrue (missing):
     1302        if fail_on_NaN:
     1303            msg = 'NetCDFFile %s contains missing values'\
     1304                  %(basename_in+'_ua.nc')
     1305            raise msg
     1306        else:
     1307            uspeed = uspeed*(missing==0) + missing*NaN_filler
     1308
     1309    missing = (vspeed == nan_va)
     1310    if sometrue (missing):
     1311        if fail_on_NaN:
     1312            msg = 'NetCDFFile %s contains missing values'\
     1313                  %(basename_in+'_va.nc')
     1314            raise msg
     1315        else:
     1316            vspeed = vspeed*(missing==0) + missing*NaN_filler
     1317
     1318
     1319
     1320    #######
     1321
     1322               
    12791323
    12801324    number_of_times = times.shape[0]
     
    13221366
    13231367
    1324     if verbose: print 'Store to SWW file %s' %swwname
    13251368    # NetCDF file definition
    13261369    outfile = NetCDFFile(swwname, 'w')
     
    13851428
    13861429
     1430    if verbose: print 'Making triangular grid'
    13871431    #Check zone boundaries
    13881432    refzone, _, _ = redfearn(latitudes[0],longitudes[0])   
     
    14441488    outfile.variables['z'][:] = z
    14451489    outfile.variables['elevation'][:] = z  #FIXME HACK
    1446     outfile.variables['time'][:] = times
     1490    outfile.variables['time'][:] = times - times[0] #Store time relative
    14471491    outfile.variables['volumes'][:] = volumes.astype(Int32) #On Opteron 64
    14481492   
     
    14551499
    14561500
    1457    
    1458     for j in range(len(times)):
     1501    if verbose: print 'Converting quantities'
     1502    n = len(times)
     1503    for j in range(n):
     1504        if verbose and j%((n+10)/10)==0: print '  Doing %d of %d' %(j, n)
    14591505        i = 0
    14601506        for k in range(number_of_latitudes):      #Y direction
     
    14781524        print '    Lower left corner: [%f, %f]'\
    14791525              %(xllcorner, yllcorner)
     1526        print '    Start time: %f' %times[0]
    14801527        print '  Extent:'
    14811528        print '    x [m] in [%f, %f], len(x) == %d'\
  • inundation/ga/storm_surge/pyvolution/domain.py

    r1087 r1102  
    7272        self.starttime = 0 #Physical starttime if any (0 is 1 Jan 1970 00:00:00)
    7373        #Origin in UTM coordinates
     74        #FIXME: This should be set if read by a msh file
    7475        self.zone = zone
    7576        self.xllcorner = xllcorner
  • inundation/ga/storm_surge/pyvolution/generic_boundary_conditions.py

    r900 r1102  
    245245            return self.F(t, point_id = i)
    246246        else:
    247             return self.F(t) #FIXME: What should the semantics be?
     247            #raise 'Boundary call without point_id not implemented'
     248            #FIXME: What should the semantics be?       
     249            return self.F(t)
    248250
    249251
  • inundation/ga/storm_surge/pyvolution/util.py

    r1093 r1102  
    209209
    210210        if domain is not None:
    211             msg = 'WARNING: Start time as specified in domain (%s)'\
     211            msg = 'WARNING: Start time as specified in domain (%f)'\
    212212                  %domain.starttime
    213             msg += ' is earlier than the starttime of file %s: %s.'\
     213            msg += ' is earlier than the starttime of file %s (%f).'\
    214214                     %(self.filename, self.starttime)
    215             msg += 'Modifying starttime accordingly.'
     215            msg += ' Modifying domain starttime accordingly.'
    216216            if self.starttime > domain.starttime:
    217                 #FIXME: Print depending on some verbosity setting
    218                 #print msg
     217                if verbose: print msg
    219218                domain.starttime = self.starttime #Modifying model time
     219                if verbose: print 'Domain starttime is now set to %f' %domain.starttime
    220220
    221221        #Read all data in and produce values for desired data points at each timestep
     
    237237
    238238        #Get variables
    239         if verbose: print 'Get varibles'
     239        if verbose: print 'Get variables'
    240240        x = fid.variables['x'][:]
    241241        y = fid.variables['y'][:]
     
    298298                print '    Lower left corner: [%f, %f]'\
    299299                      %(self.xllcorner, self.yllcorner)
    300                 print '    Start time: %f' %self.starttime
     300                print '    Start time (file):   %f' %self.starttime
     301                #print '    Start time (domain): %f' %domain.starttime
    301302                print '  Extent:'
    302303                print '    x in [%f, %f], len(x) == %d'\
     
    366367            tau = self.domain.starttime-self.starttime+t
    367368        else:
     369            #print 'DOMAIN IS NONE!!!!!!!!!'
    368370            tau = t
    369371
     
    375377        msg = 'Time interval derived from file %s [%s:%s]'\
    376378              %(self.filename, self.T[0], self.T[1])
    377         msg += ' does not match model time: %s' %tau
     379        msg += ' does not match model time: %s\n' %tau
     380        msg += 'Domain says its starttime == %f' %(self.domain.starttime)
    378381
    379382        if tau < self.T[0]: raise msg
     
    514517            if self.starttime > domain.starttime:
    515518                #FIXME: Print depending on some verbosity setting
    516                 #print msg
     519                ##if verbose: print msg
    517520                domain.starttime = self.starttime #Modifying model time
    518521       
Note: See TracChangeset for help on using the changeset viewer.