Changeset 2222 in lmdz_wrf


Ignore:
Timestamp:
Nov 8, 2018, 10:59:59 PM (6 years ago)
Author:
lfita
Message:

Adding calculation of `range_faces' for lonlat regular

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diagnostics.py

    r2215 r2222  
    101101
    102102# Variables not to check
    103 NONcheckingvars = ['accum', 'cllmh', 'deaccum', 'face', 'TSrhs',                     \
     103NONcheckingvars = ['accum', 'cllmh', 'deaccum', 'face', 'LONLATdxdy', 'TSrhs',       \
    104104  'TStd', 'TSwds', 'TSwss',                                                          \
    105105  'WRFbils',                                                                         \
     
    167167WRFz_compute = False
    168168WRFdxdy_compute = False
     169LONLATdxdy_compute = False
    169170
    170171# File creation
     
    192193    if dnv == 'WRFz':WRFz_compute = True
    193194    if dnv == 'WRFdxdy':WRFdxdy_compute = True
     195    if dnv == 'LONLATdxdy':LONLATdxdy_compute = True
    194196
    195197# diagnostics to compute
     
    221223        if gen.searchInlist(depvars, 'WRFz'): WRFz_compute = True
    222224        if gen.searchInlist(depvars, 'WRFdxdy'): WRFdxdy_compute = True
     225        if gen.searchInlist(depvars, 'LONLATdxdy'): LONLATdxdy_compute = True
    223226
    224227# Dictionary with the new computed variables to be able to add them
     
    422425    WRFdx[:,0:dimx-1]=(WRFlon[:,1:dimx]-WRFlon[:,0:dimx-1])*DX/WRFmapfac_m[:,0:dimx-1]
    423426    WRFdy[0:dimy-1,:]=(WRFlat[1:dimy,:]-WRFlat[0:dimy-1,:])*DY/WRFmapfac_m[0:dimy-1,:]
     427    WRFds = np.sqrt(WRFdx**2 + WRFdy**2)
     428
     429    # Attributes of the variable
     430    Vvals = gen.variables_values('WRFdx')
     431    dictcompvars['WRFdx'] = {'name': Vvals[0], 'standard_name': Vvals[1],             \
     432      'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]}
     433    Vvals = gen.variables_values('WRFdy')
     434    dictcompvars['WRFdy'] = {'name': Vvals[0], 'standard_name': Vvals[1],             \
     435      'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]}
     436    Vvals = gen.variables_values('WRFds')
     437    dictcompvars['WRFds'] = {'name': Vvals[0], 'standard_name': Vvals[1],            \
     438      'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]}
     439
     440if LONLATdxdy_compute:
     441    print '  ' + main + ': Retrieving dxdy: real distance between grid points ' +    \
     442      'from a regular lonlat projection as dx=(lon[i+1]-lon[i])*raddeg*Rearth*' +    \
     443      'cos(abs(lat[i])); dy=(lat[j+1]-lat[i])*raddeg*Rearth; ds=sqrt(dx**2+dy**2); '+\
     444      'raddeg = pi/180; Rearth=6370.0e03'
     445    dimv = ncobj.variables['lon'].shape
     446    lon = ncobj.variables['lon'][:]
     447    lat = ncobj.variables['lat'][:]
     448
     449    WRFlon, WRFlat = gen.lonlat2D(lon,lat)
     450
     451    dimx = WRFlon.shape[1]
     452    dimy = WRFlon.shape[0]
     453
     454    WRFdx = np.zeros((dimy,dimx), dtype=np.float)
     455    WRFdy = np.zeros((dimy,dimx), dtype=np.float)
     456
     457    raddeg = np.pi/180.
     458
     459    Rearth = fdef.module_definitions.earthradii
     460
     461    WRFdx[:,0:dimx-1]=(WRFlon[:,1:dimx]-WRFlon[:,0:dimx-1])*raddeg*Rearth*           \
     462      np.cos(np.abs(WRFlat[:,0:dimx-1]*raddeg))
     463    WRFdy[0:dimy-1,:]=(WRFlat[1:dimy,:]-WRFlat[0:dimy-1,:])*raddeg*Rearth
    424464    WRFds = np.sqrt(WRFdx**2 + WRFdy**2)
    425465
     
    728768        hvalleyrange = np.float(depvars[4].split(':')[4])
    729769
    730         dnamesvar = list(ncobj.variables[depvars[0]].dimensions)
     770        dnamesvar = list(ncobj.variables[depvars[2]].dimensions)
    731771        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
    732772        lon, lat = gen.lonlat2D(var0, var1)
     
    760800
    761801        ncvar.insert_variable(ncobj, 'orogmax', rngorogmax, diagoutd, diagoutvd,     \
    762           newnc)
     802          newnc, fill=gen.fillValueF)
    763803        newnc.renameVariable('orogmax', 'rangeorogmax')
    764804        ovar = newnc.variables['rangeorogmax']
Note: See TracChangeset for help on using the changeset viewer.