-
Notifications
You must be signed in to change notification settings - Fork 0
/
exrange.pro
51 lines (47 loc) · 1.71 KB
/
exrange.pro
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
;-------------------------------------------------------------
;+
; NAME:
; EXRANGE
; PURPOSE:
; Return a range array with range expanded by given fraction.
; CATEGORY:
; CALLING SEQUENCE:
; b = exrange(a, f)
; INPUTS:
; a = array. in
; KEYWORD PARAMETERS:
; OUTPUTS:
; b = [mn-, mx+] out
; where mn- = min(a) - f*d
; mx+ = max(a) + f*d
; d = max(a) - min(a)
; COMMON BLOCKS:
; NOTES:
; MODIFICATION HISTORY:
; R. Sterner, 7 Sep, 1989.
;
; Copyright (C) 1989, Johns Hopkins University/Applied Physics Laboratory
; This software may be used, copied, or redistributed as long as it is not
; sold and this copyright notice is reproduced on each copy made. This
; routine is provided as is without any express or implied warranties
; whatsoever. Other limitations apply as described in the file disclaimer.txt.
;-
;-------------------------------------------------------------
function exrange, x, f, help=hlp
if (n_params(0) lt 1) or keyword_set(hlp) then begin
print,' Return a range array with range expanded by given fraction.'
print,' b = exrange(a, f)'
print,' a = numeric input array. in'
print,' f = fraction to expand array range (def=0).'
print,' b = adjusted 2-element range of array. out'
print,' Min and max of array if adjusted by given fraction'
print,' of the total range to give: [min(a)-f*d,max(a)+f*d]'
print,' where d = max(a) - min(a)'
print,' Notes: if fraction f not given the array extremes are'
print,' returned: [min(a), max(a)].'
return, -1
end
d = max(x) - min(x)
if n_elements(f) eq 0 then f=0.
return, [min(x)-f*d, max(x)+f*d]
end