Ignore:
Timestamp:
08/13/14 12:50:36 (10 years ago)
Author:
tbretz
Message:
Make use of new central current prediction.
File:
1 edited

Legend:

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

    r17668 r17957  
    1 #include "externals/nova.h"
     1#include "externals/Prediction.h"
    22
    33#include "Database.h"
     
    121121    cout << "Rise: " << Time(sun_rise.rise) << endl;
    122122
    123     const double jd0 = fmod(sun_set.set,   1);   // ~0.3
    124     const double jd1 = fmod(sun_rise.rise, 1);   // ~0.8
     123    const double sunset  = sun_set.set;
     124    const double sunrise = sun_rise.rise;
    125125
    126126    const string fDatabase = conf.Get<string>("source-database");
    127127
    128     // ------------------ Precalc moon coord ---------------------
    129 
    130     vector<tuple<EquPosn, double, double>> fMoonCoords;
    131     vector<EquPosn> fSunCoords;
     128    // ------------------ Precalc coord ---------------------
     129
     130    vector<SolarObjects> fCoordinates;
    132131
    133132    for (double h=0; h<1; h+=1./(24*12))
    134     {
    135         const EquPosn sun  = GetSolarEquCoords(jd+h);
    136         const EquPosn moon = GetLunarEquCoords(jd+h, 0.01);
    137         const double  disk = GetLunarDisk(jd+h);
    138         const double edist = GetLunarEarthDist(jd+h)/384400;
    139 
    140         fMoonCoords.emplace_back(moon, disk, edist);
    141         fSunCoords.emplace_back(sun);
    142     }
     133        if (jd+h>sunset && jd+h<sunrise)
     134            fCoordinates.emplace_back(jd+h);
    143135
    144136    // ------------- Get Sources from databasse ---------------------
     
    152144    // 1970-01-01 00:00:00. This one will not work if your
    153145    // local time zone is positive!
    154     TH1S hframe("", "", 1, (mjd+jd0)*24*3600, (mjd+jd1)*24*3600);
     146    TH1S hframe("", "", 1, Time(sunset).Mjd()*24*3600, Time(sunrise).Mjd()*24*3600);
    155147    hframe.SetStats(kFALSE);
    156148    hframe.GetXaxis()->SetTimeFormat("%Hh%M%F1995-01-01 00:00:00 GMT");
     
    262254
    263255        // Loop over 24 hours
    264         int i=0;
    265         for (double h=0; h<1; h+=1./(24*12), i++)
     256        for (auto it=fCoordinates.begin(); it!=fCoordinates.end(); it++)
    266257        {
    267             // check if it is betwene sun-rise and sun-set
    268             if (h<jd0 || h>jd1)
    269                 continue;
    270 
    271258            // get local position of source
    272             const HrzPosn hrz = GetHrzFromEqu(pos, jd+h);
    273 
    274             // Get sun and moon properties and
    275             const EquPosn  sun   = fSunCoords[i];
    276             const EquPosn  moon  = get<0>(fMoonCoords[i]);
    277             const double   disk  = get<1>(fMoonCoords[i]);
    278             const double   edist = get<2>(fMoonCoords[i]);
    279             const HrzPosn  hrzm  = GetHrzFromEqu(moon, jd+h);
    280             const ZdAzPosn hrzs  = GetHrzFromEqu(sun,  jd+h);
     259            const HrzPosn hrz = GetHrzFromEqu(pos, it->fJD);
    281260
    282261            if (v==res.begin())
    283                 cout << Time(jd+h) <<" " << 90-hrzm.alt <<  endl;
    284 
    285             // Distance between source and moon
    286             const double angle = GetAngularSeparation(moon, pos);
    287 
    288             // Current prediction
    289             const double sin_malt  = hrzm.alt<0 ? 0 : sin(hrzm.alt*M_PI/180);
    290             const double cos_mdist = cos(angle*M_PI/180);
    291             const double sin_szd   = sin(hrzs.zd*M_PI/180);
    292 
    293             const double k0 = pow(disk,      2.63);
    294             const double k1 = pow(sin_malt,  0.60);
    295             const double k2 = pow(edist,    -2.00);
    296             const double k3 = exp(0.67*cos_mdist*cos_mdist*cos_mdist*cos_mdist);
    297             const double k4 = exp(-97.8+105.8*sin_szd*sin_szd);
    298 
    299             const double cur = 6.2 + 95.7*k0*k1*k2*k3 + k4;
     262                cout << Time(it->fJD) <<" " << 90-it->fMoonHrz.alt <<  endl;
     263
     264            const double cur = FACT::PredictI(*it, pos);
    300265
    301266            // Relative  energy threshold prediction
    302             //const double cs = cos((90+hrz.alt)*M_PI/180);
    303             //const double ratio = (10.*sqrt(409600.*cs*cs+9009.) + 6400.*cs - 60.)/10.;
    304267            const double ratio = pow(cos((90-hrz.alt)*M_PI/180), -2.664);
    305268
    306269            // Add points to curve
    307             const double axis = (mjd+h)*24*3600;
     270            const double axis = Time(it->fJD).Mjd()*24*3600;
    308271
    309272            // If there is a gap of more than one bin, start a new curve
     
    325288
    326289            if (no_limits || (cur<max_current && 90-hrz.alt<max_zd))
     290            {
     291                const double angle = GetAngularSeparation(it->fMoonEqu, pos);
    327292                g4.SetPoint(g4.GetN(), axis, angle);
     293            }
    328294
    329295            if (cnt==0)
    330                 gm.SetPoint(gm.GetN(), axis, hrzm.alt);
     296                gm.SetPoint(gm.GetN(), axis, it->fMoonHrz.alt);
    331297        }
    332298
Note: See TracChangeset for help on using the changeset viewer.