Changeset 864 in lmdz_wrf for trunk


Ignore:
Timestamp:
Jun 17, 2016, 7:33:43 PM (8 years ago)
Author:
lfita
Message:

Using dictionary in 'CFvar_DIAGvar'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r851 r864  
    621621      'diagnostics.inf' (reference for diagnostics.py')
    622622       [CFname], [moddiag], [varcombo]
    623          [moddiag]: name of the diagnosted variable
     623         [CFname]: CF name of the variable
     624         [moddiag]: name of the diagnosted variable (for `diagnostic.py')
    624625         [varcombo]: combnination of variables to be used to compute diagnostic
    625626    CFvar_DIAGvar(varn)
    626627      [varn]= CF name of the variable
    627628    >>> CFvar_MODvar('pr')
    628     [[' RAINC', 'RAINNC']]
     629    {'RAINTOT': ['RAINC', 'RAINNC']}
    629630    >>> CFvar_MODvar('hurs')
    630     [[' psol', 't2m', 'q2m'], [' psfc', 't', 'q'], [' PSFC', 'T2', 'Q2']]
     631    {'TSrhs': ['psfc', 't', 'q'], 'LMDZrhs': ['psol', 't2m', 'q2m'], 'WRFrhs': ['PSFC', 'T2', 'Q2']}
    631632    """
    632633    import subprocess as sub
     
    642643
    643644    infile = folder + '/diagnostics.inf'
    644 
    645645    if not os.path.isfile(infile):
    646646        print errormsg
     
    650650    ncf = open(infile, 'r')
    651651
    652     MODvars = []
     652    MODvars = {}
    653653    for line in ncf:
    654654        if line[0:1] != '#':
    655655            values = line.replace('\n','').replace(' ','').split(',')
    656             if values[0] == varn: MODvars.append(values[2].split('@'))
     656            if values[0] == varn: MODvars[values[1]] = values[2].split('@')
    657657
    658658    if len(MODvars) == 0:
     
    662662        return None
    663663    else:
     664        ncf.close()
    664665        return MODvars
    665666
Note: See TracChangeset for help on using the changeset viewer.