Changeset 1066 in lmdz_wrf for trunk


Ignore:
Timestamp:
Aug 30, 2016, 6:49:41 PM (9 years ago)
Author:
lfita
Message:

Fixing diagnostics variable retrievals for multiple possibilities (different models)

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r1065 r1066  
    666666    >>> CFvar_DIAGvar('hurs')
    667667    {'TSrhs': ['psfc', 't', 'q'], 'LMDZrhs': ['psol', 't2m', 'q2m'], 'WRFrhs': ['PSFC', 'T2', 'Q2']}
     668    >>> CFvar_DIAGvar('wss')
     669    {'wss': [['U10', 'V10'], ['u10m', 'v10m']]}
    668670    """
    669671    import subprocess as sub
     
    687689
    688690    MODvars = {}
     691    MODdiags = []
    689692    for line in ncf:
    690693        if line[0:1] != '#':
    691694            values = line.replace('\n','').replace(' ','').split(',')
    692             if values[0] == varn: MODvars[values[1]] = values[2].split('@')
     695            if values[0] == varn:
     696                MODdiags.append(values[2].split('@'))
     697
     698    MODvars[varn] = MODdiags
    693699
    694700    if len(MODvars) == 0:
  • trunk/tools/nc_var_tools.py

    r1063 r1066  
    1599815998    modelvars = gen.CFvar_MODvar(varname)
    1599915999    diagvars = gen.CFvar_DIAGvar(varname)
     16000    print fname + '; Lluis varname:', varname,' diagvars:', diagvars
    1600016001
    1600116002    computevarmod = []
     
    1600816009    if diagvars is not None:
    1600916010        for diagn in diagvars.keys():
    16010             combovar = diagvars[diagn]
    16011             alltrue = False
    16012             if len(combovar) > 1:
    16013                 for cvar in combovar:
    16014                     if gen.searchInlist(NOchk,cvar):
    16015                         alltrue = True
    16016                     else:
    16017                         if gen.searchInlist(ncvars,cvar): alltrue = True
    16018             else:
    16019                 if gen.searchInlist(ncvars,combovar[0]): alltrue = True
    16020 
    16021             if alltrue: computevardiag.append([diagn] + combovar)
     16011            combovars = diagvars[diagn]
     16012            for combovar in combovars:
     16013                alltrue = False
     16014                if type(combovar) == type([1,2]):
     16015                    for cvar in combovar:
     16016                        if gen.searchInlist(NOchk,cvar):
     16017                            alltrue = True
     16018                        elif gen.searchInlist(ncvars,cvar):
     16019                            alltrue = True
     16020                        else:
     16021                            alltrue = False
     16022                else:
     16023                    if gen.searchInlist(ncvars,combovar): alltrue = True
     16024
     16025                if alltrue:
     16026                    computevardiag.append([diagn] + combovar)
     16027                    break
    1602216028
    1602316029    if len(computevardiag) < 1: computevardiag = None
Note: See TracChangeset for help on using the changeset viewer.