New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
nice_contourlevels.pro in branches/UKMO/r6232_tracer_advection/NEMOGCM/TOOLS/OBSTOOLS/dataplot – NEMO

source: branches/UKMO/r6232_tracer_advection/NEMOGCM/TOOLS/OBSTOOLS/dataplot/nice_contourlevels.pro @ 9295

Last change on this file since 9295 was 3002, checked in by djlea, 13 years ago

Update documentation for obstools and dataplot. Removal of dataplot code not needed. Addition of headers to some dataplot code. Addition of .exe to command example in obstools.

File size: 1.2 KB
Line 
1function 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
11if (n_elements(nlevels) eq 0) then nlevels=15
12
13mx=max(data)
14mn=min(data)
15
16; use this to select colors to plot and labels
17
18clevels=findgen(nlevels)/nlevels*(mx-mn)+mn
19
20ocint=1./nlevels*(mx-mn)
21print,'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?
31digits=1
32p10 = floor(alog10(abs(ocint)))
33expo = 10.0d^(digits -1 - p10)
34cint = long(ocint*expo)/expo
35print,'cint ',cint
36
37if (mx ne mn) then begin
38mxfix=fix(mx/cint)*cint
39mnfix=fix(mn/cint)*cint
40print, mx, mxfix
41print, mn, mnfix
42
43; nice contour values
44
45;calculate new nlevels
46nlevels=fix((mxfix-mnfix)/cint+1)
47
48;print,nlevels
49if (nlevels gt 0) then begin
50   clevels=findgen(nlevels)*cint+mnfix
51endif else begin
52   clevels=mnfix
53endelse
54endif else begin
55   clevels=mn
56endelse
57
58return, clevels
59
60end
Note: See TracBrowser for help on using the repository browser.