IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 5, 2010, 5:31:23 PM (16 years ago)
Author:
Paul Price
Message:

Produce ds9 region files as well, if desired. Must now explicitly turn on output modes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/microtest.pl

    r27572 r27612  
    1616my ($db_host, $db_name, $db_user, $db_pw); # Database details
    1717my ($label);                               # Label of interest
     18my ($exp_id);                              # Exposure of interest
    1819my ($group);                               # Data group
    1920my ($verbose);                             # Verbosity?
    2021my ($save_temps);                          # Save temporary outputs?
     22my ($clusters_raw, $clusters_ds9, $streaks_ds9);     # Output modes
    2123
    2224GetOptions(
     
    2628           'dbpass=s' => \$db_pw, # Database p/w
    2729           'label=s' => \$label, # Label of interest
     30    'exp_id=s' => \$exp_id,      # Exposure identifier of interest
    2831    'data_group=s' => \$group,   # Data group
     32    'clusters-raw' => \$clusters_raw,       # Output raw x,y for clusters?
     33    'clusters-ds9' => \$clusters_ds9, # Output ds9 region files of clusters?
     34    'streaks-ds9' => \$streaks_ds9,   # Output ds9 region files of streaks?
    2935           'verbose' => \$verbose, # Verbosity?
    3036    'save-temps' => \$save_temps,  # Save temporary outputs?
     
    4854
    4955# Exposures of interest
    50 my $sql = "SELECT DISTINCT exp_id, exp_name, magic_id, magicRun.workdir AS magic_path, camProcessedExp.path_base AS cam_path FROM magicRun JOIN rawExp USING(exp_id) JOIN diffRun USING(diff_id) JOIN diffInputSkyfile USING(diff_id) JOIN warpRun ON warpRun.warp_id = diffInputSkyfile.warp1 JOIN fakeRun USING(fake_id) JOIN camProcessedExp USING(cam_id) WHERE magicRun.label = '$label' AND magicRun.state = 'full'";
     56my $sql = "SELECT DISTINCT exp_id, exp_name, magic_id, magicRun.workdir AS magic_path, camProcessedExp.path_base AS cam_path FROM magicRun JOIN rawExp USING(exp_id) JOIN diffRun USING(diff_id) JOIN diffInputSkyfile USING(diff_id) JOIN warpRun ON warpRun.warp_id = diffInputSkyfile.warp1 JOIN fakeRun USING(fake_id) JOIN camProcessedExp USING(cam_id) WHERE magicRun.state = 'full'";
     57$sql .= " AND magicRun.label = '$label'" if defined $label;
     58$sql .= " AND magicRun.exp_id = ${exp_id}" if defined $exp_id;
    5159$sql .= " AND magicRun.data_group = '$group'" if defined $group;
    5260my $exps = $db->selectall_arrayref($sql, { Slice => {} }) or die "Unable to execute SQL: $DBI::errstr";
     
    6371    my $clusters = "${magic_path}/$id/$id.mgc.$magic.verify/${id}_clusterPos.txt"; # File with cluster RA,Dec
    6472    die "Cannot find clusters file $clusters" unless $ipprc->file_exists($clusters);
     73
     74    my $streaks = "${magic_path}/$id/$id.mgc.$magic.root.streaks"; # File with streaks
     75    die "Cannot find streaks file $streaks" unless $ipprc->file_exists($streaks);
    6576
    6677    my $astrom = "${cam_path}.smf"; # Astrometry file
     
    8192    close $radecFile;
    8293
    83     my $raws = $db->selectcol_arrayref("SELECT uri FROM rawImfile where exp_id = $id") or
    84         die "Unable to execute SQL: $DBI::errstr";
     94    my $chips = $db->selectall_arrayref("SELECT class_id, uri FROM rawImfile where exp_id = $id",
     95                                        { Slice => {} }
     96        ) or die "Unable to execute SQL: $DBI::errstr";
    8597
    86     open my $outFile, "> $label.${name}.clusters.xy" or die "Cannot open output file: $!";
    87     foreach my $raw (@$raws) {
    88 #        my $resolved = `neb-locate --path $raw`; # Resolved filename
    89 #        chomp $resolved;
    90         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    91             run(command => "$ppCoord -astrom $astrom -raw $raw -radec $radecName", verbose => $verbose);
    92         die "Unable to run ppCoord" unless $success;
     98    open my $outFile, "> $label.${name}.clusters.xy" or die "Cannot open output file: $!" if defined $clusters_raw;
     99    foreach my $chip (@$chips) {
     100        my $class = $chip->{class_id};
     101        my $uri = $chip->{uri};
    93102
    94         my @lines = split(/\n/, join("", @$stdout_buf));
    95         foreach my $line (@lines) {
    96             my @line = split /\s+/, $line;
     103        if (defined $clusters_raw) {
     104            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     105                run(command => "$ppCoord -astrom $astrom -raw $uri -radec $radecName", verbose => $verbose);
     106            die "Unable to run ppCoord" unless $success;
    97107
    98             my $ra = $line[0];
    99             my $dec = $line[1];
    100             my $x = $line[3];
    101             my $y = $line[4];
    102             my $chip = $line[5];
    103             my $cell = $line[6];
     108            my @lines = split(/\n/, join("", @$stdout_buf));
     109            foreach my $line (@lines) {
     110                my @line = split /\s+/, $line;
    104111
    105             print $outFile "$chip $cell $x $y $ra $dec\n";
     112                my $ra = $line[0];
     113                my $dec = $line[1];
     114                my $x = $line[3];
     115                my $y = $line[4];
     116                my $chipName = $line[5];
     117                my $cellName = $line[6];
     118
     119                print $outFile "$chipName $cellName $x $y $ra $dec\n";
     120            }
    106121        }
     122
     123        if (defined $clusters_ds9) {
     124            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     125                run(command => "$ppCoord -astrom $astrom -radec $radecName -chip $class -ds9 $label.$name.clusters.$class.ds9 -ds9-color blue",
     126                    verbose => $verbose);
     127            die "Unable to run ppCoord" unless $success;
     128        }
     129
     130        if (defined $streaks_ds9) {
     131            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     132                run(command => "$ppCoord -astrom $astrom -streaks $streaks -chip $class -ds9 $label.$name.streaks.$class.ds9 -ds9-color red",
     133                    verbose => $verbose);
     134            die "Unable to run ppCoord" unless $success;
     135        }
     136
    107137    }
    108     close $outFile;
     138    close $outFile if defined $clusters_raw;
    109139}
Note: See TracChangeset for help on using the changeset viewer.