@@ -44,8 +44,11 @@ export function getUnitConvExpr({cname, from, to, alias, args=[]}) {
44
44
*/
45
45
export function getUnitInfo ( unit , cname ) {
46
46
cname = cname ?. match ( / ^ " ( .+ ) " $ / ) ?. [ 1 ] ?? cname ; // remove enclosing double-quotes if exists
47
+ // TODO: account aliases in the lookup
47
48
const meas = Object . values ( UnitXref . measurement ) . find ( ( m ) => m ?. options . find ( ( o ) => o ?. value === unit ) ) || { } ;
48
49
let label = meas . label ? sprintf ( meas . label , unit ) : '' ;
50
+
51
+ // use column name (or expression) if couldn't recognize the unit in options of each measurement
49
52
if ( ! label && cname ) {
50
53
label = cname + ( unit ? `[${ unit } ]` : '' ) ;
51
54
}
@@ -69,20 +72,28 @@ const UnitXref = {
69
72
options : [ { value : 'A' } , { value : 'nm' } , { value :'um' } , { value : 'mm' } , { value :'cm' } , { value :'m' } ] ,
70
73
label : 'λ [%s]'
71
74
} ,
72
- flux_density : {
73
- options : [ { value :'W/m^2/Hz' } , { value :'Jy' } ] ,
75
+ flux_density_frequency : {
76
+ options : [ { value :'W/m^2/Hz' } , { value :'erg/s/cm^2/Hz' } , { value : ' Jy'} ] ,
74
77
label : 'F𝛎 [%s]'
75
78
} ,
79
+ flux_density_wavelength : {
80
+ options : [ { value :'W/m^2/um' } , { value :'erg/s/cm^2/A' } ] ,
81
+ label : 'Fλ [%s]'
82
+ } ,
76
83
inband_flux : {
77
84
options : [ { value :'W/m^2' } , { value :'Jy*Hz' } ] ,
78
85
label : '𝛎*F𝛎 [%s]'
79
86
}
80
87
} ,
81
88
89
+ aliases : {
90
+ //TODO: add Angstrom, dot product notations of flux density, etc.
91
+ } ,
92
+
82
93
// Unit Conversions follow
83
94
// "outer" layer is the unit you *have*; "inner" layer is the unit you *want*
84
95
85
- // frequency
96
+ // frequency -------------
86
97
Hz : {
87
98
Hz : '%s' ,
88
99
KHz : '%s / 1000.0' ,
@@ -107,7 +118,7 @@ const UnitXref = {
107
118
MHz : '%s * 1000.0' ,
108
119
GHz : '%s'
109
120
} ,
110
- // wavelength
121
+ // wavelength -------------
111
122
A : {
112
123
A : '%s' ,
113
124
nm : '%s / 10' ,
@@ -156,25 +167,47 @@ const UnitXref = {
156
167
cm : '%s * 100' ,
157
168
m : '%s'
158
169
} ,
159
- // flux density
170
+ // flux density in frequency space -------------
160
171
'W/m^2/Hz' : {
161
172
'W/m^2/Hz' : '%s' ,
173
+ 'erg/s/cm^2/Hz' : '%s * 1.0E+3' ,
162
174
Jy : '%s * 1.0E+26' ,
163
175
} ,
176
+ 'erg/s/cm^2/Hz' : {
177
+ 'W/m^2/Hz' : '%s / 1.0E+3' ,
178
+ 'erg/s/cm^2/Hz' : '%s' ,
179
+ Jy : '%s * 1.0E+23' ,
180
+ } ,
164
181
Jy : {
165
- 'W/m^2/Hz' : '%s / 1.0E+26' ,
182
+ 'W/m^2/Hz' : '%s / 1.0E+26' , //SI units
183
+ 'erg/s/cm^2/Hz' : '%s / 1.0E+23' , //CGS units
166
184
Jy : '%s' ,
167
185
} ,
168
- // inband flux
186
+ // flux density in wavelength space -------------
187
+ 'erg/s/cm^2/A' : {
188
+ 'erg/s/cm^2/A' : '%s' ,
189
+ 'W/m^2/um' : '%s * 10'
190
+ } ,
191
+ 'W/m^2/um' : {
192
+ 'erg/s/cm^2/A' : '%s / 10' ,
193
+ 'W/m^2/um' : '%s' ,
194
+ } ,
195
+ // inband flux (independent of frequency or wavelength) -------------
169
196
'W/m^2' : {
170
197
'W/m^2' : '%s' ,
198
+ 'erg/s/cm^2' : '%s * 1.0E+3' ,
171
199
'Jy*Hz' : '%s * 1.0E+26' ,
172
200
} ,
201
+ 'erg/s/cm^2' : {
202
+ 'W/m^2' : '%s / 1.0E+3' ,
203
+ 'erg/s/cm^2' : '%s' ,
204
+ 'Jy*Hz' : '%s * 1.0E+23' ,
205
+ } ,
173
206
'Jy*Hz' : {
174
207
'W/m^2' : '%s / 1.0E+26' ,
208
+ 'erg/s/cm^2' : '%s / 1.0E+23' ,
175
209
'Jy*Hz' : '%s' ,
176
- }
177
-
210
+ } ,
178
211
} ;
179
212
180
213
/**
0 commit comments