Changeset 1701 in lmdz_wrf


Ignore:
Timestamp:
Dec 8, 2017, 6:01:22 PM (7 years ago)
Author:
lfita
Message:

Adding more general generation of 2D X,Y variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/get_stations.py

    r1698 r1701  
    388388
    389389# Looking for 2D 'lon', 'lat' related variables
    390 Xvarvals = dimvarvalues[dimvariables['lon']]
    391 Yvarvals = dimvarvalues[dimvariables['lat']]
    392 if len(Xvarvals.shape) == 1:
    393     newXvarvals, newYvarvals = np.meshgrid(Xvarvals, Yvarvals)
    394     dimvarvalues[dimvariables['lon']] = newXvarvals
    395     dimvarvalues[dimvariables['lat']] = newYvarvals
    396     dx = newXvarvals.shape[1]
    397     dy = newXvarvals.shape[0]
    398 
    399 # Looking for 4D 'plev' variable for calculation of diagnostics
    400 Zvarvals = dimvarvalues[dimvariables['plev']]
    401 Tvarvals = dimvarvalues[dimvariables['time']]
    402 if len(Zvarvals.shape) == 1:
    403     dz = Zvarvals.shape[0]
    404     dt = Tvarvals.shape[0]
    405     newZvarvals = np.zeros((dt, dz, dy, dx), dtype=np.float)
    406     for it in range(dt):
    407         for iy in range(dy):
    408             for ix in range(dx):
    409                 newZvarvals[it,:,iy,ix] = Zvarvals
    410     dimvarvalues[dimvariables['plev']] = newZvarvals
     390for xn in axesvars['X']:
     391    Xvarvals = dimvarvalues[dimvariables[xn]]
     392    Yvarvals = dimvarvalues[CFdims['lat']]
     393    if len(Xvarvals.shape) == 1:
     394        newXvarvals, newYvarvals = np.meshgrid(Xvarvals, Yvarvals)
     395        dimvarvalues[dimvariables[dimvariables[xn]] = newXvarvals
     396for yn in axesvars['Y']:
     397    Xvarvals = dimvarvalues[CFdims['lon']]
     398    Yvarvals = dimvarvalues[dimvariables[yn]]
     399    if len(Yvarvals.shape) == 1:
     400        newXvarvals, newYvarvals = np.meshgrid(Xvarvals, Yvarvals)
     401        dimvarvalues[dimvariables[dimvariables[yn]] = newYvarvals
    411402
    412403# Retrieving surface data
Note: See TracChangeset for help on using the changeset viewer.