1 | pro 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 | ; |
---|
35 | missing_value=1.e30 |
---|
36 | SPAWN, 'touch param_plot.idl' |
---|
37 | @param_plot.idl |
---|
38 | ; |
---|
39 | ;------------------ |
---|
40 | |
---|
41 | |
---|
42 | ;----------------------------- |
---|
43 | ; user and default settings |
---|
44 | ;----------------------------- |
---|
45 | if (n_elements(title_user) eq 0) then title='Profile' |
---|
46 | if (n_elements(title_axis) ne 2) then begin |
---|
47 | xtitle='Field' |
---|
48 | ytitle='Altitude' |
---|
49 | endif else begin |
---|
50 | xtitle=title_axis(0) |
---|
51 | ytitle=title_axis(1) |
---|
52 | endelse |
---|
53 | if (n_elements(maxfield_init) eq 0) then maxfield_init=0 |
---|
54 | if (n_elements(minfield_init) eq 0) then minfield_init=0 |
---|
55 | |
---|
56 | if (n_elements(column) eq 0) then column=findgen(n_elements(what_I_plot)) |
---|
57 | if (n_elements(mention) eq 0) then mention='' |
---|
58 | if (mention ne '') then mention='('+mention+')' |
---|
59 | |
---|
60 | ;------------------ |
---|
61 | ; missing values |
---|
62 | ;------------------ |
---|
63 | w=where(abs(what_I_plot) gt missing_value) |
---|
64 | if (w(0) ne -1) then what_I_plot[w]=!Values.F_NAN |
---|
65 | |
---|
66 | |
---|
67 | ;------------------ |
---|
68 | ; limits |
---|
69 | ;------------------ |
---|
70 | if (minfield_init*maxfield_init eq 0) then begin |
---|
71 | xrange=[min(what_I_plot),max(what_I_plot)] |
---|
72 | print, xrange |
---|
73 | endif else begin |
---|
74 | xrange=[minfield_init,maxfield_init] |
---|
75 | print, xrange |
---|
76 | endelse |
---|
77 | |
---|
78 | if (xrange(0)*xrange(1) eq 0) then begin |
---|
79 | print, 'nothing to plot ... skipping this plot ...' |
---|
80 | stop |
---|
81 | endif |
---|
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 | ;------------- |
---|
117 | plot, $ |
---|
118 | what_I_plot,column, $ |
---|
119 | xrange=xrange, $ |
---|
120 | ; yrange=[min(column),max(column)], $ |
---|
121 | yrange=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 | ;------------- |
---|
133 | if (n_elements(discrete) ne 0) then begin |
---|
134 | if (discrete ne 0) then begin |
---|
135 | !psym=discrete |
---|
136 | oplot, $ |
---|
137 | what_I_plot,column |
---|
138 | !psym=0 |
---|
139 | endif |
---|
140 | endif |
---|
141 | |
---|
142 | if (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 |
---|
147 | oplot, $ |
---|
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 |
---|
156 | endif |
---|
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 | |
---|
171 | end |
---|