[85] | 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='' else mention='('+mention+')' |
---|
| 58 | |
---|
| 59 | ;------------------ |
---|
| 60 | ; missing values |
---|
| 61 | ;------------------ |
---|
| 62 | w=where(abs(what_I_plot) gt missing_value) |
---|
| 63 | if (w(0) ne -1) then what_I_plot[w]=!Values.F_NAN |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | ;------------------ |
---|
| 67 | ; limits |
---|
| 68 | ;------------------ |
---|
| 69 | if (minfield_init*maxfield_init eq 0) then begin |
---|
| 70 | xrange=[min(what_I_plot),max(what_I_plot)] |
---|
| 71 | print, xrange |
---|
| 72 | endif else begin |
---|
| 73 | xrange=[minfield_init,maxfield_init] |
---|
| 74 | print, xrange |
---|
| 75 | endelse |
---|
| 76 | |
---|
| 77 | if (xrange(0)*xrange(1) eq 0) then begin |
---|
| 78 | print, 'nothing to plot ... skipping this plot ...' |
---|
| 79 | stop |
---|
| 80 | endif |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | ;--------------- |
---|
| 84 | ; adapt ticks |
---|
| 85 | ;--------------- |
---|
| 86 | ;intervalx=round((xrange(1)-xrange(0))/5.) |
---|
| 87 | ;intervaly=round(abs(max(column)-min(column))/5.) |
---|
| 88 | ;intervalx=5. |
---|
| 89 | ;intervaly=5. |
---|
| 90 | |
---|
| 91 | ;if (n_elements(intervalx) eq 0) then intervalx=round((xrange(1)-xrange(0))/8.) |
---|
| 92 | ;;if (n_elements(intervaly) eq 0) then intervaly=round((abs(max(column)-min(column))/5.)) |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | ;; ---------------------------- |
---|
| 96 | ;; manage the altitude range |
---|
| 97 | ;; ---------------------------- |
---|
| 98 | ;if (n_elements(alt) eq 2) then begin |
---|
| 99 | ; altmin=alt(0) |
---|
| 100 | ; altmax=alt(1) |
---|
| 101 | ; w=where((column ge altmin) and (column le altmax)) |
---|
| 102 | ; if (n_elements(intervaly) eq 0) then intervaly=(altmax-altmin)/5 |
---|
| 103 | ; if (w(0) ne -1) then begin |
---|
| 104 | ; column=column[w] |
---|
| 105 | ; what_I_plot=what_I_plot[w] |
---|
| 106 | ; minfield=min(what_I_plot) |
---|
| 107 | ; maxfield=max(what_I_plot) |
---|
| 108 | ; endif |
---|
| 109 | ;endif |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | ;------------- |
---|
| 114 | ; plot |
---|
| 115 | ;------------- |
---|
| 116 | plot, $ |
---|
| 117 | what_I_plot,column, $ |
---|
| 118 | xrange=xrange, $ |
---|
| 119 | ; yrange=[min(column),max(column)], $ |
---|
| 120 | yrange=alt, $ |
---|
| 121 | xtickinterval=intervalx, $ |
---|
| 122 | ytickinterval=intervaly, $ |
---|
| 123 | xtitle=xtitle, $ |
---|
| 124 | ytitle=ytitle,$ |
---|
| 125 | title=title_user,$ |
---|
| 126 | ;/ylog |
---|
| 127 | subtitle=mention |
---|
| 128 | |
---|
| 129 | ;------------- |
---|
| 130 | ; overplot |
---|
| 131 | ;------------- |
---|
| 132 | if (n_elements(discrete) ne 0) then begin |
---|
| 133 | if (discrete ne 0) then begin |
---|
| 134 | !psym=discrete |
---|
| 135 | oplot, $ |
---|
| 136 | what_I_plot,column |
---|
| 137 | !psym=0 |
---|
| 138 | endif |
---|
| 139 | endif |
---|
| 140 | |
---|
| 141 | if (n_elements(overplot) gt 1) then begin |
---|
| 142 | column_overplot=column |
---|
| 143 | w=where(abs(overplot) gt missing_value) |
---|
| 144 | if (w(0) ne -1) then overplot[w]=!Values.F_NAN |
---|
| 145 | if (n_elements(overplot_column) gt 1) then column_overplot=overplot_column |
---|
| 146 | oplot, $ |
---|
| 147 | overplot, column_overplot, $ |
---|
| 148 | linestyle=2 |
---|
| 149 | if (n_elements(discrete) ne 0) then begin |
---|
| 150 | !psym=discrete |
---|
| 151 | oplot, $ |
---|
| 152 | overplot,column_overplot |
---|
| 153 | !psym=0 |
---|
| 154 | endif |
---|
| 155 | endif |
---|
| 156 | |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | ;;-------------- |
---|
| 160 | ;; text inside |
---|
| 161 | ;;-------------- |
---|
| 162 | ;if (n_elements(mention) ne 0) then begin |
---|
| 163 | ; alignx=(max(what_I_plot)+min(what_I_plot))/2 |
---|
| 164 | ; aligny=max(column)-intervaly/2 |
---|
| 165 | ; xyouts, alignx, $ |
---|
| 166 | ; aligny, $ |
---|
| 167 | ; mention |
---|
| 168 | ;endif |
---|
| 169 | |
---|
| 170 | end |
---|