IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 10, 2010, 4:22:42 PM (16 years ago)
Author:
watersc1
Message:

experimental sweetspot stack code. Test for july lunation seemed to work.

File:
1 edited

Legend:

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

    r28875 r28887  
    2525my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    2626my $mkBTpcontrol = can_run('make_burntool_pcontrol.pl') or (warn "Can't find make_burntool_pcontrol.pl" and $missing_tools = 1);
     27my $moondata = can_run('moondata') or (warn "Can't find moondata" and $missing_tools = 1);
    2728
    2829if ($missing_tools) {
     
    4344my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only, $this_mode_only, $check_mode, $burntool_stats);
    4445my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips);
    45 my ( $check_stacks, $queue_stacks, $check_diffs, $queue_diffs, $clean_old);
     46my ( $check_stacks, $queue_stacks, $check_sweetspot, $queue_sweetspot, $check_diffs, $queue_diffs, $clean_old);
    4647my ( $check_detrends, $queue_detrends, $check_dqstats, $queue_dqstats);
    4748
     
    6970    'check_stacks'         => \$check_stacks,
    7071    'queue_stacks'         => \$queue_stacks,
     72    'check_sweetspot'      => \$check_sweetspot,
     73    'queue_sweetspot'      => \$queue_sweetspot,
    7174    'check_detrends'       => \$check_detrends,
    7275    'queue_detrends'       => \$queue_detrends,
     
    99102           --check_stacks         Confirm that stacks can be built.
    100103           --queue_stacks         Issue stacktool commands to queue stacks.
     104           --check_sweetspot      See if we should queue SweetSpot stacks.
     105           --queue_sweetspot      Issue stacktool commands to queue SweetSpot stacks.
    101106           --check_detrends       Confirm that detrend verify runs can be built.
    102107           --queue_detrends       Issue dettool commands to queue detrend verify runs.
     
    113118          ) unless
    114119    defined $check_registration or defined $define_burntool or defined $queue_burntool or
    115     defined $queue_chips or defined $queue_stacks or $queue_detrends or $queue_dqstats or
    116     defined $check_chips or defined $check_stacks or $check_detrends or $check_dqstats or
     120    defined $queue_chips or defined $queue_stacks or $queue_sweetspot or $queue_detrends or $queue_dqstats or
     121    defined $check_chips or defined $check_stacks or $check_sweetspot or $check_detrends or $check_dqstats or
    117122    defined $test_mode or defined $clean_old or defined $check_mode;
    118123
     
    306311    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    307312}
     313
    308314if (defined($check_dqstats) || defined($test_mode)) {
    309315    $metadata_out{nsState} = 'CHECKDQSTATS';
     
    318324    unless (defined($test_mode)) { exit(0); }
    319325}
     326
    320327if (defined($check_detrends) || defined($test_mode) || defined($check_mode)) {
    321328    $metadata_out{nsState} = 'CHECKDETRENDS';
     
    330337    exit(0);
    331338}
     339
    332340if (defined($define_burntool) || defined($test_mode)) {
    333341    $metadata_out{nsState} = 'QUEUEBURNING';
     
    341349    unless (defined($test_mode)) { exit(0); }
    342350}
     351
    343352if (defined($check_chips) || defined($test_mode) || defined($check_mode)) {
    344353    $metadata_out{nsState} = 'QUEUECHIPS';
     
    356365    exit(0);
    357366}
     367
    358368if (defined($check_stacks) || defined($test_mode) || defined($check_mode)) {
    359369    $metadata_out{nsState} = 'TOWARP';
     
    374384    exit(0);
    375385}
     386
     387if (defined($check_sweetspot) || defined($test_mode) || defined($check_mode)) {
     388    $metadata_out{nsState} = 'CHECKSWEETSPOT';
     389    &execute_sweetspot($date,"pretend");
     390    return_metadata($date);
     391    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
     392}
     393if (defined($queue_sweetspot)) {
     394    $metadata_out{nsState} = 'CHECKSWEETSPOT';
     395    &execute_sweetspot($date);
     396    return_metadata($date);
     397    exit(0);
     398}
     399
    376400if (defined($check_diffs) || defined($queue_diffs)) {
    377401    die("Diffs are currently not implemented.");
    378402}
     403
    379404if (defined($clean_old) || defined($test_mode)) {
    380405    if (defined($test_mode)) {
     
    864889    if (($metadata_out{nsState} eq 'CHECKDETRENDS') && ($exposures > 0)) {
    865890        $metadata_out{nsState} eq 'QUEUEDETRENDS';
     891    }
     892}
     893
     894#
     895# SweetSpot Stacking
     896################################################################################
     897sub construct_sweetspot_cmd {
     898    my $date = shift;
     899    my $target = 'SweetSpot';
     900    my $filter = 'w.00000';
     901
     902    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target);
     903
     904    # Dateobs begin end?
     905    my ($dateobs_begin,$dateobs_end) = get_lunation_extent($date);
     906    my $select = "-select_dateobs_begin ${dateobs_begin}T00:00:00 -select_dateobs_end ${dateobs_end}T00:00:00";
     907    my $cmd = "$stacktool";
     908    $cmd .= " -simple -dbname $dbname -definebyquery ";
     909    $cmd .= " -set_label SweetSpot.refstack -select_label $label ";
     910    $cmd .= " -set_workdir $workdir -set_dist_group $dist_group ";
     911    $cmd .= " -select_filter $filter -set_data_group $data_group ";
     912    $cmd .= " -select_good_frac_min 0.1 -select_fwhm_major_max 8.0 ";
     913    $cmd .= " -min_num 7 -min_new 4";
     914    $cmd .= " $select ";
     915    if ($debug == 1) {
     916        $cmd .= ' -pretend ';
     917    }
     918    print STDERR "$cmd\n";
     919    return($cmd);
     920}
     921
     922sub get_lunation_extent {
     923    my $date = shift;
     924    my ($year,$month,$day) = split /-/,$date;
     925    my $dateobs_begin;
     926    my $dateobs_end;
     927
     928    my $dt = DateTime->new(year => $year, month => $month, day => $day,
     929                           hour => 0, minute => 0, second => 0, nanosecond => 0,
     930                           time_zone => 'Pacific/Honolulu');
     931    do {
     932        $dt->subtract(days => 1);
     933        my $ymd = $dt->ymd;
     934        my $md_cmd = "moondata $ymd 0 0";
     935        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     936            run ( command => $md_cmd, verbose => $verbose);
     937        unless ($success) {
     938            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     939            &my_die("Unable to perform moondata: $error_code", 0,0, $date, $PS_EXIT_SYS_ERROR);
     940        }
     941        my @result = split /\s+/,(join "\n", @$stdout_buf);
     942        if (abs($result[6]) <= 0.5) {
     943            $dateobs_end = $ymd;
     944        }
     945    } while (!defined($dateobs_end));
     946   
     947    do {
     948        $dt->subtract(days => 1);
     949        my $ymd = $dt->ymd;
     950        my $md_cmd = "moondata $ymd 0 0";
     951        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     952            run ( command => $md_cmd, verbose => $verbose);
     953        unless ($success) {
     954            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     955            &my_die("Unable to perform moondata: $error_code", 0,0, $date, $PS_EXIT_SYS_ERROR);
     956        }
     957        my @result = split /\s+/,(join "", @$stdout_buf);
     958        if (abs($result[6]) <= 0.5) {
     959            $dateobs_begin = $ymd;
     960        }
     961    } while (!defined($dateobs_begin));
     962       
     963    return($dateobs_begin,$dateobs_end);
     964}
     965
     966sub pre_sweetspot_queue {
     967    my $date = shift;
     968    my $command = construct_sweetspot_cmd($date) . ' -pretend ';
     969    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     970        run ( command => $command, verbose => $verbose );
     971    unless ($success) {
     972        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     973        &my_die("Unable to perform sweetspot stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     974    }
     975    my @stacks = split /\n/, (join '', @$stdout_buf);
     976    my $Nstacks = $#stacks + 1;
     977       
     978    return(1,$Nstacks);
     979}
     980
     981sub sweetspot_queue {
     982    my $date = shift;
     983    my $command = construct_sweetspot_cmd($date);
     984    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     985        run ( command => $command, verbose => $verbose );
     986    unless ($success) {
     987        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     988        &my_die("Unable to perform sweetspot stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     989    }
     990    my @stacks = split /\n/, (join '', @$stdout_buf);
     991    my $Nstacks = $#stacks + 1;
     992   
     993    return(1,$Nstacks);
     994}
     995
     996sub execute_sweetspot {   
     997    my $date = shift;
     998    my $pretend = shift;
     999   
     1000    my ($is_lunation_date,$Nstacks) = pre_sweetspot_queue($date);
     1001    if ($Nstacks == 0) {
     1002        print STDERR "execute_sweetspot: No new stacks to make ($Nstacks)\n";
     1003        $metadata_out{nsState} = 'SS_EMPTY';
     1004        return();
     1005    }
     1006    if ($Nstacks < 10) {
     1007        print STDERR "execute_sweetspot: Too few new stacks to make ($Nstacks)\n";
     1008        $metadata_out{nsState} = 'SS_FEW';
     1009        return();
     1010    }
     1011    if ($is_lunation_date == 0) {
     1012        print STDERR "execute_sweetspot: Invalid lunation date. ($date $is_lunation_date)\n";
     1013        $metadata_out{nsState} = 'SS_ERROR';
     1014        return();
     1015    }
     1016    $metadata_out{nsState} = 'SS_QUEUE';
     1017    $metadata_out{nsSweetSpot} = $Nstacks;
     1018    unless(defined($pretend)) {
     1019        $metadata_out{nsState} = 'SS_DONE';
     1020        sweetspot_queue($date);
    8661021    }
    8671022}
Note: See TracChangeset for help on using the changeset viewer.