Changeset 505 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jun 16, 2015, 6:48:30 PM (10 years ago)
Author:
lfita
Message:

Adding new variables:

'TSrhs': surface relative humidty fom TS variables
'WRFrhs': surface relative humidty fom WRF variables
'TSwds': surface wind direction from TS variables
'WRFwds': surface wind direction from WRF variables
'TSwss': surface wind speed from TS variables
'WRFwss': surface wind speed from WRF variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/validation_sim.py

    r503 r505  
    730730        'WRFrh': relative humidty fom WRF variables
    731731        'WRFt': temperature from WRF variables
     732        'WRFwds': surface wind direction from WRF variables
     733        'WRFwss': surface wind speed from WRF variables
    732734        'WRFz': height from WRF variables
    733735    """
     
    790792        varNOcheckv = (ncobj.variables['T'][:] + 300.)*(p/p0)**(2./7.)
    791793        dimensions = ncobj.variables['T'].dimensions
     794
     795    elif varn == 'WRFwds':
     796#        print '    ' + main + ': computing surface wind direction from WRF as ATAN2(V,U) ...'
     797        varNOcheckv = np.arctan2(ncobj.variables['V10'][:], ncobj.variables['U10'][:])
     798        dimensions = ncobj.variables['V10'].dimensions
     799
     800    elif varn == 'WRFwss':
     801#        print '    ' + main + ': computing surface wind speed from WRF as SQRT(U**2 + V**2) ...'
     802        varNOcheckv = np.sqrt(ncobj.variables['U10'][:]*ncobj.variables['U10'][:] +  \
     803          ncobj.variables['V10'][:]*ncobj.variables['V10'][:])
     804        dimensions = ncobj.variables['U10'].dimensions
    792805
    793806    elif varn == 'WRFz':
     
    812825        'WRFp': pressure from WRF variables
    813826        'WRFrh': relative humidty fom WRF variables
     827        'TSrhs': surface relative humidty fom TS variables
     828        'WRFrhs': surface relative humidty fom WRF variables
    814829        'WRFT': CF-time from WRF variables
    815830        'WRFt': temperature from WRF variables
    816831        'WRFtd': dew-point temperature from WRF variables
     832        'WRFwd': wind direction from WRF variables
     833        'TSwds': surface wind direction from TS variables
     834        'WRFwds': surface wind direction from WRF variables
    817835        'WRFws': wind speed from WRF variables
    818         'WRFwd': wind direction from WRF variables
     836        'TSwss': surface wind speed from TS variables
     837        'WRFwss': surface wind speed from WRF variables
    819838        'WRFz': height from WRF variables
    820839    """
     
    872891                p0=100000.
    873892                p=ncobj.variables['P'][:] + ncobj.variables['PB'][:]
    874                 tk = (ncobj.variables['T'][:] + 300.)*(p/p0)**(2./7.)
     893                tk = (ncobj.variables['T'][:])*(p/p0)**(2./7.)
    875894                qv = ncobj.variables['QVAPOR'][:]
    876895
     
    881900                dimensions = ncobj.variables['P'].dimensions
    882901                shape = ncobj.variables['P'].shape
     902
     903            elif varn == 'TSrhs':
     904#        print '    ' + main + ": computing surface relative humidity from TSs as 'Tetens'" +\
     905#         ' equation (T,P) ...'
     906                p0=100000.
     907                p=ncobj.variables['psfc'][:]
     908                tk = (ncobj.variables['t'][:])*(p/p0)**(2./7.)
     909                qv = ncobj.variables['q'][:]
     910
     911                data1 = 10.*0.6112*np.exp(17.67*(tk-273.16)/(tk-29.65))
     912                data2 = 0.622*data1/(0.01*p-(1.-0.622)*data1)
     913
     914                varNOcheckv = qv/data2
     915                dimensions = ncobj.variables['psfc'].dimensions
     916                shape = ncobj.variables['psfc'].shape
     917
     918            elif varn == 'WRFrhs':
     919#        print '    ' + main + ": computing surface relative humidity from WRF as 'Tetens'" +\
     920#         ' equation (T,P) ...'
     921                p0=100000.
     922                p=ncobj.variables['PSFC'][:]
     923                tk = (ncobj.variables['T2'][:] + 300.)*(p/p0)**(2./7.)
     924                qv = ncobj.variables['Q2'][:]
     925
     926                data1 = 10.*0.6112*np.exp(17.67*(tk-273.16)/(tk-29.65))
     927                data2 = 0.622*data1/(0.01*p-(1.-0.622)*data1)
     928
     929                varNOcheckv = qv/data2
     930                dimensions = ncobj.variables['PSFC'].dimensions
     931                shape = ncobj.variables['PSFC'].shape
    883932
    884933            elif varn == 'WRFT':
     
    934983                dimensions = ncobj.variables['T'].dimensions
    935984                shape = ncobj.variables['P'].shape
     985
     986            elif varn == 'WRFwd':
     987#        print '    ' + main + ': computing wind direction from WRF as ATAN2PI(V,U) ...'
     988                uwind = ncobj.variables['U'][:]
     989                vwind = ncobj.variables['V'][:]
     990                dx = uwind.shape[3]
     991                dy = vwind.shape[2]
     992
     993# de-staggering
     994                ua = 0.5*(uwind[:,:,:,0:dx-1] + uwind[:,:,:,1:dx])
     995                va = 0.5*(vwind[:,:,0:dy-1,:] + vwind[:,:,1:dy,:])
     996
     997                theta = np.arctan2(ua, va)
     998                dimensions = tuple(['Time','bottom_top','south_north','west_east'])
     999                shape = ua.shape
     1000                varNOcheckv = 360.*theta/(2.*np.pi)
     1001
     1002            elif varn == 'WRFwds':
     1003#        print '    ' + main + ': computing surface wind direction from WRF as ATAN2(V,U) ...'
     1004                theta = np.arctan2(ncobj.variables['V10'][:], ncobj.variables['U10'][:])
     1005               
     1006                varNOcheckv = 360.*theta/(2.*np.pi)
     1007                dimensions = ncobj.variables['V10'].dimensions
     1008                shape = ncobj.variables['V10'].shape
     1009
     1010            elif varn == 'TSwds':
     1011#        print '    ' + main + ': computing surface wind direction from TSs as ATAN2(v,u) ...'
     1012                theta = np.arctan2(ncobj.variables['v'][:], ncobj.variables['u'][:])
     1013
     1014                varNOcheckv = 360.*theta/(2.*np.pi)
     1015                dimensions = ncobj.variables['v'].dimensions
     1016                shape = ncobj.variables['v'].shape
    9361017
    9371018            elif varn == 'WRFws':
     
    9501031                shape = ua.shape
    9511032
    952             elif varn == 'WRFwd':
    953 #        print '    ' + main + ': computing wind direction from WRF as ATAN2PI(V,U) ...'
    954                 uwind = ncobj.variables['U'][:]
    955                 vwind = ncobj.variables['V'][:]
    956                 dx = uwind.shape[3]
    957                 dy = vwind.shape[2]
    958 
    959 # de-staggering
    960                 ua = 0.5*(uwind[:,:,:,0:dx-1] + uwind[:,:,:,1:dx])
    961                 va = 0.5*(vwind[:,:,0:dy-1,:] + vwind[:,:,1:dy,:])
    962 
    963                 theta = np.arctan2(ua, va)
    964                 dimensions = tuple(['Time','bottom_top','south_north','west_east'])
    965                 shape = ua.shape
    966                 varNOcheckv = 360.*(1. + theta/(2.*np.pi))
     1033            elif varn == 'TSwss':
     1034#        print '    ' + main + ': computing surface wind speed from TSs as SQRT(u**2 + v**2) ...'
     1035                varNOcheckv = np.sqrt(ncobj.variables['u'][:]*                       \
     1036                  ncobj.variables['u'][:] + ncobj.variables['v'][:]*                 \
     1037                  ncobj.variables['v'][:])
     1038                dimensions = ncobj.variables['u'].dimensions
     1039                shape = ncobj.variables['u'].shape
     1040
     1041            elif varn == 'WRFwss':
     1042#        print '    ' + main + ': computing surface wind speed from WRF as SQRT(U**2 + V**2) ...'
     1043                varNOcheckv = np.sqrt(ncobj.variables['U10'][:]*                     \
     1044                  ncobj.variables['U10'][:] + ncobj.variables['V10'][:]*             \
     1045                  ncobj.variables['V10'][:])
     1046                dimensions = ncobj.variables['U10'].dimensions
     1047                shape = ncobj.variables['U10'].shape
    9671048
    9681049            elif varn == 'WRFz':
     
    12241305  '[constant] to variables values; divc,[constant]: divide by [constant] to ' +      \
    12251306  'variables values'
    1226 varNOcheck = ['WRFdens', 'WRFght', 'WRFp', 'WRFrh', 'WRFT', 'WRFt', 'WRFtd', 'WRFws',\
    1227   'WRFwd', 'WRFz']
    1228 varNOcheckinf = "'WRFdens': air density from WRF variables; 'WRFght': geopotential"+ \
    1229   " height from WRF variables; 'WRFp': pressure from WRF variables; 'WRFrh': " +     \
    1230   "relative humidty fom WRF variables; 'WRFT': CF-time from WRF variables'WRFt'; " + \
    1231   " temperature from WRF variables; 'WRFtd': dew-point temperature from WRF " +      \
    1232   "variables; 'WRFws': wind speed from WRF variables; 'WRFwd': wind speed " +        \
    1233   "direction from WRF variables; 'WRFz': height from WRF variables"
     1307varNOcheck = ['WRFdens', 'WRFght', 'WRFp', 'WRFrh', 'TSrhs', 'WRFrhs', 'WRFT',       \
     1308  'WRFt', 'WRFtd', 'WRFwd', 'TSwds', 'WRFwds', 'WRFws', 'TSwss', 'WRFwss', 'WRFz']
     1309varNOcheckinf = "'WRFdens': air density from WRF variables; " +                      \
     1310  "'WRFght': geopotentiali height from WRF variables; " +                            \
     1311  "'WRFp': pressure from WRF variables; " +                                          \
     1312  "'WRFrh': relative humidty fom WRF variables; " +                                  \
     1313  "'WRFrhs': surface relative humidity from WRF variables; " +                       \
     1314  "'WRFT': CF-time from WRF variables; " +                                           \
     1315  "'WRFt': temperature from WRF variables; " +                                       \
     1316  "'WRFtd': dew-point temperature from WRF variables; " +                            \
     1317  "'WRFwd': wind direction from WRF variables; " +                                   \
     1318  "'WRFwds': surface wind direction from WRF variables; " +                          \
     1319  "'WRFws': wind speed from WRF variables; " +                                       \
     1320  "'WRFwss': surface wind speed from WRF variables; " +                              \
     1321  "'WRFz': height from WRF variables"
    12341322
    12351323dimshelp = "[DIM]@[simdim]@[obsdim] ',' list of couples of dimensions names from " + \
     
    12391327  "no value, WRFdiagnosted variables also available: " + varNOcheckinf + ")"
    12401328varshelp="[simvar]@[obsvar]@[[oper]@[val]] ',' list of couples of variables to " +   \
    1241   "validate and if necessary operation and value operations: " + opersinf +          \
    1242   "(WRFdiagnosted variables also available: " + varNOcheckinf + ")"
     1329  "validate and if necessary operation and value (sim. values) available " +         \
     1330  "operations: " + opersinf + " (WRFdiagnosted variables also available: " +         \
     1331  varNOcheckinf + ")"
    12431332statsn = ['minimum', 'maximum', 'mean', 'mean2', 'standard deviation']
    12441333gstatsn = ['bias', 'simobs_mean', 'sim_obsmin', 'sim_obsmax', 'sim_obsmean', 'mae',  \
     
    12551344  help=strkObs, metavar="FILE")
    12561345parser.add_option("-l", "--stationLocation", dest="stloc", 
    1257   help="name, longitude, latitude and height of the station (only for 'single-station')",
     1346  help="name (| for spaces), longitude, latitude and height of the station (only for 'single-station')",
    12581347  metavar="FILE")
    12591348parser.add_option("-o", "--observation", dest="fobs",
     
    13431432            quit(-1)
    13441433        else:
    1345             stationdesc = [opts.stloc.split(',')[0],                                 \
     1434            stationdesc = [opts.stloc.split(',')[0].replace('|',' '),                \
    13461435              np.float(opts.stloc.split(',')[1]), np.float(opts.stloc.split(',')[2]),\
    13471436              np.float(opts.stloc.split(',')[3])]
Note: See TracChangeset for help on using the changeset viewer.