Changeset 840 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 16, 2016, 5:19:47 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r837 r840 19 19 20 20 ####### Content 21 # CFvar_DIAGvar: Function to provide which model diagnostic values can provide a CF-variable from ASCII file 21 22 # CFvar_MODvar: Function to provide which model values can provide a CF-variable from ASCII file 22 23 # chainSnumHierarchy: Class to provide the structure of a `ChainStrNum' hierarchy … … 569 570 """ Function to provide which model values can provide a CF-variable from ASCII file 570 571 'variables_values.dat' 571 CFvar_MODvar(var Name)572 [var Name]=name of the variable572 CFvar_MODvar(varn) 573 [varn]= CF name of the variable 573 574 >>> CFvar_MODvar('hfss') 574 575 ['hfss', 'LSENS', 'sens', 'HFX', 'hfx'] … … 615 616 return MODvars 616 617 617 print CFvar_MODvar('hfss') 618 print CFvar_MODvar('pr') 618 def CFvar_DIAGvar(varn): 619 """ Function to provide which model diagnostic values can provide a CF-variable from ASCII file 620 'diagnostics.inf' (reference for diagnostics.py') 621 [CFname], [moddiag], [varcombo] 622 [moddiag]: name of the diagnosted variable 623 [varcombo]: combnination of variables to be used to compute diagnostic 624 CFvar_DIAGvar(varn) 625 [varn]= CF name of the variable 626 >>> CFvar_MODvar('pr') 627 [[' RAINC', 'RAINNC']] 628 >>> CFvar_MODvar('hurs') 629 [[' psol', 't2m', 'q2m'], [' psfc', 't', 'q'], [' PSFC', 'T2', 'Q2']] 630 """ 631 import subprocess as sub 632 633 fname='CFvar_DIAGvar' 634 635 if varn == 'h': 636 print fname + '_____________________________________________________________' 637 print CFvar_DIAGvar.__doc__ 638 quit() 639 640 folder = os.path.dirname(os.path.realpath(__file__)) 641 642 infile = folder + '/diagnostics.inf' 643 644 if not os.path.isfile(infile): 645 print errormsg 646 print ' ' + fname + ": File '" + infile + "' does not exist !!" 647 quit(-1) 648 649 ncf = open(infile, 'r') 650 651 MODvars = [] 652 for line in ncf: 653 if line[0:1] != '#': 654 values = line.replace('\n','').split(',') 655 varvals = [values[0], values[1], values[2]] 656 if varvals[0] == varn: MODvars.append(values[2].split('@')) 657 658 if len(MODvars) == 0: 659 print errormsg 660 print ' ' + fname + ": variable '" + varn + "' not defined !!!" 661 ncf.close() 662 return None 663 else: 664 return MODvars 665 666 print CFvar_DIAGvar('pr') 667 print CFvar_DIAGvar('hurs') 619 668 620 669 quit()
Note: See TracChangeset
for help on using the changeset viewer.