File: test_plot_inf_nan.pro

package info (click to toggle)
gnudatalanguage 1.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 80,368 kB
  • sloc: cpp: 189,797; ansic: 46,721; sh: 677; python: 474; makefile: 146; xml: 69; f90: 28
file content (110 lines) | stat: -rw-r--r-- 2,571 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
;
; AC, June 2007
;
; please run the last procedure "TEST_PLOT_INFO" to have informations 
; about all the routines testing PLOT ...
;
; How are managed NaN and Inf in PLOT ?
;
pro PLOT_INF_NAN, nan=nan, inf=inf, psym=psym, $
                  position=position, verbose=verbose
;
; the keywrod "position" is used to put the Nan or Inf at
; a given position in the array --> may affect plot if bug in MinMax
; procedure to check the min/max boudaries of the plot scale.
;
problem=0.
if KEYWORD_SET(nan) then problem=!values.f_nan
if KEYWORD_SET(inf) then problem=!values.f_infinity
if (problem EQ 0.) then begin
    print, 'Must select /Nan or /Inf'
    return
endif
;
if N_ELEMENTS(position) EQ 0 then position=4
;
if KEYWORD_SET(verbose) then begin
    print, 'Type of Problem: ', problem
    print, 'Position: ', position
endif
;
a=findgen(10)
a=a^2
a[position]=problem
if KEYWORD_SET(verbose) then begin
    print, 'Min, no check on /Nan', min(a)
    print, 'Max, no check on /Nan', max(a)
    print, 'Min, check on /Nan', min(a,/nan)
    print, 'Max, check on /Nan', max(a,/nan)
endif
plot, a, title=STRUPCASE(STRING(problem))+' case', psym=psym
;
;
if KEYWORD_SET(verbose) then begin
    print, '!x.crange: ', !x.crange
    print, '!y.crange: ', !y.crange
endif
;
end
;
; ------------------------------------
;
pro TEST_PLOT_TRICK, nan=nan, inf=inf
;
; Same as PLOT_INF_NAN but more direct !
; (with peculiar tests for Min/Max (NaN or Inf at beginning or end of arrays))
;
problem=0.
if KEYWORD_SET(nan) then problem=!values.f_nan
if KEYWORD_SET(inf) then problem=!values.f_infinity
if (problem EQ 0.) then begin
    print, 'Must select /Nan or /Inf'
    return
endif
;
!p.multi=[0,2,3]
window, xsize=600, ysize=900
;
a=findgen(10)
x=a
y=a^2
y[1]=problem
plot,y, psym=-2, title='No problem in X'
plot, x,y, psym=-2, title='Possible problem in X'
;
x=a
y=a^2
x[0]=problem
x[9]=problem
plot, y, psym=-4, title='No problem'
plot,x,y, psym=-4, title='X problem at (0 and last)'
;
x=a
y=a^2
y[0]=problem
y[9]=problem
plot, y, psym=-4, title='Problem for Y (0 and last)'
plot,x,y, psym=-4, title='X and Y problems at (0 and last)'
;
!p.multi=0
;
end
;
; -----------------------------------------------------
;
pro TEST_PLOT_INF_NAN, psym=psym, verbose=verbose
;
print, 'pro TEST_PLOT_INF_NAN, psym=psym, verbose=verbose'
;
WINDOW,0
PLOT_INF_NAN, /nan, psym=psym, verbose=verbose
WINDOW,2
PLOT_INF_NAN, /nan, psym=psym, pos=0, verbose=verbose
;
WINDOW,1
PLOT_INF_NAN, /inf, psym=psym, verbose=verbose
WINDOW,3
PLOT_INF_NAN, /inf, psym=psym, pos=0, verbose=verbose
;
end
;