IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26852


Ignore:
Timestamp:
Feb 10, 2010, 3:39:59 PM (16 years ago)
Author:
eugene
Message:

updates from the trunk

Location:
branches/eam_branches/20091201/tools
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/tools/examine_burntool_pcontrol.pl

    r25562 r26852  
    1717    print STDERR "         status of the processing.  On the OTA grid:\n";
    1818    print STDERR "                  _             Blank chip\n";
    19     print STDERR "                  N             Null/zero value for burntool_state. No burntool attempted.\n";
    20     print STDERR "                  O             -1 value for burntool_state. Burntool is running.\n";
    21     print STDERR "                  E             -2 value for burntool_state. Error!\n";
     19    print STDERR "                  O             Null/zero value for burntool_state. No burntool attempted (yet).\n";
     20    print STDERR "                  P             -1 value for burntool_state. Burntool is running.\n";
     21    print STDERR "                  E             -2 value for burntool_state. Error! (modified raw pixels)\n";
     22    print STDERR "                  X             -3 value for burntool_state. Burntool segfaulted on this chip.\n";
    2223    print STDERR "                  B             Current version value for burntool_state. Burntool succeeded.\n";
    2324    print STDERR "                  b             Old version value for burntool_state. Burntool needs to be rerun.\n";
     
    5152        $burncount++;
    5253    }
    53     elsif ($burntool_state == -1) {
     54    elsif ($burntool_state == -1) {   # processing
    5455        $char = '[01;33mP[m';
    5556    }
    56     elsif ($burntool_state == 0) {
     57    elsif ($burntool_state == 0) {    # has not been processed yet
    5758        $char = '[31mO[m';
    5859    }
    59     elsif ($burntool_state == -2) {
     60    elsif ($burntool_state == -2) {   # modified pixel data
    6061        $char = '[35;01;44;05mE[m';
    6162    }
    62     elsif ($burntool_state == -3) {
     63    elsif ($burntool_state == -3) {   # previous burntool segfaulted.
    6364        $char = '[34mX[m';
    6465    }
    65     else {
     66    else {                            # old version
    6667        $char = '[32mb[m';
    6768    }
     
    128129
    129130    $data_ref = $db->selectall_arrayref( $sth );
    130 
    131131
    132132    # Reset
  • branches/eam_branches/20091201/tools/gpc1_find_images.pl

    r26098 r26852  
    33use DBI;
    44use Getopt::Std;
    5 getopts('hFARCPp:BLMDWIvx:n:c:w:s:O:S:N:',\%opt);
     5getopts('hEFARCPp:BLMDWIJVYTvx:n:c:w:s:d:e:O:S:N:',\%opt);
    66#getopt('xncwOS:hARCW',\%opt);
    77unless (exists($opt{O})) {
     
    3434}
    3535
     36# abcdefghijklmnopqrstuvwxyz
     37#used:
     38# ABCDEF     LMNOP RST  W Y
     39#   c    h     n    s  vwx 
    3640if (exists($opt{h})) {
    3741    print "USAGE find_images.pl ... \n";
    3842    print "          -h              This help\n";
    39     print "          -R              Return raw data.\n";
    40     print "          -C              Return chip stage data.\n";
    41     print "          -W              Return warp stage data.\n";
     43    print "          -R              Return Raw data.\n";
     44    print "          -C              Return Chip stage data.\n";
     45    print "          -E              Return camEra stage data.\n";
     46    print "          -W              Return Warp stage data.\n";
     47    print "          -T              Get the sTacks for a given input.\n";
     48    print "          -J              Get the dIff stage data (warps only for now).\n";
    4249    print "          -A              Return not just fits images.\n";
    4350    print "          -F              Convert to real filenames.\n";
     
    4552    print "          -B              Return burntool table.\n";
    4653    print "          -M              Include masks in results.\n";
     54    print "          -L              Return the log files from this stage.\n";
    4755    print "          -D              Return only pre-destreaked images.\n";
     56    print "          -Y              Yes, I want the raw, even if it's not been processed.\n";
     57    print "          -V              Return the cmf or smf files.\n";
    4858    print "          -v              Be verbose on output.\n";
    4959    print " \n";
    5060    print "          -x <exp_id>     Specify a exp_id.\n";
    5161    print "          -c <chip_id>    ...\n";
     62    print "          -e <cam_id>     ...\n";
    5263    print "          -w <warp_id>    ...\n";
    5364    print "          -s <stack_id>   ...\n";
     65    print "          -d <diff_id>    ...\n";
    5466    print "          -n <exp_name>   ...\n";
    5567    print " \n";
     
    6476$dbname = 'gpc1';
    6577$dbserver = 'ippdb01';
    66 $dbuser = 'ipp';
    67 $dbpass = 'ipp';
     78$dbuser = 'ippuser';
     79$dbpass = 'ippuser';
    6880$db = DBI->connect("DBI:mysql:database=${dbname};host=${dbserver};" .
    6981                   "mysql_socket=" . DB_SOCKET(),
     
    7284                   ) or die "Unable to connect to database $DBI::errstr\n";
    7385
    74 $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack' from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING (exp_id)";
     86if ($opt{Y}) {
     87    $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack',camRun.cam_id,camRun.workdir,0,'nodiff' from warpRun RIGHT OUTER JOIN fakeRun USING(fake_id) RIGHT OUTER JOIN camRun USING(cam_id) RIGHT OUTER JOIN chipRun USING(chip_id) RIGHT OUTER JOIN rawExp USING (exp_id)";
     88}
     89else {
     90    $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack',camRun.cam_id,camRun.workdir,0,'nodiff' from warpRun  JOIN fakeRun USING(fake_id)  JOIN camRun USING(cam_id)  JOIN chipRun USING(chip_id)  JOIN rawExp USING (exp_id)";
     91}
    7592
    7693# What do we have?
     
    89106    push @sth_adds, "warpRun.warp_id = $opt{w}";
    90107}
    91 if (exists($opt{s})) {
    92     if ($opt{s} != 0) {
     108if (exists($opt{e})) {
     109    push @sth_adds, "camRun.cam_id = $opt{e}";
     110}
     111if (exists($opt{s})||exists($opt{T})) {
     112#    print "$opt{s}!\n";
     113    if (exists($opt{s})&&($opt{s} != 0)) {
    93114        push @sth_adds, "stackRun.stack_id = $opt{s}";
    94115    }
    95     $sth_base =~ s/0,"nostack"/stack_id,stackSumSkyfile.uri/;
     116    $sth_base =~ s/0,'nostack'/stack_id,stackSumSkyfile.uri/;
     117    if (exists($opt{T})) {
     118        $sth_base .= ' RIGHT OUTER ';
     119    }
    96120    $sth_base .= ' JOIN stackInputSkyfile USING (warp_id) JOIN stackSumSkyfile USING (stack_id) JOIN stackRun USING (stack_id)';
     121#    print "$sth_base\n";
     122}
     123if (exists($opt{J})||(exists($opt{d}))) {
     124    if (exists($opt{d})&&($opt{d} != 0)) {
     125        push @sth_adds, "diffRun.diff_id = $opt{d}";
     126    }
     127    $sth_base =~ s/0,'nodiff'/diffRun.diff_id,diffSkyfile.path_base/;
     128    if (exists($opt{J})) {
     129#       $sth_base .= ' RIGHT OUTER ';
     130    }
     131    $sth_base .= ' JOIN diffInputSkyfile ON (warpRun.warp_id = diffInputSkyfile.warp1 OR warpRun.warp_id = diffInputSkyfile.warp2) JOIN diffRun USING (diff_id) JOIN diffSkyfile USING (diff_id)';
    97132}
    98133if ($#sth_adds != -1) {
     
    112147    ($warp_id, $warp_workdir, $chip_id, $chip_workdir,
    113148     $exp_name, $exp_id, $exp_workdir, $exp_dateobs, $exp_pontime,
    114      $stack_id, $stack_sumfile_uri) = @{ $rr };
     149     $stack_id, $stack_sumfile_uri,
     150     $cam_id, $cam_workdir,
     151     $diff_id, $diff_workdir
     152    ) = @{ $rr };
    115153    if ($stack_id == 0) {
    116154        $stack_sumfile_uri = '';
    117155    }
    118 #    print (join "\t", @{ $rr }) . "\n";
     156#    print (join "\t", @{ $rr }) . "\n" . "\n";
    119157#    $exp_pontime = 0; # To stop warnings, but I want this around.
    120158    if (exists($opt{I})) {
    121159        $stack_id = 0; # Ditto.
     160        $cam_id = 0;
     161        $diff_id = 0;
    122162    }
    123163    if (exists($opt{N})) {
     
    136176        if (exists($opt{B})) { $previous_cmd .= ' -B '; }
    137177        if (exists($opt{v})) { $previous_cmd .= ' -v '; }
     178        if (exists($opt{F})) { $previous_cmd .= ' -F '; }
    138179        if ($opt{A}) { $previous_cmd .= ' -A '; }
    139180        if ($opt{M}) { $previous_cmd .= ' -M '; }
     
    156197        (exists($opt{W})&&(exists($opt{O})))||
    157198        exists($opt{I})) {
     199
    158200        $sth_mapping = "SELECT skycell_id,class_id from warpSkyCellMap WHERE warp_id = $warp_id";
    159201        $mr = $db->selectall_arrayref( $sth_mapping );
     
    166208            push @{ $mapping{$class} }, $skycell;
    167209            push @{ $mapping{$raw_class} }, $skycell;
     210#           print STDERR "$raw_class $class $skycell\n";
    168211        }
    169212    }
     
    217260        close(NLS);
    218261    }
     262    if (exists($opt{E})) {
     263        open(NLS,"neb-ls $cam_workdir/${exp_name}.${exp_id}/ |") || die "can't neb-ls";
     264        while (<NLS>) {
     265            chomp;
     266            if (is_valid_cam($_)) {
     267                push @scan, $_;
     268                $found++;
     269            }
     270        }
     271        close(NLS);
     272    }
    219273    if (exists($opt{W})) {
    220274        open(NLS,"neb-ls $warp_workdir/${exp_name}.${exp_id}/ |") || die "can't neb-ls";
     
    227281        }
    228282    }
    229     if (exists($opt{s})) {
    230         push @scan, $stack_sumfile_uri;
    231         $found++;
     283    if (exists($opt{J})) {
     284        @diff_tmp = split /\//, $diff_workdir;
     285        $diff_prefix = pop(@diff_tmp);
     286        $diff_true_dir = join '/',@diff_tmp;
     287
     288        open(NLS,"neb-ls $diff_true_dir |") || die "can't neb-ls";
     289        while (<NLS>) {
     290            chomp;
     291            if (is_valid_diff($_)) {
     292                push @scan, $_;
     293                $found++;
     294            }
     295        }
     296    }
     297    if (exists($opt{s})||exists($opt{T})) {
     298        if (defined($stack_sumfile_uri)) {
     299            push @scan, $stack_sumfile_uri;
     300            $found++;
     301        }
    232302    }
    233303
     
    277347    elsif ($opt{B}) {
    278348        if ($key =~ /burn.tbl/) {
     349            if (($opt{O} ne '')&&($key !~ /$opt{O}/)) {
     350                return(0); # Not the requested OTA
     351            }
     352            if (($opt{S} ne '')&& !(is_mapped($key,$opt{S}))) {
     353                return(0); # Not the remapped skycell requested
     354            }
    279355            return(1);
    280356        }
     
    332408        }
    333409    }
     410    elsif ($opt{V} && ($key =~ /cmf/)) {
     411        return(1);
     412    }
    334413    elsif ($key !~ /fits/) {
    335414        return(0); # Not a fits
     
    353432}
    354433
     434sub is_valid_cam {
     435    my $key = shift;
     436    if ($key =~ /\.cm\./) {
     437        if ($opt{A}) {
     438            return(1);
     439        }
     440        elsif ($opt{L} && ($key =~ /log/)) {
     441            return(1);
     442        }
     443        elsif ($opt{V} && ($key =~ /smf/)) {
     444            return(1);
     445        }
     446    }
     447    return(0);
     448}
     449
     450sub is_valid_diff {
     451    my $key = shift;
     452    if ($key =~ /$diff_prefix/) {
     453        if ($opt{D} && ($key !~ /SR/)) {
     454            return(0); # Not destreaked when required
     455        }
     456        if (($opt{S} ne '')&&($key !~ /$opt{S}/)) {
     457            return(0); # Not the requested skycell
     458        }
     459        if (($opt{O} ne '')&& !(is_mapped($key,$opt{O}))) {
     460            return(0); # Not the remapped OTA requested
     461        }
     462       
     463        if ($opt{A}) {
     464            return(1); # You asked for all,
     465        }
     466        elsif ($opt{L}) {
     467            if ($key =~ /log/) {
     468                return(1);
     469            }
     470            else {
     471                return(0);
     472            }
     473        }
     474        elsif ($opt{V} && ($key =~ /cmf/)) {
     475            return(1);
     476        }
     477        elsif ($key !~ /fits/) {
     478            return(0); # Not a fits
     479        }
     480        elsif ($key =~ /wt.fits/) {
     481            return(0); # No handler for weight right now.
     482        }
     483        elsif ($key =~ /mask/) {
     484            if ($opt{M}) {
     485                return(1); # Requested mask
     486            }
     487            else {
     488                return(0);
     489            }
     490        }
     491        else {
     492            return(1); # Should be just the warp.
     493        }
     494    }
     495   
     496    return(0);
     497}
    355498sub is_valid_warp {
    356499    my $key = shift;
     
    380523        }
    381524    }
     525    elsif ($opt{V} && ($key =~ /cmf/)) {
     526        return(1);
     527    }
    382528    elsif ($key !~ /fits/) {
    383529        return(0); # Not a fits
     
    399545    return(0);
    400546}
    401        
    402 
    403 
    404    
    405    
  • branches/eam_branches/20091201/tools/make_burntool_pcontrol.pl

    r25952 r26852  
    3535                   ) or die "Unable to connect to database $DBI::errstr\n";
    3636
     37# Determine what the value of "BURNTOOL.STATE.GOOD" currently is:
     38$burntoolStateGood = 999;
     39open(LAZY,"ppConfigDump -camera GPC1 -dump-camera - |") || die "Can't run ppConfigDump\n";
     40while(<LAZY>) {
     41    chomp;
     42    if ($_ =~ /BURNTOOL.STATE.GOOD/) {
     43        @line = split /\s+/;
     44        $burntoolStateGood = $line[2];
     45    }
     46}
     47close(LAZY);
     48#unless( $burntoolStateGood == 999) {
     49#    print STDERR "GOOD == $burntoolStateGood\n";
     50#}
     51
     52
    3753# List of which obs_modes are "science" and which are something else.
    3854%science = ('MD' => 1, '3PI' => 1, 'STS' => 1, 'CAL' => 1, 'M31' => 1, 'SS' => 1,
     
    4157    $science{Unknown} = 1;
    4258}
    43 # Zero the arrays.
     59
     60# Zero the arrays and counters
    4461@dates_min = ();
    4562@dates_max = ();
    46 
     63$N_burntooled_images = 0;
     64$N_total_images = 0;
     65$N_ranges = 0;
    4766# Parse SQL query and fill any valid dates to the arrays
    4867if (exists($opt{Q})) {
     
    6685    }
    6786}
     87
    6888# Read a single date, and calculate the end and insert
    6989elsif (exists($opt{d})) {
     
    7393    push @dates_max, sprintf("%04d-%02d-%02d",$year,$mon,$date);
    7494}
     95
    7596# Just shift the supplied values into the arrays.
    7697else {
     
    92113    print "##query: SELECT dateobs FROM rawExp WHERE $opt{Q}\n";
    93114}
    94 #for ($d = 0; $d <= $#dates_min; $d++) {
     115
    95116while ($#dates_min > -1) {
    96117    $date_min = shift(@dates_min);
     
    138159            $science{$obs_mode} = 0;
    139160        }
    140 #%science = ('MD' => 1, '3PI' => 1, 'STS' => 1, 'CAL' => 1, 'M31' => 1, 'SS' => 1,
    141 #           'ENGINEERING' => 0, 'NULL' => 0, 'Unknown' => 0, ' ' => 0);
    142 # I don't like this bit, but we need to work around the bad values of obs_mode that periodically crop up.
    143 # This isn't the most robust solution (which would of course be "having trustworthy obs_mode values"), but
    144 # it'll probably work for now.
    145161        if ((($science{$obs_mode} == 1)&&($comment !~ /Daytime/))||
    146162            (($science{$obs_mode} == 0)&&(
    147163                                          ($comment =~ /MD/)||($comment =~ /ThreePi/)||
    148164                                          ($comment =~ /STS/)||($comment =~ /M31/)||
    149                                           ($comment =~ /CAL/)||($comment =~ /SS/)||($comment =~ /SVS/)|| ($comment =~ /Sweetspot/)|| ($comment =~ /cal/)|| ($comment =~ /virgo/)|| ($comment =~ /Virgo/)|| ($comment =~ /kepler/)||
     165                                          ($comment =~ /CAL/i)||($comment =~ /SS/)||($comment =~ /SVS/)||
     166                                          ($comment =~ /Sweetspot/)||($comment =~ /virgo/i)||($comment =~ /kepler/)||
    150167                                          ($comment =~ /sdss/))))                                         
    151168        {
     
    174191        next;
    175192    }
     193
    176194    # Scan again and count how many exposures are between windows
    177195    foreach $row_ref (@{ $data_ref }) {
     
    212230                }
    213231            }
    214 #           print ">>>$i $start_s[$i] $skips[$i]\n";
    215         }
    216 #       print ">>> $dateobs\n";
     232        }
    217233    }
    218234
     
    227243    }
    228244    # Print out the end points in the format burntool wants.
     245
    229246    for ($i = 0; $i <= $#start_s; $i++) {
    230247        @start_t = localtime($start_s[$i]);
    231248        @end_t = localtime($end_s[$i]);
    232         printf(" burntool %04d-%02d-%02dT%02d:%02d:%02d %04d-%02d-%02dT%02d:%02d:%02d\n",
    233                $start_t[5] + 1900,$start_t[4] + 1,$start_t[3],
    234                $start_t[2],$start_t[1],$start_t[0],
    235                $end_t[5] + 1900,$end_t[4] + 1,$end_t[3],
    236                $end_t[2],$end_t[1],$end_t[0]);
    237     }
    238     print "\n";
    239 }
    240 
    241 unless(exists($opt{b})) {
     249       
     250        my $date_min = sprintf("%04d-%02d-%02dT%02d:%02d:%02d",
     251                               $start_t[5] + 1900,$start_t[4] + 1,$start_t[3],
     252                               $start_t[2],$start_t[1],$start_t[0]);
     253        my $date_max = sprintf("%04d-%02d-%02dT%02d:%02d:%02d",
     254                               $end_t[5] + 1900,$end_t[4] + 1,$end_t[3],
     255                               $end_t[2],$end_t[1],$end_t[0]);
     256
     257        my $total_images_sth = "SELECT count(exp_id) from rawImfile where dateobs >= '$date_min' AND dateobs <= '$date_max'";
     258        my $im_ref = $db->selectall_arrayref( $total_images_sth );
     259        $N_total_images += ${ $im_ref }[0][0];
     260
     261        my $burntooled_images_sth = "SELECT count(exp_id) from rawImfile where dateobs >= '$date_min' AND dateobs <= '$date_max' AND abs(burntool_state) = $burntoolStateGood";
     262        $im_ref = $db->selectall_arrayref( $burntooled_images_sth );
     263        $N_burntooled_images += ${ $im_ref }[0][0];
     264       
     265
     266        printf(" burntool %s %s\n",$date_min,$date_max);
     267    }
     268    unless(exists($opt{d})) {
     269        print "\n";
     270    }
     271    $N_ranges += ($#start_s + 1);
     272}
     273
     274if ($N_ranges == 0) {
     275    print_short_epilogue();
     276}
     277
     278unless(exists($opt{b}) || ($N_ranges == 0)) {
    242279    print_epilogue();
    243280}
     
    275312return(0);
    276313}
     314sub print_short_epilogue {
     315    if (exists($opt{b})) {
     316        print STDERR "There were no science exposures to process. Sorry, try again tomorrow.\n";
     317        return();
     318    }
     319    print << 'END_SHORT_EPILOGUE';
     320
     321    echo "There were no science exposures to process. Sorry, try again tomorrow."
     322
     323end
     324END_SHORT_EPILOGUE
     325}
    277326
    278327sub print_epilogue {
     328    print " echo 'There were $N_total_images total images, of which $N_burntooled_images were already burntooled.'\n";
     329    print "### BTSTAT $N_total_images $N_burntooled_images\n";
    279330    print << 'END_EPILOGUE';
    280331   
  • branches/eam_branches/20091201/tools/neb-ds9.pl

    r26276 r26852  
    44getopts('AM',\%opt);
    55
    6 $cmd = 'ds9 -scale mode zscale ';
     6$cmd = 'ds9  -scale mode zscale ';
    77
    88if (exists($opt{A})) {
     
    2121    }
    2222}
     23#$cmd .= "  -zoom to fit -regions format xy -regions system wcs -regions load targets.reg  ";
    2324system("$cmd");
  • branches/eam_branches/20091201/tools/warp_outputs.pl

    r25859 r26852  
    2424my ($input);                    # Input list
    2525my ($products);                 # Products of interest
     26my ($muggle);                   # No magicked inputs?
    2627
    2728GetOptions(
     
    3334           'skycell_id=s' => \$skycell_id, # Skycell identifier
    3435           'products=s' => \$products, # Products of interest
    35            ) or die "Unable to parse arguments.\n";
     36           'muggle'   => \$muggle, # No magicked inputs?
     37           ) or
     38die "Unable to parse arguments.\n";
    3639die "Unknown option: @ARGV\n" if @ARGV;
    3740die "Required options: --dbhost --dbname --dbuser --dbpass --warp_id\n"
     
    8083
    8184    my $file = "$path$ext"; # File
     85
     86    if (defined $muggle and $ext ne ".psf") {
     87        my @file = split /\//, $file;
     88        my $last = pop @file;
     89        push @file, "SR_$last";
     90        $file = join '/', @file;
     91    }
     92
    8293    my $source = `ipp_datapath.pl $file` or die "Unable to locate $file\n"; # Actual file
    8394    chomp $source;
Note: See TracChangeset for help on using the changeset viewer.