Ignore:
Timestamp:
04/12/07 21:45:12 (17 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r8236 r8404  
    3535// Make sure, that database and password are corretly set.
    3636//
    37 // Returns 0 in case of failure and 1 in case of success.
     37// Returns 1 in case of success.
     38// Returns 2 in case of invalid file or line in file.
     39// Returns 3 in case of a missing object name in the database.
    3840//
    3941///////////////////////////////////////////////////////////////////////////
     
    102104    TVector3 v;
    103105
    104     cout << fname << endl;
    105 
    106     if (fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_R[_]?[12]?[.]instr", kFALSE)).IsNull())
     106    if (fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr", kFALSE)).IsNull())
    107107    {
    108108        cout << "Found not valid file: " << fname << endl;
     
    115115        line.ReadLine(fin);
    116116        if (!fin)
     117        {
     118            cout << numstars << " objects inserted for this exposure. " << endl;
    117119            break;
     120        }
    118121
    119122        if (line.IsNull())
     
    123126
    124127        if (line=="KVA_Celestron_ST8  KVA_Celestron_R" ||
     128            line=="KVA_Celestron_ST8  KVA_Celestron_V" ||
    125129            line=="Tuorla_ST1001E  Tuorla_R")
    126130        {
     
    147151            }
    148152            numexp+=1;
     153            if (numstars)
     154                cout << numstars << " objects inserted for this exposure. " << endl;
    149155            numstars=0;
    150156            timestamp =Form("%s %s", (*arr)[0]->GetName(),(*arr)[1]->GetName());
     
    164170            }
    165171
     172            //calculation of zd if ra and dec are available
    166173            if (numstars==0)
    167174            {
     
    174181
    175182                TSQLRow *row=res->Next();
    176 
    177183                if (!row)
    178184                {
    179                     cout << "Query failed: " << select << endl;
    180                     continue;
     185                    cout << "Couldn't get ZD - Query failed: " << select << endl;
     186                    cout << "Position of the object is missing in the DB." << endl;
     187                    return 3;
    181188                }
    182 
    183                 ra =(*row)[0]?atof((*row)[0]):0;
    184                 dec=(*row)[1]?atof((*row)[1]):0;
     189                else
     190                {
     191                    ra =atof((*row)[0]);
     192                    dec=atof((*row)[1]);
     193                    v.SetMagThetaPhi(1, TMath::Pi()/2-(dec*TMath::DegToRad()), ra*TMath::DegToRad()*15);
     194                    v *= MAstroSky2Local(t, obs);
     195                    zd = v.Theta()*TMath::RadToDeg();
     196                }
    185197                delete res;
    186 
    187                 v.SetMagThetaPhi(1, TMath::Pi()/2-(dec*TMath::DegToRad()), ra*TMath::DegToRad()*15);
    188                 v *= MAstroSky2Local(t, obs);
    189 
    190                 zd = v.Theta()*TMath::RadToDeg();
    191 
    192198            }
    193199
    194             object= Form("%s/%s", (*arr)[0]->GetName(),(*arr)[1]->GetName());
    195             skylevel   = (*arr)[2]->GetName();
     200            object    = Form("%s/%s", (*arr)[0]->GetName(),(*arr)[1]->GetName());
     201            skylevel  = (*arr)[2]->GetName();
     202            fwhm      = (*arr)[3]->GetName();
     203            aperturer = (*arr)[4]->GetName();
     204            mag       = (*arr)[5]->GetName();
     205            magerr    = (*arr)[6]->GetName();
     206            status    = (*arr)[7]->GetName();
     207            //make sure that no nonsense values enter the db
    196208            if (skylevel.Contains("-"))
    197                 skylevel="NULL";
    198             fwhm = (*arr)[3]->GetName();
     209                skylevel = "NULL";
    199210            if (fwhm.Contains("-") || !fwhm.IsFloat())
    200                 fwhm="NULL";
    201             aperturer = (*arr)[4]->GetName();
    202             mag = (*arr)[5]->GetName();
     211                fwhm     = "NULL";
    203212            if (!mag.IsFloat())
    204                 mag="NULL";
    205             magerr = (*arr)[6]->GetName();
     213                mag      = "NULL";
    206214            if (!magerr.IsFloat())
    207                 magerr="NULL";
    208             status = (*arr)[7]->GetName();
     215                magerr   = "NULL";
    209216            numstars+=1;
    210217        }
     
    238245                       "fInstrumentalMagErr=%s, fStatusKEY=%d, fCCDKEY=%d, "
    239246                       "fFilterKEY=%d, fTelescopeKEY=%d, fBandKEY=%d, "
    240                        "fZenithDistance=",
     247                       "fZenithDistance=%.1f ",
    241248                       timestamp.Data(), exposure.Data(), fitsfilekey,
    242249                       objectkey, skylevel.Data(), fwhm.Data(),
    243250                       aperturer.Data(), mag.Data(), magerr.Data(),
    244                        statuskey, ccdkey, filterkey, telkey, bandkey);
    245 
    246             if (ra==0 || dec==0)
     251                       statuskey, ccdkey, filterkey, telkey, bandkey, zd);
     252
     253            /*
     254            if (ra==0 || dec==0 || zd==0)
    247255                query+="NULL";
    248256            else
    249257                query+=Form("%.1f", zd);
    250 
     258            */
    251259            if (serv.Insert("OpticalData", query)==kFALSE)
    252260                return 2;
    253 
    254         }
    255 
    256     }
    257 
    258     cout << fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_R[_]?[12]?[.]instr", kFALSE))
    259         << ": " << setw(2) << numexp << " exposures, " <<  setw(2) << numstars << " stars" << endl;
     261        }
     262    }
     263
     264    cout << fname(TRegexp("20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]_.*_[RV][_]?[12]?[.]instr", kFALSE))
     265        << ": " << setw(2) << numexp << " exposures." << endl << endl;
    260266
    261267    return 1;
Note: See TracChangeset for help on using the changeset viewer.