Changeset 38008
- Timestamp:
- Mar 25, 2015, 12:40:19 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstampparse.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstampparse.pl
r37998 r38008 18 18 use POSIX; 19 19 use Time::HiRes qw(gettimeofday); 20 use Time::Local; 20 21 21 22 my $verbose; … … 569 570 $option_mask |= $PSTAMP_NO_WAIT_FOR_UPDATE if $no_updates_allowed; 570 571 572 # determine if there is a cut off date for data access for this user 573 my $mjd_max; 574 my $adjustedDateCuts = adjustDateCuts($row, \$mjd_max); 575 571 576 my $roi_string; 572 577 … … 612 617 613 618 my $imagefile = $image->{image}; 614 if (($stage ne "stack") and ($need_magic and !$image->{magicked})) { 615 # XXX: should we add a faulted job so the client can know what happened if no images come back? 616 # The test for destreaked is made in locate_images now so this code never runs. This leads to no feedback 617 # to users, but speeds up processing significantly 618 print STDERR "skipping non-magicked image $imagefile\n" if $verbose; 619 620 # for now assume yes. 621 622 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED); 623 return 1; 624 } elsif ($stage eq "stack") { 619 620 if ($stage eq "stack") { 625 621 # unconvolved stack images weren't available prior to some point in time. 626 622 # XXX: handle this more correctly by examining the stack run's config dump file. … … 633 629 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_AVAILABLE); 634 630 return 1; 631 } 632 } else { 633 if ($need_magic and !$image->{magicked}) { 634 # XXX: should we add a faulted job so the client can know what happened if no images come back? 635 # The test for destreaked is made in locate_images now so this code never runs. This leads to no feedback 636 # to users, but speeds up processing significantly 637 print STDERR "skipping non-magicked image $imagefile\n" if $verbose; 638 639 # for now assume yes. 640 641 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED); 642 return 1; 643 } 644 645 if ($adjustedDateCuts) { 646 my $mjd = 0; 647 my $exp_id; 648 if ($stage eq 'diff') { 649 # diff stage doesn't have a dateobs so we need to hack it. 650 # Extract dateobs from the exp_name_1 651 if ($row->{PROJECT} eq 'gpc1') { 652 my $exp_name = $image->{exp_name_1}; 653 if ($exp_name ne 'NULL') { 654 $mjd = 50000 + (substr($exp_name, 1, 4)); 655 $exp_id = $image->{exp_id_1}; 656 } else { 657 # it's stack-stack diff just let it go with mjd = 0 658 # XXX: deal with this 659 } 660 } 661 } else { 662 $exp_id = $image->{exp_id}; 663 $mjd = dateobsToMJD($image->{dateobs}); 664 } 665 666 if ($mjd > $mjd_max) { 667 print STDERR "User is not authorized for stamps from this exposure.\n"; 668 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_AUTHORIZED, $exp_id); 669 return 1; 670 } 635 671 } 636 672 } … … 863 899 my $job_num = shift; 864 900 my $fault = shift; 901 my $exp_id = shift; 865 902 866 903 my ($job_type, $rownum); … … 885 922 my $command = "$pstamptool -addjob -req_id $req_id -job_type $job_type" 886 923 . " -rownum $rownum -state stop -fault $fault"; 924 $command .= " -exp_id $exp_id" if $exp_id and $exp_id ne 'NULL'; 887 925 888 926 if (!$no_update) { … … 1153 1191 # set the access rights based on the assigned label. 1154 1192 if ($label eq 'IFA' or $label eq 'QUB' or $label =~ 'MOPS') { 1155 $level = 2;1193 $level = 0; 1156 1194 } else { 1157 1195 # access rights PS1 data only … … 1164 1202 $domain = lc($domain); 1165 1203 if ($domain eq 'ifa.hawaii.edu' or $domain eq 'qub.ac.uk') { 1166 $level = 2;1204 $level = 0; 1167 1205 } else { 1168 1206 # XXX check for special users … … 1178 1216 } 1179 1217 1218 1219 # determine the latest exposure date that a user may have access to 1220 # based on the user's accessLevel. 1221 sub adjustDateCuts { 1222 my $row = shift; 1223 my $r_mjd_max = shift; 1224 my $adjusted = 0; 1225 1226 my $MJD_PS1_BEGIN = 54922; # 2009-04-01 1227 my $MJD_PS1_END = 56838; # 2014-06-30 XXX get the actual date 1228 1229 if ($row->{accessLevel} == 1) { 1230 # User has access to PS1 data only 1231 my $mjd_max_user = $row->{MJD_MAX}; 1232 if (!$mjd_max_user or $mjd_max_user > $MJD_PS1_END) { 1233 $$r_mjd_max = $MJD_PS1_END; 1234 $adjusted = 1; 1235 } 1236 } 1237 return $adjusted; 1238 } 1239 1240 sub dateobsToMJD { 1241 my $dateobs = shift; 1242 1243 my ($date, $time) = split "T", $dateobs; 1244 1245 my ($year, $mon, $day) = split "-", $date; 1246 1247 my ($hr, $min, $sec) = split ":", $time; 1248 my $fraction = $sec - int($sec); 1249 $sec = int($sec); 1250 1251 my $ticks = timegm($sec, $min, $hr, $day, $mon-1, $year-1900); 1252 $ticks += $fraction; 1253 1254 # I'm not allowing for leap seconds here but for our purposes here that is ok 1255 my $mjd = 40587.0 + ($ticks / 86400.); 1256 return $mjd; 1257 } 1258 1180 1259 sub my_die 1181 1260 {
Note:
See TracChangeset
for help on using the changeset viewer.
