source: trunk/UTIL/PYTHON/zrecast_wrapper.py @ 361

Last change on this file since 361 was 361, checked in by acolaitis, 14 years ago

PYTHON.

Added zrecast capabilites for gcm.py. Interp modes AGL and P are working. Adding more is not difficult.
One should make sure that his zrecast.e is up to date and in his $PATH.

Note: we could also use f2py to compile a python module... However, most people do have zrecast in their path.

Note2: When using inter-file comparisons, such as field differences, one should make sure to use zrecast (or -i with gcm.py) to
make sure that operations are done at the same altitudes ! (levels in different simulations a priori do not represent same altitudes)

Note3: zrecast has been modified in previous commit to work with teta instead of temp, if needed.

File size: 1.5 KB
Line 
1
2### A. Colaitis -- LMD -- 08/11/2011
3
4def call_zrecast (  interp_mode   = '3', \
5                    input_name      = None, \
6                    fields  = 'all'):
7
8    import numpy as np
9    from myplot import separatenames
10    from os import system
11
12    system("rm -f zrecast.auto.def")
13    system("touch zrecast.auto.def")
14    indicefile=0
15    outputfilename=""
16    for zfile in input_name:
17        system("echo "+zfile+" >> zrecast.auto.def")
18        for zvar in [fields]:
19            system("echo "+zvar+" >> zrecast.auto.def")
20        system("echo >> zrecast.auto.def")
21        if interp_mode == 4:
22             system("echo 3 >> zrecast.auto.def")
23             system("echo yes >> zrecast.auto.def")
24             system("echo 0 150000 >> zrecast.auto.def")
25        elif interp_mode == 2:
26             system("echo 1 >> zrecast.auto.def")
27             system("echo yes >> zrecast.auto.def")
28             system("echo 0.0001 6. >> zrecast.auto.def")  #I put that randomly! (a.c.)
29        else:
30             print "zrecast interp option unsupported for now. Exiting."
31             exit()
32        system("zrecast.e < zrecast.auto.def")
33        if indicefile is 0:
34              outputfilename=input_name[indicefile][0:len(input_name[0])-3]+"_S.nc"
35        else:
36              outputfilename=outputfilename+","+input_name[indicefile][0:len(input_name[0])-3]+"_S.nc"
37        indicefile = indicefile +1
38
39        for i in range(len(outputfilename)):
40            output_name = separatenames(outputfilename)
41
42    return output_name
43
Note: See TracBrowser for help on using the repository browser.