IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16276


Ignore:
Timestamp:
Feb 1, 2008, 1:43:05 PM (18 years ago)
Author:
eugene
Message:

updates to use actual caltool, flatcorr commands

Location:
trunk/ippScripts/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/calibrate_dvo.pl

    r15314 r16276  
    3636use Pod::Usage qw( pod2usage );
    3737
    38 my ($dvo_id, $catdir, $region, $dbname, $workdir, $no_update, $no_op);
     38my ($cal_id, $dvodb, $region, $dbname, $workdir, $no_update, $no_op);
    3939GetOptions(
    40     'dvo_id|i=s'       => \$dvo_id,
    41     'catdir|c=s'       => \$catdir,
     40    'cal_id|i=s'       => \$cal_id,
     41    'dvodb|c=s'        => \$dvodb,
    4242    'region|r=s'       => \$region,
    4343    'dbname|d=s'       => \$dbname,# Database name
     
    4848
    4949pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    50 pod2usage( -msg => "Required options: --dvo_id --catdir --region",
     50pod2usage( -msg => "Required options: --cal_id --dvodb --region",
    5151           -exitval => 3) unless
    52     defined $dvo_id and
    53     defined $catdir and
     52    defined $cal_id and
     53    defined $dvodb and
    5454    defined $region;
    5555
     
    7878{
    7979    my $command = "$addstar -resort";
    80     $command .= "-D CATDIR $catdir";
     80    $command .= "-D CATDIR $dvodb";
    8181    $command .= "-region $RAs $RAe $DECs $DECe";
    8282
     
    8686    unless ($success) {
    8787        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    88         &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RESORT", $status, $dbname);
     88        &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RESORT", $status, $dbname);
    8989    }
    9090}
     
    9494    foreach my $filter (@filters) {
    9595        my $command = "$relphot $filter";
    96         $command .= "-D CATDIR $catdir";
     96        $command .= "-D CATDIR $dvodb";
    9797        $command .= "-region $RAs $RAe $DECs $DECe";
    9898
     
    102102        unless ($success) {
    103103            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    104             &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELPHOT", $status, $dbname);
     104            &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELPHOT", $status, $dbname);
    105105        }
    106106    }
     
    112112    foreach my $filter (@filters) {
    113113        my $command = "$uniphot $filter";
    114         $command .= "-D CATDIR $catdir";
     114        $command .= "-D CATDIR $dvodb";
    115115        $command .= "-region $RAs $RAe $DECs $DECe";
    116116
     
    120120        unless ($success) {
    121121            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    122             &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "UNIPHOT", $status, $dbname);
     122            &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "UNIPHOT", $status, $dbname);
    123123        }
    124124    }
     
    127127{
    128128    my $command = "$relastro -objects";
    129     $command .= "-D CATDIR $catdir";
     129    $command .= "-D CATDIR $dvodb";
    130130    $command .= "-region $RAs $RAe $DECs $DECe";
    131131
     
    135135    unless ($success) {
    136136        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    137         &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELASTRO.OBJECTS", $status, $dbname);
     137        &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.OBJECTS", $status, $dbname);
    138138    }
    139139}
     
    141141{
    142142    my $command = "$relastro -images";
    143     $command .= "-D CATDIR $catdir";
     143    $command .= "-D CATDIR $dvodb";
    144144    $command .= "-region $RAs $RAe $DECs $DECe";
    145145
     
    149149    unless ($success) {
    150150        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    151         &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELASTRO.IMAGES", $status, $dbname);
    152     }
    153 }
    154 
    155 my $command = "$caltool -addcalrun";
    156 $command .= " -dvo_id $dvo_id";
     151        &my_die ("Unable to perform addstar -resort on region $region: $error_code", $cal_id, $region, "RELASTRO.IMAGES", $status, $dbname);
     152    }
     153}
     154
     155my $command = "$caltool -addrun";
     156$command .= " -cal_id $cal_id";
    157157$command .= " -region $region";
    158158$command .= " -last_step RELASTRO.IMAGES";
    159 $command .= " -status SUCCESS";
     159$command .= " -state 0";
    160160$command .= " -dbname $dbname" if defined $dbname;
    161161
     
    176176{
    177177    my $msg = shift; # Warning message on die
    178     my $dvo_id    = shift;
     178    my $cal_id    = shift;
    179179    my $region    = shift;
    180180    my $last_step = shift;
     
    183183
    184184    carp($msg);
    185     if ($dvo_id && $region && $last_step && $status and not $no_update) {
     185    if ($cal_id && $region && $last_step && $status and not $no_update) {
    186186        my $command = "$caltool -addcalrun";
    187         $command .= " -dvo_id $dvo_id";
     187        $command .= " -cal_id $cal_id";
    188188        $command .= " -region $region";
    189189        $command .= " -last_step $last_step";
    190         $command .= " -status $status";
     190        $command .= " -state $status";
    191191        $command .= " -dbname $dbname" if defined $dbname;
    192192        system ($command);
  • trunk/ippScripts/scripts/flatcorr_proc.pl

    r15356 r16276  
    88
    99# relphot -D CATDIR $dvodb -grid (outgrid.fits) (filter) -region 0 360 -90 90 (other parameters?)
    10 
    11 # detselect flat?
    1210
    1311# dvoMakeCorr -file outgrid.fits -ref ref.fits outcorr
     
    5250use Pod::Usage qw( pod2usage );
    5351
    54 my ($dvo_id, $catdir, $region, $dbname, $workdir, $no_update, $no_op);
     52my ($corr_id, $dvodb, $region, $filter, $dbname, $workdir, $no_update, $no_op);
    5553GetOptions(
    56     'dvo_id|i=s'       => \$dvo_id,
    57     'catdir|c=s'       => \$catdir,
     54    'corr_id|i=s'      => \$corr_id,
     55    'dvodb|c=s'        => \$dvodb,
    5856    'region|r=s'       => \$region,
     57    'filter|f=s'       => \$filter,
    5958    'dbname|d=s'       => \$dbname,# Database name
    6059    'workdir|w=s'      => \$workdir, # Working directory for output files
     
    6463
    6564pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    66 pod2usage( -msg => "Required options: --dvo_id --catdir --region",
     65pod2usage( -msg => "Required options: --corr_id --dvodb --region --filter",
    6766           -exitval => 3) unless
    68     defined $dvo_id and
    69     defined $catdir and
    70     defined $region;
     67    defined $corr_id and
     68    defined $dvodb and
     69    defined $region and
     70    defined $filter;
    7171
    7272# Look for programs we need
    7373my $missing_tools;
    74 my $addstar  = can_run('addstar')  or (warn "Can't find addstar"  and $missing_tools = 1);
    75 my $relphot  = can_run('relphot')  or (warn "Can't find relphot"  and $missing_tools = 1);
    76 my $uniphot  = can_run('uniphot')  or (warn "Can't find uniphot"  and $missing_tools = 1);
    77 my $relastro = can_run('relastro') or (warn "Can't find relastro" and $missing_tools = 1);
    78 my $caltool  = can_run('caltool')  or (warn "Can't find caltool"  and $missing_tools = 1);
     74my $relphot     = can_run('relphot')      or (warn "Can't find relphot"      and $missing_tools = 1);
     75my $dvoMakeCorr = can_run('dvoMakeCorr')  or (warn "Can't find dvoMakeCorr"  and $missing_tools = 1);
     76my $detselect   = can_run('detselect')    or (warn "Can't find detselect"    and $missing_tools = 1);
     77my $dettool     = can_run('dettool')      or (warn "Can't find dettool"      and $missing_tools = 1);
     78my $flatcorr    = can_run('flatcorr')     or (warn "Can't find flatcorr"     and $missing_tools = 1);
    7979
    8080if ($missing_tools) {
     
    8383}
    8484
    85 # select the primary filters from DVO query?
    86 my (@filters) = `photcodeList -average`;
     85my($outgrid, $outcorr);
     86
     87$outgrid = "$workdir/grid.$corr_id.fits";
     88$outcorr = "$workdir/corr.$corr_id.fits";
    8789
    8890# parse the region (RAs,RAe:DECs,DECe) : item = +/-NNN.NNNN
     
    9193my ($DECs, $DECe) = split (",", $coords[1]);
    9294
    93 # Run addstar -resort
    94 {
    95     my $command = "$addstar -resort";
    96     $command .= "-D CATDIR $catdir";
     95# Run relphot (filter) for each filter
     96{
     97    my $command = "$relphot $filter";
     98    $command .= "-D CATDIR $dvodb";
    9799    $command .= "-region $RAs $RAe $DECs $DECe";
    98 
    99     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    100         cache_run(command => $command, verbose => 1);
    101 
    102     unless ($success) {
    103         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    104         &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RESORT", $status, $dbname);
    105     }
    106 }
    107 
    108 # Run relphot (filter) for each filter
    109 {
    110     foreach my $filter (@filters) {
    111         my $command = "$relphot $filter";
    112         $command .= "-D CATDIR $catdir";
    113         $command .= "-region $RAs $RAe $DECs $DECe";
    114 
    115         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    116             cache_run(command => $command, verbose => 1);
    117 
    118         unless ($success) {
    119             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    120             &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELPHOT", $status, $dbname);
    121         }
    122     }
    123 }
    124 
    125 # Run uniphot (filter) for each filter
    126 # XXX skip this one?  run less frequently?
    127 if (0) {
    128     foreach my $filter (@filters) {
    129         my $command = "$uniphot $filter";
    130         $command .= "-D CATDIR $catdir";
    131         $command .= "-region $RAs $RAe $DECs $DECe";
    132 
    133         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    134             cache_run(command => $command, verbose => 1);
    135 
    136         unless ($success) {
    137             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    138             &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "UNIPHOT", $status, $dbname);
    139         }
    140     }
    141 }
    142 
    143 {
    144     my $command = "$relastro -objects";
    145     $command .= "-D CATDIR $catdir";
     100    $command .= "-grid $outgrid";
     101    $command .= "-imfreeze?";
     102
     103    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     104        cache_run(command => $command, verbose => 1);
     105
     106    unless ($success) {
     107        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     108        &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELPHOT", $status, $dbname);
     109    }
     110}
     111
     112# use one of the input raw images as a reference image
     113my ($reffile)
     114{
     115    my $command = "$flatcoor -flatcorrimfile -limit 1";
     116
     117    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     118        cache_run(command => $command, verbose => 1);
     119
     120    unless ($success) {
     121        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     122        &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELPHOT", $status, $dbname);
     123    }
     124
     125    # parse the output metadata to get the refernece image filename
     126    $reffile = "foobar";
     127}
     128
     129{
     130    my $command = "$dvoMakeCorr -file $outgrid -ref $reffile $outcorr";
     131    $command .= "-D CATDIR $dvodb";
    146132    $command .= "-region $RAs $RAe $DECs $DECe";
    147133
     
    156142
    157143{
    158     my $command = "$relastro -images";
    159     $command .= "-D CATDIR $catdir";
    160     $command .= "-region $RAs $RAe $DECs $DECe";
     144    my $command = "$dettool -register";
     145    $command .= "-det_type FLATCORR";
     146    $command .= "-file_level $fileLevel";
     147    $command .= "-workdir $workdir";
     148    $command .= "-inst $inst";
     149    $command .= " -dbname $dbname" if defined $dbname;
     150    ## XXX what else do we need, and where do we get it?
    161151
    162152    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    169159}
    170160
    171 my $command = "$caltool -addcalrun";
    172 $command .= " -dvo_id $dvo_id";
    173 $command .= " -region $region";
    174 $command .= " -last_step RELASTRO.IMAGES";
    175 $command .= " -status SUCCESS";
     161my $command = "$flatcorr -done";
     162$command .= " -corr_id $corr_id";
     163$command .= " -stats UNKNOWN";
    176164$command .= " -dbname $dbname" if defined $dbname;
    177165
Note: See TracChangeset for help on using the changeset viewer.