Ignore:
Timestamp:
10/20/06 19:26:01 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/macros/plotoptical.C

    r8134 r8140  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: plotoptical.C,v 1.1 2006-10-19 18:45:51 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: plotoptical.C,v 1.2 2006-10-20 18:26:00 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    101101
    102102    TString fCondition;
     103    Bool_t  fGroupBy;
    103104
    104105    void PlotTable(TSQLResult &res, TString name, Float_t fmin, Float_t fmax, Float_t resolution)
     
    298299
    299300        gz.DrawClone("AP");
     301
    300302        if (gz0.GetN()>0)
    301303            gz0.DrawClone("P");
     
    306308public:
    307309    MPlot(MSQLMagic &server) : fServer(server), fDataSet(NULL),
    308         fRequestPeriod(-1), fPlotMin(0), fPlotMax(-1), fHistMin(0), fHistMax(-1)
     310        fRequestPeriod(-1), fPlotMin(0), fPlotMax(-1), fHistMin(0), fHistMax(-1), fGroupBy(kFALSE)
    309311    {
    310312    }
     
    335337    { fCondition = cond; }
    336338    void SetDescription(const char *d, const char *t=0) { fDescription = d; fNameTab = t; }
     339    void EnableGroupBy(Bool_t b=kTRUE) { fGroupBy=b; }
    337340
    338341    Int_t QueryKeyOfSource(TString src)
     
    343346    Bool_t Plot(const char *value, Float_t min=0, Float_t max=-1, Float_t resolution=0)
    344347    {
    345         TString named  = "OpticalData.fTimestamp";
    346         TString named2 = "fSkyLevel";
     348        TString named  = "OpticalData.fTimeStamp";
     349        TString named2 = fGroupBy ? "AVG(fZenithDistance)" : "fZenithDistance";
    347350        TString namev  = value;
    348351        TString join   = "fSequenceFirst";
     
    355358
    356359        TString query;
    357         query  = Form("select %s, %s, %s ", valued.Data(), named2.Data(), valuev.Data());
     360        query  = Form("select %s, %s, %s ", valued.Data(), named2.Data(), value);
    358361        query += Form("from %s ",           tabled.Data());
    359362
    360         const Bool_t interval = !fRequestFrom.IsNull() && !fRequestTo.IsNull();
    361 
    362         if (!fDataSet && !interval && tabled=="Star")
    363         {
    364             if (!query.Contains("Star.fSequenceFirst"))
    365                 query += "left join Star on Sequences.fSequenceFirst=Star.fSequenceFirst ";
    366             query += "where Star.fEffOnTime>300 ";
    367         }
    368 
    369         if (interval)
    370         {
    371             query += query.Contains(" where ") ? "and " : "where ";
    372             query += Form("fRunStart between '%s' and '%s' ",
    373                           fRequestFrom.Data(), fRequestTo.Data());
     363        //const Bool_t interval = !fRequestFrom.IsNull() && !fRequestTo.IsNull();
     364
     365        if (TString(value).Contains("Object."))
     366        {
     367            query += "left join Object on Object.fObjectKEY=OpticalData.fObjectKEY ";
    374368        }
    375369
     
    381375        }
    382376
    383         query += "order by fTimestamp";
     377        if (fGroupBy)
     378            query += " GROUP BY fTimeStamp ";
     379
     380        query += "order by fTimeStamp";
    384381
    385382        TSQLResult *res = fServer.Query(query);
     
    421418    plot.SetDescription("Aperture Radius;R_{A}", "ApRad");
    422419    plot.Plot("OpticalData.fApertureRadius", 0, 10, 1);
    423 
     420/*
    424421    plot.SetDescription("Instrumental Magnitude;M_{I}\\cdot s^{-1}", "InstMag/s");
    425422    plot.Plot("OpticalData.fInstrumentalMag/OpticalData.fExposure",  0, 0.2, 0.005);
     
    433430    plot.SetDescription("Instrumental Magnitude Error;\\sigma_{M}", "MagErr");
    434431    plot.Plot("OpticalData.fInstrumentalMagErr",  0, 1, 0.01);
     432  */
     433    plot.SetDescription("m_{1};m_{1}", "M1");
     434    plot.Plot("OpticalData.fInstrumentalMag+2.5*log10(OpticalData.fExposure)", 10, 35, 0.2);
     435
     436    cond += " and Object.fObjectName not like '%/BL' and not IsNull(Object.fMagnitude) ";
     437    plot.SetCondition(cond);
     438
     439    TString ext("3080/25.0*pow(10, (OpticalData.fInstrumentalMag+2.5*log10(OpticalData.fExposure)-Object.fMagnitude)/-2.5)");
     440    ext += "+0.0028*fZenithDistance-0.08";
     441/*
     442    plot.SetDescription("m_{1}-m_{true} (Extinction per Object);m_{1}-m_{true}", "ExtObj");
     443    plot.Plot(ext, 0.5, 1.2, 0.01);
     444    */
     445
     446    plot.EnableGroupBy();
     447    plot.SetDescription("m_{1}-m_{true} (Extinction per Image);m_{1}-m_{true}", "ExtImg");
     448    plot.Plot(Form("AVG(%s)", ext.Data()), 0.05, 1.2, 0.01);
     449
     450    plot.SetDescription("Error m_{1}-m_{true} (Extinction per Image);ERR m_{1}-m_{true}", "ExtImgErr");
     451    plot.Plot(Form("STD(%s)", ext.Data()), 0, 0.3, 0.005);
     452
     453    plot.SetDescription("m_{1}-m_{true} (Extinction per Hour);m_{1}-m_{true}", "ExtHour");
     454    plot.Plot(Form("AVG(%s), date_format(fTimeStamp, '%%Y-%%m-%%d %%H') as fTimeStamp", ext.Data()),
     455              0.5, 1.2, 0.01);
     456
     457    plot.SetDescription("m_{1}-m_{true} (Extinction per Night);m_{1}-m_{true}", "ExtNight");
     458    plot.Plot(Form("AVG(%s), date_format(adddate(fTimeStamp,Interval 12 hour),'%%Y-%%m-%%d') as fTimeStamp", ext.Data()),
     459              0.5, 1.2, 0.01);
    435460}
    436461
Note: See TracChangeset for help on using the changeset viewer.