4 #include <UnitTest++.h>
16 Flux Ferg_s_cm20(E,1.);
17 CHECK(
fp_equal( Ferg_s_cm20.get(), 1. ) );
18 Flux Ferg_s_cm21(E,1.,
"erg/s/cm2");
19 CHECK(
fp_equal( Ferg_s_cm21.get(), 1. ) );
20 Flux Ferg_s_cm2_A(E,1.,
"erg/s/cm2/A");
21 CHECK(
fp_equal( Ferg_s_cm2_A.get(), E.Angstrom() ) );
22 Flux Ferg_s_cm2_micron(E,1.,
"erg/s/cm2/micron");
23 CHECK(
fp_equal( Ferg_s_cm2_micron.get(), E.micron() ) );
24 Flux Ferg_s_cm2_Hz(E,1.,
"erg/s/cm2/Hz");
25 CHECK(
fp_equal( Ferg_s_cm2_Hz.get(), E.Hz() ) );
26 Flux FW_m2(E,1.,
"W/m2");
27 CHECK(
fp_equal( FW_m2.get(), 1.e3 ) );
28 Flux FW_m2_A(E,1.,
"W/m2/A");
29 CHECK(
fp_equal( FW_m2_A.get(), 1.e3*E.Angstrom() ) );
30 Flux FW_m2_nm(E,1.,
"W/m2/nm");
31 CHECK(
fp_equal( FW_m2_nm.get(), 1.e3*E.nm() ) );
32 Flux FW_m2_micron(E,1.,
"W/m2/micron");
33 CHECK(
fp_equal( FW_m2_micron.get(), 1.e3*E.micron() ) );
34 Flux FW_m2_Hz(E,1.,
"W/m2/Hz");
35 CHECK(
fp_equal( FW_m2_Hz.get(), 1.e3*E.Hz() ) );
36 Flux FW_cm2(E,1.,
"W/cm2");
37 CHECK(
fp_equal( FW_cm2.get(), 1.e7 ) );
38 Flux FW_cm2_A(E,1.,
"W/cm2/A");
39 CHECK(
fp_equal( FW_cm2_A.get(), 1.e7*E.Angstrom() ) );
40 Flux FW_cm2_micron(E,1.,
"W/cm2/micron");
41 CHECK(
fp_equal( FW_cm2_micron.get(), 1.e7*E.micron() ) );
42 Flux FW_cm2_Hz(E,1.,
"W/cm2/Hz");
43 CHECK(
fp_equal( FW_cm2_Hz.get(), 1.e7*E.Hz() ) );
44 Flux FW_cm2_Hz_sr(E,1.,
"W/cm2/Hz/sr");
45 CHECK(
fp_equal( FW_cm2_Hz_sr.get(), 1.e7*E.Hz()*PI4 ) );
46 Flux FW_cm2_Hz_arcsec2(E,1.,
"W/cm2/Hz/arcsec2");
47 CHECK(
fp_equal( FW_cm2_Hz_arcsec2.get(), 1.e7*E.Hz()*SQAS_SKY ) );
49 CHECK(
fp_equal( FJy.get(), 1.e-23*E.Hz() ) );
50 Flux FmJy(E,1.,
"mJy");
51 CHECK(
fp_equal( FmJy.get(), 1.e-26*E.Hz() ) );
52 Flux FMJy_sr(E,1.,
"MJy/sr");
53 CHECK(
fp_equal( FMJy_sr.get(), 1.e-17*E.Hz()*PI4 ) );
62 CHECK_EQUAL(
"erg/s/cm2", F.
uu() );
64 F.
set(E,10.,
"erg/s/cm2");
66 CHECK_EQUAL(
"erg/s/cm2", F.
uu() );
68 F.
set(E,10.,
"erg/s/cm2/A");
70 CHECK_EQUAL(
"erg/s/cm2/A", F.
uu() );
72 F.
set(E,10.,
"erg/s/cm2/micron");
74 CHECK_EQUAL(
"erg/s/cm2/micron", F.
uu() );
76 F.
set(E,10.,
"erg/s/cm2/Hz");
78 CHECK_EQUAL(
"erg/s/cm2/Hz", F.
uu() );
82 CHECK_EQUAL(
"W/m2", F.
uu() );
84 F.
set(E,10.,
"W/m2/A");
86 CHECK_EQUAL(
"W/m2/A", F.
uu() );
88 F.
set(E,10.,
"W/m2/nm");
90 CHECK_EQUAL(
"W/m2/nm", F.
uu() );
92 F.
set(E,10.,
"W/m2/micron");
94 CHECK_EQUAL(
"W/m2/micron", F.
uu() );
96 F.
set(E,10.,
"W/m2/Hz");
98 CHECK_EQUAL(
"W/m2/Hz", F.
uu() );
100 F.
set(E,10.,
"W/cm2");
102 CHECK_EQUAL(
"W/cm2", F.
uu() );
104 F.
set(E,10.,
"W/cm2/A");
106 CHECK_EQUAL(
"W/cm2/A", F.
uu() );
108 F.
set(E,10.,
"W/cm2/micron");
110 CHECK_EQUAL(
"W/cm2/micron", F.
uu() );
112 F.
set(E,10.,
"W/cm2/Hz");
114 CHECK_EQUAL(
"W/cm2/Hz", F.
uu() );
116 F.
set(E,10.,
"W/cm2/Hz/sr");
118 CHECK_EQUAL(
"W/cm2/Hz/sr", F.
uu() );
120 F.
set(E,10.,
"W/cm2/Hz/arcsec2");
121 CHECK(
fp_equal( F.
get(), 1.e8*E.Hz()*SQAS_SKY ) );
122 CHECK_EQUAL(
"W/cm2/Hz/arcsec2", F.
uu() );
126 CHECK_EQUAL(
"Jy", F.
uu() );
130 CHECK_EQUAL(
"mJy", F.
uu() );
132 F.
set(E,10.,
"MJy/sr");
134 CHECK_EQUAL(
"MJy/sr", F.
uu() );
142 CHECK(
fp_equal( F.
get(
"erg/s/cm2/A"), 1./E.Angstrom() ) );
143 CHECK(
fp_equal( F.
get(
"erg/s/cm2/micron"), 1./E.micron() ) );
144 CHECK(
fp_equal( F.
get(
"erg/s/cm2/Hz"), 1./E.Hz() ) );
146 CHECK(
fp_equal( F.
get(
"W/m2/A"), 1.e-3/E.Angstrom() ) );
147 CHECK(
fp_equal( F.
get(
"W/m2/micron"), 1.e-3/E.micron() ) );
148 CHECK(
fp_equal( F.
get(
"W/m2/Hz"), 1.e-3/E.Hz() ) );
150 CHECK(
fp_equal( F.
get(
"W/cm2/A"), 1.e-7/E.Angstrom() ) );
151 CHECK(
fp_equal( F.
get(
"W/cm2/nm"), 1.e-7/E.nm() ) );
152 CHECK(
fp_equal( F.
get(
"W/cm2/micron"), 1.e-7/E.micron() ) );
153 CHECK(
fp_equal( F.
get(
"W/cm2/Hz"), 1.e-7/E.Hz() ) );
154 CHECK(
fp_equal( F.
get(
"W/cm2/Hz/sr"), 1.e-7/E.Hz()/PI4 ) );
155 CHECK(
fp_equal( F.
get(
"W/cm2/Hz/arcsec2"), 1.e-7/E.Hz()/SQAS_SKY ) );
158 CHECK(
fp_equal( F.
get(
"MJy/sr"), 1.e17/E.Hz()/PI4 ) );
161 TEST(TestFluxUnitConversion)
186 TEST(TestValidFluxUnit)
200 TEST(TestEnergyFluxParser1)
203 strcpy( chCard,
"OPTIMIZE FLUX 0.03 RYD 24 ERG/S/SQCM/MICRON" );
211 CHECK(
fp_equal( F.
get(
"erg/s/cm2/micron"), 24. ) );
214 TEST(TestEnergyFluxParser2)
217 strcpy( chCard,
"OPTIMIZE FLUX 12 MICRON 24 ERG/S/SQCM" );
224 CHECK(
fp_equal( E.micron(), 12. ) );
228 TEST(TestEnergyFluxParser3)
231 strcpy( chCard,
"OPTIMIZE FLUX 12E-14 ERG 24 W/SQCM" );
238 CHECK(
fp_equal( E.Erg(), 12.e-14 ) );
void setline(const char *const card)
bool ValidFluxUnit(const string &unit)
bool fp_equal(sys_float x, sys_float y, int n=3)
string StandardFluxUnit(void) const
double energy(const genericState &gs)
const char * StandardEnergyUnit(void) const
string StandardFluxUnit(const char *chCard)
void set(Energy e, double flux)