dstmwrp_exp.pro
1.88 KB
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
FUNCTION dstmwrp_exp, axis, index, number
;+
; NAME:
; dstmwrp_exp
;
; PURPOSE:
; Returns formatted string for exponents in graphical output
;
; CATEGORY:
; DustEMWrap, Distributed, LowLevel, Plotting
;
; CALLING SEQUENCE:
; dstmwrp_exp, axis, index, number
;
; INPUTS:
; axis : deprecated but kept for backwards compatibility
; index : deprecated but kept for backwards compatibility
; number : value to be converted to exponential as formatted string
;
; OPTIONAL INPUT PARAMETERS:
; None
;
; OUTPUTS:
; exponential as formatted string
;
; OPTIONAL OUTPUT PARAMETERS:
;
; ACCEPTED KEY-WORDS:
;
; COMMON BLOCKS:
; None
;
; SIDE EFFECTS:
;
; RESTRICTIONS:
; The DustEMWrap IDL code must be installed
;
; PROCEDURES AND SUBROUTINES USED:
;
; EXAMPLES
; expstr=dstmwrp_exp(axis, index, 15000.)
;
; MODIFICATION HISTORY:
; Written by IC
; Evolution details on the DustEMWrap gitlab.
; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
;-
;A special case.
IF number EQ 0 THEN RETURN, '0'
; Assuming multiples of 10 with format.
ex = String(number, Format='(e8.0)')
pt = StrPos(ex, '.')
first = StrMid(ex, 0, pt)
sign = StrMid(ex, pt+2, 1)
thisExponent = StrMid(ex, pt+3)
; Shave off leading zero in exponent
WHILE StrMid(thisExponent, 0, 1) EQ '0' DO thisExponent = StrMid(thisExponent, 1)
; Fix for sign and missing zero problem.
IF (Long(thisExponent) EQ 0) THEN BEGIN
sign = ''
thisExponent = '0'
ENDIF
frmt = '10!U'
IF !dustem_mlog then frmt='-'+frmt
; Make the exponent a superscript.
IF sign EQ '-' THEN BEGIN
IF first EQ 1 then RETURN, frmt + sign + thisExponent + '!N' ELSE RETURN, first + 'x' + frmt + sign + thisExponent + '!N'
ENDIF ELSE BEGIN
IF first EQ 1 then RETURN, frmt + thisExponent + '!N' ELSE RETURN, first + 'x' + frmt + thisExponent + '!N'
ENDELSE
the_end:
END