Changeset 1068 in lmdz_wrf


Ignore:
Timestamp:
Aug 31, 2016, 1:12:33 PM (9 years ago)
Author:
lfita
Message:

Fixing multiple possible diagnostics for the same CF variable (different models)

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r1066 r1068  
    689689
    690690    MODvars = {}
    691     MODdiags = []
    692691    for line in ncf:
    693692        if line[0:1] != '#':
    694693            values = line.replace('\n','').replace(' ','').split(',')
    695694            if values[0] == varn:
    696                 MODdiags.append(values[2].split('@'))
    697 
    698     MODvars[varn] = MODdiags
     695                MODdiags = values[2].split('@')
     696                if MODvars.has_key(values[1]):
     697                    oldvals = MODvars[values[1]]
     698                    oldvals = [oldvals, MODdiags]
     699                    MODvars[values[1]] = oldvals
     700                else:
     701                    MODvars[values[1]] = MODdiags
    699702
    700703    if len(MODvars) == 0:
  • trunk/tools/nc_var_tools.py

    r1066 r1068  
    1599815998    modelvars = gen.CFvar_MODvar(varname)
    1599915999    diagvars = gen.CFvar_DIAGvar(varname)
    16000     print fname + '; Lluis varname:', varname,' diagvars:', diagvars
    1600116000
    1600216001    computevarmod = []
     
    1601016009        for diagn in diagvars.keys():
    1601116010            combovars = diagvars[diagn]
    16012             for combovar in combovars:
     16011            # Checking if there is more than one possible combination
     16012            if type(combovars[0]) == type([1,2]):
     16013                for combovs in combovars:
     16014                  alltrue = False
     16015                  if type(combovs) == type([1,2]):
     16016                      for cvar in combovs:
     16017                          if gen.searchInlist(NOchk,cvar):
     16018                              alltrue = True
     16019                          elif gen.searchInlist(ncvars,cvar):
     16020                              alltrue = True
     16021                          else:
     16022                              alltrue = False
     16023                  else:
     16024                      if gen.searchInlist(ncvars,combovs): alltrue = True
     16025
     16026                  if alltrue:
     16027                      computevardiag.append([diagn] + combovs)
     16028                      break
     16029            else:
     16030                combovar = combovars
    1601316031                alltrue = False
    1601416032                if type(combovar) == type([1,2]):
     
    1602616044                    computevardiag.append([diagn] + combovar)
    1602716045                    break
     16046            if alltrue: break
    1602816047
    1602916048    if len(computevardiag) < 1: computevardiag = None
     
    1603316052def computevar_model(values, ncfile):
    1603416053    """ Function to provide the way to compute a CF-variable providing its name
    16035       varname= CF-compilant variable name
     16054      values= CF-compilant variable name
    1603616055      ncfile= netCDF file from which the variable should be retrieved
    1603716056    """
Note: See TracChangeset for help on using the changeset viewer.