source: trunk/MESOSCALE/PLOT/MINIMAL/profile.pro @ 205

Last change on this file since 205 was 114, checked in by aslmd, 14 years ago

LMD_MM_MARS: update graphic tools for GW, water cycle + generic graphic stuff (ps_start, map_latlon) + update notes

File size: 4.3 KB
Line 
1pro profile, $
2        what_I_plot, $                          ; 1D vertical profile
3        column, $                               ; altitudes     
4        alt=alt, $                              ; altitude range [altmin, altmax]
5        minfield=minfield_init, $               ; minimum value of plotted field (=0: calculate)
6        maxfield=maxfield_init, $               ; maximum value of plotted field (=0: calculate)
7        inprofile=overplot, $                   ; another vertical profile to overplot
8        incolumn=overplot_column, $             ; altitudes of the other vertical profile (in case /= column)
9        discrete=discrete, $                    ; show the profile points (= type of points in !psym)
10        title_plot=title_user, $                ; title of the plot ('Profile' is default)
11        title_axis=title_axis, $                ; title of the [x,y] axis (['Field','Altitude'] is default)
12        mention=mention                         ; add text precision within the plot window (default is nothing or '')
13
14;--------------------------------------------
15;
16; A general routine to plot 1D profiles
17;
18; USE: see comments above
19;
20; EXAMPLE:
21;       profile, findgen(30)^2, findgen(30)
22;       profile, findgen(30)^2, findgen(30), overplot=findgen(30)^2.2, discrete=4, title_plot='An example of profile'
23;       profile, findgen(30)^2, findgen(30), title_axis=['Dumb profile', 'Dumb Altitude']
24;
25;--------------------------------------------
26; A. Spiga, September 2007
27;--------------------------------------------
28
29
30
31;---------------------------
32; a few permanent settings
33;---------------------------
34;
35missing_value=1.e30
36SPAWN, 'touch param_plot.idl'
37@param_plot.idl
38;
39;------------------
40
41
42;-----------------------------
43; user and default settings
44;-----------------------------
45if (n_elements(title_user) eq 0) then title='Profile'
46if (n_elements(title_axis) ne 2) then begin
47        xtitle='Field'
48        ytitle='Altitude'
49endif else begin
50        xtitle=title_axis(0)
51        ytitle=title_axis(1)
52endelse
53if (n_elements(maxfield_init) eq 0) then maxfield_init=0
54if (n_elements(minfield_init) eq 0) then minfield_init=0
55
56if (n_elements(column) eq 0) then column=findgen(n_elements(what_I_plot))
57if (n_elements(mention) eq 0) then mention=''
58if (mention ne '') then mention='('+mention+')'
59
60;------------------
61; missing values
62;------------------
63w=where(abs(what_I_plot) gt missing_value)
64if (w(0) ne -1) then what_I_plot[w]=!Values.F_NAN
65
66
67;------------------
68; limits
69;------------------
70if (minfield_init*maxfield_init eq 0) then begin
71        xrange=[min(what_I_plot),max(what_I_plot)]
72        print, xrange
73endif else begin
74        xrange=[minfield_init,maxfield_init]
75        print, xrange
76endelse
77
78if (xrange(0)*xrange(1) eq 0) then begin
79        print, 'nothing to plot ... skipping this plot ...'
80        stop
81endif
82
83 
84;---------------
85; adapt ticks
86;---------------
87;intervalx=round((xrange(1)-xrange(0))/5.)
88;intervaly=round(abs(max(column)-min(column))/5.)
89;intervalx=5.
90;intervaly=5.
91
92;if (n_elements(intervalx) eq 0) then intervalx=round((xrange(1)-xrange(0))/8.)
93;;if (n_elements(intervaly) eq 0) then intervaly=round((abs(max(column)-min(column))/5.))
94
95
96;; ----------------------------
97;; manage the altitude range
98;; ----------------------------
99;if (n_elements(alt) eq 2) then begin
100;       altmin=alt(0)
101;       altmax=alt(1)
102;       w=where((column ge altmin) and (column le altmax))
103;       if (n_elements(intervaly) eq 0) then intervaly=(altmax-altmin)/5
104;       if (w(0) ne -1) then begin
105;               column=column[w]
106;               what_I_plot=what_I_plot[w]
107;               minfield=min(what_I_plot)
108;               maxfield=max(what_I_plot)       
109;       endif
110;endif
111
112
113
114;-------------
115; plot
116;-------------
117plot, $
118        what_I_plot,column, $
119        xrange=xrange, $
120;       yrange=[min(column),max(column)], $
121yrange=alt, $
122        xtickinterval=intervalx, $
123        ytickinterval=intervaly, $     
124        xtitle=xtitle, $
125        ytitle=ytitle,$
126        title=title_user,$
127;/ylog, $
128        subtitle=mention
129
130;-------------
131; overplot
132;-------------
133if (n_elements(discrete) ne 0) then begin
134if (discrete ne 0) then begin
135        !psym=discrete
136        oplot, $
137                what_I_plot,column
138        !psym=0
139endif
140endif   
141
142if (n_elements(overplot) gt 1) then begin
143        column_overplot=column
144        w=where(abs(overplot) gt missing_value)
145        if (w(0) ne -1) then overplot[w]=!Values.F_NAN
146        if (n_elements(overplot_column) gt 1) then column_overplot=overplot_column
147oplot, $
148        overplot, column_overplot, $
149        linestyle=2
150        if (n_elements(discrete) ne 0) then begin
151                !psym=discrete
152                oplot, $
153                        overplot,column_overplot
154                !psym=0
155        endif   
156endif   
157
158
159
160;;--------------
161;; text inside
162;;--------------
163;if (n_elements(mention) ne 0) then begin
164;       alignx=(max(what_I_plot)+min(what_I_plot))/2
165;       aligny=max(column)-intervaly/2
166;       xyouts, alignx, $
167;               aligny, $
168;               mention
169;endif
170
171end
Note: See TracBrowser for help on using the repository browser.