1 | |
---|
2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
3 | |
---|
4 | PYTHON COMMAND LINE PLOTS EXAMPLES |
---|
5 | |
---|
6 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
7 | |
---|
8 | |
---|
9 | *********************************************************************************** |
---|
10 | Simple 2D plot: Zonal mean. |
---|
11 | ********************************************************************************** |
---|
12 | |
---|
13 | Goal: |
---|
14 | |
---|
15 | Plot the zonal mean temperature from a netcdf fiel representing one month. |
---|
16 | |
---|
17 | Command: |
---|
18 | |
---|
19 | gcm.py -f POLAR_NIGHT_RUN/diagfi16.nc --var temp --lon 180,-180 --time 0,65 |
---|
20 | |
---|
21 | Note: |
---|
22 | |
---|
23 | The --time, --lat, --lon and --vert command takes in input values corresponding to the unit stored in the netcdf file, and not indices ! For example, if the "Time" unit is in sol (which is common for a gcm output), --time 2 means sol 2.0 and not index 2 along the time direction. Consequently, one can ask --time 2.5 for temperatures at 12:00 on sol 2. |
---|
24 | |
---|
25 | Means are easy to perform by specifying a range. Here: --time 0,65 and --lat -180,180. |
---|
26 | |
---|
27 | *********************************************************************************** |
---|
28 | Vertical interpolation of the field. |
---|
29 | *********************************************************************************** |
---|
30 | |
---|
31 | Goal: |
---|
32 | |
---|
33 | Calls to zrecast and api are built-in the python functions. One can call them using -i with the appropriate argument (see meso.py -h or gcm.py -h). Here is an example that re-interpolates data using zrecast before plotting it in a 2D contour. |
---|
34 | |
---|
35 | Command: |
---|
36 | |
---|
37 | gcm.py -f POLAR_NIGHT_RUN/diagfi16.nc --var temp --lon -180,180 --time 0,65 -i 4 |
---|
38 | |
---|
39 | Note: |
---|
40 | |
---|
41 | All interpolation modes available in zrecast and api (pressure, AGL, distance from planet center, etc...) are theoretically possible, but may not be coded yet in the routine. See gcm.py -h or meso.py -h. |
---|
42 | |
---|
43 | For this example, the default behavior of zrecast for -i 4 is to interpolate in (m) from the local surface, between 0 and 150 km. The command will generate a reinterpolated netcdf file "POLAR_NIGHT_RUN/diagfi16_S.nc" with only the requested field, which is not deleted afterward. |
---|
44 | |
---|
45 | |
---|
46 | *********************************************************************************** |
---|
47 | 2D plot of the difference between two files. |
---|
48 | *********************************************************************************** |
---|
49 | |
---|
50 | Goal: |
---|
51 | |
---|
52 | Comparing two .nc files with similar dimension axis can be done in a single command, by specifying which files to compare and the comparison operator (i.e. is it a difference, an addition, etc...). When comparing data along a vertical axis, it can be wise to also ask for an interpolation of the fields to make sure the comparison is correct. |
---|
53 | |
---|
54 | Command: |
---|
55 | |
---|
56 | gcm.py -f POLAR_NIGHT_RUN/stats16.nc --var temp --lon -180,180 --time 1 -i 4 --fref POLAR_NIGHT_REF/stats16.nc --operation - --mope -2 --Mope 2 --title "Polar temperatures with new parametrizations" --titleref "Reference run" |
---|
57 | |
---|
58 | Note: |
---|
59 | |
---|
60 | The command will output 3 plots: the field from file 1, the field from file 2, and the comparison between the two. One can specify specific names for the title of these plots by using --title and --titleref for the titles of file 1 and file 2, and can specify different plotting range for the normal field (-m -M) and the compared field (--mope --Mope). |
---|
61 | |
---|
62 | One can combine this command with projections and means, so that for example, to compare co2 depletion at the south pole: |
---|
63 | |
---|
64 | gcm.py -f POLAR_NIGHT_RUN/start16.nc --var co2 --vert 0,150 --proj spstere --time 1 -i 4 --fref POLAR_NIGHT_REF/start16.nc --operation - --mope -0.5 --Mope 0.5 --title "Polar co2 with new parametrizations" --titleref "Reference run" |
---|
65 | |
---|
66 | *********************************************************************************** |
---|
67 | 2D plot of data with missing values, along a pressure axis (decreasing with height). |
---|
68 | *********************************************************************************** |
---|
69 | |
---|
70 | Goal: |
---|
71 | |
---|
72 | By default, python will force the y-axis of a 2D plot to be ordered by increasing values. Here is how to force it otherwise. |
---|
73 | |
---|
74 | Command: |
---|
75 | |
---|
76 | gcm.py -f TES.MappedClimatology.nadir.MY25.nc --var T_nadir_day --lat -76. --time 90 --ymin 500 --ymax 1 -m 128 -M 148 -H |
---|
77 | |
---|
78 | Note: |
---|
79 | |
---|
80 | The axis reversal is done by specifying ymin and ymax in the right order. One can also simply use --inverty and not specify (ymin,ymax). Missing values (out of range values) are replaced by holes by the option "-H". |
---|