IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 26, 2010, 10:33:29 AM (16 years ago)
Author:
eugene
Message:

merge updates from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/tools/czartool/Gpc1Db.pm

    r28924 r29834  
    6060###########################################################################
    6161#
     62# Returns the number of science exposures taken 'last night' for a given day
     63#
     64# Notes:
     65#
     66# - 03:00 HST = 17:00 last night UTC
     67# - 17:00 HST = 07:00 this morning UTC
     68# - 'OBJECT' = science exposures
     69#
     70###########################################################################
     71sub countScienceExposuresFromLastNight {
     72    my ($self, $day) = @_;
     73
     74    my $begin = "$day 03";
     75    my $end = "$day 17";
     76
     77    my $query = $self->{_db}->prepare(<<SQL);
     78    SELECT COUNT(*)
     79        FROM summitExp
     80        WHERE dateobs > '$begin'
     81        AND dateobs < '$end' AND
     82        exp_type = 'OBJECT';
     83SQL
     84
     85    $query->execute;
     86return scalar $query->fetchrow_array();
     87}
     88
     89###########################################################################
     90#
     91# Returns the number of exposures between two dates that have been registered with chip
     92#
     93# Notes:
     94#
     95# necessary to convert times as rawExp.dateobs is in UTC
     96#
     97###########################################################################
     98sub getProcessedExposures {
     99    my ($self, $beginDate, $endDate, $expIds) = @_;
     100
     101    $beginDate = "$beginDate 03";
     102    $endDate = "$endDate 17";
     103
     104    my $query = $self->{_db}->prepare(<<SQL);
     105        SELECT rawExp.exp_id
     106        FROM chipRun, rawExp
     107        WHERE chipRun.exp_id = rawExp.exp_id
     108        AND rawExp.dateobs >= '$beginDate'
     109        AND rawExp.dateobs <= '$endDate';
     110SQL
     111
     112    $query->execute;
     113    ${$expIds} = $query->fetchall_arrayref();
     114
     115    return 1;
     116}
     117
     118###########################################################################
     119#
    62120# Returns count of faults for this stage and label
    63121#
     
    158216    }
    159217
    160 
    161218    $query->execute;
    162219    return scalar $query->fetchrow_array();
    163220}
     221
     222###########################################################################
     223#
     224# Returns magic mask fraction across all chips for a particular exposure
     225#
     226###########################################################################
     227sub getMagicMaskFraction {
     228        my ($self, $exp_id, $fracs) = @_;
     229
     230            my $query = $self->{_db}->prepare(<<SQL);
     231            SELECT component, streak_frac
     232                FROM magicDSFile 
     233                JOIN magicDSRun USING(magic_ds_id)
     234                JOIN camRun USING(cam_id)
     235                JOIN chipRun USING(chip_id)
     236                WHERE exp_id = $exp_id
     237                AND camRun.label LIKE "%nightlyscience"
     238                AND component LIKE "XY%";
     239SQL
     240    $query->execute;
     241    ${$fracs} = $query->fetchall_arrayref();
     242
     243    return 1;
     244}
     245
     246###########################################################################
     247#
     248# Returns average magic mask fraction across all chips for a particular exposure
     249#
     250###########################################################################
     251sub getAverageMagicMaskFraction {
     252        my ($self, $exp_id) = @_;
     253
     254            my $query = $self->{_db}->prepare(<<SQL);
     255            SELECT AVG(streak_frac)
     256                FROM magicDSFile 
     257                JOIN magicDSRun USING(magic_ds_id)
     258                JOIN camRun USING(cam_id)
     259                JOIN chipRun USING(chip_id)
     260                WHERE exp_id = $exp_id
     261                AND camRun.label LIKE "%nightlyscience"
     262                AND component LIKE "XY%";
     263SQL
     264    $query->execute;
     265    return scalar $query->fetchrow_array();
     266}
    1642671;
Note: See TracChangeset for help on using the changeset viewer.