IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 6, 2014, 11:48:53 AM (12 years ago)
Author:
eugene
Message:

merging changes from trunk

Location:
branches/eam_branches/ipp-20131211
Files:
91 edited
17 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20131211

  • branches/eam_branches/ipp-20131211/Nebulous

  • branches/eam_branches/ipp-20131211/Nebulous-Server

  • branches/eam_branches/ipp-20131211/Ohana

  • branches/eam_branches/ipp-20131211/Ohana/src/dvomerge

  • branches/eam_branches/ipp-20131211/Ohana/src/libohana/src

  • branches/eam_branches/ipp-20131211/Ohana/src/opihi

  • branches/eam_branches/ipp-20131211/Ohana/src/opihi/cmd.astro

  • branches/eam_branches/ipp-20131211/Ohana/src/opihi/cmd.data

  • branches/eam_branches/ipp-20131211/Ohana/src/relastro/src

  • branches/eam_branches/ipp-20131211/dbconfig/cam.md

  • branches/eam_branches/ipp-20131211/dbconfig/changes.txt

    r36374 r36480  
    24322432UPDATE dbversion set schema_version = '1.1.77', updated= CURRENT_TIMESTAMP();
    24332433
     2434--
     2435
     2436CREATE TABLE fullForceRun (
     2437    ff_id           BIGINT NOT NULL AUTO_INCREMENT,
     2438    skycal_id       BIGINT,
     2439    sources_path_base VARCHAR(255),
     2440    state           VARCHAR(64),
     2441    workdir         VARCHAR(255),
     2442    label           VARCHAR(64),
     2443    data_group      VARCHAR(64),
     2444    dist_group      VARCHAR(64),
     2445    note            VARCHAR(255),
     2446    reduction       VARCHAR(64),
     2447    registered TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- time run was registered
     2448    PRIMARY KEY(ff_id),
     2449    KEY(state),
     2450    KEY(label),
     2451    KEY(data_group),
     2452    KEY(skycal_id),
     2453    FOREIGN KEY(skycal_id) REFERENCES skycalRun(skycal_id)
     2454) ENGINE=innodb DEFAULT CHARSET=latin1;
     2455
     2456CREATE TABLE fullForceInput (
     2457    ff_id           BIGINT,
     2458    warp_id         BIGINT,
     2459    PRIMARY KEY(ff_id, warp_id),
     2460    FOREIGN KEY(ff_id) REFERENCES fullForceRun(ff_id),
     2461    FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id)
     2462) ENGINE=innodb DEFAULT CHARSET=latin1;
     2463
     2464CREATE TABLE fullForceResult (
     2465    ff_id           BIGINT,
     2466    warp_id         BIGINT,
     2467    path_base       VARCHAR(255) NOT NULL,
     2468    dtime_script    FLOAT,
     2469    quality         SMALLINT NOT NULL,
     2470    hostname        VARCHAR(64) NOT NULL,
     2471    software_ver    VARCHAR(16),
     2472    fault           SMALLINT NOT NULL,
     2473    PRIMARY KEY(ff_id, warp_id),
     2474    KEY(fault),
     2475    KEY(quality),
     2476    FOREIGN KEY(ff_id) REFERENCES fullForceRun(ff_id),
     2477    FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id)
     2478) ENGINE=innodb DEFAULT CHARSET=latin1;
     2479
     2480CREATE TABLE fullForceSummary (
     2481    ff_id           BIGINT,
     2482    path_base       VARCHAR(255) NOT NULL,
     2483    dtime_script    FLOAT,
     2484    quality         SMALLINT NOT NULL,
     2485    hostname        VARCHAR(64) NOT NULL,
     2486    software_ver    VARCHAR(16),
     2487    fault           SMALLINT NOT NULL,
     2488    PRIMARY KEY(ff_id),
     2489    KEY(fault),
     2490    KEY(quality),
     2491    FOREIGN KEY(ff_id) REFERENCES fullForceRun(ff_id)
     2492) ENGINE=innodb DEFAULT CHARSET=latin1;
     2493
     2494UPDATE dbversion set schema_version = '1.1.78', updated= CURRENT_TIMESTAMP();
     2495
  • branches/eam_branches/ipp-20131211/dbconfig/ipp.m4

    r34911 r36480  
    4040include(skycell.md)
    4141include(release.md)
     42include(ff.md)
  • branches/eam_branches/ipp-20131211/ippMonitor

  • branches/eam_branches/ipp-20131211/ippMonitor/czartool/czartool/Gpc1Db.pm

    r33814 r36480  
    139139    my $stateCol =  $table.".state";
    140140
     141    my $extraState = "";
     142    if ($state eq 'new') {
     143        $extraState = " OR $stateCol = 'update' ";
     144    }
     145
    141146    my $query =  $self->{_db}->prepare(<<SQL);
    142147    SELECT COUNT(DISTINCT $id)
     
    144149        JOIN $joinTable USING ($id)
    145150        WHERE label LIKE '$label'
    146         AND (($faultCol != 0 AND $stateCol = '$state') OR $stateCol = 'failed_revert')
     151        AND ($faultCol != 0 AND ($stateCol = '$state' $extraState))
    147152SQL
    148153    $query->execute;
     
    208213    my $query = undef;
    209214
     215    my $joinTable = undef;
     216    my $id = undef;
     217    if (!getJoinTableAndId($self, $stage, \$joinTable, \$id)) {return -1;}
     218
     219    # XXX: the "update" page is now obsolete. The standard processing page should now show
     220    # counts in new and update state
    210221    if ($state eq "update") {
    211 
    212222        if ($stage eq "dist") {return 0;}
    213         my $joinTable = undef;
    214         my $id = undef;
    215         if (!getJoinTableAndId($self, $stage, \$joinTable, \$id)) {return -1;}
    216223
    217224        if ($stage eq "chip" || $stage eq "fake" || $stage eq "warp" || $stage eq "diff" || $stage eq "magicDS") {
     
    226233        }
    227234        else {
    228        
    229235            $query = $self->{_db}->prepare(<<SQL);
    230236            SELECT COUNT(state)
    231                 FROM $table JOIN $joinTable
    232                 USING($id)
     237                FROM $table
    233238                WHERE label LIKE '$label'
    234239                AND state = 'update';
    235240SQL
     241       
    236242        }
    237243
     
    240246    elsif ($state eq "new") {
    241247
    242         $query = $self->{_db}->prepare(<<SQL);
    243         SELECT COUNT(state) 
    244             FROM $table
    245             WHERE label LIKE '$label'
    246             AND (state = 'new' OR state = 'update')
    247 SQL
     248        if ($stage eq "chip" || $stage eq "fake" || $stage eq "warp" || $stage eq "diff" || $stage eq "magicDS") {
     249            # get count of runs in new state and update state that have components left to update
     250            $query = $self->{_db}->prepare(<<SQL);
     251            SELECT COUNT(DISTINCT $id) 
     252                FROM $table LEFT JOIN $joinTable
     253                USING($id)
     254                WHERE label LIKE '$label'
     255                AND (state = 'new' OR (state = 'update' AND data_state = 'update'))
     256SQL
     257        } else {
     258            $query = $self->{_db}->prepare(<<SQL);
     259            SELECT COUNT(state)
     260                FROM $table
     261                WHERE label LIKE '$label'
     262                AND (state = 'new' OR state = 'update');
     263SQL
     264        }
    248265    }
    249266    else {
     
    256273SQL
    257274    }
     275
     276    # print $query->{Statement} . "\n";
    258277
    259278    $query->execute;
  • branches/eam_branches/ipp-20131211/ippScripts/Build.PL

    r36374 r36480  
    133133        scripts/queuestaticsky.pl
    134134        scripts/psphot_fullforce_warp.pl
     135        scripts/psphot_fullforce_summary.pl
    135136    )],
    136137    dist_abstract => 'Scripts for running the Pan-STARRS IPP',
  • branches/eam_branches/ipp-20131211/ippScripts/scripts/chip_imfile.pl

  • branches/eam_branches/ipp-20131211/ippScripts/scripts/destreak_restore_camera.pl

  • branches/eam_branches/ipp-20131211/ippScripts/scripts/dist_bundle.pl

    r36223 r36480  
    5050                     'PPSUB.INVERSE.MASK' => 'inv_mask',
    5151                     'PPSUB.INVERSE.VARIANCE' => 'inv_variance' );
    52 my %stack_cleaned = ( 'PPSTACK.OUTPUT' => 'image',
     52
     53my %stack_cleaned = ( 'PPSTACK.UNCONV' => 'image',
     54                      'PPSTACK.UNCONV.MASK' => 'mask',
     55                      'PPSTACK.UNCONV.VARIANCE' => 'variance',
     56                      'PPSTACK.UNCONV.EXP' => 'exp',
     57                      'PPSTACK.UNCONV.EXPNUM' => 'expnum',
     58                      'PPSTACK.UNCONV.EXPWT' => 'expwt'
     59                      );
     60
     61my %stack_convolved = ( 'PPSTACK.OUTPUT' => 'image',
    5362                      'PPSTACK.OUTPUT.MASK' => 'mask',
    54                       'PPSTACK.OUTPUT.VARIANCE' => 'variance' );
     63                      'PPSTACK.OUTPUT.VARIANCE' => 'variance',
     64                      'PPSTACK.OUTPUT.EXP' => 'exp',
     65                      'PPSTACK.OUTPUT.EXPNUM' => 'expnum',
     66                      'PPSTACK.OUTPUT.EXPWT' => 'expwt'
     67                      );
    5568my %empty_cleaned = ();
     69
    5670
    5771
     
    136150if (($stage ne 'raw') and ($stage ne 'fake') and ($stage ne 'stack_summary') and !$poor_quality) {
    137151    # If the file list is empty it is an error because we should at least get a config dump file
    138     # except for fake stage which doesn't do anything yet
     152    # except for fake stage which doesn't do anything yet, stack_summary stage, and of course raw files have
     153    # no config dump because they aren't processed
    139154    &my_die("empty file list", $component, $PS_EXIT_CONFIG_ERROR) if (!scalar @$file_list);
    140155}
     
    165180    my $image_type = get_image_type($stage, $file_rule);
    166181
     182    # skip useless empty trace files
     183    next if ($file_rule =~ /TRACE/);
     184
    167185    # if this is an image and we are building a clean bundle or if quality is bad skip this rule
    168186    next if $image_type and ($clean or $poor_quality);
     187
     188    if ($stage eq 'stack') {
     189        # skip convolved stacks since they are deleted just after they are created now
     190        next if $stack_convolved{$file_rule};
     191    }
    169192
    170193    # if magic is required, don't ship jpegs or binned fits images
     
    180203
    181204    my $file_name = $file->{name};
    182     my $base = basename($file_name);
    183205    my $path = $ipprc->file_resolve($file_name);
     206
     207    if (!$path and $file_rule =~ /LOG/) {
     208        my $compressed_file_name = $file_name . '.bz2';
     209        my $compressed_path = $ipprc->file_resolve($compressed_file_name);
     210        if ($compressed_path) {
     211            $path = $compressed_path;
     212            $file_name = $compressed_file_name;
     213        }
     214    }
     215
    184216
    185217    if (!$path) {
     
    194226        # XXX: perhaps only do this for stages where we know that this happens
    195227        next if $file_rule =~ /STATS/;
    196         # don't fail on these "non-essential files"
     228        # don't fail if these "non-essential files" are missing
     229        next if $file_rule =~ /LOG/;
    197230        next if $file_rule =~ /TRACE/;
    198         next if $file_rule =~ /LOG/;
    199231        next if $file_rule =~ /BIN/;
    200232
     
    236268        # create a symbolic link from the file in the nebulous repository
    237269        # in the temporary directory
    238         symlink $path, "$tmpdir/$base";
     270        symlink $path, "$tmpdir/" . basename($file_name);
    239271    }
    240272}
  • branches/eam_branches/ipp-20131211/ippScripts/scripts/ipp_apply_burntool_single.pl

  • branches/eam_branches/ipp-20131211/ippScripts/scripts/lap_science.pl

  • branches/eam_branches/ipp-20131211/ippScripts/scripts/magic_destreak.pl

  • branches/eam_branches/ipp-20131211/ippScripts/scripts/psphot_fullforce_warp.pl

    r36374 r36480  
    3131my $psphotFullForce = can_run('psphotFullForce') or (warn "Can't find psphotFullForce" and $missing_tools = 1);
    3232my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    33 # XXX: fftool is yet to be written
    34 my $fftool = "fftool";  # can_run('fftool') or (warn "Can't find fftool" and $missing_tools = 1);
     33my $fftool = can_run('fftool') or (warn "Can't find fftool" and $missing_tools = 1);
    3534if ($missing_tools) {
    3635    warn("Can't find required tools.");
     
    3837}
    3938
    40 my ($ffw_id, $warp_id, $skycell_id, $path_base, $sourceroot, $camera);
     39my ($ff_id, $warp_id, $skycell_id, $path_base, $sourceroot, $camera);
    4140my ($outroot, $reduction);
    4241my ($dbname, $threads, $verbose, $no_update, $no_op, $redirect);
    4342
    4443GetOptions(
    45     'ffw_id=s'          => \$ffw_id,
     44    'ff_id=s'          => \$ff_id,
    4645    'warp_id=s'         => \$warp_id,   # warp identifier
    4746    'skycell_id=s'      => \$skycell_id,# Skycell identifier
    4847    'warp_path_base=s'  => \$path_base, # path_base of the warp skycell
    49     'sourceroot=s'      => \$sourceroot,# path_base of sources
     48    'sources_path_base=s' => \$sourceroot,# path_base of sources
    5049    'camera=s'          => \$camera,    # camera name of sources
    5150    'dbname|d=s'        => \$dbname,    # Database name
     
    6160pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    6261pod2usage(
    63     -msg => "Required options: --ffw_id --sourceroot --skycell_id --warp_path_base --outroot --camera",
     62    -msg => "Required options: --ff_id --warp_id --sourceroot --skycell_id --warp_path_base --outroot --camera",
    6463    -exitval => 3,
    65           ) unless defined $ffw_id,
     64          ) unless defined $ff_id,
    6665    and defined $sourceroot
    67     and (defined $path_base or defined $warp_id) # if we don't have warp's path_base we need warp_id
     66    and defined $path_base
     67    and defined $warp_id
    6868    and defined $skycell_id
    6969    and defined $camera
    7070    and defined $outroot;
    7171
    72 # XXX: fftool is not ready to run commands that update the database
    73 $no_update = 1;
    74 
    75 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $ffw_id, $skycell_id, $PS_EXIT_CONFIG_ERROR );
     72my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $ff_id, $warp_id, $skycell_id, $PS_EXIT_CONFIG_ERROR );
    7673
    7774my $neb;
     
    8481
    8582$ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output",
    86     $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    87 
    88 if (!$path_base) {
     83    $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
     84
     85if (0) {
     86# if (!$path_base) {
    8987    # If path_base is not supplied, look it up in the database.
    9088    my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    9896            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    9997            &my_die("Unable to perform warptool -warpskyfile -inputskyfile: $error_code",
    100                 $ffw_id, $skycell_id, $error_code);
     98                $ff_id, $warp_id, $skycell_id, $error_code);
    10199        }
    102100
    103101        my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    104             &my_die("Unable to parse metadata config doc", $ffw_id, $skycell_id, $PS_EXIT_PROG_ERROR);
     102            &my_die("Unable to parse metadata config doc", $ff_id, $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR);
    105103        $files = parse_md_list($metadata) or
    106             &my_die("Unable to parse metadata list", $ffw_id, $skycell_id, $PS_EXIT_PROG_ERROR);
    107     }
    108 
    109     &my_die("Input list does not contain exactly one elements", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR)
     104            &my_die("Unable to parse metadata list", $ff_id, $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR);
     105    }
     106
     107    &my_die("Input list does not contain exactly one elements", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR)
    110108        unless scalar @$files == 1;
    111109
     
    113111
    114112    $path_base = $warp->{path_base};
    115     &my_die("Couldn't find input path in warptool output", $ffw_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR)
     113    &my_die("Couldn't find input path in warptool output", $ff_id, $warp_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR)
    116114        unless defined $path_base;
    117115
     
    123121unless ($recipe_psphot) {
    124122    &my_die("Couldn't find selected reduction for PSPHOT: $reduction\n",
    125         $ffw_id, $skycell_id, $PS_EXIT_CONFIG_ERROR);
     123        $ff_id, $warp_id, $skycell_id, $PS_EXIT_CONFIG_ERROR);
    126124}
    127125
     
    134132print "recipe_psphot: $recipe_psphot\n";
    135133
     134# use psf measured on input warp
     135# XXX: get this from recipe
     136my $useWarpPSF = 0;
     137
    136138my $input         = $ipprc->filename('PSWARP.OUTPUT', $path_base);
    137139my $inputMask     = $ipprc->filename('PSWARP.OUTPUT.MASK', $path_base);
    138140my $inputVariance = $ipprc->filename('PSWARP.OUTPUT.VARIANCE', $path_base);
    139 my $inputPSF      = $ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base);
     141my $inputPSF      = $useWarpPSF ? $ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base) : "";
    140142my $inputSources  = $ipprc->filename('PSPHOT.OUTPUT.CFF', $sourceroot);
    141143
     
    144146    print "inputMask:     $inputMask\n";
    145147    print "inputVariance: $inputVariance\n";
    146     # print "inputPath:     $path_base\n";
    147     print "inputPSF:      $inputPSF\n";
     148    print "inputPSF:      $inputPSF\n" if $inputPSF;
    148149    print "inputSources:  $inputSources\n";
    149150}
    150151
    151152# check that the inputs exist (and have non-zero size)
    152 &my_die("Couldn't find input: $input", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);
    153 &my_die("Couldn't find input: $inputMask", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);
    154 &my_die("Couldn't find input: $inputVariance", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);
    155 &my_die("Couldn't find input: $inputPSF", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputPSF);
    156 &my_die("Couldn't find input: $inputSources", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputSources);
     153&my_die("Couldn't find input: $input", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);
     154&my_die("Couldn't find input: $inputMask", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);
     155&my_die("Couldn't find input: $inputVariance", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);
     156&my_die("Couldn't find input: $inputPSF", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) if ($inputPSF && !$ipprc->file_exists($inputPSF));
     157&my_die("Couldn't find input: $inputSources", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputSources);
    157158
    158159my $dump_config = 1;
     
    193194        unless ($success) {
    194195            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    195             &my_die("Unable to perform ppSub: $error_code", $ffw_id, $skycell_id, $error_code);
     196            &my_die("Unable to perform ppSub: $error_code", $ff_id, $warp_id, $skycell_id, $error_code);
    196197        }
    197198
     
    207208            unless ($success) {
    208209                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    209                 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $ffw_id, $skycell_id, $error_code);
     210                &my_die("Unable to perform ppStatsFromMetadata: $error_code", $ff_id, $warp_id, $skycell_id, $error_code);
    210211            }
    211212            foreach my $line (@$stdout_buf) {
     
    226227# Add the result to the database
    227228{
    228     my $command = "$fftool -ffw_id $ffw_id -skycell_id $skycell_id";
    229     $command .= " -addwarped -path_base $outroot";
     229    my $command = "$fftool -ff_id $ff_id -warp_id $warp_id";
     230    $command .= " -addresult -path_base $outroot";
    230231    $command .= " $cmdflags";
    231232    $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
     
    239240            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    240241            my $err_message = "Unable to perform fftool -addwarped" ;
    241                 &my_die("$err_message: $error_code", $ffw_id, $skycell_id, $error_code);
     242                &my_die("$err_message: $error_code", $ff_id, $warp_id, $skycell_id, $error_code);
    242243        }
    243244    } else {
     
    262263    my $error;
    263264    my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error)
    264                     or &my_die("failed to prepare output file for: $filerule", $ffw_id, $skycell_id, $error);
     265                    or &my_die("failed to prepare output file for: $filerule", $ff_id, $warp_id, $skycell_id, $error);
    265266    return $output;
    266267}
     
    275276    }
    276277
    277     &my_die("Couldn't find expected output file: $file",  $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
     278    &my_die("Couldn't find expected output file: $file",  $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
    278279
    279280    # Funpack to confirm we've really made things correctly
    280281    my $diskfile = $ipprc->file_resolve($file);
    281282    if ($diskfile =~ /fits/) {
    282         my $funpack  = can_run('funpack') or &my_die ("Can't find funpack", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     283        my $funpack  = can_run('funpack') or &my_die ("Can't find funpack", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    283284        my $check_command = "$funpack -S $diskfile > /dev/null";
    284285        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    285286            run(command => $check_command, verbose => $verbose);
    286287        if (!$success) {
    287             &my_die("Output file not a valid fits file: $file", $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     288            &my_die("Output file not a valid fits file: $file", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    288289        }
    289290    }
     
    291292
    292293    if ($replicate and $neb) {
    293         $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     294        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    294295    }
    295296}
     
    299300{
    300301    my $msg = shift;            # Warning message on die
    301     my $ffw_id = shift;         # full force warp identifier
     302    my $ff_id = shift;          # full force run identifier
     303    my $warp_id = shift;        # full force warp id
    302304    my $skycell_id = shift;     # Skycell identifier
    303305    my $exit_code = shift;      # Exit code to add
     
    306308
    307309    warn($msg);
    308     if (defined $ffw_id and defined $skycell_id) {
    309         my $command = "$fftool -ffw_id $ffw_id -skycell_id $skycell_id -fault $exit_code";
    310         $command .= " -addffskyfile";
     310    if (defined $ff_id and defined $skycell_id) {
     311        my $command = "$fftool -ff_id $ff_id -warp_id $warp_id -fault $exit_code";
     312        $command .= " -addresult";
    311313        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
    312314        $command .= " -hostname $host" if defined $host;
  • branches/eam_branches/ipp-20131211/ippScripts/scripts/publish_file.pl

  • branches/eam_branches/ipp-20131211/ippScripts/scripts/queuestaticsky.pl

    r35329 r36480  
    3333};
    3434
     35# don't update the database if we are pretending
     36$no_update = 1 if $pretend;
    3537
    3638my $missing_tools;
     
    113115        }
    114116    }
     117    last if $pretend;   # only do the first (full) set if we are in pretend mode
    115118}
    116119{
  • branches/eam_branches/ipp-20131211/ippScripts/scripts/stack_skycell.pl

    r35950 r36480  
    4040}
    4141
    42 my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);
     42my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps, $delete_convolved_images);
    4343GetOptions(
    4444    'stack_id|d=s'      => \$stack_id, # Stack identifier
     
    5555    'redirect-output'   => \$redirect,
    5656    'save-temps'        => \$save_temps, # Save temporary files?
     57    'delete-convolved'  => \$delete_convolved_images,
    5758) or pod2usage( 2 );
    5859
     
    9293);
    9394
     95
    9496my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    9597$| = 1;
     
    360362
    361363    if (!$quality) {
     364       
     365
    362366        check_outputs(\@outputFiles, $replicate_outputs);
     367
     368        if (($convolve)&&($delete_convolved_images)) { # We made convolved products, but do not wish to keep them anymore
     369            my @products_to_clear = ('PPSTACK.OUTPUT',
     370                                     'PPSTACK.OUTPUT.MASK',
     371                                     'PPSTACK.OUTPUT.VARIANCE',
     372                                     'PPSTACK.OUTPUT.EXP',
     373                                     'PPSTACK.OUTPUT.EXPNUM',
     374                                     'PPSTACK.OUTPUT.EXPWT');
     375            foreach my $product (@products_to_clear) {
     376                my $file = $ipprc->filename($product,$outroot,$skycell_id);
     377                print "Deleting unwanted convolved product: $file\n";
     378                my $error= $ipprc->kill_file($file);
     379                if ($error_code) {
     380                    print "Failed to delete unwanted convolved product: $error_code\n";
     381                }
     382            }
     383        }
     384
    363385    }
    364386
  • branches/eam_branches/ipp-20131211/ippScripts/scripts/staticsky.pl

    r34852 r36480  
    138138        my $configuration = $ipprc->filename("PSPHOT.STACK.CONFIG", $outroot);
    139139
     140        my $needConvolvedImages = 0;
     141
    140142        foreach my $file (@$files) {
    141143            print $listFile "INPUT   METADATA\n";
     
    146148            my $stack_id = $file->{stack_id};
    147149
    148             my $imageCnv  = $ipprc->filename("PPSTACK.OUTPUT",          $path_base ); # Image name
    149             my $maskCnv   = $ipprc->filename("PPSTACK.OUTPUT.MASK",     $path_base ); # Mask name
    150             my $weightCnv = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $path_base ); # Weight name
    151             my $expnumCnv = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM",   $path_base ); # Expnum name
     150            my ($imageCnv, $maskCnv, $weightCnv, $expnumCnv);
     151            if ($needConvolvedImages) {
     152                $imageCnv  = $ipprc->filename("PPSTACK.OUTPUT",          $path_base ); # Image name
     153                $maskCnv   = $ipprc->filename("PPSTACK.OUTPUT.MASK",     $path_base ); # Mask name
     154                $weightCnv = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $path_base ); # Weight name
     155                $expnumCnv = $ipprc->filename("PPSTACK.OUTPUT.EXPNUM",   $path_base ); # Expnum name
     156            }
    152157
    153158            my $imageRaw  = $ipprc->filename("PPSTACK.UNCONV",          $path_base ); # Image name
     
    166171            &my_die("Couldn't find input: $weightRaw", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$weightRaw");
    167172            &my_die("Couldn't find input: $expnumRaw", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$expnumRaw");
    168             &my_die("Couldn't find input: $imageCnv",  $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$imageCnv");
    169             &my_die("Couldn't find input: $maskCnv",   $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$maskCnv");
    170             &my_die("Couldn't find input: $weightCnv", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$weightCnv");
    171             &my_die("Couldn't find input: $expnumCnv", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$expnumCnv");
    172             &my_die("Couldn't find input: $psfCnv",    $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$psfCnv");
     173            if ($needConvolvedImages) {
     174                &my_die("Couldn't find input: $imageCnv",  $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$imageCnv");
     175                &my_die("Couldn't find input: $maskCnv",   $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$maskCnv");
     176                &my_die("Couldn't find input: $weightCnv", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$weightCnv");
     177                &my_die("Couldn't find input: $expnumCnv", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$expnumCnv");
     178                &my_die("Couldn't find input: $psfCnv",    $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$psfCnv");
     179            }
    173180            &my_die("Couldn't find input: $sources",   $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$sources");
    174181
     
    178185            print $listFile "  RAW:VARIANCE  STR  " . $weightRaw . "\n";
    179186            print $listFile "  RAW:EXPNUM    STR  " . $expnumRaw . "\n";
    180 
    181             print $listFile "  CNV:IMAGE     STR  " . $imageCnv  . "\n";
    182             print $listFile "  CNV:MASK      STR  " . $maskCnv   . "\n";
    183             print $listFile "  CNV:VARIANCE  STR  " . $weightCnv . "\n";
    184             print $listFile "  CNV:EXPNUM    STR  " . $expnumCnv . "\n";
    185             print $listFile "  CNV:PSF       STR  " . $psfCnv    . "\n";
    186 
    187187            print $listFile "  SOURCES       STR  " . $sources   . "\n";
     188            if ($needConvolvedImages) {
     189                print $listFile "  CNV:IMAGE     STR  " . $imageCnv  . "\n";
     190                print $listFile "  CNV:MASK      STR  " . $maskCnv   . "\n";
     191                print $listFile "  CNV:VARIANCE  STR  " . $weightCnv . "\n";
     192                print $listFile "  CNV:EXPNUM    STR  " . $expnumCnv . "\n";
     193                print $listFile "  CNV:PSF       STR  " . $psfCnv    . "\n";
     194            }
    188195
    189196            print $listFile "END\n\n";
  • branches/eam_branches/ipp-20131211/ippScripts/scripts/warp_skycell.pl

  • branches/eam_branches/ipp-20131211/ippTasks

  • branches/eam_branches/ipp-20131211/ippTasks/Makefile.am

    r36372 r36480  
    4646        diffphot.pro \
    4747        lap.pro \
     48        lapgroup.pro \
    4849        vp.pro \
    49         bg.regeneration.pro
     50        bg.regeneration.pro \
     51        fullforce.pro
    5052
    5153other_files = \
  • branches/eam_branches/ipp-20131211/ippTasks/pstamp.pro

    r35462 r36480  
    825825        book getword pstampDependent $pageName imagedb    -var IMAGEDB
    826826        book getword pstampDependent $pageName rlabel     -var RLABEL
     827        book getword pstampDependent $pageName label      -var LABEL
    827828        book getword pstampDependent $pageName outdir     -var OUTDIR
    828829        book getword pstampDependent $pageName need_magic -var NEED_MAGIC
     
    846847        stderr $MYLOGFILE
    847848
    848         $run = pstamp_checkdependent.pl --dep_id $DEP_ID --stage_id $STAGE_ID --stage $STAGE --component $COMPONENT --imagedb $IMAGEDB --rlabel $RLABEL $NEED_MAGIC --fault_count $FAULT_COUNT --max_fault_count $PSTAMP_MAX_FAULT_COUNT --logfile $MYLOGFILE
     849        $run = pstamp_checkdependent.pl --dep_id $DEP_ID --stage_id $STAGE_ID --stage $STAGE --component $COMPONENT --imagedb $IMAGEDB --rlabel $RLABEL --label $LABEL $NEED_MAGIC --fault_count $FAULT_COUNT --max_fault_count $PSTAMP_MAX_FAULT_COUNT --logfile $MYLOGFILE
    849850
    850851        add_standard_args run
  • branches/eam_branches/ipp-20131211/ippTasks/rawcheck.pro

    r36372 r36480  
    7575  task.exec
    7676      book npages rawcheckPending -var N
    77       if ($N > 2000)
     77      if ($N > 200)
    7878        process_cleanup rawcheckPending
    7979        break
  • branches/eam_branches/ipp-20131211/ippToPsps

  • branches/eam_branches/ipp-20131211/ippToPsps/jython/dvo.py

    r36201 r36480  
    6565        if not self.correctDvo:
    6666            print "*******************************************************************************"
    67             self.logger.warning("switching to a new dvo: " + self.skychunk.dvoLocation)
     67            self.logger.warning("switching to a new dvo: '" + self.skychunk.dvoLocation + "'")
    6868            # response = raw_input("(y/n) ")
    6969            # if response == "y":
     
    669669            cmd += " -time-start " + time_start
    670670            cmd += " -time-end " + time_end
    671    
     671
     672        useP2 = 0   
     673        useST = 0
     674       
     675        for batchType in self.skychunk.batchTypes:
     676            self.logger.infoPair("batchType", batchType)
     677            if batchType == "ST":
     678                useST = 1
     679            if batchType == "P2":
     680                useP2 = 1
     681
     682        if (useP2 ==0 and useST ==1):
     683            #grab only stacks
     684            cmd += " -photcode-start 11000 -photcode-end 11500"
     685
     686        if (useP2 ==1 and useST==0):
     687            #grabd only P2s   
     688            cmd += " -photcode-start 10000 -photcode-end 10577"
     689
     690
    672691        self.logger.infoPair("Running dvopsps", cmd)
    673692        p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
  • branches/eam_branches/ipp-20131211/ippToPsps/jython/gpc1db.py

    r36201 r36480  
    9393                   JOIN mergedvodbRun USING(minidvodb_id) \
    9494                   JOIN mergedvodbProcessed USING (merge_id) \
    95                    JOIN  stackRun USING(stack_id) JOIN skycell USING(skycell_id) \
     95                   JOIN stackRun USING(stack_id) \
     96                   JOIN stackSumSkyfile using (stack_id) \
     97                   JOIN skycell USING(skycell_id) \
    9698                   WHERE mergedvodbRun.mergedvodb = '" + dvoDb + "' \
    9799                   AND minidvodbRun.state = 'merged' \
     
    102104                   AND addRun.state = 'full' \
    103105                   AND decdeg BETWEEN " + str(minDec) + " AND " + str(maxDec) + " \
    104                    AND radeg BETWEEN " + str(minRA) + " AND " + str(maxRA)
    105            
     106                   AND radeg BETWEEN " + str(minRA) + " AND " + str(maxRA) + " \
     107                   AND mjd_obs >= (to_days('" + tstart + "')-678941) \
     108                   AND mjd_obs <= (to_days('" + tend + "') - 678941) "
     109            self.logger.infoPair("sql",sql)     
    106110        try:
    107111            # XXX EAM : test output
  • branches/eam_branches/ipp-20131211/ippToPsps/jython/queue.py

    r36202 r36480  
    4545
    4646        try:
     47            print "why doesn't this work"
    4748            self.dvoObjects = DvoObjects(self.logger, self.config, self.skychunk, self.ippToPspsDb, self.scratchDb)
    4849        except:
  • branches/eam_branches/ipp-20131211/ippToPsps/jython/stackbatch.py

    r36190 r36480  
    303303            modelLong = model;
    304304
     305        #does it have the EXT_COVAR in there?
     306
     307        sql = "DESCRIBE SkyChip_xfit 'EXT_COVAR_%'"
     308        rs = self.scratchDb.executeQuery(sql)
     309        rs.first()
     310        hasResult = rs.next()
     311        if hasResult:
     312           print "EXT_COVARs exist"
     313        else:
     314           print "No EXT_COVARS here"
     315
     316        ext_covar_sql = ""
     317 
     318        if (hasResult):
     319            ext_covar_sql = ", "+modelLong+"Covar11=b.EXT_COVAR_00_00,  \
     320            "+modelLong+"Covar12=b.EXT_COVAR_00_01,  \
     321            "+modelLong+"Covar13=b.EXT_COVAR_00_02,  \
     322            "+modelLong+"Covar14=b.EXT_COVAR_00_03,  \
     323            "+modelLong+"Covar15=b.EXT_COVAR_00_04,  \
     324            "+modelLong+"Covar16=b.EXT_COVAR_00_05,  \
     325            "+modelLong+"Covar17=b.EXT_COVAR_00_06,  \
     326            "+modelLong+"Covar22=b.EXT_COVAR_01_01,  \
     327            "+modelLong+"Covar23=b.EXT_COVAR_01_02,  \
     328            "+modelLong+"Covar24=b.EXT_COVAR_01_03,  \
     329            "+modelLong+"Covar25=b.EXT_COVAR_01_04,  \
     330            "+modelLong+"Covar26=b.EXT_COVAR_01_05,  \
     331            "+modelLong+"Covar27=b.EXT_COVAR_01_06,  \
     332            "+modelLong+"Covar33=b.EXT_COVAR_02_02,  \
     333            "+modelLong+"Covar34=b.EXT_COVAR_02_03,  \
     334            "+modelLong+"Covar35=b.EXT_COVAR_02_04,  \
     335            "+modelLong+"Covar36=b.EXT_COVAR_02_05,  \
     336            "+modelLong+"Covar37=b.EXT_COVAR_02_06,  \
     337            "+modelLong+"Covar44=b.EXT_COVAR_03_03,  \
     338            "+modelLong+"Covar45=b.EXT_COVAR_03_04,  \
     339            "+modelLong+"Covar46=b.EXT_COVAR_03_05,  \
     340            "+modelLong+"Covar47=b.EXT_COVAR_03_06,  \
     341            "+modelLong+"Covar55=b.EXT_COVAR_04_04,  \
     342            "+modelLong+"Covar56=b.EXT_COVAR_04_05,  \
     343            "+modelLong+"Covar57=b.EXT_COVAR_04_06,  \
     344            "+modelLong+"Covar66=b.EXT_COVAR_05_05,  \
     345            "+modelLong+"Covar67=b.EXT_COVAR_05_06,  \
     346            "+modelLong+"Covar77=b.EXT_COVAR_06_06"
     347       
     348       
     349
     350
    305351        sql = "UPDATE StackModelFit AS a, SkyChip_xfit AS b SET \
    306352        "+model+"Radius=b.EXT_WIDTH_MAJ,  \
     
    308354        "+model+"FluxErr=ABS(b.EXT_INST_MAG_SIG) * POW(10, -0.4 * b.EXT_INST_MAG) / " + str(self.expTime) + " / 1.085736, \
    309355        "+model+"Ab=b.EXT_WIDTH_MAJ/b.EXT_WIDTH_MIN, \
    310         "+model+"Phi=b.EXT_THETA,  \
    311         "+modelLong+"Covar11=b.EXT_COVAR_00_00,  \
    312         "+modelLong+"Covar12=b.EXT_COVAR_00_01,  \
    313         "+modelLong+"Covar13=b.EXT_COVAR_00_02,  \
    314         "+modelLong+"Covar14=b.EXT_COVAR_00_03,  \
    315         "+modelLong+"Covar15=b.EXT_COVAR_00_04,  \
    316         "+modelLong+"Covar16=b.EXT_COVAR_00_05,  \
    317         "+modelLong+"Covar17=b.EXT_COVAR_00_06,  \
    318         "+modelLong+"Covar22=b.EXT_COVAR_01_01,  \
    319         "+modelLong+"Covar23=b.EXT_COVAR_01_02,  \
    320         "+modelLong+"Covar24=b.EXT_COVAR_01_03,  \
    321         "+modelLong+"Covar25=b.EXT_COVAR_01_04,  \
    322         "+modelLong+"Covar26=b.EXT_COVAR_01_05,  \
    323         "+modelLong+"Covar27=b.EXT_COVAR_01_06,  \
    324         "+modelLong+"Covar33=b.EXT_COVAR_02_02,  \
    325         "+modelLong+"Covar34=b.EXT_COVAR_02_03,  \
    326         "+modelLong+"Covar35=b.EXT_COVAR_02_04,  \
    327         "+modelLong+"Covar36=b.EXT_COVAR_02_05,  \
    328         "+modelLong+"Covar37=b.EXT_COVAR_02_06,  \
    329         "+modelLong+"Covar44=b.EXT_COVAR_03_03,  \
    330         "+modelLong+"Covar45=b.EXT_COVAR_03_04,  \
    331         "+modelLong+"Covar46=b.EXT_COVAR_03_05,  \
    332         "+modelLong+"Covar47=b.EXT_COVAR_03_06,  \
    333         "+modelLong+"Covar55=b.EXT_COVAR_04_04,  \
    334         "+modelLong+"Covar56=b.EXT_COVAR_04_05,  \
    335         "+modelLong+"Covar57=b.EXT_COVAR_04_06,  \
    336         "+modelLong+"Covar66=b.EXT_COVAR_05_05,  \
    337         "+modelLong+"Covar67=b.EXT_COVAR_05_06,  \
    338         "+modelLong+"Covar77=b.EXT_COVAR_06_06   \
     356        "+model+"Phi=b.EXT_THETA  \
     357        "+ext_covar_sql+"  \
    339358        WHERE a.ippDetectID=b.IPP_IDET AND b.MODEL_TYPE = '"+ippModelType+"'"
    340359
     360        print sql
    341361        self.scratchDb.execute(sql)
    342362
    343363        # sersic fit has an extra parameter
    344         if ippModelType == "PS_MODEL_SERSIC":
     364        if (ippModelType == "PS_MODEL_SERSIC" and hasResult > 0):
    345365            sql = "UPDATE StackModelFit AS a, SkyChip_xfit AS b SET \
    346366            "+modelLong+"Covar18=b.EXT_COVAR_00_07,  \
  • branches/eam_branches/ipp-20131211/ippTools/share

  • branches/eam_branches/ipp-20131211/ippTools/share/Makefile.am

    r36361 r36480  
    488488        releasetool_definerelgroup_select_exp_lap.sql \
    489489        releasetool_stacksummary.sql \
    490         releasetool_pendingrelgroup.sql
     490        releasetool_pendingrelgroup.sql \
     491        fftool_definebyquery.sql \
     492        fftool_definebyquery_select_warps.sql \
     493        fftool_result.sql \
     494        fftool_revert.sql \
     495        fftool_revertsummary.sql \
     496        fftool_summary.sql \
     497        fftool_todo.sql \
     498        fftool_toadvance.sql
    491499
  • branches/eam_branches/ipp-20131211/ippTools/share/camtool_find_pendingimfile.sql

  • branches/eam_branches/ipp-20131211/ippTools/share/chiptool_pendingcleanuprun.sql

    r34766 r36480  
    44    rawExp.exp_tag,
    55    chipRun.state,
    6     chipRun.workdir
     6    chipRun.workdir,
     7    chipRun.label,
     8    IFNULL(Label.priority, 10000) AS priority
    79FROM chipRun
    810JOIN rawExp
    911USING (exp_id)
     12LEFT JOIN Label ON chipRun.label = Label.label
    1013WHERE
    1114    (chipRun.state = 'goto_cleaned' OR chipRun.state = 'goto_scrubbed' OR chipRun.state = 'goto_purged')
  • branches/eam_branches/ipp-20131211/ippTools/share/chiptool_setimfiletoupdate.sql

  • branches/eam_branches/ipp-20131211/ippTools/share/pxadmin_create_tables.sql

    r36374 r36480  
    23072307) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    23082308
     2309CREATE TABLE fullForceRun (
     2310    ff_id           BIGINT NOT NULL AUTO_INCREMENT,
     2311    skycal_id       BIGINT,
     2312    sources_path_base VARCHAR(255),
     2313    state           VARCHAR(64),
     2314    workdir         VARCHAR(255),
     2315    label           VARCHAR(64),
     2316    data_group      VARCHAR(64),
     2317    dist_group      VARCHAR(64),
     2318    note            VARCHAR(255),
     2319    reduction       VARCHAR(64),
     2320    registered TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- time run was registered
     2321    PRIMARY KEY(ff_id),
     2322    KEY(state),
     2323    KEY(label),
     2324    KEY(data_group),
     2325    KEY(skycal_id),
     2326    FOREIGN KEY(skycal_id) REFERENCES skycalRun(skycal_id)
     2327) ENGINE=innodb DEFAULT CHARSET=latin1;
     2328
     2329CREATE TABLE fullForceInput (
     2330    ff_id           BIGINT,
     2331    warp_id         BIGINT,
     2332    PRIMARY KEY(ff_id, warp_id),
     2333    FOREIGN KEY(ff_id) REFERENCES fullForceRun(ff_id),
     2334    FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id)
     2335) ENGINE=innodb DEFAULT CHARSET=latin1;
     2336
     2337CREATE TABLE fullForceResult (
     2338    ff_id           BIGINT,
     2339    warp_id         BIGINT,
     2340    path_base       VARCHAR(255) NOT NULL,
     2341    dtime_script    FLOAT,
     2342    quality         SMALLINT NOT NULL,
     2343    hostname        VARCHAR(64) NOT NULL,
     2344    software_ver    VARCHAR(16),
     2345    fault           SMALLINT NOT NULL,
     2346    PRIMARY KEY(ff_id, warp_id),
     2347    KEY(fault),
     2348    KEY(quality),
     2349    FOREIGN KEY(ff_id) REFERENCES fullForceRun(ff_id),
     2350    FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id)
     2351) ENGINE=innodb DEFAULT CHARSET=latin1;
     2352
     2353CREATE TABLE fullForceSummary (
     2354    ff_id           BIGINT,
     2355    path_base       VARCHAR(255) NOT NULL,
     2356    dtime_script    FLOAT,
     2357    quality         SMALLINT NOT NULL,
     2358    hostname        VARCHAR(64) NOT NULL,
     2359    software_ver    VARCHAR(16),
     2360    fault           SMALLINT NOT NULL,
     2361    PRIMARY KEY(ff_id),
     2362    KEY(fault),
     2363    KEY(quality),
     2364    FOREIGN KEY(ff_id) REFERENCES fullForceRun(ff_id)
     2365) ENGINE=innodb DEFAULT CHARSET=latin1;
     2366
    23092367
    23102368-- These comment lines are here to avoid an empty query error.
  • branches/eam_branches/ipp-20131211/ippTools/share/pxadmin_drop_tables.sql

    r35896 r36480  
    120120DROP TABLE IF EXISTS dqstatsContent;
    121121DROP TABLE IF EXISTS dqstatsRun;
     122DROP TABLE IF EXISTS fullForceRun;
     123DROP TABLE IF EXISTS fullForceInput;
     124DROP TABLE IF EXISTS fullForceResult;
     125DROP TABLE IF EXISTS fullForceSummary;
     126
    122127
    123128SET FOREIGN_KEY_CHECKS=1
  • branches/eam_branches/ipp-20131211/ippTools/share/warptool_towarped.sql

  • branches/eam_branches/ipp-20131211/ippTools/src

  • branches/eam_branches/ipp-20131211/ippTools/src/Makefile.am

    r34913 r36480  
    3333        vptool \
    3434        sctool \
    35         releasetool
     35        releasetool \
     36        fftool
    3637
    3738pkginclude_HEADERS = \
     
    8788        vptool.h \
    8889        sctool.h \
    89         releasetool.h
     90        releasetool.h \
     91        fftool.h
    9092
    9193lib_LTLIBRARIES = libpxtools.la
     
    332334    releasetoolConfig.c
    333335
     336fftool_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(IPPDB_CFLAGS)
     337fftool_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(IPPDB_LIBS) libpxtools.la
     338fftool_SOURCES = \
     339    fftool.c \
     340    fftoolConfig.c
     341
    334342clean-local:
    335343        -rm -f TAGS
  • branches/eam_branches/ipp-20131211/ippTools/src/camtool.c

  • branches/eam_branches/ipp-20131211/ippTools/src/camtoolConfig.c

  • branches/eam_branches/ipp-20131211/ippTools/src/chiptool.c

    r35789 r36480  
    12551255
    12561256    psMetadata *where = psMetadataAlloc();
    1257     pxAddLabelSearchArgs (config, where, "-label", "label", "==");
     1257    pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "==");
    12581258
    12591259    psString query = pxDataGet("chiptool_pendingcleanuprun.sql");
     
    12691269    }
    12701270    psFree(where);
     1271
     1272    psStringAppend(&query, "\nORDER BY priority DESC, chip_id");
    12711273
    12721274    // treat limit == 0 as "no limit"
  • branches/eam_branches/ipp-20131211/ippTools/src/magictool.c

  • branches/eam_branches/ipp-20131211/ippconfig

  • branches/eam_branches/ipp-20131211/ippconfig/gpc1

  • branches/eam_branches/ipp-20131211/ippconfig/gpc1/psastro.config

    r35723 r36480  
    380380END
    381381
     382POLE_REFCAT METADATA
     383   PSASTRO.CATDIR               STR  SYNTH.GRIZY
     384   ZERO.POINT.USE.MEAN               BOOL TRUE 
     385   PSASTRO.GRID.MIN.ANGLE       F32  -20
     386   PSASTRO.GRID.MAX.ANGLE       F32  +20
     387   PSASTRO.GRID.DEL.ANGLE       F32   0.5
     388   PSASTRO.FIELD.PADDING        F32   0.5
     389END
     390
    382391TEST_REFCAT METADATA
    383392   PSASTRO.CATDIR               STR /data/ipp064.0/ipp/ippRefs/catdir.refcat.20120524.v0
  • branches/eam_branches/ipp-20131211/ippconfig/recipes/filerules-split.mdc

    r36375 r36480  
    262262PSPHOT.STACK.RESID           OUTPUT {OUTPUT}.stk.{FILE.ID}.res.fits   IMAGE           COMP_SUB   FPA        TRUE      NONE
    263263PSPHOT.STACK.CONFIG          OUTPUT {OUTPUT}.psphotStack.mdc          TEXT            NONE       FPA        TRUE      NONE
     264
     265PSPHOT.FULLFORCE.OUTPUT      OUTPUT {OUTPUT}.cmf                      CMF             NONE       FPA        TRUE      NONE
    264266                                                     
    265267SOURCE.PLOT.RAW.MOMENTS      OUTPUT {OUTPUT}.{CHIP.NAME}.mnt.png      KAPA            NONE       CHIP       TRUE      NONE
  • branches/eam_branches/ipp-20131211/ippconfig/recipes/ppSub.config

  • branches/eam_branches/ipp-20131211/ippconfig/recipes/psastro.config

    r35723 r36480  
    33PSASTRO.ONLY.REFSTARS      BOOL FALSE  # skip all but refstar matches
    44PSASTRO.SAVE.REFMATCH      BOOL FALSE  # save refstar matches as table in output smf file
     5PSASTRO.SAVE.CFF           BOOL FALSE  # save a cff file (input for psphotFullForce)
    56
    67# select which WCS style to use on output images.
     
    272273END
    273274
     275POLE_REFCAT METADATA
     276END
     277
    274278TEST_REFCAT METADATA
    275279END
    276280
    277281STATICSKY_CAL   METADATA
     282    PSASTRO.SAVE.CFF           BOOL TRUE  # save a cff file (input for psphotFullForce)
    278283END
    279284
  • branches/eam_branches/ipp-20131211/ippconfig/recipes/psphot.config

    r36375 r36480  
    196196EXT.NSIGMA.LIMIT.USE                BOOL  TRUE
    197197
    198 EXT.FIT.MIN.GAL.LIMIT               F32   10.0
    199 EXT.FIT.MIN.GAL.LIMIT.USE           BOOL  FALSE
     198# Limits on extended source fits by galactic coordinates
     199EXT.FIT.MIN.GAL.LIMIT.USE           BOOL  FALSE # if true apply the galactic latitude cut
     200# objects are skipped for extended source fits if they have a abs(galactic latitude) larger than
     201# a limit value which is a function of galactic longitude.
     202#     The galactic latitude limit is the sum of the following constant value ...
     203EXT.FIT.MIN.GAL.LIMIT               F32   20.0
     204# ... and a gaussian function of galactic longitude centered at b = 0 with this magnitude
     205EXT.FIT.MIN.GAL.LIMIT.BULGE         F32   15.0 
     206# ... and this sigma
     207EXT.FIT.MIN.GAL.LIMIT.BULGE.SIGMA   F32   50.0  # with this sigma value
     208
    200209
    201210KRON_ITERATIONS                     S32   2
     
    224233 #QGAUSS_PSF  EXTENDED_SOURCE_MODEL  PS_MODEL_QGAUSS   20.0    TRUE
    225234 # TRAIL_RAW EXTENDED_SOURCE_MODEL  PS_MODEL_TRAIL    10.0   FALSE
    226  EXP_PCM  EXTENDED_SOURCE_MODEL  PS_MODEL_EXP      10.0    TRUE
    227  DEV_PCM  EXTENDED_SOURCE_MODEL  PS_MODEL_DEV      10.0    TRUE
    228  SER_PCM  EXTENDED_SOURCE_MODEL  PS_MODEL_SERSIC   10.0    TRUE
     235 EXP_PCM  EXTENDED_SOURCE_MODEL  PS_MODEL_EXP      0.0    TRUE
     236 DEV_PCM  EXTENDED_SOURCE_MODEL  PS_MODEL_DEV      0.0    TRUE
     237 SER_PCM  EXTENDED_SOURCE_MODEL  PS_MODEL_SERSIC   0.0    TRUE
    229238END
    230239
     
    407416
    408417EXT.ANALYSIS.MAG.LIMITS METADATA
    409     TYPE  DATA FILTER.ID MAG.LIMIT
    410     gband DATA g         NAN           
    411     rband DATA r         NAN           
    412     iband DATA i         NAN             
    413     zband DATA z         NAN             
    414     yband DATA y         NAN             
    415     wband DATA w         NAN             
    416     other DATA any       NAN             
     418    TYPE  DATA FILTER.ID MAG.LIMIT.PETRO    MAG.LIMIT.EXTFIT
     419    gband DATA g         25                 21.5
     420    rband DATA r         25                 21.5
     421    iband DATA i         25                 21.5
     422    zband DATA z         25                 20.5
     423    yband DATA y         25                 19.5
     424    wband DATA w         25                 21.5
     425    other DATA any       25                 21.5
    417426END
    418427
     
    423432RADIAL_APERTURES_SN_LIM             F32   0.0  # S/N limit for radial aperture calculation
    424433
     434# zero point and exposure time to which fullForceSummary scales fluxes to
     435PSPHOT.FULLFORCE.EXPTIME            F32   1.00
     436PSPHOT.FULLFORCE.ZERO_PT            F32   25.00
     437
     438
    425439GALAXY_SHAPES                       BOOL  F
     440GALAXY_SHAPES_STYLE                 STR   R_MAJ_R_MIN
     441
    426442GALAXY_SHAPES_FR_MAJOR_MIN          F32   0.5
    427 GALAXY_SHAPES_FR_MAJOR_MAX          F32   2.0
    428 GALAXY_SHAPES_FR_MAJOR_DEL          F32   0.1
     443GALAXY_SHAPES_FR_MAJOR_MAX          F32   2.00
     444GALAXY_SHAPES_FR_MAJOR_DEL          F32   0.05
    429445GALAXY_SHAPES_FR_MINOR_MIN          F32   0.5
    430 GALAXY_SHAPES_FR_MINOR_MAX          F32   2.0
    431 GALAXY_SHAPES_FR_MINOR_DEL          F32   0.1
    432 
     446GALAXY_SHAPES_FR_MINOR_MAX          F32   2.00
     447GALAXY_SHAPES_FR_MINOR_DEL          F32   0.05
     448
     449#GALAXY_SHAPES_FR_MAJOR_MIN          F32   0.85
     450#GALAXY_SHAPES_FR_MAJOR_MAX          F32   1.15
     451#GALAXY_SHAPES_FR_MAJOR_DEL          F32   0.05
     452#GALAXY_SHAPES_FR_MINOR_MIN          F32   0.85
     453#GALAXY_SHAPES_FR_MINOR_MAX          F32   1.15
     454#GALAXY_SHAPES_FR_MINOR_DEL          F32   0.05
    433455
    434456# Extended source fit parameters
     
    439461  EXTENDED_SOURCE_ANNULI              BOOL  TRUE
    440462  EXT.NSIGMA.LIMIT.USE                BOOL  FALSE
     463  EXT.FIT.MIN.GAL.LIMIT.USE           BOOL  TRUE  # limit extended source fits by galactic coordinates
    441464
    442465  PSPHOT.STACK.MATCH.PSF.SOURCE       STR   AUTO # which inputs to convolve? (RAW, CNV, AUTO)
     
    465488  EXT_MODEL                           STR   PS_MODEL_QGAUSS
    466489  PEAKS_NMAX_TOTAL                    S32   0 # set this to limit the allowed number of peaks - Yields fault instead of avoid memory explosion
     490
    467491
    468492  SAVE.RESID                          BOOL  TRUE
     
    683707    RADIAL_APERTURES        BOOL    TRUE
    684708    EXTENDED_SOURCE_FITS    BOOL    TRUE    # this casues the xfit extension to be written out
    685     EXTENDED_SOURCE_PETROSIAN BOOL    TRUE  # I want petrosian mags
     709    EXTENDED_SOURCE_PETROSIAN BOOL  TRUE    # To measure petrosian magnitudes
     710    EXTENDED_SOURCE_ANNULI  BOOL    TRUE
    686711    SAVE.PSF                BOOL    FALSE
    687712    SAVE.BACKMDL            BOOL    FALSE
    688     # SAVE.RESID            BOOL    FALSE
    689     # OUTPUT.FORMAT         STR     PS1_V3
    690 END
     713    SAVE.RESID              BOOL    TRUE
     714    OUTPUT.FORMAT           STR     PS1_SV2
     715END
  • branches/eam_branches/ipp-20131211/ippconfig/recipes/reductionClasses.mdc

    r36375 r36480  
    251251        BACKGROUND_PSWARP       STR     BACKGROUND
    252252        FULLFORCE_PSPHOT  STR   FULLFORCE_WARP
     253END
     254
     255# basic science analysis
     256POLE_REFCAT             METADATA
     257        CHIP_PPIMAGE      STR     CHIP
     258        CHIP_PSPHOT       STR     CHIP
     259        JPEG_BIN1         STR     PPIMAGE_J1
     260        JPEG_BIN2         STR     PPIMAGE_J2
     261        ADDSTAR           STR     ADDSTAR
     262        PSASTRO           STR     POLE_REFCAT
    253263END
    254264
  • branches/eam_branches/ipp-20131211/ppImage/src

  • branches/eam_branches/ipp-20131211/ppSub/src/ppSubMatchPSFs.c

    r35924 r36480  
    156156    psLogMsg("ppSub", PS_LOG_INFO, "Input FWHM: %f\nReference FWHM: %f\n", inFWHM, refFWHM);
    157157    if (!isfinite(inFWHM) || !isfinite(refFWHM)) {
    158         psError(PPSUB_ERR_DATA, false, "Cannot determine FHWM for images, giving up.");
    159         return false;
     158        psErrorStackPrint(stderr, "Cannot determine FHWM for images, giving up.");
     159        int error = psErrorCodeLast(); // Error code
     160        ppSubDataQuality(data, error, PPSUB_FILES_ALL);
     161        return true;
    160162    }
    161163
  • branches/eam_branches/ipp-20131211/psLib/src/math/psMixtureModels.c

    r36375 r36480  
    120120  *Ncensored = 0;
    121121
     122  int k = 0;
    122123  for (int i = 0; i < in->numRows; i++) {
    123124    int isCensored = 0;
     
    130131      *Ncensored = *Ncensored + 1;
    131132    }
    132     offsets->data.S32[i] = *Ncensored;
    133   }
     133    else {
     134      offsets->data.S32[k] = i - k;
     135      k++;
     136    }
     137    //    offsets->data.S32[i] = isCensored;
     138  }
     139
    134140  psImage *out;
    135141  if (*Ncensored == 0) {
     
    320326        }
    321327      }
    322       i = modes->data.F32[k];
    323       counts->data.F32[i] += 1.0;
     328      if (modes->data.F32[k] != -1) {
     329        i = modes->data.F32[k];
     330        counts->data.F32[i] += 1.0;
     331      }
    324332    }
    325333
     
    335343    for (k = 0; k < N; k++) {
    336344      i = modes->data.F32[k];
    337       for (j = 0; j < dim; j++) {
    338         means->data.F32[i][j] += D->data.F32[k][j];
     345      if (i != -1) {
     346        for (j = 0; j < dim; j++) {
     347          means->data.F32[i][j] += D->data.F32[k][j];
     348        }
    339349      }
    340350    }
  • branches/eam_branches/ipp-20131211/psModules

  • branches/eam_branches/ipp-20131211/psModules/src/camera/pmFPAfile.c

    r36375 r36480  
    565565      case PM_FPA_FILE_CMF:
    566566        return ("CMF");
     567      case PM_FPA_FILE_CFF:
     568        return ("CFF");
    567569      case PM_FPA_FILE_WCS:
    568570        return ("WCS");
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmModelClass.c

    r34259 r36480  
    6666
    6767static pmModelClass *models = NULL;
     68static psVector *modelClassLookupTable = NULL;  // translation between model types in header and here
    6869static int Nmodels = 0;
    6970
     
    135136    models = NULL;
    136137    Nmodels = 0;
     138    psFree(modelClassLookupTable);
     139    modelClassLookupTable = NULL;
    137140    return;
    138141}
     
    193196}
    194197
     198
     199bool pmModelClassWriteHeader(psMetadata *header)
     200{
     201    psMetadataAddS32(header, PS_LIST_TAIL, "MTNUM", PS_META_REPLACE, "number of model types", Nmodels);
     202    for (int i = 0; i < Nmodels; i++) {
     203        char modelNameKey[16];
     204        char modelValKey[16];
     205        sprintf(modelNameKey, "MTNAM%02d", i);
     206        sprintf(modelValKey,  "MTVAL%02d", i);
     207        psMetadataAddStr(header, PS_LIST_TAIL, modelNameKey, PS_META_REPLACE, "", models[i].name);
     208        psMetadataAddS32(header, PS_LIST_TAIL, modelValKey, PS_META_REPLACE, "", i);
     209    }
     210
     211    return true;
     212}
     213
     214bool pmModelClassReadHeader(psMetadata *header) {
     215    psFree(modelClassLookupTable);
     216
     217    bool status;
     218    int numHeaderModels = psMetadataLookupS32(&status, header, "MTNUM");
     219    if (!status) {
     220        return false;
     221    }
     222
     223    psVector *inputTypes = psVectorAlloc(numHeaderModels, PS_TYPE_S32);
     224    psVector *localTypes = psVectorAlloc(numHeaderModels, PS_TYPE_S32);
     225    int max_val = -1;
     226    for (int i = 0; i < numHeaderModels; i++) {
     227        char modelNameKey[16];
     228        char modelValKey[16];
     229        sprintf(modelNameKey, "MTNAM%02d", i);
     230        sprintf(modelValKey,  "MTVAL%02d", i);
     231        psString thisName = psMetadataLookupStr(&status, header, modelNameKey);
     232        int thisVal = psMetadataLookupS32(&status, header, modelValKey);
     233        if (thisVal > max_val) {
     234            max_val = thisVal;
     235        }
     236        inputTypes->data.S32[i] = thisVal;
     237        localTypes->data.S32[i] = pmModelClassGetType(thisName);
     238    }
     239    if (max_val < 0) {
     240        psFree(inputTypes);
     241        psFree(localTypes);
     242        return false;
     243    }
     244
     245    modelClassLookupTable = psVectorAlloc(max_val + 1, PS_TYPE_S32);
     246    psVectorInit(modelClassLookupTable, -1);
     247
     248    for (int i = 0; i < numHeaderModels; i++) {
     249        int thisVal = inputTypes->data.S32[i];
     250        int localVal = localTypes->data.S32[i];
     251        modelClassLookupTable->data.S32[thisVal] = localVal;
     252    }
     253    psFree(inputTypes);
     254    psFree(localTypes);
     255
     256    return true;
     257}
     258
     259pmModelType pmModelClassGetLocalType(pmModelType inputType) {
     260    pmModelType localType = -1;
     261
     262    if (modelClassLookupTable) {
     263        if (inputType >= 0 && inputType < modelClassLookupTable->n) {
     264            localType = modelClassLookupTable->data.S32[inputType];
     265        }
     266    } else {
     267        // no lookup table defined
     268        // for backwards compatability if inputType refers to a defined model, return it
     269        if (inputType >= 0 && pmModelClassGetName(inputType)) {
     270            localType = inputType;
     271        }
     272    }
     273
     274    return localType;
     275}
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmModelClass.h

    r29004 r36480  
    7676void pmModelClassSetLimits(pmModelLimitsType type);
    7777
     78// write keywords to header definining the model type values used by this program
     79bool pmModelClassWriteHeader(psMetadata *header);
     80// create a lookup table for translating input model type values to local model type values
     81bool pmModelClassReadHeader(psMetadata *header);
     82// translate input model type value to local value
     83pmModelType pmModelClassGetLocalType(pmModelType inputType);
    7884
    7985/// @}
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmSourceIO.c

    r36375 r36480  
    6161static bool pmReadoutReadXFIT(pmFPAfile *file, pmReadout *readout, char * exttype, psMetadata *hduHeader, psString xfitname, psArray *sources, long *sourceIndex);
    6262static bool pmReadoutReadXRAD(pmFPAfile *file, pmReadout *readout, char * exttype, psMetadata *hduHeader, psString xfitname, psArray *sources, long *sourceIndex);
     63static bool pmReadoutReadXGAL(pmFPAfile *file, pmReadout *readout, char * exttype, psMetadata *hduHeader, psString xfitname, psArray *sources, long *sourceIndex);
    6364
    6465// lookup the EXTNAME values used for table data and image header segments
     
    374375        }                                                               \
    375376        if (xgalname) {                                                 \
    376             status &= pmSourcesWrite_##TYPE##_XGAL (file->fits, sources, xgalname, recipe); \
     377            status &= pmSourcesWrite_##TYPE##_XGAL (file->fits, readout, sources, xgalname, recipe); \
    377378        }                                                               \
    378379    }
     
    10361037        bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_FITS");
    10371038        bool XRAD_OUTPUT = psMetadataLookupBool(&status, recipe, "RADIAL_APERTURES");
    1038         bool XGAL_OUTPUT = false; // psMetadataLookupBool(&status, recipe, "GALAXY_SHAPES");
     1039        bool XGAL_OUTPUT = psMetadataLookupBool(&status, recipe, "GALAXY_SHAPES");
    10391040
    10401041        if (!pmSourceIOextnames(&headname, &dataname, &deteffname,
     
    11221123
    11231124            long *sourceIndex = NULL;
    1124             if (XSRC_OUTPUT || XFIT_OUTPUT || XRAD_OUTPUT) {
     1125            if (XSRC_OUTPUT || XFIT_OUTPUT || XRAD_OUTPUT || XGAL_OUTPUT) {
     1126                // Build sourceIndex. Lookup table from source->seq to index in sources array.
     1127                // Consists of an array of length max(source->seq) + 1.
     1128
     1129                // find maximum sequence number
    11251130                long seq_max = -1;
    11261131                for (long i = sources->n -1; i >= 0; i--) {
     
    11351140                    }
    11361141                }
     1142                // allocate and initialize the index
    11371143                sourceIndex = psAlloc((seq_max + 1) * sizeof(long));
    11381144                for (long i = 0; i < seq_max; i++) {
    11391145                    sourceIndex[i] = -1;
    11401146                }
     1147                // populate the index
    11411148                for (long i = 0; i < sources->n; i++) {
    11421149                    pmSource *source = sources->data[i];
     
    11651172                psFree(xradname);
    11661173            }
     1174            if (XGAL_OUTPUT && xgalname) {
     1175                // a cmf file may have an XGAL extension, but it is not required
     1176                if (!pmReadoutReadXGAL(file, readout, exttype, hdu->header, xgalname, sources, sourceIndex)) {
     1177                    // do anything?
     1178                }
     1179                psFree(xgalname);
     1180            }
    11671181            psFree(sourceIndex);
    11681182
     
    14611475    return status;
    14621476}
     1477static bool pmReadoutReadXGAL(pmFPAfile *file, pmReadout *readout, char *exttype, psMetadata *hduHeader, psString xgalname, psArray *sources, long *sourceIndex)
     1478{
     1479    if (!psFitsMoveExtNameClean (file->fits, xgalname)) {
     1480        psTrace ("pmFPAfile", 1, "cannot find xgal extension %s in %s, skipping", xgalname, file->filename);
     1481        return false;
     1482    }
     1483
     1484    psMetadata *tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header
     1485    if (!tableHeader) psAbort("cannot read table header");
     1486
     1487    char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION");
     1488    if (!xtension) psAbort("cannot read table type");
     1489    if (strcmp (xtension, "BINTABLE")) {
     1490        psFree(tableHeader);
     1491        psWarning ("no binary table in extension %s, skipping\n", xgalname);
     1492        return false;
     1493    }
     1494
     1495# define PM_SOURCES_READ_XGAL(NAME,TYPE)                                \
     1496    if (!strcmp (exttype, NAME)) {                                      \
     1497        status = pmSourcesRead_##TYPE##_XGAL(file->fits, readout, hduHeader, tableHeader, sources, sourceIndex); \
     1498    }                                                                   
     1499
     1500    bool status = false;
     1501    if (file->type == PM_FPA_FILE_CMF) {
     1502        PM_SOURCES_READ_XGAL("PS1_V1",    CMF_PS1_V1);
     1503        PM_SOURCES_READ_XGAL("PS1_V2",    CMF_PS1_V2);
     1504        PM_SOURCES_READ_XGAL("PS1_V3",    CMF_PS1_V3);
     1505        PM_SOURCES_READ_XGAL("PS1_V4",    CMF_PS1_V4);
     1506        PM_SOURCES_READ_XGAL("PS1_SV1",   CMF_PS1_SV1);
     1507        PM_SOURCES_READ_XGAL("PS1_SV2",   CMF_PS1_SV2);
     1508        PM_SOURCES_READ_XGAL("PS1_DV1",   CMF_PS1_DV1);
     1509        PM_SOURCES_READ_XGAL("PS1_DV2",   CMF_PS1_DV2);
     1510        PM_SOURCES_READ_XGAL("PS1_DV3",   CMF_PS1_DV3);
     1511    }
     1512    psFree(tableHeader);
     1513    return status;
     1514}
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmSourceIO.h

    r36375 r36480  
    2121  bool pmSourcesWrite_##TYPE##_XFIT(psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname); \
    2222  bool pmSourcesWrite_##TYPE##_XRAD(psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname, psMetadata *recipe); \
    23   bool pmSourcesWrite_##TYPE##_XGAL(psFits *fits, psArray *sources, char *extname, psMetadata *recipe); \
     23  bool pmSourcesWrite_##TYPE##_XGAL(psFits *fits, pmReadout *readout, psArray *sources, char *extname, psMetadata *recipe); \
    2424  psArray *pmSourcesRead_##TYPE (psFits *fits, psMetadata *header); \
    2525  bool pmSourcesRead_##TYPE##_XSRC (psFits *fits, pmReadout *readout, psMetadata *header, psMetadata *tableHeader, psArray *sources, long *index); \
    2626  bool pmSourcesRead_##TYPE##_XFIT (psFits *fits, pmReadout *readout, psMetadata *header, psMetadata *tableHeader, psArray *sources, long *index); \
    2727  bool pmSourcesRead_##TYPE##_XRAD (psFits *fits, pmReadout *readout, psMetadata *header, psMetadata *tableHeader, psArray *sources, long *index);\
     28  bool pmSourcesRead_##TYPE##_XGAL (psFits *fits, pmReadout *readout, psMetadata *header, psMetadata *tableHeader, psArray *sources, long *index);\
    2829 
    2930// All of these functions need to use the same API, even if not all elements are used in a specific case
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmSourceIO_CFF.c

    r36375 r36480  
    6565    int modelType = pmModelClassGetType ("PS_MODEL_GAUSS");
    6666
     67    // Read lookup table for model classes (if defined)
     68    pmModelClassReadHeader(header);
     69
    6770    char *PSF_NAME = psMetadataLookupStr (&status, header, "PSFMODEL");
    6871    if (PSF_NAME != NULL) {
     
    111114        float theta      = psMetadataLookupF32 (&status, row, "THETA");
    112115
    113         // XXX: we need to put a lookup table in the cff header to define the correspondence of the
    114         // model type values in the cff with our models. (We want to use an interger for efficiency
    115         // but the value for each model type is set on the organization of the the array in pmModelClass.c
    116         // For now use the input values verbatim and trust the user that this is valid value
    117116        int   galaxyModelType = psMetadataLookupS32(&status, row, "MODEL_TYPE");
     117        if (status) {
     118            galaxyModelType = pmModelClassGetLocalType(galaxyModelType);
     119        } else {
     120            galaxyModelType = -1;
     121        }
    118122        float Sindex     = psMetadataLookupF32 (&status, row, "INDEX"); // Should this be PAR_07 not sersic index
    119123
     
    123127        source->type = PM_SOURCE_TYPE_STAR; // XXX this should be added to the flags
    124128
    125         // XXX we can set this in general, but for a specific image, we need to weed out SATSTARS
     129        // XXX we can set this in general, but for a specific image, we need to weed out SATSTARS and
     130        // stars that are masked
    126131        if (psfStar) {
    127132            source->tmpFlags |= PM_SOURCE_TMPF_CANDIDATE_PSFSTAR;
     
    180185        }
    181186
    182         // XXX: should use < 0 as invalid galaxyModelType
    183 
    184         if (fitGalaxy && galaxyModelType > 0) {
     187        if (fitGalaxy && galaxyModelType >= 0) {
    185188            source->modelFits = psArrayAllocEmpty (1);
    186189            pmModel *model = pmModelAlloc(galaxyModelType);
     
    235238    PS_ASSERT(mdok, false);
    236239
     240    // write the definition of the model class type values to the header
     241    psMetadata *outputHeader = psMetadataAlloc();
     242    pmModelClassWriteHeader(outputHeader);
     243
    237244    psArray *table = psArrayAllocEmpty(sources->n);
    238245
     
    246253        psS32 modelType = 0;
    247254        bool fitGalaxy = false;
    248         bool psfStar = false;
     255        bool psfStar = (source->mode & PM_SOURCE_MODE_PSFSTAR) ? true : false;
    249256        psF32 sersicIndex = 0;
    250         if (source->modelFits == NULL) {
     257        // For now only perform galaxy fits on extended objects
     258        if (source->modelEXT == NULL) {
    251259            pmModel *model = source->modelPSF;
    252260            if (model == NULL) continue;
     
    260268            yPos = model->params->data.F32[PM_PAR_YPOS];
    261269            flux = source->psfFlux;
    262             psfStar = (source->mode & PM_SOURCE_MODE_PSFSTAR) ? true : false;
    263270            rMajor = 0;
    264271            rMinor = 0;
     
    329336
    330337        psArrayAdd(table, 100, row);
     338        psFree(row);
    331339    }
    332340
    333     if (!psFitsWriteTable(fits, NULL, table, extname)) {
     341    if (!psFitsWriteTable(fits, outputHeader, table, extname)) {
    334342        psError(psErrorCodeLast(), false, "writing ext data %s\n", extname);
    335343        psFree(table);
    336         psFree(header);
     344        psFree(outputHeader);
    337345        return false;
    338346    }
    339347    psFree(table);
    340     // psFree(header);
     348    psFree(outputHeader);
    341349
    342350    return true;
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmSourceIO_CMF.c.in

    r36375 r36480  
    708708            return false;
    709709        }
    710         // Find the source with this sequence number.
    711         // XXX: I am assuming that sources is sorted in order of seq
     710        // Find the source with this sequence number using the sourceIndex.
    712711        long seq = psMetadataLookupU32 (&status, row, "IPP_IDET");
    713         pmSource *source = NULL;
    714 #ifndef ASSUME_SORTED
    715         long j = seq < sources->n ? seq : sources->n - 1;
    716         for (; j >= 0; j--) {
    717             source = sources->data[j];
    718             if (source->seq == seq) {
    719                 break;
    720             }
    721         }
    722 #else
    723712        long j = sourceIndex[seq];
    724713        psAssert(j >= 0 && j < sources->n, "invalid sourceIndex");
    725         source = sources->data[j];
    726 #endif
     714        pmSource *source = sources->data[j];
    727715        if (!source) {
    728716            psError(PS_ERR_UNKNOWN, false, "Failed to find source for row %ld sequence number %ld\n", i, seq);
     
    793781    // create a header to hold the output data
    794782    psMetadata *outhead = psMetadataAlloc ();
     783
     784    pmModelClassWriteHeader(outhead);
    795785
    796786    // write the links to the image header
     
    10341024        return false;
    10351025    }
     1026    // set up the lookup table to translate between input model types and output model types
     1027    // if not defined it is assumed that the tables are the same
     1028    pmModelClassReadHeader(tableHeader);
    10361029
    10371030    for (long i = 0; i < numSources; i++) {
     
    10421035            return false;
    10431036        }
    1044         // Find the source with this sequence number.
    1045         // XXX: I am assuming that sources is sorted in order of seq.
    10461037        long seq = psMetadataLookupU32 (&status, row, "IPP_IDET");
    1047         long j = seq < sources->n ? seq : sources->n - 1;
    1048         pmSource *source = NULL;
    1049         for (; j >= 0; j--) {
    1050             source = sources->data[j];
    1051             if (source->seq == seq) {
    1052                 break;
    1053             }
    1054         }
     1038        long j = sourceIndex[seq];
     1039        psAssert(j >= 0 && j < sources->n, "invalid sourceIndex");
     1040        pmSource *source = sources->data[j];
    10551041        if (!source) {
    10561042            psError(PS_ERR_UNKNOWN, false, "Failed to find source for row %ld sequence number %ld\n", i, seq);
     
    10951081        // in the psf table.
    10961082        psS32 extModelType = psMetadataLookupS32(&status, row, "EXT_MODEL_TYPE");
    1097         if (!status) {
     1083        if (status) {
     1084            // translate between the type value in xfit and values used by this program
     1085            extModelType = pmModelClassGetLocalType(extModelType);
     1086        } else {
    10981087            // older cmfs don't have this column
    10991088            extModelType = -1;
    1100         }
     1089        } 
    11011090
    11021091        psEllipseAxes axes;
     
    13391328            return false;
    13401329        }
    1341         // Find the source with this sequence number.
    1342         // XXX: I am assuming that sources is sorted in order of seq.
    13431330        long seq = psMetadataLookupU32 (&status, row, "IPP_IDET");
    1344         long j = seq < sources->n ? seq : sources->n - 1;
    1345         pmSource *source = NULL;
    1346         for (; j >= 0; j--) {
    1347             source = sources->data[j];
    1348             if (source->seq == seq) {
    1349                 break;
    1350             }
    1351         }
     1331        long j = sourceIndex[seq];
     1332        psAssert(j >= 0 && j < sources->n, "invalid sourceIndex");
     1333        pmSource *source = sources->data[j];
    13521334        if (!source) {
    13531335            psError(PS_ERR_UNKNOWN, false, "Failed to find source for row %ld sequence number %ld\n", i, seq);
     
    14071389
    14081390// XXX where should I record the number of columns??
    1409 bool pmSourcesWrite_CMF_@CMFMODE@_XGAL (psFits *fits, psArray *sources, char *extname, psMetadata *recipe)
     1391bool pmSourcesWrite_CMF_@CMFMODE@_XGAL (psFits *fits, pmReadout *readout, psArray *sources, char *extname, psMetadata *recipe)
    14101392{
    14111393    bool status = false;
     
    14221404    // write the links to the image header
    14231405    psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "galaxy table extension", extname);
     1406
     1407    psMetadataAddStr (outhead, PS_LIST_TAIL, "HI", PS_META_REPLACE, "does this get through?", "THERE");
    14241408
    14251409    // let's write these out in S/N order
     
    14911475}
    14921476
     1477bool pmSourcesRead_CMF_@CMFMODE@_XGAL(psFits *fits, pmReadout *readout, psMetadata *hduHeader, psMetadata *tableHeader, psArray *sources, long *sourceIndex)
     1478{
     1479    PS_ASSERT_PTR_NON_NULL(fits, false);
     1480    PS_ASSERT_PTR_NON_NULL(sources, false);
     1481
     1482    bool status;
     1483    long numSources = psFitsTableSize(fits); // Number of sources in table
     1484    if (numSources == 0) {
     1485        psError(psErrorCodeLast(), false, "XGAL Table contains no entries\n");
     1486        return false;
     1487    }
     1488
     1489    for (long i = 0; i < numSources; i++) {
     1490        psMetadata *row = psFitsReadTableRow(fits, i); // Table row
     1491        if (!row) {
     1492            psError(psErrorCodeLast(), false, "Unable to read row %ld of sources", i);
     1493            psFree(row);
     1494            return false;
     1495        }
     1496        // Find the source with this sequence number.
     1497        // XXX: I am assuming that sources is sorted in order of seq
     1498        long seq = psMetadataLookupU32 (&status, row, "IPP_IDET");
     1499        long j = sourceIndex[seq];
     1500        psAssert(j >= 0 && j < sources->n, "invalid sourceIndex");
     1501
     1502        pmSource *source = sources->data[j];
     1503        if (!source) {
     1504            psError(PS_ERR_UNKNOWN, false, "Failed to find source for row %ld sequence number %ld\n", i, seq);
     1505            psFree(row);
     1506            return false;
     1507        }
     1508
     1509        psVector *Flux  = psMetadataLookupVector(&status, row, "GAL_FLUX");
     1510        psVector *dFlux = psMetadataLookupVector(&status, row, "GAL_FLUX_ERR");
     1511        psVector *chisq = psMetadataLookupVector(&status, row, "GAL_CHISQ");
     1512
     1513        if (Flux && Flux->n > 0) {
     1514            psFree(source->galaxyFits);
     1515            source->galaxyFits = pmSourceGalaxyFitsAlloc();
     1516            source->galaxyFits->nPix = psMetadataLookupF32(&status, row, "NPIX");
     1517
     1518            psFree(source->galaxyFits->Flux);
     1519            source->galaxyFits->Flux  = psMemIncrRefCounter(Flux);
     1520            psFree(source->galaxyFits->dFlux);
     1521            source->galaxyFits->dFlux = psMemIncrRefCounter(dFlux);
     1522            psFree(source->galaxyFits->chisq);
     1523            source->galaxyFits->chisq = psMemIncrRefCounter(chisq);
     1524        }
     1525
     1526        psFree(row);
     1527    }
     1528
     1529    return true;
     1530}
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmSourceIO_PS1_CAL_0.c

    r36375 r36480  
    714714}
    715715
    716 bool pmSourcesWrite_PS1_CAL_0_XGAL (psFits *fits, psArray *sources, char *extname, psMetadata *recipe)
     716bool pmSourcesWrite_PS1_CAL_0_XGAL (psFits *fits, pmReadout *readout, psArray *sources, char *extname, psMetadata *recipe)
    717717{
    718718    return true;
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmSourceIO_PS1_DEV_0.c

    r36375 r36480  
    256256}
    257257
    258 bool pmSourcesWrite_PS1_DEV_0_XGAL(psFits *fits, psArray *sources, char *extname, psMetadata *recipe)
    259 {
    260     return true;
    261 }
     258bool pmSourcesWrite_PS1_DEV_0_XGAL(psFits *fits, pmReadout *readout, psArray *sources, char *extname, psMetadata *recipe)
     259{
     260    return true;
     261}
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmSourceIO_PS1_DEV_1.c

    r36375 r36480  
    596596}
    597597
    598 bool pmSourcesWrite_PS1_DEV_1_XGAL(psFits *fits, psArray *sources, char *extname, psMetadata *recipe)
     598bool pmSourcesWrite_PS1_DEV_1_XGAL(psFits *fits, pmReadout *readout, psArray *sources, char *extname, psMetadata *recipe)
    599599{
    600600    return true;
  • branches/eam_branches/ipp-20131211/psModules/src/objects/pmSourceIO_SMPDATA.c

    r36375 r36480  
    226226}
    227227
    228 bool pmSourcesWrite_SMPDATA_XGAL(psFits *fits, psArray *sources, char *extname, psMetadata *recipe)
     228bool pmSourcesWrite_SMPDATA_XGAL(psFits *fits, pmReadout *readout, psArray *sources, char *extname, psMetadata *recipe)
    229229{
    230230    return true;
  • branches/eam_branches/ipp-20131211/psastro/src/psastroDataSave.c

    r33669 r36480  
    4242    }
    4343
    44     // de-activate all files except PSASTRO.OUTPUT
     44    // de-activate all files except PSASTRO.OUTPUT, PSASTRO.OUT.ASTROM, and PSPHOT.OUTPUT.CFF
    4545    pmFPAfileActivate (config->files, false, NULL);
    4646    pmFPAfileActivate (config->files, true, "PSASTRO.OUTPUT");
    4747    pmFPAfileActivate (config->files, true, "PSASTRO.OUT.ASTROM");
     48    pmFPAfileActivate (config->files, true, "PSPHOT.OUTPUT.CFF");
    4849
    4950    pmFPAview *view = pmFPAviewAlloc (0);
     
    103104    }
    104105
    105     // activate all files except PSASTRO.OUTPUT
     106    // activate all files except PSASTRO.OUTPUT, and PSPHOT.OUTPUT.CFF
    106107    pmFPAfileActivate (config->files, true, NULL);
    107108    pmFPAfileActivate (config->files, false, "PSASTRO.OUTPUT");
     109    pmFPAfileActivate (config->files, false, "PSPHOT.OUTPUT.CFF");
    108110
    109111    psFree (view);
  • branches/eam_branches/ipp-20131211/psastro/src/psastroDefineFiles.c

    r32964 r36480  
    100100    }
    101101
     102    bool writeCff = psMetadataLookupBool (&status, recipe, "PSASTRO.SAVE.CFF");
     103    if (writeCff) {
     104        pmFPAfile *file = pmFPAfileDefineOutputFromFile  (config, input, "PSPHOT.OUTPUT.CFF");
     105        if (!file) {
     106            psError (PS_ERR_IO, false, "Can't find the output cff file definition");
     107            return NULL;
     108        }
     109        if (file->type != PM_FPA_FILE_CFF) {
     110            psError(PS_ERR_IO, true, "%s is not of type %s", "PSPHOT.OUTPUT.CFF", pmFPAfileStringFromType (PM_FPA_FILE_CFF));
     111            return NULL;
     112        }
     113        file->save = true;
     114    }
     115
    102116
    103117# if (0)
  • branches/eam_branches/ipp-20131211/psconfig

  • branches/eam_branches/ipp-20131211/psphot

  • branches/eam_branches/ipp-20131211/psphot/src

  • branches/eam_branches/ipp-20131211/psphot/src/Makefile.am

    r36375 r36480  
    2525libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    2626
    27 bin_PROGRAMS = psphot psphotForced psphotFullForce psphotMinimal psphotMakePSF psphotStack psphotModelTest psmakecff
     27bin_PROGRAMS = psphot psphotForced psphotFullForce psphotFullForceSummary psphotMinimal psphotMakePSF psphotStack psphotModelTest psmakecff
    2828# bin_PROGRAMS = psphotPetrosianStudy psphotTest psphotMomentsStudy
    2929
     
    3939psphotFullForce_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    4040psphotFullForce_LDADD = libpsphot.la
     41
     42psphotFullForceSummary_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     43psphotFullForceSummary_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
     44psphotFullForceSummary_LDADD = libpsphot.la
    4145
    4246psphotMinimal_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     
    99103        psphotMosaicChip.c         \
    100104        psphotCleanup.c
     105
     106# combine full force results from several inputs
     107psphotFullForceSummary_SOURCES = \
     108        psphotFullForceSummary.c \
     109        psphotFullForceSummaryReadout.c
    101110
    102111# forced photometry of specified positions given a specified psf
  • branches/eam_branches/ipp-20131211/psphot/src/psmakecff.c

    r36375 r36480  
    22# include <config.h>
    33# endif
     4
     5// psmakecff : A program to make read a cmf file and write a cff file
     6// The real work is done in psModules.
    47
    58#include <stdio.h>
     
    811#include "psphot.h"
    912
     13// For simplicilty, this program's (simple) functions are all contained in this file.
    1014static pmConfig* psmakecffArguments(int, char**);
    1115static bool psmakecffParseCamera(pmConfig *);
     
    2529//    psphotVersionPrint();
    2630
    27     // load input data (config and images (signal, noise, mask)
    2831    if (!psmakecffParseCamera (config)) {
    2932        psErrorStackPrint(stderr, "Error setting up the camera\n");
     
    3134    }
    3235
    33     // call psphot for each readout
    3436    if (!psmakecffImageLoop (config)) {
    3537        psErrorStackPrint(stderr, "Error in the psphot image loop\n");
     
    3739    }
    3840
    39 //    psLogMsg ("psphot", PS_LOG_WARN, "complete psphot run: %f sec\n", psTimerMark ("complete"));
    40 
    41 //    psErrorCode exit_status = psphotGetExitStatus();
    42 //    psphotCleanup (config);
    4341    exit (0);
    4442}
     
    7371    return config;
    7472}
     73
    7574static bool psmakecffParseCamera(pmConfig *config) {
    7675    bool status = false;
     
    127126    psAssert (recipe, "missing recipe?");
    128127
    129 //    psImageMaskType maskTest = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    130128
    131129    // for psphot, we force data to be read at the chip level
    132130    while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
    133         psLogMsg ("psmakecmf", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     131        psLogMsg ("psmakecff", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    134132        if (! chip->process || ! chip->file_exists) { continue; }
    135133
    136 #ifdef notdef
    137         pmFPAfileActivate (config->files, false, NULL);
    138         pmFPAfileActivate (config->files, true, "PSPHOT.LOAD");
    139 #endif
    140134        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for Chip in psmakecff.");
    141135
    142136        // there is now only a single chip (multiple readouts?). loop over it and process
    143137        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    144             psLogMsg ("psmakecmf", 5, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     138            psLogMsg ("psmakecff", 5, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    145139
    146140            // process each of the readouts
    147141            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    148                 psLogMsg ("psmakecmf", 6, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     142                psLogMsg ("psmakecff", 6, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    149143                if (! readout->data_exists) { continue; }
    150144
    151145                pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell);
    152146                if (hdu && hdu != lastHDU) {
     147                    // XXX: probably should do this
    153148                    // psphotVersionHeaderFull(hdu->header);
    154149                    lastHDU = hdu;
     
    157152
    158153        }
    159         // Defer output and closing of files until we've (possibly) done the NFrames analysis below
    160 //        pmFPAfileActivate (config->files, false, NULL);
    161 
    162154        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE ("failed pmFPAfileIOChecks for Chip in psmakecff.");
    163155    }
    164156    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE ("failed pmFPAfileIOChecks for FPA in psphot.");
    165157
    166     // fail if we failed to handle an error
     158    // fail if we encountered an unhandled error
    167159    if (psErrorCodeLast() != PS_ERR_NONE) psAbort ("failed to handle an error!");
    168160
  • branches/eam_branches/ipp-20131211/psphot/src/psphot.h

    r36375 r36480  
    361361bool psphotModelTestReadout(pmConfig *config, const pmFPAview *view, const char *filerule);
    362362
     363bool psphotFullForceSummaryReadout (pmConfig * config, const pmFPAview *view);
     364
    363365int psphotFileruleCount(const pmConfig *config, const char *filerule);
    364366bool psphotFileruleCountSet(const pmConfig *config, const char *filerule, int num);
  • branches/eam_branches/ipp-20131211/psphot/src/psphotChooseAnalysisOptions.c

    r36375 r36480  
    6060}
    6161
    62 bool GetGalacticCoords (psSphere *ptGal, psSphere *ptSky, psSphereRot *toGal, pmChip *chip, float xPos, float yPos);
     62static bool GetGalacticCoords (psSphere *ptGal, psSphere *ptSky, psSphereRot *toGal, pmChip *chip, float xPos, float yPos);
    6363
    6464// this function use an internal flag to mark sources which have already been measured
     
    121121    psSphereRot *toGal = NULL;
    122122    float GAL_LIMIT = 0.0;
     123    float GAL_LIMIT_BULGE = 0.0;
     124    float GAL_LIMIT_SIGMA2 = 0.0;
    123125    bool useGAL_LIMIT = psMetadataLookupBool(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.USE");
    124126    assert (status);
    125127    if (useGAL_LIMIT) {
     128        toGal = psSphereRotICRSToGalactic();
    126129        GAL_LIMIT = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT");
    127         toGal = psSphereRotICRSToGalactic();
     130        assert (status);
     131        GAL_LIMIT = DEG_TO_RAD(GAL_LIMIT);
     132        GAL_LIMIT_BULGE = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.BULGE");
     133        assert (status);
     134        GAL_LIMIT_BULGE = DEG_TO_RAD(GAL_LIMIT_BULGE);
     135        float GAL_LIMIT_SIGMA = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.BULGE.SIGMA");
     136        assert (status);
     137        assert(GAL_LIMIT_SIGMA > 0);
     138        GAL_LIMIT_SIGMA = DEG_TO_RAD(GAL_LIMIT_SIGMA);
     139        GAL_LIMIT_SIGMA2 = GAL_LIMIT_SIGMA * GAL_LIMIT_SIGMA;
    128140    }
    129141
     
    135147    }
    136148
     149    float petroFluxLim = NAN;
    137150    float extFitFluxLim = NAN;
    138151
     
    140153        float extFitMagLimDefault = NAN;
    141154        float extFitMagLim = NAN;
     155        float petroMagLimDefault = NAN;
     156        float petroMagLim = NAN;
    142157
    143158        // match to the given filter
     
    156171            // find a matching filter or default to 'any'
    157172            if (!strcasecmp (thisFilter, "any")) {
    158                 psString extFitMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT");
    159                 psAssert(extFitMagLimStr, "missing MAG.LIMIT");
     173                psString petroMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.PETRO");
     174                psAssert(petroMagLimStr, "missing MAG.LIMIT.PETRO");
     175                petroMagLimDefault = atof (petroMagLimStr);
     176
     177                psString extFitMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.EXTFIT");
     178                psAssert(extFitMagLimStr, "missing MAG.LIMIT.EXTFIT");
    160179                extFitMagLimDefault = atof (extFitMagLimStr);
    161180            }
    162181
    163             // find a matching filter or default to 'any'
    164182            if (!strcasecmp (thisFilter, filterID)) {
    165                 psString extFitMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT");
    166                 psAssert(extFitMagLimStr, "missing MAG.LIMIT");
     183                psString petroMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.PETRO");
     184                psAssert(petroMagLimStr, "missing MAG.LIMIT.PETRO");
     185                petroMagLim = atof (petroMagLimStr);
     186
     187                psString extFitMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.EXTFIT");
     188                psAssert(extFitMagLimStr, "missing MAG.LIMIT.EXTFIT");
    167189                extFitMagLim = atof (extFitMagLimStr);
    168190                break;
    169191            }
    170192        }
     193        psFree(iter);
     194        if (!isfinite (petroMagLim)) petroMagLim = petroMagLimDefault;
    171195        if (!isfinite (extFitMagLim)) extFitMagLim = extFitMagLimDefault;
    172196
     
    185209        psAssert (status, "missing FPA.ZP?");
    186210
     211        petroFluxLim = exptime * pow (10.0, 0.4*(zeropt - petroMagLim));
    187212        extFitFluxLim = exptime * pow (10.0, 0.4*(zeropt - extFitMagLim));
    188213    }
     
    225250            psSphere ptGal, ptSky;
    226251            GetGalacticCoords (&ptGal, &ptSky, toGal, chip, source->peak->xf, source->peak->yf);
    227             if (fabs(ptGal.d) < GAL_LIMIT) continue;
     252            float l = ptGal.r;
     253            float b_min = GAL_LIMIT + GAL_LIMIT_BULGE * exp(-0.5*(l*l/GAL_LIMIT_SIGMA2));
     254            if (fabs(ptGal.d) < b_min) continue;
    228255            // include an exception for low density skycells below the limit?
    229256        }
    230257
    231258        // for petro and extFit, we will either use the mag limits or the S/N
     259        if (doPetrosian) {
     260            if (isfinite(petroFluxLim)) {
     261                if (source->moments->KronFlux > petroFluxLim) {
     262                    source->tmpFlags |= PM_SOURCE_TMPF_PETRO;
     263                }
     264            } else if (source->moments->KronFlux > SN_LIM * source->moments->KronFluxErr) {
     265                source->tmpFlags |= PM_SOURCE_TMPF_PETRO;
     266            }
     267        }
    232268        if (isfinite(extFitFluxLim)) {
    233269            if (source->moments->KronFlux > extFitFluxLim) {
    234270                source->tmpFlags |= PM_SOURCE_TMPF_EXT_FIT;
    235                 if (doPetrosian) source->tmpFlags |= PM_SOURCE_TMPF_PETRO;
    236271            }
    237272        } else {
    238273            if (source->moments->KronFlux > SN_LIM * source->moments->KronFluxErr) {
    239274                source->tmpFlags |= PM_SOURCE_TMPF_EXT_FIT;
    240                 if (doPetrosian) source->tmpFlags |= PM_SOURCE_TMPF_PETRO;
    241275            }
    242276        }
     
    244278
    245279    psLogMsg ("psphot.options", PS_LOG_WARN, "choose analysis options for %ld sources: %f sec\n", sources->n, psTimerMark ("psphot.options"));
     280
     281    psFree(toGal);
    246282
    247283    return true;
     
    287323    psSphereRot *toGal = NULL;
    288324    float GAL_LIMIT = 0.0;
     325    float GAL_LIMIT_BULGE = 0.0;
     326    float GAL_LIMIT_SIGMA2 = 0.0;
    289327    bool useGAL_LIMIT = psMetadataLookupBool(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.USE");
    290328    assert (status);
    291329    if (useGAL_LIMIT) {
     330        toGal = psSphereRotICRSToGalactic();
    292331        GAL_LIMIT = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT");
    293         toGal = psSphereRotICRSToGalactic();
     332        assert (status);
     333        GAL_LIMIT = DEG_TO_RAD(GAL_LIMIT);
     334        GAL_LIMIT_BULGE = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.BULGE");
     335        assert (status);
     336        GAL_LIMIT_BULGE = DEG_TO_RAD(GAL_LIMIT_BULGE);
     337        float GAL_LIMIT_SIGMA = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.BULGE.SIGMA");
     338        assert (status);
     339        assert(GAL_LIMIT_SIGMA > 0);
     340        GAL_LIMIT_SIGMA = DEG_TO_RAD(GAL_LIMIT_SIGMA);
     341        GAL_LIMIT_SIGMA2 = GAL_LIMIT_SIGMA * GAL_LIMIT_SIGMA;
    294342    }
    295343
     
    365413    // find extFitFluxLim->data.F32[i] for i == image number
    366414    psVector *extFitFluxLim = NULL;
     415    psVector *petroFluxLim = NULL;
    367416    if (magLimits) {
    368417        extFitFluxLim = psVectorAlloc (inputFilters->n, PS_TYPE_F32);
     418        petroFluxLim = psVectorAlloc (inputFilters->n, PS_TYPE_F32);
    369419        psVectorInit (extFitFluxLim, NAN);
     420        psVectorInit (petroFluxLim, NAN);
    370421
    371422        float extFitMagLimDefault = NAN;
     423        float petroMagLimDefault = NAN;
    372424
    373425        // match mag limits (flux limits) to the filters
     
    383435            // save the default value to assign to unset filters
    384436            if (!strcasecmp (thisFilter, "any")) {
    385                 psString magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT");
    386                 psAssert(magString, "missing MAG.LIMIT");
     437                psString magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.EXTFIT");
     438                psAssert(magString, "missing MAG.LIMIT.EXTFIT");
    387439                extFitMagLimDefault = atof (magString);
     440
     441                magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.PETRO");
     442                psAssert(magString, "missing MAG.LIMIT.PETRO");
     443                petroMagLimDefault = atof (magString);
    388444                continue;
    389445            }
     
    393449                if (i == chisqNum) continue;
    394450                if (!strcasecmp (thisFilter, inputFilters->data[i])) {
    395                     psString magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT");
    396                     psAssert(magString, "missing MAG.LIMIT");
     451                    psString magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.PETRO");
     452                    psAssert(magString, "missing MAG.LIMIT.PETRO");
    397453                    float magvalue = atof (magString);
     454                    petroFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - magvalue));
     455
     456                    magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.EXTFIT");
     457                    psAssert(magString, "missing MAG.LIMIT.EXTFIT");
     458                    magvalue = atof (magString);
    398459                    extFitFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - magvalue));
    399460                    break;
     
    401462            }
    402463        }
     464        psFree(iter);
    403465
    404466        for (int i = 0; i < num; i++) {
    405467            if (i == chisqNum) continue;
    406             if (isfinite(extFitFluxLim->data.F32[i])) continue;
    407             extFitFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - extFitMagLimDefault));
     468            if (!isfinite(petroFluxLim->data.F32[i])) {
     469                petroFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - petroMagLimDefault));
     470            }
     471            if (!isfinite(extFitFluxLim->data.F32[i])) {
     472                extFitFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - extFitMagLimDefault));
     473            }
    408474        }
    409475    }
     
    420486        bool doObjectRadial = false;
    421487        bool doObjectExtFit = false;
    422         for (int j = 0; !doObjectExtFit && !doObjectRadial && (j < object->sources->n); j++) {
     488        bool doObjectPetrosian = false;
     489        for (int j = 0; !doObjectExtFit && !doObjectRadial && !doObjectPetrosian && (j < object->sources->n); j++) {
    423490
    424491            pmSource *source = object->sources->data[j];
     
    451518            if (extFitAll) {
    452519                doObjectExtFit = true;
     520                doObjectPetrosian = doPetrosian;
    453521                continue;
    454522            }
     
    465533                psSphere ptGal, ptSky;
    466534                GetGalacticCoords (&ptGal, &ptSky, toGal, chips->data[imageID], source->peak->xf, source->peak->yf);
    467                 if (fabs(ptGal.d) < GAL_LIMIT) continue;
    468                 // include an exception for low density skycells below the limit?
    469             }
    470 
    471             float fluxLim = extFitFluxLim ? extFitFluxLim->data.F32[imageID] : NAN;
     535                float l = ptGal.r;
     536                float b_min = GAL_LIMIT + GAL_LIMIT_BULGE * exp(-0.5*(l*l/GAL_LIMIT_SIGMA2));
     537                if (fabs(ptGal.d) < b_min) continue;
     538            }
     539
     540            float fluxLim = NAN;
     541            // for petro and extFit, we will either use the mag limits or the S/N
     542            if (doPetrosian) {
     543                fluxLim = petroFluxLim ? petroFluxLim->data.F32[imageID] : NAN;
     544                if (isfinite(fluxLim)) {
     545                    if (source->moments->KronFlux > extFitFluxLim->data.F32[imageID]) {
     546                        doObjectPetrosian = true;
     547                    }
     548                } else {
     549                    if (source->moments->KronFlux > SN_LIM * source->moments->KronFluxErr) {
     550                        doObjectPetrosian = true;
     551                    }
     552                }
     553            }
     554            fluxLim = extFitFluxLim ? extFitFluxLim->data.F32[imageID] : NAN;
    472555            // for petro and extFit, we will either use the mag limits or the S/N
    473556            if (isfinite(fluxLim)) {
     
    503586            if (source->modelPSF == NULL) continue;
    504587               
    505             // Do the fits if the recipe requests we do extended source fits to everything
    506588            if (doObjectExtFit) {
    507589                source->tmpFlags |= PM_SOURCE_TMPF_EXT_FIT;
    508                 if (doPetrosian) source->tmpFlags |= PM_SOURCE_TMPF_PETRO;
    509             }
     590            }
     591            if (doObjectPetrosian) {
     592                source->tmpFlags |= PM_SOURCE_TMPF_PETRO;
     593            }
    510594
    511595            // Do the fits if the recipe requests we do extended source fits to everything
     
    522606    psLogMsg ("psphot.options", PS_LOG_WARN, "choose analysis options for %ld objects: %f sec\n", objects->n, psTimerMark ("psphot.options"));
    523607
     608    psFree(toGal);
     609
    524610    return true;
    525611}
    526612
    527 bool GetGalacticCoords (psSphere *ptGal, psSphere *ptSky, psSphereRot *toGal, pmChip *chip, float xPos, float yPos) {
     613static bool GetGalacticCoords (psSphere *ptGal, psSphere *ptSky, psSphereRot *toGal, pmChip *chip, float xPos, float yPos) {
    528614
    529615    pmFPA *fpa = chip->parent;
     
    543629    psSphereRotApply (ptGal, toGal, ptSky);
    544630
     631    // psSphereRotApply insures that 0 < r < 2PI. We want -PI < b <= PI
     632    if (ptGal->r > M_PI) {
     633        ptGal->r -= 2.0 * M_PI;
     634    }
     635
    545636    return true;
    546637
  • branches/eam_branches/ipp-20131211/psphot/src/psphotGalaxyShape.c

    r36375 r36480  
    283283    }
    284284
     285#ifdef SAVE_BEST_MODEL
     286    // Save model with smallest chisq
    285287    if (isfinite(chisqBest)) {
     288#else
     289    // Save model with nominal parameters
     290    {
     291        fRmajorBest = 1;
     292        fRminorBest = 1;
     293#endif
    286294        // now save the best fitting model as the source's extended model
    287295        psEllipseAxes testAxes = guessAxes;
     
    293301        psphotGalaxyShapeSource (pcm, source, maskVal, psfSize, false);
    294302
     303        // Replace modelEXT with this model
     304        // XXX: only do this if the model is good
    295305        psFree (source->modelEXT);
    296306
     
    299309        source->mode |= PM_SOURCE_MODE_EXTMODEL;
    300310        source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;
    301 
    302         // adjust the window so the subtraction covers the faint wings
    303         // psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal);
    304311
    305312        // cache the model flux
  • branches/eam_branches/ipp-20131211/psphot/src/psphotStackImageLoop.c

  • branches/eam_branches/ipp-20131211/pstamp/scripts

  • branches/eam_branches/ipp-20131211/pstamp/scripts/dqueryparse.pl

    r34331 r36480  
    502502    $command .= " -need_magic" if $need_magic;
    503503
    504     my $rlabel = "dq_ud_" . $label if $label;
     504    my $rlabel = "ps_ud_" . $label if $label;
    505505    $command .= " -rlabel $rlabel" if $rlabel;
    506506
  • branches/eam_branches/ipp-20131211/pstamp/scripts/pstamp_checkdependent.pl

    r36166 r36480  
    2727my $IPP_DIFF_MODE_STACK_STACK = 4;
    2828
    29 my ($dep_id, $stage, $stage_id, $component, $imagedb, $rlabel, $need_magic, $fault_count, $max_fault_count, $logfile);
     29my ($dep_id, $stage, $stage_id, $component, $imagedb, $label, $rlabel, $need_magic, $fault_count, $max_fault_count, $logfile);
    3030my ($dbname, $ps_dbserver, $verbose, $save_temps, $no_update);
    3131
     
    3636    'component=s'   =>  \$component,
    3737    'imagedb=s'     =>  \$imagedb,      # dbname for images lookups.
    38     'rlabel=s'      =>  \$rlabel,
     38    'label=s'       =>  \$label,        # request's label
     39    'rlabel=s'      =>  \$rlabel,       # pstampDependent.rlabel (deprecated)
    3940    'need_magic'    =>  \$need_magic,
    4041    'fault_count=i' =>  \$fault_count,
     
    7374}
    7475
     76if ($label) {
     77    # rlabel is deprecated. Use one based on the supplied label parameter which is the current label
     78    # for the request, which may be different than the one given to the dependent when the job was parsed.
     79    # XXX: having the convention that update label is 'ps_ud_' . $label of request embedded here
     80    # (and formerly in pstampparse.pl) is not particularly clean but it's simple.
     81    my $new_rlabel = 'ps_ud_' . $label;
     82    if ($new_rlabel ne $rlabel) {
     83        print "Notice: using $new_rlabel instead of $rlabel for update label.\n";
     84        $rlabel = $new_rlabel;
     85    }
     86}
     87
     88
    7589if (!$ps_dbserver) {
    7690    $ps_dbserver =  metadataLookupStr($ipprc->{_siteConfig}, 'PS_DBSERVER');
     
    559573            }
    560574            return $warp_status;
     575        } elsif ($warp->{quality} != 0) {
     576            print STDERR "input warp has quality error\n";
     577            faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
     578            return $PSTAMP_GONE;
    561579        }
    562580        # warps are ready fall through and queue the diff update
  • branches/eam_branches/ipp-20131211/psvideophot

  • branches/eam_branches/ipp-20131211/tools/mysql-dump/gpc1_install.sh

    r34112 r36480  
    6262log INFO "Symlinking backup file [$TARGET/$BACKUP_FILE] to distribution [$DISTRIBUTION_TARGET]"
    6363/usr/bin/ln -f $TARGET/$BACKUP_FILE $DISTRIBUTION_TARGET
    64 /usr/bin/mv -f $TARGET/$MD5FILE $DISTRIBUTION_MD5
     64/usr/bin/cp -f $TARGET/$MD5FILE $DISTRIBUTION_MD5
    6565
    6666# if it is between 0 and 4, ingest into gpc1_0 or gpc1_1
  • branches/eam_branches/ipp-20131211/tools/neb_rawOTA_host_scan.pl

    r36337 r36480  
    2121    ) or die "Unable to connect to database $DBI::errstr\n";
    2222
    23 my ($host,$min_ins_id,$verbose,$limit,$continue);
     23my ($host,$min_ins_id,$verbose,$limit,$continue,$alt,$vol_label);
    2424$min_ins_id = 0;
    2525$verbose = 0;
    2626$limit = 10000;
    2727$continue = 0;
     28$alt = 0;
     29$vol_label = 0;
    2830
    2931GetOptions(
     
    3335    'limit|l=s'     => \$limit,
    3436    'continue|c'    => \$continue,
     37    'alternate|a'   => \$alt,
     38    'vol_label|L=s'   => \$vol_label,
    3539    ) or pod2usage( 2 );
    3640pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     
    3943    defined($host);
    4044
    41 my $volume = $host . ".0";
     45my $volume = $host . "." . $vol_label;
    4246my $rr;
    4347
     
    5054my $vol_id = shift( @{ ${ $r_vol }[0] });
    5155
     56# Get max ins_id
     57my $max_id_sth = "SELECT ins_id FROM instance WHERE vol_id = $vol_id ORDER BY ins_id DESC limit 1";
     58my $r_max_id   = $db->selectall_arrayref( $max_id_sth );
     59unless (defined(${ $r_max_id }[0])) {
     60    die "Cannot find max_id";
     61}
     62my $max_ins_id = shift( @{ ${ $r_max_id }[0] });
     63
    5264if ($verbose) {
    53     print "$host $volume $vol_id $min_ins_id\n";
     65    print "$host $volume $vol_id $min_ins_id $max_ins_id\n";
    5466}
    5567
     
    7082my $number = 0;
    7183do {
    72     my $ins_id_sth = "SELECT ins_id,so_id,uri FROM instance WHERE vol_id = ${vol_id} AND ins_id > $min_ins_id LIMIT $limit";
     84    my $ins_id_sth = "SELECT ins_id,so_id,uri FROM instance WHERE vol_id = ${vol_id} AND ins_id > $min_ins_id AND ins_id <= $max_ins_id  LIMIT $limit";
     85    if ($alt) {
     86        $ins_id_sth = "SELECT ins_id,so_id,uri,vol_id FROM instance WHERE ins_id > $min_ins_id AND ins_id <= $max_ins_id  LIMIT $limit";
     87    }
    7388    my $r_ins      = $db->selectall_arrayref( $ins_id_sth );
    74     my $last_ins_id = 0;
     89    my $last_ins_id = $max_ins_id;
    7590    $number = 0;
    7691    foreach $rr (@{ $r_ins }) {
    77         my ($ins_id,$so_id,$uri) = @{ $rr };
     92        my ($ins_id,$so_id,$uri,$v_id) = @{ $rr };
    7893        if ($verbose) {
    7994#       print ("  $ins_id $so_id $uri\n");
     
    8196        $number++;
    8297        $last_ins_id = $ins_id;
     98        if ($alt) {
     99            if ($v_id != $vol_id) { next; }
     100        }
    83101        if ($uri !~ /ota...fits/) { next; }
    84102        my $have_b_node = 0;
     
    138156        $min_ins_id = $last_ins_id;
    139157    }
    140 } while ($continue && $number != 0);
     158} while (($continue && $number != 0) || ($min_ins_id < $max_ins_id));
Note: See TracChangeset for help on using the changeset viewer.