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

Last change on this file since 409 was 409, checked in by acolaitis, 13 years ago

PYTHON. 1/ mcs.py now works on a list of 3D and 4D variables given by -v or --var (it will also put aps and bps in the diagfi). 2/ added option --intas which is a template for the -i 2 gcm interpolation. -i 2 --intas mcs will interpolate the field on the same pressure levels as mcs. Works also with --intas tes. 3/ Corrected a small bug in make_gcm_netcdf

File size: 3.3 KB
Line 
1
2### A. Colaitis -- LMD -- 08/11/2011
3
4def call_zrecast (  interp_mode   = '4', \
5                    input_name      = None, \
6                    fields  = 'all', \
7                    predifined = None):
8
9    import numpy as np
10    from myplot import separatenames
11    from os import system
12    pressure_axis_tes=[1658.152,1291.37,1005.72,783.2555,610.,475.0685,369.9837,288.1436,224.4065,174.7679,136.1094,106.0021,82.55452,64.29353,50.07185,38.99599,30.37011,23.65227,18.4204,14.34583,11.17254]
13    pressure_axis_mcs=[1878.9, 1658.2, 1463.3, 1291.4, 1139.6, 1005.7, 887.54, 783.26,691.22, 610, 538.32, 475.07, 419.25, 369.98, 326.51, 288.14, 254.29,224.41, 198.04, 174.77, 154.23, 136.11, 120.12, 106, 93.547, 82.555,72.854, 64.294, 56.739, 50.072, 44.188, 38.996, 34.414, 30.37, 26.802,23.652, 20.873, 18.42, 16.256, 14.346, 12.66, 11.173, 9.8597, 8.7012,7.6788, 6.7765, 5.9802, 5.2775, 4.6574, 4.1101, 3.6272, 3.201, 2.8249,2.4929, 2.2, 1.9415, 1.7134, 1.512, 1.3344, 1.1776, 1.0392, 0.9171,0.80934, 0.71424, 0.63031, 0.55625, 0.49089, 0.43321, 0.3823, 0.33738,0.29774, 0.26275, 0.23188, 0.20463, 0.18059, 0.15937, 0.14064, 0.12412,0.10953, 0.096661, 0.085303, 0.07528, 0.066434, 0.058628, 0.051739,0.04566, 0.040294, 0.03556, 0.031381, 0.027694, 0.02444, 0.021568,0.019034, 0.016797, 0.014824, 0.013082, 0.011545, 0.010188, 0.0089909,0.0079345, 0.0070021, 0.0061794, 0.0054533, 0.0048125, 0.004247]
14    system("rm -f zrecast.auto.def")
15    system("touch zrecast.auto.def")
16    indicefile=0
17    outputfilename=""
18    for zfile in input_name:
19        system("echo "+zfile+" >> zrecast.auto.def")
20        for zvar in fields:
21            system("echo "+zvar+" >> zrecast.auto.def")
22        system("echo >> zrecast.auto.def")
23        if interp_mode == 4:
24             append="_S"
25             system("echo 3 >> zrecast.auto.def")
26             system("echo yes >> zrecast.auto.def")
27             system("echo 0 150000 >> zrecast.auto.def")
28        elif interp_mode == 2:
29             append="_P"
30             if predifined is "TES":
31                system("echo 1 >> zrecast.auto.def")
32                system("echo no >> zrecast.auto.def")
33                system("echo "+len(pressure_axis_tes)+" >> zrecast.auto.def")
34                for zp in pressure_axis_tes:
35                   system("echo "+zp+" >> zrecast.auto.def")
36             elif predifined is "MCS":
37                system("echo no >> zrecast.auto.def")
38                system("echo "+len(pressure_axis_mcs)+" >> zrecast.auto.def")
39                for zp in pressure_axis_mcs:
40                   system("echo "+zp+" >> zrecast.auto.def")
41             else:
42                system("echo 1 >> zrecast.auto.def")
43                system("echo yes >> zrecast.auto.def")
44                system("echo 370 0.1 >> zrecast.auto.def")  #I put that randomly! (a.c.)
45                system("echo 20 >> zrecast.auto.def")
46        else:
47             print "zrecast interp option unsupported for now. Exiting."
48             exit()
49        system("zrecast.e < zrecast.auto.def")
50
51        if indicefile is 0:
52              outputfilename=input_name[indicefile][0:len(input_name[0])-3]+append+".nc"
53        else:
54              outputfilename=outputfilename+","+input_name[indicefile][0:len(input_name[0])-3]+append+".nc"
55        indicefile = indicefile +1
56
57        for i in range(len(outputfilename)):
58            output_name = separatenames(outputfilename)
59
60    return output_name
61
Note: See TracBrowser for help on using the repository browser.