source: trunk/UTIL/PYTHON/planetoplot_v2/examples/intercompare.py @ 930

Last change on this file since 930 was 930, checked in by aslmd, 12 years ago

UTIL PYTHON planetoplot_v2. Added attribute allfield so that the user can easily access values. See examples/easy_get_field.py. Added attribute includedate to select option for naming files. Corrected index bug in meanarea mode. Added an example intercompare.py which shows how to easily compare results in two quite different netCDF files.

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1#! /usr/bin/env python
2from ppclass import pp
3
4### LMD simulation results
5### ----------------------
6### set object
7lmdu = pp()
8### set file var coord
9lmdu.file = 'LMD/wrfout_d01_2024-09-08_01:00:00_z'
10lmdu.var = 'Um'
11lmdu.x = -6.
12lmdu.y = -2.
13lmdu.t = 0.
14### get data
15lmdu.get()
16
17### MRAMS simulation results
18### ------------------------
19### set object
20mramsu = pp()
21### get attributes from lmd object
22mramsu << lmdu
23### OK just change what changes in MRAMS
24mramsu.file = 'MRAMS/mramsout_d01_2024-09-08_01:00:00_z'
25mramsu.var = 'u_areo'
26### get data
27mramsu.get()
28
29### THE SAME BUT FOR V
30### ------------------
31lmdv = pp()
32lmdv << lmdu
33lmdv.var = 'Vm'
34lmdv.get()
35mramsv = pp()
36mramsv << mramsu
37mramsv.var = 'v_areo'
38mramsv.get()
39
40### COMPUTE WIND SPEED
41### ------------------
42lmd = (lmdu**2+lmdv**2)**0.5
43mrams = (mramsu**2+mramsv**2)**0.5
44
45### NOW PLOT
46### --------
47### define plot for LMD
48### ... and prepare it so that MRAMS will be superimposed
49lmd.superpose = True
50lmd.defineplot(extraplot=1)
51### ... add a few personal settings
52lmd.p[0].title = "LMD (blue) vs. MRAMS (red)"
53lmd.p[0].swaplab = False
54lmd.p[0].xlabel = "Wind speed (m s$^{-1})$"
55lmd.p[0].ylabel = "Altitude above MOLA zero datum (km)"
56lmd.p[0].ycoeff = 1./1000.
57### ... and make plot (no output, wait for extraplot)
58lmd.makeplot()
59### --------
60### define plot for MRAMS
61### ... say we will plot this in lmd figure
62mrams.plotin = lmd
63mrams.superpose = True
64### ... and make plot (now there is an output)
65mrams.out = 'png'
66mrams.filename = 'wind_intercomp'
67mrams.plot()
68
69### COMPUTE REL DIFF in % AND PLOT IT INDEPENDENTLY
70### -----------------------------------------------
71diff = ((lmd-mrams)/(lmd*0.5+mrams*0.5))*100.
72diff.filename = 'wind_intercomp_diff'
73diff.superpose = False
74diff.out = 'png'
75diff.defineplot()
76diff.p[0].title = ""
77diff.p[0].swaplab = False
78diff.p[0].xlabel = "Relative difference in wind LMD vs. MRAMS (%)"
79diff.p[0].ylabel = "Altitude above MOLA zero datum (km)"
80diff.p[0].ycoeff = 1./1000.
81diff.makeplot()
82
83### SAME FOR TEMPERATURE
84### --------------------
85lmdt = pp()
86lmdt << lmdu
87lmdt.var = 'tk'
88lmdt.get()
89mramst = pp()
90mramst << mramsu
91mramst.var = 'tk'
92mramst.get()
93difft = ((lmdt-mramst)/(lmdt*0.5+mramst*0.5))*100.
94difft.defineplot()
95difft.filename = 'temp_intercomp_diff'
96difft.superpose = False
97difft.out = 'png'
98difft.defineplot()
99difft.p[0].title = ""
100difft.p[0].swaplab = False
101difft.p[0].xlabel = "Relative difference in temperature LMD vs. MRAMS (%)"
102difft.p[0].ylabel = "Altitude above MOLA zero datum (km)"
103difft.p[0].ycoeff = 1./1000.
104difft.makeplot()
105
106### TEMPERATURE
107###############
108
109int = pp()
110int.file = ['LMD/wrfout_d01_2024-09-08_01:00:00_z','MRAMS/mramsout_d01_2024-09-08_01:00:00_z']
111int.var = 'tk'
112int.x = -6.
113int.y = -2.
114int.t = 0.
115int.out = 'png'
116int.filename = 'temp_intercomp'
117int.superpose = True
118int.getdefineplot()
119
120int.p[0].title = "LMD (blue) vs. MRAMS (red)"
121int.p[0].swaplab = False
122int.p[0].ylabel = "Altitude above MOLA zero datum (km)"
123int.p[0].ycoeff = 1./1000.
124int.p[0].title = lmd.p[0].title
125int.p[0].xlabel = "Temperature (K)"
126
127int.makeplot()
128
Note: See TracBrowser for help on using the repository browser.