00001
00002
00003
00004 #ifndef FLUX_H_
00005 #define FLUX_H_
00006
00007 #include "energy.h"
00008
00009 class Flux
00010 {
00011 typedef enum {
00012 FU_NONE, FU_ERG_S, FU_W, FU_JY, FU_MJY, FU_MJY_SR, FU_CM2,
00013 FU_M2, FU_A, FU_NM, FU_MU, FU_HZ, FU_SR, FU_SQAS, FU_TOP
00014 } fu_flag;
00015 typedef bitset<FU_TOP> fu_bits;
00016
00017 Energy p_energy;
00018 double p_flux;
00019 fu_bits p_userunits;
00020
00021 fu_bits p_InternalFluxUnitNoCheck(const string& unit, size_t& len) const;
00022 fu_bits p_InternalFluxUnit(const string& unit) const;
00023 bool p_ValidFluxUnit(fu_bits) const;
00024 void p_set(Energy e, double value, fu_bits bits);
00025 double p_get(fu_bits bits) const;
00026 public:
00027
00028 Flux()
00029 {
00030 set(0., 0.);
00031 p_userunits.reset();
00032 }
00033 Flux(Energy e, double flux)
00034 {
00035 set(e, flux);
00036 }
00037 Flux(Energy e, double flux, const string& unit)
00038 {
00039 set(e, flux, unit);
00040 }
00041
00042 void set(Energy e, double flux)
00043 {
00044 set( e, flux, "erg/s/cm2" );
00045 }
00046 void set(Energy e, double flux, const string& unit)
00047 {
00048 p_set( e, flux, p_InternalFluxUnit(unit) );
00049 }
00050
00051 double get() const
00052 {
00053 return p_flux;
00054 }
00055 double get(const string& unit) const
00056 {
00057 return p_get( p_InternalFluxUnit(unit) );
00058 }
00059 Energy E() const
00060 {
00061 return p_energy;
00062 }
00063 string uu() const;
00064 friend inline bool ValidFluxUnit(const string& unit);
00065 };
00066
00067
00068 string StandardFluxUnit(const char*);
00069
00070
00071 inline bool ValidFluxUnit(const string& unit)
00072 {
00073 Flux f;
00074 size_t p;
00075 Flux::fu_bits bits = f.p_InternalFluxUnitNoCheck(unit,p);
00076 return ( p == unit.length() && f.p_ValidFluxUnit(bits) );
00077 }
00078
00079 #endif