IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36441


Ignore:
Timestamp:
Jan 14, 2014, 2:28:47 PM (12 years ago)
Author:
bills
Message:

Iniital implementation of the full force stages to the pipeline.
Maginitude and galactic coordinate limits on extended source fits

Location:
trunk
Files:
74 edited
17 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Nebulous

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/Nebulous-Server

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/Ohana

  • trunk/Ohana/src/dvomerge

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/Ohana/src/libohana/src

  • trunk/Ohana/src/opihi

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/Ohana/src/opihi/cmd.astro

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/Ohana/src/opihi/cmd.data

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/Ohana/src/relastro/src

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/dbconfig/cam.md

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/dbconfig/changes.txt

    r36374 r36441  
    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
  • trunk/dbconfig/ipp.m4

    r34911 r36441  
    4040include(skycell.md)
    4141include(release.md)
     42include(ff.md)
  • trunk/ippMonitor

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippScripts/Build.PL

    r36374 r36441  
    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',
  • trunk/ippScripts/scripts/chip_imfile.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippScripts/scripts/destreak_restore_camera.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippScripts/scripts/ipp_apply_burntool_single.pl

  • trunk/ippScripts/scripts/lap_science.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippScripts/scripts/magic_destreak.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippScripts/scripts/psphot_fullforce_warp.pl

    r36374 r36441  
    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;
  • trunk/ippScripts/scripts/publish_file.pl

  • trunk/ippScripts/scripts/staticsky.pl

    r34852 r36441  
    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";
  • trunk/ippScripts/scripts/warp_skycell.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippTasks

  • trunk/ippTasks/Makefile.am

    r36372 r36441  
    4747        lap.pro \
    4848        vp.pro \
    49         bg.regeneration.pro
     49        bg.regeneration.pro \
     50        fullforce.pro
    5051
    5152other_files = \
  • trunk/ippToPsps

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippTools/share

  • trunk/ippTools/share/Makefile.am

    r36361 r36441  
    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
  • trunk/ippTools/share/camtool_find_pendingimfile.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippTools/share/chiptool_setimfiletoupdate.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippTools/share/pxadmin_create_tables.sql

    r36374 r36441  
    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.
  • trunk/ippTools/share/pxadmin_drop_tables.sql

    r35896 r36441  
    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
  • trunk/ippTools/share/warptool_towarped.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippTools/src

  • trunk/ippTools/src/Makefile.am

    r34913 r36441  
    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
  • trunk/ippTools/src/camtool.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippTools/src/camtoolConfig.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippTools/src/magictool.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippconfig

  • trunk/ippconfig/gpc1

  • trunk/ippconfig/recipes/filerules-split.mdc

    r36375 r36441  
    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
  • trunk/ippconfig/recipes/ppSub.config

  • trunk/ippconfig/recipes/psastro.config

    r36403 r36441  
    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.
     
    279280
    280281STATICSKY_CAL   METADATA
     282    PSASTRO.SAVE.CFF           BOOL TRUE  # save a cff file (input for psphotFullForce)
    281283END
    282284
  • trunk/ippconfig/recipes/psphot.config

    r36375 r36441  
    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
     
    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                 22
     420    rband DATA r         25                 22
     421    iband DATA i         25                 22
     422    zband DATA z         25                 21
     423    yband DATA y         25                 20
     424    wband DATA w         25                 22
     425    other DATA any       25                 22
    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
  • trunk/ippconfig/recipes/reductionClasses.mdc

  • trunk/ppImage/src

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ppSub/src/ppSubMatchPSFs.c

    r35924 r36441  
    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
  • trunk/psLib/src/math/psMixtureModels.c

  • trunk/psModules

  • trunk/psModules/src/camera/pmFPAfile.c

    r36375 r36441  
    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");
  • trunk/psModules/src/objects/pmModelClass.c

    r34259 r36441  
    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}
  • trunk/psModules/src/objects/pmModelClass.h

    r29004 r36441  
    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/// @}
  • trunk/psModules/src/objects/pmSourceIO.c

    r36375 r36441  
    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}
  • trunk/psModules/src/objects/pmSourceIO.h

    r36375 r36441  
    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
  • trunk/psModules/src/objects/pmSourceIO_CFF.c

    r36375 r36441  
    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;
  • trunk/psModules/src/objects/pmSourceIO_CMF.c.in

    r36375 r36441  
    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}
  • trunk/psModules/src/objects/pmSourceIO_PS1_CAL_0.c

    r36375 r36441  
    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;
  • trunk/psModules/src/objects/pmSourceIO_PS1_DEV_0.c

    r36375 r36441  
    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}
  • trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c

    r36375 r36441  
    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;
  • trunk/psModules/src/objects/pmSourceIO_SMPDATA.c

    r36375 r36441  
    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;
  • trunk/psastro/src/psastroDataSave.c

    r33669 r36441  
    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);
  • trunk/psastro/src/psastroDefineFiles.c

    r32964 r36441  
    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)
  • trunk/psconfig

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/psphot

  • trunk/psphot/src

  • trunk/psphot/src/Makefile.am

    r36375 r36441  
    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
  • trunk/psphot/src/psmakecff.c

    r36375 r36441  
    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
  • trunk/psphot/src/psphot.h

    r36375 r36441  
    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);
  • trunk/psphot/src/psphotChooseAnalysisOptions.c

    r36375 r36441  
    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 b = ptGal.r;
     253            float limit = GAL_LIMIT + GAL_LIMIT_BULGE * exp(-0.5*(b*b/GAL_LIMIT_SIGMA2));
     254            if (fabs(ptGal.d) < limit) 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 b = ptGal.r;
     536                float limit = GAL_LIMIT + GAL_LIMIT_BULGE * exp(-0.5*(b*b/GAL_LIMIT_SIGMA2));
     537                if (fabs(ptGal.d) < limit) 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
  • trunk/psphot/src/psphotGalaxyShape.c

    r36375 r36441  
    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
  • trunk/psphot/src/psphotStackImageLoop.c

  • trunk/pstamp/scripts

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/psvideophot

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.