Last change
on this file since 1 was
1,
checked in by cholod, 12 years ago
|
importing initial nemo vendor drop (v3.4_r_3220)
|
File size:
1.2 KB
|
Line | |
---|
1 | function nice_contourlevels, data, nlevels=nlevels |
---|
2 | ;+---------------------------------------------------------------------------------------- |
---|
3 | ; nice_contourlevels.pro |
---|
4 | ; |
---|
5 | ; Select nice contour levels based on the data input and the number of levels |
---|
6 | ; |
---|
7 | ; Author: D. J. Lea - Feb 2008 |
---|
8 | ; |
---|
9 | ;+---------------------------------------------------------------------------------------- |
---|
10 | |
---|
11 | if (n_elements(nlevels) eq 0) then nlevels=15 |
---|
12 | |
---|
13 | mx=max(data) |
---|
14 | mn=min(data) |
---|
15 | |
---|
16 | ; use this to select colors to plot and labels |
---|
17 | |
---|
18 | clevels=findgen(nlevels)/nlevels*(mx-mn)+mn |
---|
19 | |
---|
20 | ocint=1./nlevels*(mx-mn) |
---|
21 | print,'ocint ',ocint |
---|
22 | |
---|
23 | ; contour interval at 2 sig figs |
---|
24 | ;digits=2 |
---|
25 | ;p10 = floor(alog10(abs(ocint))) |
---|
26 | ;expo = 10.0d^(digits -1 - p10) |
---|
27 | ;cint = long(ocint*expo)/expo |
---|
28 | ;print,'cint ',cint |
---|
29 | |
---|
30 | ;does it end in 5 or 0? |
---|
31 | digits=1 |
---|
32 | p10 = floor(alog10(abs(ocint))) |
---|
33 | expo = 10.0d^(digits -1 - p10) |
---|
34 | cint = long(ocint*expo)/expo |
---|
35 | print,'cint ',cint |
---|
36 | |
---|
37 | if (mx ne mn) then begin |
---|
38 | mxfix=fix(mx/cint)*cint |
---|
39 | mnfix=fix(mn/cint)*cint |
---|
40 | print, mx, mxfix |
---|
41 | print, mn, mnfix |
---|
42 | |
---|
43 | ; nice contour values |
---|
44 | |
---|
45 | ;calculate new nlevels |
---|
46 | nlevels=fix((mxfix-mnfix)/cint+1) |
---|
47 | |
---|
48 | ;print,nlevels |
---|
49 | if (nlevels gt 0) then begin |
---|
50 | clevels=findgen(nlevels)*cint+mnfix |
---|
51 | endif else begin |
---|
52 | clevels=mnfix |
---|
53 | endelse |
---|
54 | endif else begin |
---|
55 | clevels=mn |
---|
56 | endelse |
---|
57 | |
---|
58 | return, clevels |
---|
59 | |
---|
60 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.