Changeset 16969 for trunk/FACT++/src


Ignore:
Timestamp:
07/21/13 17:04:15 (11 years ago)
Author:
tbretz
Message:
Fixed a stupid bug: ln__equ_posn stores RS in degree not in hours, therefore the result of Angle() was wrong
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/makedata.cc

    r16379 r16969  
    77
    88using namespace std;
    9 
    10 // ------------------------------------------------------------------------
    11 
    12 double Angle(double ra, double dec, double r, double d)
    13 {
    14     const double theta0 = M_PI/2-d*M_PI/180;
    15     const double phi0   = r*M_PI/12;
    16 
    17     const double theta1 = M_PI/2-dec*M_PI/180;
    18     const double phi1   = ra*M_PI/12;
    19 
    20     const double x0 = sin(theta0) * cos(phi0);
    21     const double y0 = sin(theta0) * sin(phi0);
    22     const double z0 = cos(theta0);
    23 
    24     const double x1 = sin(theta1) * cos(phi1);
    25     const double y1 = sin(theta1) * sin(phi1);
    26     const double z1 = cos(theta1);
    27 
    28     double arg = x0*x1 + y0*y1 + z0*z1;
    29     if(arg >  1.0) arg =  1.0;
    30     if(arg < -1.0) arg = -1.0;
    31 
    32     return acos(arg) * 180/M_PI;
    33 }
     9using namespace Nova;
    3410
    3511// ========================================================================
     
    9268    // ------------------ Eval config ---------------------
    9369
    94     const double lon = -(17.+53./60+26.525/3600);
    95     const double lat =   28.+45./60+42.462/3600;
    96 
    97     ln_lnlat_posn observer;
    98     observer.lng = lon;
    99     observer.lat = lat;
    100 
    10170    Time time;
    10271    if (conf.Has("date-time"))
     
    10877
    10978    // -12: nautical
    110     ln_rst_time sun_set;   // Sun set with the same date than th provided date
    111     ln_rst_time sun_rise;  // Sun rise on the following day
    112     ln_get_solar_rst_horizon(time.JD()-0.5, &observer, -12, &sun_set);
    113     ln_get_solar_rst_horizon(time.JD()+0.5, &observer, -12, &sun_rise);
     79    const RstTime sun_set  = GetSolarRst(time.JD()-0.5, -12);   // Sun set with the same date than th provided date
     80    const RstTime sun_rise = GetSolarRst(time.JD()+0.5, -12);  // Sun rise on the following day
    11481
    11582    const double jd  = floor(time.Mjd())+2400001;
     
    13299    // ------------------ Precalc moon coord ---------------------
    133100
    134     vector<pair<ln_equ_posn, double>> fMoonCoords;
     101    vector<pair<EquPosn, double>> fMoonCoords;
    135102
    136103    for (double h=0; h<1; h+=1./(24*12))
    137104    {
    138         ln_equ_posn  moon;
    139         ln_get_lunar_equ_coords_prec(jd+h, &moon, 0.01);
    140 
    141         const double disk = ln_get_lunar_disk(jd+h);
     105        const EquPosn moon = GetLunarEquCoords(jd+h);
     106        const double  disk = GetLunarDisk(jd+h);
    142107
    143108        fMoonCoords.emplace_back(moon, disk);
     
    155120        return 1;
    156121
    157     Nova::EquPosn pos;
     122    EquPosn pos;
    158123    pos.ra  = double((*row)[0])*15;
    159124    pos.dec = double((*row)[1]);
     
    169134
    170135        // get local position of source
    171         const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(pos, jd+h);
     136        const HrzPosn hrz = GetHrzFromEqu(pos, jd+h);
    172137
    173138        // Get moon properties and
    174         const Nova::EquPosn moon = fMoonCoords[i].first;
    175         const double disk = fMoonCoords[i].second;
    176 
    177         const Nova::HrzPosn hrzm = Nova::GetHrzFromEqu(moon, jd+h);
     139        const EquPosn moon = fMoonCoords[i].first;
     140        const double  disk = fMoonCoords[i].second;
     141        const HrzPosn hrzm = GetHrzFromEqu(moon, jd+h);
    178142
    179143        // Distance between source and moon
    180         const double angle = Angle(moon.ra, moon.dec, pos.ra, pos.dec);
     144        const double angle = GetAngularSeparation(moon, pos);
    181145
    182146        // Current prediction
  • trunk/FACT++/src/makeplots.cc

    r16379 r16969  
    1313
    1414using namespace std;
     15using namespace Nova;
    1516
    1617// ------------------------------------------------------------------------
    17 
    18 double Angle(double ra, double dec, double r, double d)
    19 {
    20     const double theta0 = M_PI/2-d*M_PI/180;
    21     const double phi0   = r*M_PI/12;
    22 
    23     const double theta1 = M_PI/2-dec*M_PI/180;
    24     const double phi1   = ra*M_PI/12;
    25 
    26     const double x0 = sin(theta0) * cos(phi0);
    27     const double y0 = sin(theta0) * sin(phi0);
    28     const double z0 = cos(theta0);
    29 
    30     const double x1 = sin(theta1) * cos(phi1);
    31     const double y1 = sin(theta1) * sin(phi1);
    32     const double z1 = cos(theta1);
    33 
    34     double arg = x0*x1 + y0*y1 + z0*z1;
    35     if(arg >  1.0) arg =  1.0;
    36     if(arg < -1.0) arg = -1.0;
    37 
    38     return acos(arg) * 180/M_PI;
    39 }
    4018
    4119void CheckForGap(TCanvas &c, TGraph &g, double axis)
     
    131109    // Sun set with the same date than th provided date
    132110    // Sun rise on the following day
    133     const Nova::RstTime sun_set  = Nova::GetSolarRst(time.JD()-0.5, -12);
    134     const Nova::RstTime sun_rise = Nova::GetSolarRst(time.JD()+0.5, -12);
     111    const RstTime sun_set  = GetSolarRst(time.JD()-0.5, -12);
     112    const RstTime sun_rise = GetSolarRst(time.JD()+0.5, -12);
    135113
    136114    const double jd  = floor(time.Mjd())+2400001;
     
    149127    // ------------------ Precalc moon coord ---------------------
    150128
    151     vector<pair<Nova::EquPosn, double>> fMoonCoords;
     129    vector<pair<EquPosn, double>> fMoonCoords;
    152130
    153131    for (double h=0; h<1; h+=1./(24*12))
    154132    {
    155         const Nova::EquPosn moon = Nova::GetLunarEquCoords(jd+h, 0.01);
    156 
    157         const double disk = Nova::GetLunarDisk(jd+h);
     133        const EquPosn moon = GetLunarEquCoords(jd+h, 0.01);
     134        const double  disk = GetLunarDisk(jd+h);
    158135
    159136        fMoonCoords.emplace_back(moon, disk);
     
    249226        const string name = (*v)[0].c_str();
    250227
    251         Nova::EquPosn pos;
     228        EquPosn pos;
    252229        pos.ra  = double((*v)[1])*15;
    253230        pos.dec = double((*v)[2]);
     
    287264
    288265            // get local position of source
    289             const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(pos, jd+h);
     266            const HrzPosn hrz = GetHrzFromEqu(pos, jd+h);
    290267
    291268            // Get moon properties and
    292             const Nova::EquPosn moon = fMoonCoords[i].first;
    293             const double disk = fMoonCoords[i].second;
    294 
    295             const Nova::HrzPosn hrzm = Nova::GetHrzFromEqu(moon, jd+h);
     269            const EquPosn moon = fMoonCoords[i].first;
     270            const double  disk = fMoonCoords[i].second;
     271            const HrzPosn hrzm = GetHrzFromEqu(moon, jd+h);
    296272
    297273            if (v==res.begin())
     
    299275
    300276            // Distance between source and moon
    301             const double angle = Angle(moon.ra, moon.dec, pos.ra, pos.dec);
     277            const double angle = GetAngularSeparation(moon, pos);
    302278
    303279            // Current prediction
Note: See TracChangeset for help on using the changeset viewer.