IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34735


Ignore:
Timestamp:
Nov 29, 2012, 2:15:01 PM (14 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20120905
Files:
83 edited
7 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120905

  • branches/eam_branches/ipp-20120905/Ohana

    • Property svn:mergeinfo deleted
  • branches/eam_branches/ipp-20120905/Ohana/src/addstar/src/psps_ids.c

    r34260 r34735  
    2121CreatePSPSStackDetectionID(int sourceID, int imageID, int detID)
    2222{
    23   // sourceID : ID of database + table that tracked the image (< 0x100 = 256)
     23  // sourceID : ID of database + table that tracked the image (< 0x7f = 127)
    2424  // imageID : external ID of the image which provided the detections (< 0x1000.0000 ~ 2.7e8)
    2525  // detID : detection sequence in image (< 0x1000.0000 ~ 2.7e8)
     
    2727  assert (detID    < 0x10000000);
    2828  assert (imageID  < 0x10000000);
    29   assert (sourceID < 0x100);
     29  assert (sourceID < 0x7f);
    3030 
    3131  uint64_t detectid = ((uint64_t)sourceID << 56) + ((uint64_t)imageID << 28) + (uint64_t)detID;
  • branches/eam_branches/ipp-20120905/Ohana/src/libdvo/include/dvo.h

    r34728 r34735  
    193193  ID_PHOTOM_PASS_3    = 0x00000800, // average magnitude calculated in 3th pass
    194194  ID_PHOTOM_PASS_4    = 0x00001000, // average magnitude calculated in 4th pass
     195  ID_PSPS_OBJ_EXT     = 0x00002000, // In PSPS ID_SECF_OBJ_EXT is moved here so it fits within 16 bits
    195196  ID_SECF_OBJ_EXT     = 0x01000000, // extended in this band
    196197} DVOSecfiltFlags;
  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r34229 r34735  
    304304        $skycell_id = $component;
    305305        $command = "$stacktool -sumskyfile -dbname $imagedb";
     306        # only consider stacks in full state.
     307        $command .= " -state full";
    306308        $id_opt = "-stack_id";
    307309        $component_args = " -skycell_id $skycell_id" if $skycell_id and $skycell_id ne  'all';
     
    894896        } else {
    895897            # skip these obsolete tesselations unless they were explicitly asked for
    896             # should I do this?
    897898            next if $tess_id eq "FIXNS";
    898899            next if $tess_id eq "ALLSKY";
     900            next if $tess_id eq "RINGS.V0";
    899901        }
    900902        next if $requested_skycell and ($skycell_id ne $requested_skycell);
     
    12871289
    12881290    my $id_name = $stage . "_id";
     1291    $id_name = 'exp_id' if $stage eq 'raw';
    12891292
    12901293    # input list is "order by exp_id, run_id DESC"   run_id is one of (chip_id, warp_id, diff_id)
     
    13071310        my $magicked = $input->{magicked};  # this will be either stageRun.magicked or stage%file.magicked
    13081311        my $state = $input->{state};
     1312        $state = $input->{data_state} if !defined $state;
    13091313
    13101314        # can't process run in these states
  • branches/eam_branches/ipp-20120905/ippMonitor

  • branches/eam_branches/ipp-20120905/ippMonitor/INSTALL

    r34006 r34735  
    2424# Note: we use a 'science databases (replication) slave' and the ippMonitor read-only account to connect to that database
    2525psconfigure --dbhost scidbs1 --dbuser ippMonitor --dbpass ippMonitor --htdocs /var/www/localhost/htdocs --site ~/ippconfig/ippmonitor.config
     26
     27psconfigure --dbhost scidbm --dbuser ipp --dbpass ipp --htdocs /var/www/localhost/htdocs --site ~/ippconfig/ippmonitor.config
     28
  • branches/eam_branches/ipp-20120905/ippMonitor/Makefile.in

    r34466 r34735  
    240240$(DESTWWW)/lapRuns.php \
    241241$(DESTWWW)/lapExposures.php \
    242 $(DESTWWW)/lapStacks.php
     242$(DESTWWW)/lapStacks.php \
     243$(DESTWWW)/failedStaticsky.php \
     244$(DESTWWW)/staticsky_failure.php
    243245
    244246PICTURES = \
  • branches/eam_branches/ipp-20120905/ippMonitor/raw/czartool_labels.php

    r34566 r34735  
    465465        createFormattedTableCell($anyFaults, $link, $str, $anyFaults, 0);
    466466
    467         $link = $defaultlink;
     467        $link = "failedStaticsky.php?pass=" . $pass . "&proj=" . $proj . "&staticskyRun.label=" . $thisLabel . "&staticskyRun.state=".$searchState;
    468468        getStateAndFaults($db, $thisLabel, $selectedState, "staticsky", $str, $anyFaults);
    469469        createFormattedTableCell($anyFaults, $link, $str, $anyFaults, 0);
  • branches/eam_branches/ipp-20120905/ippMonitor/raw/ipp.php

    r30454 r34735  
    799799  // echo "<b>class_id: $class_id</b><br>\n";
    800800  // echo "<b>camera:   $camera</b><br>\n";
     801  // echo "<b>filerule:   $filerule</b><br>\n";
    801802
    802803  if (! $class_id) { $class_id = "NONE"; }
    803804
     805  //SCH: I set a default value for the 'camera' which is based on the
     806  //'proj' parameter.
     807  //It's necessary for staticsky logs and it would require to join tables
     808  //back to the warpRun table
     809  if (! $camera) { $camera = strtoupper($_GET['proj']); }
     810
    804811  if ($basename && $camera && $filerule) {
    805 
    806812    // do I need to do this to the output result as well?
    807813    $basename = escapeshellarg($basename);
     
    841847      return;
    842848    }
     849    echo "<b>log filename: $filename</b><br>\n";
    843850
    844851    echo "<pre>\n";
     
    850857  }
    851858}
     859
    852860
    853861// expect image supplied with key=name
  • branches/eam_branches/ipp-20120905/ippMonitor/raw/ipp.stack.dat

    r28654 r34735  
    3636menulink  | menuselect   | link    | Static Sky Processed Skyfile | staticskyProcessedSkyfile.php
    3737menulink  | menuselect   | link    | Static Sky Failed Skyfile    | staticskyFailedSkyfile.php
     38menulink  | menuselect   | link    | Static Sky Failed            | failedStaticsky.php
  • branches/eam_branches/ipp-20120905/ippMonitor/raw/site.php.in

    r34566 r34735  
    4747$REPL_DBNAME_ISP = "ippc17 (isp)";
    4848
    49 $REPL_HOST_NEBULOUS_SECONDARY = "ippc63.IfA.Hawaii.Edu";
     49$REPL_HOST_NEBULOUS_SECONDARY = "ippdb04.IfA.Hawaii.Edu";
    5050$REPL_USER_NEBULOUS_SECONDARY = "ippMonitor";
    5151$REPL_PASSWORD_NEBULOUS_SECONDARY = "ippMonitor";
    52 $REPL_DBNAME_NEBULOUS_SECONDARY = "ippc63 (secondary nebulous / 50,000 sec behind is acceptable)";
     52$REPL_DBNAME_NEBULOUS_SECONDARY = "ippdb04 (secondary nebulous / 50,000 sec behind is acceptable / usually stopped on Mondays and Tuesdays)";
     53
     54$REPL_HOST_NEBULOUS_TERNARY = "ippc63.IfA.Hawaii.Edu";
     55$REPL_USER_NEBULOUS_TERNARY = "ippMonitor";
     56$REPL_PASSWORD_NEBULOUS_TERNARY = "ippMonitor";
     57$REPL_DBNAME_NEBULOUS_TERNARY = "ippc63 (secondary nebulous / 50,000 sec behind is acceptable / usually stopped on Mondays and Tuesdays)";
    5358
    5459
  • branches/eam_branches/ipp-20120905/ippScripts/scripts/background_warp.pl

    r33054 r34735  
    8888my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id) or my_die( "Unable to get log filename", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR );
    8989
    90 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
     90$ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    9191
    9292# Recipes to use based on reduction class
     
    158158&my_die("Can't find input astrometry: $astrometry", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($astrometry);
    159159
    160 my $out_image = $ipprc->filename("PSWARP.OUTPUT", $outroot, $skycell_id );
    161 my $out_mask = $ipprc->filename("PSWARP.OUTPUT.MASK", $outroot, $skycell_id);
    162 my $out_stats = $ipprc->filename("SKYCELL.STATS", $outroot, $skycell_id );
    163 my $out_config = $ipprc->filename("PSWARP.CONFIG", $outroot, $skycell_id);
    164 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot, $skycell_id);
    165 
    166 my $skyFile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id );
     160#my $out_image = $ipprc->filename("PSWARP.OUTPUT", $outroot, $skycell_id );
     161#my $out_mask = $ipprc->filename("PSWARP.OUTPUT.MASK", $outroot, $skycell_id);
     162#my $out_stats = $ipprc->filename("SKYCELL.STATS", $outroot, $skycell_id );
     163#my $out_config = $ipprc->filename("PSWARP.CONFIG", $outroot, $skycell_id);
     164#my $traceDest = $ipprc->filename("TRACE.EXP", $outroot, $skycell_id);
     165
     166my $out_image = prepare_output("PSWARP.OUTPUT", $outroot, $skycell_id,  1);
     167my $out_mask = prepare_output("PSWARP.OUTPUT.MASK", $outroot, $skycell_id, 1);
     168my $out_stats = prepare_output("SKYCELL.STATS", $outroot, $skycell_id, 1);
     169my $out_config = prepare_output("PSWARP.CONFIG", $outroot, $skycell_id, 1);
     170my $traceDest = prepare_output("TRACE.EXP", $outroot, $skycell_id, 1);
     171
     172my $skyFile = prepare_output("SKYCELL.TEMPLATE", $outroot, $skycell_id, 1);
     173
    167174$ipprc->skycell_file( $tess_dir, $skycell_id, $skyFile, $verbose ) or &my_die("Unable to generate template skycell", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    168175
     
    239246### Pau.
    240247
     248sub prepare_output
     249{
     250    my $filerule = shift;
     251    my $outroot  = shift;
     252    my $skycell_id = shift;
     253    my $delete = shift;
     254    $delete = 0 if !defined $delete;
     255
     256    my $error;
     257    my $output = $ipprc->prepare_output($filerule, $outroot, $skycell_id, $delete, \$error)
     258                    or &my_die("failed to prepare output file for: $filerule", $warp_bg_id, $skycell_id, $error);
     259    return $output;
     260}
     261
    241262
    242263sub my_die
  • branches/eam_branches/ipp-20120905/ippScripts/scripts/destreak_restore_camera.pl

    r34575 r34735  
    440440    }
    441441
     442    my $backup_url = shift;
    442443    my $original_url = shift;
    443     my $backup_url = shift;
    444444
    445445    # rename the backup as the orig
     
    449449    my $moved;
    450450    eval {
    451         $moved = nebulous->move($backup_url, $original_url);
     451        $moved = $nebulous->move($backup_url, $original_url);
    452452    };
    453453    if ($@ or not $moved) {
  • branches/eam_branches/ipp-20120905/ippScripts/scripts/ipp_apply_burntool_single.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/ippScripts/scripts/lap_science.pl

    r34313 r34735  
    671671#       }
    672672        # Do quality checks here
     673        if ($verbose) {
     674            printf("TEST: %d %d %d\n",$exposure->{exp_id},$exposure->{chip_id},$exposure->{chip_component_count});
     675        }
     676        # Checks to ensure we do not divide by zero.  Mostly happens with old diffs, it seems.
     677        if ($exposure->{chip_component_count} == 0) {
     678            $exposure->{chip_component_count} = 1;
     679        }
     680        if ($exposure->{cam_component_count} == 0) {
     681            $exposure->{cam_component_count} = 1;
     682        }
     683        if ($exposure->{warp_component_count} == 0) {
     684            $exposure->{warp_component_count} = 1;
     685        }
     686        if ($exposure->{diff_component_count} == 0) {
     687            $exposure->{diff_component_count} = 1;
     688        }
     689
    673690        my $is_bad_quality = 0;
    674691        if ((defined($exposure->{chipRun_state}))&&($exposure->{chipRun_state} eq 'full')&&
  • branches/eam_branches/ipp-20120905/ippScripts/scripts/magic_destreak.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/ippToPsps

  • branches/eam_branches/ipp-20120905/ippToPsps/config/OB/tables.vot

    r34275 r34735  
    4545        <DESCRIPTION> Declination error</DESCRIPTION>
    4646      </FIELD>
    47       <FIELD name="cx" arraysize="1" datatype="double" unit="unknown">
    48         <DESCRIPTION>Cartesian x</DESCRIPTION>
    49       </FIELD>
    50       <FIELD name="cy" arraysize="1" datatype="double" unit="unknown">
    51         <DESCRIPTION>Cartesian y</DESCRIPTION>
    52       </FIELD>
    53       <FIELD name="cz" arraysize="1" datatype="double" unit="unknown">
    54         <DESCRIPTION>Cartesian z</DESCRIPTION>
    55       </FIELD>
    5647      <FIELD name="lambda" arraysize="1" datatype="double" unit="degree">
    5748        <DESCRIPTION> ecliptic longitude</DESCRIPTION>
     
    6657        <DESCRIPTION> galactic latitude</DESCRIPTION>
    6758      </FIELD>
    68       <FIELD name="lsg" arraysize="1" datatype="double" unit="unknown">
    69         <DESCRIPTION>supergalactic longitude</DESCRIPTION>
    70       </FIELD>
    71       <FIELD name="bsg" arraysize="1" datatype="double" unit="unknown">
    72         <DESCRIPTION>supergalactic latitude</DESCRIPTION>
    73       </FIELD>
    7459      <FIELD name="nDetections" arraysize="1" datatype="short" unit="unknown">
    7560        <DESCRIPTION>total number of detection measurements in all filters</DESCRIPTION>
     
    201186        <DESCRIPTION> 80 pct w magnitude</DESCRIPTION>
    202187      </FIELD>
    203       <FIELD name="gStackPSFFlux" arraysize="1" datatype="float" unit="mag">
     188      <FIELD name="gStackPSFMag" arraysize="1" datatype="float" unit="mag">
    204189        <DESCRIPTION> g stack psf flux </DESCRIPTION>
    205190      </FIELD>
    206       <FIELD name="gStackPSFFluxErr" arraysize="1" datatype="double" unit="mag">
     191      <FIELD name="gStackPSFMagErr" arraysize="1" datatype="double" unit="mag">
    207192        <DESCRIPTION> estimated error in g stack psf flux</DESCRIPTION>
    208193      </FIELD>
     
    216201        <DESCRIPTION>flags for g stack</DESCRIPTION>
    217202      </FIELD>
    218       <FIELD name="rStackPSFFlux" arraysize="1" datatype="float" unit="mag">
     203      <FIELD name="gStackDetectID" arraysize="1" datatype="long" unit="unknown">
     204        <DESCRIPTION>ODM detection identifier</DESCRIPTION>
     205      </FIELD>
     206      <FIELD name="rStackPSFMag" arraysize="1" datatype="float" unit="mag">
    219207        <DESCRIPTION> r stack psf flux </DESCRIPTION>
    220208      </FIELD>
    221       <FIELD name="rStackPSFFluxErr" arraysize="1" datatype="double" unit="mag">
     209      <FIELD name="rStackPSFMagErr" arraysize="1" datatype="double" unit="mag">
    222210        <DESCRIPTION> estimated error in r stack psf flux</DESCRIPTION>
    223211      </FIELD>
     
    231219        <DESCRIPTION>flags for r stack</DESCRIPTION>
    232220      </FIELD>
    233       <FIELD name="iStackPSFFlux" arraysize="1" datatype="float" unit="mag">
     221      <FIELD name="rStackDetectID" arraysize="1" datatype="long" unit="unknown">
     222        <DESCRIPTION>ODM detection identifier</DESCRIPTION>
     223      </FIELD>
     224      <FIELD name="iStackPSFMag" arraysize="1" datatype="float" unit="mag">
    234225        <DESCRIPTION> i stack psf flux </DESCRIPTION>
    235226      </FIELD>
    236       <FIELD name="iStackPSFFluxErr" arraysize="1" datatype="float" unit="mag">
     227      <FIELD name="iStackPSFMagErr" arraysize="1" datatype="float" unit="mag">
    237228        <DESCRIPTION> estimated error in i stack psf flux</DESCRIPTION>
    238229      </FIELD>
     
    246237        <DESCRIPTION>flags for i stack</DESCRIPTION>
    247238      </FIELD>
    248       <FIELD name="zStackPSFFlux" arraysize="1" datatype="float" unit="mag">
     239      <FIELD name="iStackDetectID" arraysize="1" datatype="long" unit="unknown">
     240        <DESCRIPTION>ODM detection identifier</DESCRIPTION>
     241      </FIELD>
     242      <FIELD name="zStackPSFMag" arraysize="1" datatype="float" unit="mag">
    249243        <DESCRIPTION> z stack psf flux </DESCRIPTION>
    250244      </FIELD>
    251       <FIELD name="zStackPSFFluxErr" arraysize="1" datatype="float" unit="mag">
     245      <FIELD name="zStackPSFMagErr" arraysize="1" datatype="float" unit="mag">
    252246        <DESCRIPTION> estimated error in z stack psf flux</DESCRIPTION>
    253247      </FIELD>
     
    261255        <DESCRIPTION>flags for z stack</DESCRIPTION>
    262256      </FIELD>
    263       <FIELD name="yStackPSFFlux" arraysize="1" datatype="float" unit="unknown">
     257      <FIELD name="zStackDetectID" arraysize="1" datatype="long" unit="unknown">
     258        <DESCRIPTION>ODM detection identifier</DESCRIPTION>
     259      </FIELD>
     260      <FIELD name="yStackPSFMag" arraysize="1" datatype="float" unit="unknown">
    264261        <DESCRIPTION>y band stack PSF flux</DESCRIPTION>
    265262      </FIELD>
    266       <FIELD name="yStackPSFFluxErr" arraysize="1" datatype="float" unit="unknown">
     263      <FIELD name="yStackPSFMagErr" arraysize="1" datatype="float" unit="unknown">
    267264        <DESCRIPTION>y band stack psf flux err</DESCRIPTION>
    268265      </FIELD>
     
    276273        <DESCRIPTION>flags for y stack</DESCRIPTION>
    277274      </FIELD>
    278       <FIELD name="extra" arraysize="1" datatype="float" unit="unknown">
    279         <DESCRIPTION>currently unused</DESCRIPTION>
     275      <FIELD name="yStackDetectID" arraysize="1" datatype="long" unit="unknown">
     276        <DESCRIPTION>ODM detection identifier</DESCRIPTION>
     277      </FIELD>
     278      <FIELD name="qfPerfect" arraysize="1" datatype="float" unit="unknown">
     279        <DESCRIPTION>qf perfect</DESCRIPTION>
    280280      </FIELD>
    281281      <FIELD name="sgSep" arraysize="1" datatype="float" unit="unknown">
  • branches/eam_branches/ipp-20120905/ippToPsps/config/P2/tables.vot

    r32031 r34735  
    404404        <DESCRIPTION> estimated error in y</DESCRIPTION>
    405405      </FIELD>
    406       <FIELD name="instFlux" arraysize="1" datatype="float" unit="adu/s">
     406      <FIELD name="psfFlux" arraysize="1" datatype="float" unit="adu/s">
    407407        <DESCRIPTION> PSF instrumental flux</DESCRIPTION>
    408408      </FIELD>
    409       <FIELD name="instFluxErr" arraysize="1" datatype="float" unit="adu/s">
     409      <FIELD name="psfFluxErr" arraysize="1" datatype="float" unit="adu/s">
    410410        <DESCRIPTION> estimated error in flux</DESCRIPTION>
    411411      </FIELD>
     
    425425        <DESCRIPTION>PSF likelihood</DESCRIPTION>
    426426      </FIELD>
    427       <FIELD name="psfCf" arraysize="1" datatype="float" unit="unknown">
    428         <DESCRIPTION>PSF coverage factor</DESCRIPTION>
     427      <FIELD name="psfQf" arraysize="1" datatype="float" unit="unknown">
     428        <DESCRIPTION>PSF qf</DESCRIPTION>
    429429      </FIELD>
    430430      <FIELD name="momentXX" arraysize="1" datatype="float" unit="arcsec">
     
    437437        <DESCRIPTION> momeny YY</DESCRIPTION>
    438438      </FIELD>
    439       <FIELD name="apMag" arraysize="1" datatype="float" unit="magnitude">
    440         <DESCRIPTION> Aperture magnitude</DESCRIPTION>
    441       </FIELD>
    442       <FIELD name="apMagErr" arraysize="1" datatype="float" unit="magnitude">
    443         <DESCRIPTION> Aperture magnitude error</DESCRIPTION>
    444       </FIELD>
    445       <FIELD name="kronFlux" arraysize="1" datatype="float" unit="magnitude">
     439      <FIELD name="apFlux" arraysize="1" datatype="float" unit="adu/s">
     440        <DESCRIPTION> Aperture Flux</DESCRIPTION>
     441      </FIELD>
     442      <FIELD name="apFluxErr" arraysize="1" datatype="float" unit="adu/s">
     443        <DESCRIPTION> Aperture Flux error</DESCRIPTION>
     444      </FIELD>
     445      <FIELD name="kronFlux" arraysize="1" datatype="float" unit="adu/s">
    446446        <DESCRIPTION> Kron flux</DESCRIPTION>
    447447      </FIELD>
    448       <FIELD name="kronFluxErr" arraysize="1" datatype="float" unit="magnitude">
     448      <FIELD name="kronFluxErr" arraysize="1" datatype="float" unit="adu/s">
    449449        <DESCRIPTION> Kron flux error</DESCRIPTION>
    450450      </FIELD>
     
    455455        <DESCRIPTION> Kron radius error</DESCRIPTION>
    456456      </FIELD>
    457       <FIELD name="crLikelihood" arraysize="1" datatype="float" unit="unknown">
    458         <DESCRIPTION>Likelihood the source is a cosmic ray</DESCRIPTION>
    459       </FIELD>
    460       <FIELD name="extendedLikelihood" arraysize="1" datatype="float" unit="unknown">
    461         <DESCRIPTION>Likelihood the source is extended</DESCRIPTION>
     457      <FIELD name="psfQfPerfect" arraysize="1" datatype="float" unit="unknown">
     458        <DESCRIPTION>psf QF Perfect</DESCRIPTION>
     459      </FIELD>
     460      <FIELD name="psfChiSq" arraysize="1" datatype="float" unit="unknown">
     461        <DESCRIPTION>PSF Chi sq</DESCRIPTION>
    462462      </FIELD>
    463463      <FIELD name="infoFlag" arraysize="1" datatype="long" unit="unknown">
    464464        <DESCRIPTION>flag indicating provenance information</DESCRIPTION>
    465465      </FIELD>
    466       <FIELD name="sky" arraysize="1" datatype="float" unit="adu">
     466      <FIELD name="sky" arraysize="1" datatype="float" unit="adu/s/pixel">
    467467        <DESCRIPTION> PSF sky level at source</DESCRIPTION>
    468468      </FIELD>
    469       <FIELD name="skyErr" arraysize="1" datatype="float" unit="adu">
     469      <FIELD name="skyErr" arraysize="1" datatype="float" unit="adu/s/pixel">
    470470        <DESCRIPTION> estimated error in sky</DESCRIPTION>
    471471      </FIELD>
     
    539539      </DATA>
    540540    </TABLE>
     541    <TABLE name="DetectionCalib">
     542      <DESCRIPTION>VOTable description of PSPS table DetectionCalib</DESCRIPTION>
     543      <PARAM arraysize="1" datatype="char" ucd="meta.bib.author" name="Author" value="PSPS"></PARAM>
     544      <FIELD name="objID" arraysize="1" datatype="long" unit="unknown">
     545        <DESCRIPTION>ODM object identifier index</DESCRIPTION>
     546      </FIELD>
     547      <FIELD name="detectID" arraysize="1" datatype="long" unit="unknown">
     548        <DESCRIPTION>ODM detection identifier index</DESCRIPTION>
     549      </FIELD>
     550      <FIELD name="ippObjID" arraysize="1" datatype="long" unit="unknown">
     551        <DESCRIPTION>IPP object number</DESCRIPTION>
     552      </FIELD>
     553      <FIELD name="ippDetectID" arraysize="1" datatype="long" unit="unknown">
     554        <DESCRIPTION>detection ID generated by IPP</DESCRIPTION>
     555      </FIELD>
     556      <FIELD name="filterID" arraysize="1" datatype="unsignedByte" unit="unknown">
     557        <DESCRIPTION>filter identifier</DESCRIPTION>
     558      </FIELD>
     559      <FIELD name="surveyID" arraysize="1" datatype="unsignedByte" unit="unknown">
     560        <DESCRIPTION>survey identifier</DESCRIPTION>
     561      </FIELD>
     562      <FIELD name="ra" arraysize="1" datatype="double" unit="degrees">
     563        <DESCRIPTION>right ascension</DESCRIPTION>
     564      </FIELD>
     565      <FIELD name="dec" arraysize="1" datatype="double" unit="degrees">
     566        <DESCRIPTION>declination</DESCRIPTION>
     567      </FIELD>
     568      <FIELD name="raErr" arraysize="1" datatype="float" unit="arcsec">
     569        <DESCRIPTION>right ascension error</DESCRIPTION>
     570      </FIELD>
     571      <FIELD name="decErr" arraysize="1" datatype="float" unit="arcsec">
     572        <DESCRIPTION>declination error</DESCRIPTION>
     573      </FIELD>
     574      <FIELD name="zp" arraysize="1" datatype="float" unit="magnitude">
     575        <DESCRIPTION>zero point offset</DESCRIPTION>
     576      </FIELD>
     577      <FIELD name="zpErr" arraysize="1" datatype="float" unit="magnitude">
     578        <DESCRIPTION>zerop point offset error</DESCRIPTION>
     579      </FIELD>
     580      <FIELD name="expTime" arraysize="1" datatype="float" unit="s">
     581        <DESCRIPTION>exposure time</DESCRIPTION>
     582      </FIELD>
     583      <FIELD name="airMass" arraysize="1" datatype="float" unit="unknown">
     584        <DESCRIPTION>airmass</DESCRIPTION>
     585      </FIELD>
     586      <FIELD name="dataRelease" arraysize="1" datatype="unsignedByte" unit="unknown">
     587        <DESCRIPTION>Data release to propagate to the object</DESCRIPTION>
     588      </FIELD>
     589      <DATA>
     590        <TABLEDATA></TABLEDATA>
     591      </DATA>
     592    </TABLE>
    541593  </RESOURCE>
    542594</VOTABLE>
  • branches/eam_branches/ipp-20120905/ippToPsps/config/ST/tables.vot

    r32031 r34735  
    148148        <DESCRIPTION>projection cell identifier</DESCRIPTION>
    149149      </FIELD>
    150       <FIELD name="obsTime" arraysize="1" datatype="double">
    151         <DESCRIPTION> Time of mid observation (unit = day)</DESCRIPTION>
    152       </FIELD>
    153150      <FIELD name="xPos" arraysize="1" datatype="float">
    154151        <DESCRIPTION>measured x on CCD from PSF fit</DESCRIPTION>
     
    163160        <DESCRIPTION>estimated error in y</DESCRIPTION>
    164161      </FIELD>
    165       <FIELD name="instFlux" arraysize="1" datatype="float">
     162      <FIELD name="psfFlux" arraysize="1" datatype="float">
    166163        <DESCRIPTION>PSF instrumental flux</DESCRIPTION>
    167164      </FIELD>
    168       <FIELD name="instFluxErr" arraysize="1" datatype="float">
     165      <FIELD name="psfFluxErr" arraysize="1" datatype="float">
    169166        <DESCRIPTION>estimated error in instrumental flux</DESCRIPTION>
    170167      </FIELD>
     
    193190        <DESCRIPTION>PSF likelihood</DESCRIPTION>
    194191      </FIELD>
    195       <FIELD name="psfCf" arraysize="1" datatype="float">
    196         <DESCRIPTION>PSF coverage factor</DESCRIPTION>
    197       </FIELD>
     192      <FIELD name="psfQf" arraysize="1" datatype="float">
     193        <DESCRIPTION>PSF Q factor</DESCRIPTION>
     194      </FIELD>
     195       <FIELD name="psfQfPerfect" arraysize="1" datatype="float">
     196        <DESCRIPTION>PSF QF Perfect</DESCRIPTION>
     197      </FIELD>
    198198      <FIELD name="momentXX" arraysize="1" datatype="float">
    199199        <DESCRIPTION> moment XX (unit = arcsec)</DESCRIPTION>
     
    223223        <DESCRIPTION> moment RH (unit = arcsec)</DESCRIPTION>
    224224      </FIELD>
    225       <FIELD name="apMag" arraysize="1" datatype="float">
    226         <DESCRIPTION> Aperture magnitude (unit = magnitude)</DESCRIPTION>
    227       </FIELD>
    228       <FIELD name="apMagErr" arraysize="1" datatype="float">
    229         <DESCRIPTION> Aperture magnitude error (unit = magnitude)</DESCRIPTION>
     225      <FIELD name="apFlux" arraysize="1" datatype="float">
     226        <DESCRIPTION> Aperture flux (unit = adu/s)</DESCRIPTION>
     227      </FIELD>
     228      <FIELD name="apFluxErr" arraysize="1" datatype="float">
     229        <DESCRIPTION> Aperture flux error (unit = adu/s)</DESCRIPTION>
    230230      </FIELD>
    231231      <FIELD name="kronFlux" arraysize="1" datatype="float">
    232         <DESCRIPTION> Kron flux (unit = magnitude)</DESCRIPTION>
     232        <DESCRIPTION> Kron flux (unit = adu/s)</DESCRIPTION>
    233233      </FIELD>
    234234      <FIELD name="kronFluxErr" arraysize="1" datatype="float">
    235         <DESCRIPTION> Kron flux error (unit = magnitude)</DESCRIPTION>
     235        <DESCRIPTION> Kron flux error (unit = adu/s)</DESCRIPTION>
    236236      </FIELD>
    237237      <FIELD name="kronRad" arraysize="1" datatype="float">
    238238        <DESCRIPTION> Kron radius (unit = arcsecs)</DESCRIPTION>
    239239      </FIELD>
    240       <FIELD name="kronRadErr" arraysize="1" datatype="float">
    241         <DESCRIPTION> Kron radius error (unit = arcsecs)</DESCRIPTION>
     240      <FIELD name="psfChiSq" arraysize="1" datatype="float">
     241        <DESCRIPTION> psf chi sq</DESCRIPTION>
    242242      </FIELD>
    243243      <FIELD name="infoFlag" arraysize="1" datatype="long">
     
    293293        <DESCRIPTION>stack identifier</DESCRIPTION>
    294294      </FIELD>
    295       <FIELD name="isophotMag" arraysize="1" datatype="float">
    296         <DESCRIPTION>isophotal magnitude</DESCRIPTION>
    297       </FIELD>
    298       <FIELD name="isophotMagErr" arraysize="1" datatype="float">
    299         <DESCRIPTION>estimated error in isophotal magnitude</DESCRIPTION>
     295      <FIELD name="isophotFlux" arraysize="1" datatype="float">
     296        <DESCRIPTION>isophotal flux</DESCRIPTION>
     297      </FIELD>
     298      <FIELD name="isophotFluxErr" arraysize="1" datatype="float">
     299        <DESCRIPTION>estimated error in isophotal flux</DESCRIPTION>
    300300      </FIELD>
    301301      <FIELD name="isophotMajAxis" arraysize="1" datatype="float">
     
    332332        <DESCRIPTION>estimated error inPetrosian radius</DESCRIPTION>
    333333      </FIELD>
    334       <FIELD name="petMag" arraysize="1" datatype="float">
    335         <DESCRIPTION>Petrosian magntiude</DESCRIPTION>
    336       </FIELD>
    337       <FIELD name="petMagErr" arraysize="1" datatype="float">
    338         <DESCRIPTION>estimated error in petMag</DESCRIPTION>
     334      <FIELD name="petFlux" arraysize="1" datatype="float">
     335        <DESCRIPTION>Petrosian Flux</DESCRIPTION>
     336      </FIELD>
     337      <FIELD name="petFluxErr" arraysize="1" datatype="float">
     338        <DESCRIPTION>estimated error in petFlux</DESCRIPTION>
    339339      </FIELD>
    340340      <FIELD name="petR50" arraysize="1" datatype="float">
     
    765765        <DESCRIPTION>estimated error in deVaucouleurs radius</DESCRIPTION>
    766766      </FIELD>
    767       <FIELD name="deVMag" arraysize="1" datatype="float">
     767      <FIELD name="deVFlux" arraysize="1" datatype="float">
    768768        <DESCRIPTION>deVaucouleurs magntiude</DESCRIPTION>
    769769      </FIELD>
    770       <FIELD name="deVMagErr" arraysize="1" datatype="float">
     770      <FIELD name="deVFluxErr" arraysize="1" datatype="float">
    771771        <DESCRIPTION>estimated error in deV_mag</DESCRIPTION>
    772772      </FIELD>
     
    891891        <DESCRIPTION>estimated error in Exponential fit radius</DESCRIPTION>
    892892      </FIELD>
    893       <FIELD name="expMag" arraysize="1" datatype="float">
    894         <DESCRIPTION>Exponential fit magntiude</DESCRIPTION>
    895       </FIELD>
    896       <FIELD name="expMagErr" arraysize="1" datatype="float">
    897         <DESCRIPTION>estimated error in expMag</DESCRIPTION>
     893      <FIELD name="expFlux" arraysize="1" datatype="float">
     894        <DESCRIPTION>Exponential fit flux</DESCRIPTION>
     895      </FIELD>
     896      <FIELD name="expFluxErr" arraysize="1" datatype="float">
     897        <DESCRIPTION>estimated error in expFlux</DESCRIPTION>
    898898      </FIELD>
    899899      <FIELD name="expAb" arraysize="1" datatype="float">
     
    10171017        <DESCRIPTION>estimated error in Sersic radius</DESCRIPTION>
    10181018      </FIELD>
    1019       <FIELD name="serMag" arraysize="1" datatype="float">
    1020         <DESCRIPTION>Sersic magntiude</DESCRIPTION>
    1021       </FIELD>
    1022       <FIELD name="serMagErr" arraysize="1" datatype="float">
    1023         <DESCRIPTION>estimated error in serMag</DESCRIPTION>
     1019      <FIELD name="serFlux" arraysize="1" datatype="float">
     1020        <DESCRIPTION>Sersic Flux</DESCRIPTION>
     1021      </FIELD>
     1022      <FIELD name="serFluxErr" arraysize="1" datatype="float">
     1023        <DESCRIPTION>estimated error in serFlux</DESCRIPTION>
    10241024      </FIELD>
    10251025      <FIELD name="serAb" arraysize="1" datatype="float">
     
    12401240      </DATA>
    12411241    </TABLE>
     1242       <TABLE name="StackDetectionCalib">
     1243      <DESCRIPTION>VOTable description of PSPS table StackDetectionCalib</DESCRIPTION>
     1244      <PARAM arraysize="1" datatype="char" ucd="meta.bib.author" name="Author" value="PSPS"></PARAM>
     1245      <FIELD name="objID" arraysize="1" datatype="long" unit="unknown">
     1246        <DESCRIPTION>ODM object identifier index</DESCRIPTION>
     1247      </FIELD>
     1248      <FIELD name="stackDetectID" arraysize="1" datatype="long" unit="unknown">
     1249        <DESCRIPTION>ODM detection identifier index</DESCRIPTION>
     1250      </FIELD>
     1251      <FIELD name="ippObjID" arraysize="1" datatype="long" unit="unknown">
     1252        <DESCRIPTION>IPP object number</DESCRIPTION>
     1253      </FIELD>
     1254      <FIELD name="ippDetectID" arraysize="1" datatype="long" unit="unknown">
     1255        <DESCRIPTION>detection ID generated by IPP</DESCRIPTION>
     1256      </FIELD>
     1257      <FIELD name="filterID" arraysize="1" datatype="unsignedByte" unit="unknown">
     1258        <DESCRIPTION>filter identifier</DESCRIPTION>
     1259      </FIELD>
     1260      <FIELD name="surveyID" arraysize="1" datatype="unsignedByte" unit="unknown">
     1261        <DESCRIPTION>survey identifier</DESCRIPTION>
     1262      </FIELD>
     1263      <FIELD name="ra" arraysize="1" datatype="double" unit="degrees">
     1264        <DESCRIPTION>right ascension</DESCRIPTION>
     1265      </FIELD>
     1266      <FIELD name="dec" arraysize="1" datatype="double" unit="degrees">
     1267        <DESCRIPTION>declination</DESCRIPTION>
     1268      </FIELD>
     1269      <FIELD name="raErr" arraysize="1" datatype="float" unit="arcsec">
     1270        <DESCRIPTION>right ascension error</DESCRIPTION>
     1271      </FIELD>
     1272      <FIELD name="decErr" arraysize="1" datatype="float" unit="arcsec">
     1273        <DESCRIPTION>declination error</DESCRIPTION>
     1274      </FIELD>
     1275      <FIELD name="zp" arraysize="1" datatype="float" unit="magnitude">
     1276        <DESCRIPTION>zero point offset</DESCRIPTION>
     1277      </FIELD>
     1278      <FIELD name="zpErr" arraysize="1" datatype="float" unit="magnitude">
     1279        <DESCRIPTION>zerop point offset error</DESCRIPTION>
     1280      </FIELD>
     1281      <FIELD name="expTime" arraysize="1" datatype="float" unit="s">
     1282        <DESCRIPTION>exposure time</DESCRIPTION>
     1283      </FIELD>
     1284      <FIELD name="airMass" arraysize="1" datatype="float" unit="unknown">
     1285        <DESCRIPTION>airmass</DESCRIPTION>
     1286      </FIELD>
     1287      <FIELD name="dataRelease" arraysize="1" datatype="unsignedByte" unit="unknown">
     1288        <DESCRIPTION>Data release to propagate to the object</DESCRIPTION>
     1289      </FIELD>
     1290      <DATA>
     1291        <TABLEDATA></TABLEDATA>
     1292      </DATA>
     1293    </TABLE>
    12421294  </RESOURCE>
    12431295</VOTABLE>
  • branches/eam_branches/ipp-20120905/ippToPsps/jython/detectionbatch.py

    r33830 r34735  
    388388        # delete all detections with PSF_INST_MAG < 17.5, as decreed by Gene
    389389        BEFORE = self.scratchDb.getRowCount(ippTableName)
    390         sql = "DELETE FROM " + ippTableName + " WHERE PSF_INST_MAG < -17.5"
    391         self.scratchDb.execute(sql)
     390        #don't do this anymore
     391        #sql = "DELETE FROM " + ippTableName + " WHERE PSF_INST_MAG < -17.5"
     392        #self.scratchDb.execute(sql)
    392393        #DELETED = BEFORE - self.scratchDb.getRowCount(ippTableName)
    393         results['SATDET'] = BEFORE - self.scratchDb.getRowCount(ippTableName)
     394        #results['SATDET'] = BEFORE - self.scratchDb.getRowCount(ippTableName)
     395        #we aren't deletng these now
     396        results['SATDET'] = 0
    394397        #self.logger.infoPair("Saturated detections", "%d deleted" % DELETED)
    395398
     
    404407               ,xPosErr \
    405408               ,yPosErr \
    406                ,instFlux \
    407                ,instFluxErr \
     409               ,psfFlux \
     410               ,psfFluxErr \
    408411               ,peakADU \
    409412               ,psfWidMajor \
     
    411414               ,psfTheta \
    412415               ,psfLikelihood \
    413                ,psfCf \
     416               ,psfQf \
    414417               ,momentXX \
    415418               ,momentXY \
    416419               ,momentYY \
    417                ,apMag \
     420               ,apFlux \
    418421               ,kronFlux \
    419422               ,kronFluxErr \
     423               ,psfQfPerfect \
     424               ,psfChiSq \
    420425               ,infoFlag \
    421426               ,sky \
     
    447452               ,MOMENTS_XY \
    448453               ,MOMENTS_YY \
    449                ,AP_MAG \
     454               ,POW(10.0, -0.4 *AP_MAG) / " + self.header['EXPTIME'] + " \
    450455               ,KRON_FLUX / " + self.header['EXPTIME'] + " \
    451456               ,KRON_FLUX_ERR / " + self.header['EXPTIME'] + " \
    452                ,FLAGS\
    453                ,SKY \
    454                ,SKY_SIGMA \
     457               ,PSF_QF_PERFECT \
     458               ,PSF_CHISQ \
     459               ,FLAGS2 << 32 | FLAGS \
     460               ,SKY  / " + self.header['EXPTIME'] + " \
     461               ,SKY_SIGMA  / " + self.header['EXPTIME'] + " \
    455462               ,EXT_NSIGMA \
    456463               , 0 \
     
    459466               , " + str(self.config.dataRelease) + "\
    460467               FROM " + ippTableName
     468        # self.logger.info(sql)
    461469        self.scratchDb.execute(sql)
    462470
    463471        # now delete bad flux and bad chip positions
    464         sql="DELETE FROM " + pspsTableName + " WHERE instFlux < 0.0000001" # TODO clearly a hack = 0 not allowed for instFlux
    465         self.scratchDb.execute(sql)
    466 
     472        #sql="DELETE FROM " + pspsTableName + " WHERE instFlux < 0.0000001" # TODO clearly a hack = 0 not allowed for instFlux
     473        #self.scratchDb.execute(sql)
     474
     475        # add a instFlux = 0.0 -> 0.000001
     476        sql="UPDATE " + pspsTableName + " SET psfFlux = 0.0000001 WHERE psfFlux =  0"
     477        self.scratchDb.execute(sql)
     478     
    467479        # update cosmic ray and extended likelihoods
    468         sql="UPDATE " + pspsTableName + " SET extendedLikelihood = 0, crLikelihood = 1.0 - psfLikelihood WHERE sgSep <= 0"
    469         self.scratchDb.execute(sql)
    470         sql="UPDATE " + pspsTableName + " SET crLikelihood = 0, extendedLikelihood = 1.0 - psfLikelihood WHERE sgSep > 0"
    471         self.scratchDb.execute(sql)
     480        #sql="UPDATE " + pspsTableName + " SET extendedLikelihood = 0, crLikelihood = 1.0 - psfLikelihood WHERE sgSep <= 0"
     481        #self.scratchDb.execute(sql)
     482        #sql="UPDATE " + pspsTableName + " SET crLikelihood = 0, extendedLikelihood = 1.0 - psfLikelihood WHERE sgSep > 0"
     483        #self.scratchDb.execute(sql)
    472484
    473485        # remove detections will NULL inst flux or NULL peak ADU
    474         results['NULLINSTFLUX'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "instFlux")
    475         results['NULLPEAKADU'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "peakADU")
     486        # leave them in at this stage- don't delete them.
     487        #results['NULLINSTFLUX'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "instFlux")
     488        #results['NULLPEAKADU'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "peakADU")
     489        #we don't delete thos anymore
     490        results['NULLINSTFLUX'] = 0;
     491        results['NULLPEAKADU'] = 0;
    476492
    477493    '''
     
    504520
    505521    '''
     522    Populates the DetectionCalib table for this OTA
     523    '''
     524    def populateDetectionCalibTable(self, ota):
     525
     526        tableName = "DetectionCalib_" + ota
     527        # drop then re-create table
     528        self.scratchDb.dropTable(tableName)
     529        sql = "CREATE TABLE " + tableName + " LIKE DetectionCalib"
     530        try: self.scratchDb.execute(sql)
     531        except: pass
     532
     533        # insert all detections into table
     534        sql = "INSERT INTO " + tableName + " ( \
     535               objID \
     536               ,detectID \
     537               ,ippObjID \
     538               ,ippDetectID \
     539               ,filterID \
     540               ,surveyID \
     541               ) \
     542               SELECT \
     543               objID \
     544               ,detectID \
     545               ,ippObjID \
     546               ,ippDetectID \
     547               ,filterID \
     548               ,surveyID \
     549               FROM Detection_" + ota
     550        self.scratchDb.execute(sql)
     551
     552        # insert calibration information from dvoDetections into the Table
     553        sql = "UPDATE " + tableName + " AS a, "  + self.scratchDb.dvoDetectionTable + " AS b \
     554            SET a.ra = b.ra, \
     555            a.dec = b.dec_, \
     556            a.raErr = b.raErr, \
     557            a.decErr = b.decErr, \
     558            a.zp = b.zp, \
     559            a.zpErr = b.zpErr, \
     560            a.expTime = b.expTime, \
     561            a.airMass = b.airMass   \
     562            WHERE a.objID = b.objID AND a.detectID = b.detectID"
     563        self.scratchDb.execute(sql)
     564        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
     565       
     566    '''
    506567    Populates the Detection table for this OTA
    507568    '''
     
    587648            if not self.getIDsFromDVO(): return False
    588649
     650        # dec is reserved in MySQL, so STILTS replaces if with dec_, which is not the name of
     651        # the column in PSPS
     652        self.scratchDb.execute("ALTER TABLE DetectionCalib CHANGE dec_ `dec` double")
     653
     654
     655
    589656        return True
    590657
     
    608675                extension = "XY%d%d_psf" % (x, y)
    609676                self.scratchDb.createIndex(extension, "IPP_IDET")
    610 
     677        self.logger.infoPair("created indexes on", "IPP tables")     
    611678    '''
    612679    Updates provided table with DVO IDs from DVO table
     
    620687               a.detectID = b.detectID, \
    621688               a.objID = b.objID, \
    622                a.infoFlag = b.flags << 32 | a.infoFlag \
     689               a.infoFlag = b.flags << 45 | a.infoFlag \
    623690               WHERE a.ippDetectID = b.ippDetectID \
    624691               AND b.imageID = " + str(imageID)
     
    658725                    self.logger.info("| %5s |            ------------- Bad astrometric solution : rejecting ------------                    |" % ota)
    659726                    continue
    660 
     727               # self.logger.info("populate stuff ");
    661728                # populate remainder of tables
    662729                self.populateDetectionTable(ota, results)
    663 
     730               # self.logger.info("successful populate ");
    664731                # now add DVO IDs
    665732                self.updateDvoIDs("Detection_" + ota, self.imageIDs[ota])
     733               # self.logger.info("updated dvoids")
    666734                results['NULLOBJID'] = self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + ota, "objID")
    667                 self.updateImageID("Detection_" + ota, x, y)
     735                #self.logger.info("deleted nulls")
     736                self.updateImageID("Detection_" + ota, x, y)
     737               # self.logger.info("updateImageId")
    668738                rowCount = self.scratchDb.getRowCount("Detection_" + ota)
     739              #  self.logger.info("got row count")
    669740                self.logger.info("| %5s | %13d | %13d | %13d | %13d | %13d | %13d |",
    670741                        ota,
     
    675746                        results['NULLOBJID'],
    676747                        rowCount)
    677 
    678748                totalOriginal = totalOriginal + results['ORIGINALTOTAL']
    679749                totalSatDet = totalSatDet + results['SATDET']
     
    682752                totalNullObjID = totalNullObjID + results['NULLOBJID']
    683753                totalDetections = totalDetections + rowCount
    684 
     754                #self.logger.info("updated totals")
    685755                # check we have something in this Detection table TODO add this to table above
    686756                if rowCount < 1:
     
    692762                       SET nDetect = %d, photoCalID = %d" % (self.scratchDb.getRowCount("Detection_" + ota), self.scratchDb.getPhotoCalID(self.imageIDs[ota]))
    693763                self.scratchDb.execute(sql)
    694 
     764               
     765                #self.logger.info("updated imagedata")
    695766                self.populateSkinnyObjectTable(ota)
     767                #self.logger.info("updated skinnyobject")
    696768                self.populateObjectCalColorTable(ota)
    697 
     769                #self.logger.info("updated objectcalcolor")
     770                self.populateDetectionCalibTable(ota)
     771                #self.logger.info("updated detectioncalibtable")
     772               
    698773                # add these to list of tables to export later
    699774                self.tablesToExport.append("ImageMeta_" + ota)
     
    701776                self.tablesToExport.append("SkinnyObject_" + ota)
    702777                self.tablesToExport.append("ObjectCalColor_" + ota)
     778                self.tablesToExport.append("DetectionCalib_" + ota)
    703779                tables.append("Detection_" + ota)
    704780           
    705781                otaCount = otaCount + 1
    706 
     782                #self.logger.info("end of ota")
    707783        # print totals
    708784        self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+---------------+")
     
    757833       else : regex = ".*.psf"
    758834 
    759        columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY AP_MAG KRON_FLUX KRON_FLUX_ERR FLAGS SKY SKY_SIGMA EXT_NSIGMA"
     835       columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY AP_MAG KRON_FLUX KRON_FLUX_ERR FLAGS FLAGS2 SKY SKY_SIGMA EXT_NSIGMA PSF_QF_PERFECT PSF_CHISQ"
    760836
    761837       return super(DetectionBatch, self).importIppTables(columns, regex)
  • branches/eam_branches/ipp-20120905/ippToPsps/jython/dvodetections.py

    r33686 r34735  
    4444           self.importFits(
    4545                   cpmPath,
    46                    "IMAGE_ID DET_ID OBJ_ID CAT_ID EXT_ID DB_FLAGS",
     46                   "IMAGE_ID DET_ID OBJ_ID CAT_ID EXT_ID DB_FLAGS PHOTCODE AIRMASS M_TIME M_CAL MAG_CAL_ERR D_RA D_DEC PLTSCALE X_CCD_ERR Y_CCD_ERR",
    4747                   cpmTableName)
    4848
     
    5050           self.scratchDb.createIndex(cpmTableName, "CAT_ID")
    5151           self.scratchDb.createIndex(cpmTableName, "OBJ_ID")
     52
     53           # XXX: Should we create index on PHOTCODE?
    5254
    5355           # we can now report that we have imported this table
     
    6062       self.importFits(
    6163               cptPath,
    62                "OBJ_ID CAT_ID EXT_ID",
     64               "OBJ_ID CAT_ID EXT_ID RA DEC",
    6365               cptTableName)
    6466
     
    6769       self.scratchDb.createIndex(cptTableName, "OBJ_ID")
    6870
     71       # SA10
     72       # Columns needed for DetectionCalib and StackDetectionCalib
     73       # zp      = photcode.K * (AIRMASS - 1) + photcode.C_LAM * 0.001 - cpm.M_CAL
     74       # zpErr   = cpm.MAG_CAL_ERR
     75       # airMass = cpm.AIRMASS
     76       # expTime = POW(10.0, 0.4 * cpm.M_TIME)
     77       # ra      = cpt.RA  - (cpm.D_RA  / 3600.0)
     78       # dec     = cpt.DEC - (cpm.D_DEC / 3600.0)
     79       # raErr   = cpm.X_CCD_ERR * cpm.PLTSCALE
     80       # decErr  = cpm.Y_CCD_ERR * cpm.PLTSCALE
     81
    6982       self.logger.infoPair("Adding","PSPS objIDs")
    70        # first try to add a column for PSPS_OBJ_ID. catch failure and continue
     83       # first try to add the new columns. catch failure and continue
    7184       try:
    72            sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT)"
     85           sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT), (ZP REAL), (RA FLOAT), (DEC FLOAT)"
    7386           self.scratchDb.execute(sql)
    7487       except:
    7588           self.logger.infoPair("Already added PSPS_OBJ_ID column to", cpmTableName)
    7689               
    77        # shove PSPS objIDs from cpt table into measurement table
    78        sql = "UPDATE " + cpmTableName + " AS a, " + cptTableName + " AS b \
    79               SET a.PSPS_OBJ_ID = b.EXT_ID \
     90       # shove PSPS objIDs from cpt table and the calibrated zero point and coordinates which are formed
     91       # by combining values from multiple tables into cpt table
     92       sql = "UPDATE " + cpmTableName + " AS a, " + cptTableName + " AS b, " \
     93              + self.scratchDb.dvoPhotcodesTable + " AS c \
     94              SET a.PSPS_OBJ_ID = b.EXT_ID, \
     95              b.ZP  = c.C_LAM * 0.001 + c.K * (b.AIRMASS - 1) - b.M_CAL, \
     96              b.RA  = a.RA  - (b.D_RA  / 3600.0), \
     97              b.DEC = a.DEC - (b.D_DEC / 3600.0) \
    8098              WHERE a.CAT_ID = b.CAT_ID \
    81               AND a.OBJ_ID = b.OBJ_ID"
     99              AND a.OBJ_ID = b.OBJ_ID   \
     100              AND b.PHOTCODE = c.CODE"
     101
    82102       self.scratchDb.execute(sql)
    83103
     
    86106       # PSPS object IDs assigned in the corresponding cpt file. This is believed to be a chip-boundary
    87107       # issue within DVO. So, for now, we take the first IMAGE_ID/DET_ID detection we find, and ignore the rest
     108       # XXX: Bills 2012-10031 Does this problem still exist?
    88109       self.logger.infoPair("Merging into", self.scratchDb.dvoDetectionTable)
    89110       sql = "INSERT IGNORE INTO " + self.scratchDb.dvoDetectionTable + " (\
     
    94115              ,objID \
    95116              ,flags \
     117              ,zp   \
     118              ,zpErr    \
     119              ,airMass  \
     120              ,expTime  \
     121              ,ra   \
     122              ,dec_  \
     123              ,raErr    \
     124              ,decErr   \
    96125              ,fileID \
    97126              ) SELECT \
     
    102131              ,PSPS_OBJ_ID \
    103132              ,DB_FLAGS \
     133              ,ZP   \
     134              ,MAG_CAL_ERR  \
     135              ,AIRMASS  \
     136              ,POW(10.0, 0.4 * M_TIME)  \
     137              ,RA   \
     138              ,DEC  \
     139              ,X_CCD_ERR*PLTSCALE   \
     140              ,Y_CCD_ERR*PLTSCALE   \
    104141              , " + str(fileId) + " \
    105142              FROM " + cpmTableName
     143
    106144       try:
    107145           self.scratchDb.execute(sql)
  • branches/eam_branches/ipp-20120905/ippToPsps/jython/ipptopspsdb.py

    r33858 r34735  
    638638            and not self.processingNow(batchType, stageID) \
    639639            and not self.consistentlyFailed(batchType, stageID)):
     640           
     641            self.logger.infoPair("heather:","passed logic")
    640642
    641643            sql = "INSERT INTO batch ( \
     
    652654                       '" + self.config.datastoreProduct + "' \
    653655                       )"
     656            self.logger.infoPair("heather:","sql")
    654657
    655658            self.execute(sql)
  • branches/eam_branches/ipp-20120905/ippToPsps/jython/loader.py

    r33832 r34735  
    123123
    124124                self.logger.infoPair("Boxes with unprocessed data", "%d" % len(boxIds))
    125    
     125                self.logger.infoPair("numAttempts", str(numAttempts))
    126126                if len(boxIds) > 0: numAttempts = 0
    127127
    128128                for boxId in boxIds:
    129          
     129                    self.logger.infoPair("Check","client status")
    130130                    if not self.checkClientStatus():
    131131                        abort = True
    132132                        break
    133    
     133                    self.logger.infoPair("client status", "ok")
    134134                    # get box info. if boxes have changed, break and start again
    135135                    try:
     
    138138                        self.logger.infoPair("Can't get details for this box", "%d" % boxId)
    139139                        break
    140      
     140                    self.logger.infoPair("client status", "ok")
    141141                    ids = self.ippToPspsDb.getPendingIdsForThisBox(boxId, batchType)
    142142               
     
    150150                    self.logger.infoPair(batchType + " items found in this box", "%d" % len(ids))
    151151                    boxSizeWithBorder = boxDim['SIDE'] + (self.config.BORDER * 2)
    152      
     152                    self.logger.infoPair("got here", "ok")
    153153                    useFullTables = 0
    154154                    if batchType != "OB":
     
    174174                        abort = True
    175175                        break
    176 
     176                    self.logger.infoPair("processed","ok")
    177177            if abort or not self.checkClientStatus(): abort = True
    178178            elif numAttempts > 1 and not self.waitForPollTime():  break
     
    188188        # loop round IDs of all items to be processed
    189189        self.ippToPspsDb.lockBatchTable()
     190        self.logger.infoPair("heather:","lockbatchtable")
    190191        unattemptedCount = 0
    191192        for id in ids:
    192    
     193            self.logger.infoPair("heather:","in ids")
     194            self.logger.infoPair("heather:id",str(id))
    193195            batchID = self.ippToPspsDb.createNewBatch(batchType, id)
    194            
     196            self.logger.infoPair("heather:","creatednewbatch")
     197            self.logger.infoPair("heather:batchId", str(batchID))
    195198            if batchID < 0:
    196199                unattemptedCount += 1
    197200                continue
    198    
     201            self.logger.infoPair("heather:","passed logic")
    199202            self.ippToPspsDb.unlockTables()
     203            self.logger.infoPair("heather:","unlock table")
    200204            self.ippToPspsDb.deletePendingItem(batchType, id)
     205            self.logger.infoPair("heather:","deleted pending item")
    201206
    202207            # catch any raised exceptions in batch constructors
     
    234239   
    235240            # if batch fails, ignore and move on to the next one
    236             except:
     241            except Exception, e:
     242                self.logger.error("EXCEPTION: " + str(e))
    237243                self.logger.errorPair("Problem with this %s batch (%d)" % (batchType, id), "skipping")
    238244                pass
    239245
    240246            if not self.checkClientStatus(): return False
    241    
     247            self.logger.infoPair("checkclient status", "ok")
     248
    242249            self.ippToPspsDb.lockBatchTable()
    243    
     250            self.logger.infoPair("lockbatchtable", "ok")
    244251            self.logger.infoSeparator()
    245252   
  • branches/eam_branches/ipp-20120905/ippToPsps/jython/objectbatch.py

    r34466 r34735  
    114114        for filter in filters:
    115115
    116             sql = "UPDATE Object \
    117                    JOIN " + cpsTable + " AS cps ON (cps.row = (Object.row*" + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \
     116            filterID = self.scratchDb.getFilterID(filter[1])
     117
     118            # NOTE: Manipulation of FLAGS from cpsTable is to move ID_SECF_OBJ_EXT flag (0x01000000)
     119            # from bit 24 to bit 13 so that it fits into the SMALLINT Object.Flags
     120
     121            sql = "UPDATE Object JOIN \
     122                   " + cpsTable + " AS cps ON (cps.row = (Object.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \
    118123                   SET \
    119124                   n" + filter[1] + " = NCODE \
     
    122127                   ," + filter[1] + "MeanKronMag = MAG_KRON \
    123128                   ," + filter[1] + "MeanKronMagErr = MAG_KRON_ERR \
    124                    ," + filter[1] + "StackPSFFlux = FLUX_PSF \
    125                    ," + filter[1] + "StackPSFFluxErr = FLUX_PSF_ERR \
     129                   ," + filter[1] + "StackPSFMag = -2.5 * log10(FLUX_PSF) + 8.9 \
     130                   ," + filter[1] + "StackPSFMagErr = FLUX_PSF_ERR / FLUX_PSF \
    126131                   ," + filter[1] + "StackKronMag = -2.5 * log10(FLUX_KRON) + 8.9 \
    127132                   ," + filter[1] + "StackKronMagErr = FLUX_KRON_ERR / FLUX_KRON \
    128133                   ," + filter[1] + "20pct = MAG_20/1000 \
    129134                   ," + filter[1] + "80pct = MAG_80/1000 \
    130                    ," + filter[1] + "Flags = FLAGS " 
    131                    
     135                   ," + filter[1] + "Flags = (0x7fff & FLAGS) | ((FLAGS >> 11) & 0x2000) \
     136                   ," + filter[1] + "StackDetectID = STACK_DETECT_ID + " + str(filterID)
     137
     138            #self.logger.info(sql)
     139            self.scratchDb.execute(sql)
     140
     141        self.logger.infoPair("Calculating nDetections from", "n[filters]")
     142        for filter in filters:
     143            # now do a sum of n[filters], but do not include the ones with -999
     144            sql = "UPDATE Object \
     145                   SET nDetections = nDetections + n" + filter[1] + " \
     146                   WHERE n" + filter[1] + " != -999"
     147            self.scratchDb.execute(sql)
    132148           
    133             self.scratchDb.execute(sql)
     149
     150
    134151
    135152        # now set to null all MeanMagErr values > 0.5 (cut set by Gene, 2012-04-12)
     
    189206        cpsTableName = self.scratchDb.getDbFriendlyTableName(self.region + ".cps")
    190207
    191         self.logger.infoPair("Populating", "Object")
     208        self.logger.infoPair("setting to null  > 1e-38 and < 1e-38 in", "cps FLUX_KRON_ERR")
     209        sql = "UPDATE " + cpsTableName + " set FLUX_KRON_ERR = NULL where FLUX_KRON_ERR < 1e-37 AND FLUX_KRON_ERR > -1e-37 "
     210     
     211        try:
     212            self.scratchDb.execute(sql)
     213        except:
     214            self.logger.errorPair("Couldn't squash out of range stuff", sql)
     215            return False
     216
     217        self.logger.infoPair("setting to null  > 1e-38 and < 1e-38 in", "cps FLUX_KRON")
     218        sql = "UPDATE " + cpsTableName + " set FLUX_KRON = NULL where FLUX_KRON < 1e-37 AND FLUX_KRON > -1e-37 "
     219     
     220        try:
     221            self.scratchDb.execute(sql)
     222        except:
     223            self.logger.errorPair("Couldn't squash out of range stuff", sql)
     224            return False
     225
     226
     227
     228
     229       
     230        self.logger.infoPair("Populating", "Object s")
    192231        self.logger.infoPair("Inserting objects from", "cpt file")
    193232
     
    204243               ,decErr \
    205244               ,nDetections \
    206                ,extra \
     245               ,qfPerfect \
    207246               ,sgSep \
    208247               ,dataRelease \
  • branches/eam_branches/ipp-20120905/ippToPsps/jython/scratchdb.py

    r34466 r34735  
    6868               DECLARE t REAL; \
    6969               DECLARE z REAL; \
     70               DECLARE s INT; \
     71               SET s= SIGN(x); \
    7072               SET x = ABS(x) / 1.4142135623731; \
    7173               SET z=ABS(x); \
     
    7577               SET ans = 2.0 - ans; \
    7678               END IF; \
     79               SET ans = ans * s; \
    7780               RETURN ans; \
    7881               END"
     
    385388               objID BIGINT, \
    386389               flags INT, \
     390               zp REAL, \
     391               zpErr REAL, \
     392               airMass REAL, \
     393               expTime REAL, \
     394               ra FLOAT, \
     395               dec_ FLOAT, \
     396               raErr REAL, \
     397               decErr REAL, \
    387398               PRIMARY KEY (imageID, ippDetectID) \
    388399               )"
  • branches/eam_branches/ipp-20120905/ippToPsps/jython/stackbatch.py

    r34466 r34735  
    7676       self.projectioncell = self.skycell
    7777
     78       # proposed new values. Need to coordinate with the SkyCell table
     79       # this fits in 32 bits for 0 < tessID < 214
     80       # self.skycell = str( (tessID * (10000 * 1000)) + (int(self.projectioncell) * 1000) + cellID )
     81
    7882       self.analysisVer = meta[2];
    7983
     
    8993       self.scratchDb.dropTable("SkinnyObject")
    9094       self.scratchDb.dropTable("ObjectCalColor")
     95       self.scratchDb.dropTable("StackDetectionCalib")
    9196
    9297       # delete IPP tables
     
    140145
    141146        sql = "UPDATE StackApFlx AS a, SkyChip_xrad AS b SET \
    142         "+prefix+"flxR1=b.APER_FLUX_1, \
    143         "+prefix+"flxR1Err=b.APER_FLUX_ERR_1, \
    144         "+prefix+"flxR1Std=b.APER_FLUX_STDEV_1, \
     147        "+prefix+"flxR1=b.APER_FLUX_1 / " + str(self.expTime) + ", \
     148        "+prefix+"flxR1Err=b.APER_FLUX_ERR_1 / " + str(self.expTime) + ", \
     149        "+prefix+"flxR1Std=b.APER_FLUX_STDEV_1 / " + str(self.expTime) + ", \
    145150        "+prefix+"flxR1Fill=b.APER_FILL_1, \
    146         "+prefix+"flxR2=b.APER_FLUX_2, \
    147         "+prefix+"flxR2Err=b.APER_FLUX_ERR_2, \
    148         "+prefix+"flxR2Std=b.APER_FLUX_STDEV_2, \
     151        "+prefix+"flxR2=b.APER_FLUX_2 / " + str(self.expTime) + ", \
     152        "+prefix+"flxR2Err=b.APER_FLUX_ERR_2 / " + str(self.expTime) + ", \
     153        "+prefix+"flxR2Std=b.APER_FLUX_STDEV_2 / " + str(self.expTime) + ", \
    149154        "+prefix+"flxR2Fill=b.APER_FILL_2, \
    150         "+prefix+"flxR3=b.APER_FLUX_3, \
    151         "+prefix+"flxR3Err=b.APER_FLUX_ERR_3, \
    152         "+prefix+"flxR3Std=b.APER_FLUX_STDEV_3, \
     155        "+prefix+"flxR3=b.APER_FLUX_3 / " + str(self.expTime) + ", \
     156        "+prefix+"flxR3Err=b.APER_FLUX_ERR_3 / " + str(self.expTime) + ", \
     157        "+prefix+"flxR3Std=b.APER_FLUX_STDEV_3 / " + str(self.expTime) + ", \
    153158        "+prefix+"flxR3Fill=b.APER_FILL_3, \
    154         "+prefix+"flxR4=b.APER_FLUX_4, \
    155         "+prefix+"flxR4Err=b.APER_FLUX_ERR_4, \
    156         "+prefix+"flxR4Std=b.APER_FLUX_STDEV_4, \
     159        "+prefix+"flxR4=b.APER_FLUX_4 / " + str(self.expTime) + ", \
     160        "+prefix+"flxR4Err=b.APER_FLUX_ERR_4 / " + str(self.expTime) + ", \
     161        "+prefix+"flxR4Std=b.APER_FLUX_STDEV_4 / " + str(self.expTime) + ", \
    157162        "+prefix+"flxR4Fill=b.APER_FILL_4, \
    158         "+prefix+"flxR5=b.APER_FLUX_5, \
    159         "+prefix+"flxR5Err=b.APER_FLUX_ERR_5, \
    160         "+prefix+"flxR5Std=b.APER_FLUX_STDEV_5, \
     163        "+prefix+"flxR5=b.APER_FLUX_5 / " + str(self.expTime) + ", \
     164        "+prefix+"flxR5Err=b.APER_FLUX_ERR_5 / " + str(self.expTime) + ", \
     165        "+prefix+"flxR5Std=b.APER_FLUX_STDEV_5 / " + str(self.expTime) + ", \
    161166        "+prefix+"flxR5Fill=b.APER_FILL_5, \
    162         "+prefix+"flxR6=b.APER_FLUX_6, \
    163         "+prefix+"flxR6Err=b.APER_FLUX_ERR_6, \
    164         "+prefix+"flxR6Std=b.APER_FLUX_STDEV_6, \
     167        "+prefix+"flxR6=b.APER_FLUX_6 / " + str(self.expTime) + ", \
     168        "+prefix+"flxR6Err=b.APER_FLUX_ERR_6 / " + str(self.expTime) + ", \
     169        "+prefix+"flxR6Std=b.APER_FLUX_STDEV_6 / " + str(self.expTime) + ", \
    165170        "+prefix+"flxR6Fill=b.APER_FILL_6, \
    166         "+prefix+"flxR7=b.APER_FLUX_7, \
    167         "+prefix+"flxR7Err=b.APER_FLUX_ERR_7, \
    168         "+prefix+"flxR7Std=b.APER_FLUX_STDEV_7, \
     171        "+prefix+"flxR7=b.APER_FLUX_7 / " + str(self.expTime) + ", \
     172        "+prefix+"flxR7Err=b.APER_FLUX_ERR_7 / " + str(self.expTime) + ", \
     173        "+prefix+"flxR7Std=b.APER_FLUX_STDEV_7 / " + str(self.expTime) + ", \
    169174        "+prefix+"flxR7Fill=b.APER_FILL_7, \
    170         "+prefix+"flxR8=b.APER_FLUX_8, \
    171         "+prefix+"flxR8Err=b.APER_FLUX_ERR_8, \
    172         "+prefix+"flxR8Std=b.APER_FLUX_STDEV_8, \
     175        "+prefix+"flxR8=b.APER_FLUX_8 / " + str(self.expTime) + ", \
     176        "+prefix+"flxR8Err=b.APER_FLUX_ERR_8 / " + str(self.expTime) + ", \
     177        "+prefix+"flxR8Std=b.APER_FLUX_STDEV_8 / " + str(self.expTime) + ", \
    173178        "+prefix+"flxR8Fill=b.APER_FILL_8, \
    174         "+prefix+"flxR9=b.APER_FLUX_9, \
    175         "+prefix+"flxR9Err=b.APER_FLUX_ERR_9, \
    176         "+prefix+"flxR9Std=b.APER_FLUX_STDEV_9, \
     179        "+prefix+"flxR9=b.APER_FLUX_9 / " + str(self.expTime) + ", \
     180        "+prefix+"flxR9Err=b.APER_FLUX_ERR_9 / " + str(self.expTime) + ", \
     181        "+prefix+"flxR9Std=b.APER_FLUX_STDEV_9 / " + str(self.expTime) + ", \
    177182        "+prefix+"flxR9Fill=b.APER_FILL_9, \
    178         "+prefix+"flxR10=b.APER_FLUX_10, \
    179         "+prefix+"flxR10Err=b.APER_FLUX_ERR_10, \
    180         "+prefix+"flxR10Std=b.APER_FLUX_STDEV_10, \
     183        "+prefix+"flxR10=b.APER_FLUX_10 / " + str(self.expTime) + ", \
     184        "+prefix+"flxR10Err=b.APER_FLUX_ERR_10 / " + str(self.expTime) + ", \
     185        "+prefix+"flxR10Std=b.APER_FLUX_STDEV_10 / " + str(self.expTime) + ", \
    181186        "+prefix+"flxR10Fill=b.APER_FILL_10 \
    182187        WHERE a.ippDetectID=b.IPP_IDET AND b.PSF_FWHM "+psfCondition
     
    196201        sql = "UPDATE StackModelFit AS a, SkyChip_xfit AS b SET \
    197202        "+model+"Radius=b.EXT_WIDTH_MAJ,  \
    198         "+model+"Mag=b.EXT_INST_MAG,  \
    199         "+model+"MagErr=b.EXT_INST_MAG_SIG, \
     203        "+model+"Flux=POW(10, -0.4 * b.EXT_INST_MAG) / " + str(self.expTime) + " ,  \
     204        "+model+"FluxErr=ABS(b.EXT_INST_MAG_SIG) * POW(10, -0.4 * b.EXT_INST_MAG) / " + str(self.expTime) + " / 1.085736, \
    200205        "+model+"Ab=b.EXT_WIDTH_MAJ/b.EXT_WIDTH_MIN, \
    201206        "+model+"Phi=b.EXT_THETA,  \
     
    319324               ,skyCellID \
    320325               ,projectionCellID \
    321                ,obsTime \
    322326               ,xPos \
    323327               ,yPos \
    324328               ,xPosErr \
    325329               ,yPosErr \
    326                ,instFlux \
    327                ,instFluxErr \
     330               ,psfFlux \
     331               ,psfFluxErr \
    328332               ,peakFlux \
    329333               ,sky \
     
    335339               ,psfLikelihood \
    336340               ,infoFlag \
    337                ,psfCf \
     341               ,psfQf \
     342               ,psfQfPerfect \
    338343               ,momentXX \
    339344               ,momentXY \
     
    345350               ,momentR1 \
    346351               ,momentRH \
    347                ,apMag \
    348                ,apMagErr \
     352               ,apFlux \
     353               ,apFluxErr \
    349354               ,kronFlux \
    350355               ,kronFluxErr \
    351356               ,kronRad \
    352                ,kronRadErr \
     357               ,psfChiSq \
    353358               ,nFrames \
    354359               ,assocDate \
     
    359364               ," + self.skycell + " \
    360365               ," + self.projectioncell + " \
    361                ," + self.header['MJD-OBS'] + " \
    362366               ,X_PSF \
    363367               ,Y_PSF \
     
    367371               ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / " + str(self.expTime) + ")) / 1.085736) \
    368372               ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / " + str(self.expTime) + " \
    369                ,SKY \
    370                ,SKY_SIGMA \
     373               ,SKY / " + str(self.expTime) + " \
     374               ,SKY_SIGMA / " + str(self.expTime) + " \
    371375               ,EXT_NSIGMA \
    372376               ,PSF_MAJOR \
     
    374378               ,PSF_THETA \
    375379               ,psfLikelihood(EXT_NSIGMA) \
    376                ,FLAGS2 << 32 | FLAGS \
     380               , FLAGS2 << 32 | FLAGS \
    377381               ,PSF_QF \
     382               ,PSF_QF_PERFECT \
    378383               ,MOMENTS_XX \
    379384               ,MOMENTS_XY \
     
    385390               ,MOMENTS_R1 \
    386391               ,MOMENTS_RH \
    387                ,AP_MAG \
    388                , NULL \
     392               ,POW(10.0, -0.4*AP_MAG) / " + str(self.expTime) + " \
     393               ,NULL \
    389394               ,KRON_FLUX / " + str(self.expTime) + " \
    390395               ,KRON_FLUX_ERR / " + str(self.expTime) + " \
    391                , MOMENTS_R1 * 2.5 \
    392                , NULL \
     396               ,MOMENTS_R1 * 2.5 \
     397               ,PSF_CHISQ \
    393398               ,N_FRAMES \
    394399               , '" + self.dateStr + "' \
     
    417422        self.updateStackTypeID("StackDetection")
    418423       
    419         self.updateDvoIDs("StackDetection")
     424        self.updateDvoIDsAndFlags("StackDetection")
    420425       
    421426        sql = "ALTER IGNORE TABLE StackDetection ADD PRIMARY KEY (objID)"
     
    427432            #if deep stack and instFlux = null and err not null
    428433            sql = "UPDATE StackDetection AS a, SkyChip_psf AS b \
    429                    SET instFlux = 2*b.PSF_INST_FLUX_SIG / " + str(self.expTime) + " \
    430                    WHERE instFlux IS NULL \
     434                   SET psfFlux = 2*b.PSF_INST_FLUX_SIG / " + str(self.expTime) + " \
     435                   WHERE psfFlux IS NULL \
    431436                   AND a.ippDetectID = b.IPP_IDET  \
    432437                   AND b.PSF_INST_FLUX_SIG IS NOT NULL"
     
    434439            self.scratchDb.execute(sql)
    435440           
    436        
    437         self.scratchDb.reportAndDeleteRowsWithNULLS("StackDetection", "instFlux")
     441        #leave null instflux in
     442        #self.scratchDb.reportAndDeleteRowsWithNULLS("StackDetection", "instFlux")
    438443       
    439444        self.scratchDb.reportAndDeleteRowsWithNULLS("StackDetection", "objID")
     
    474479        petRadius=b.PETRO_RADIUS \
    475480        ,petRadiusErr=b.PETRO_RADIUS_ERR \
    476         ,petMag=b.PETRO_MAG \
    477         ,petMagErr=b.PETRO_MAG_ERR \
     481        ,petFlux=POW(10.0, -0.4 * b.PETRO_MAG) /" + str(self.expTime) + " \
     482        ,petFluxErr=ABS(b.PETRO_MAG_ERR) * POW(10.0, (-0.4*b.PETRO_MAG)) / " + str(self.expTime) + " / 1.085736 \
    478483        ,petR50=b.PETRO_RADIUS_50 \
    479484        ,petR50Err=b.PETRO_RADIUS_50_ERR \
     
    587592        self.scratchDb.updateAllRows("SkinnyObject", "dataRelease", str(self.config.dataRelease))
    588593
     594    '''   
     595    Populates the StackDetectionCalib table
     596    '''
     597    def populateStackDetectionCalib(self):
     598        self.logger.infoPair("Processing table", "StackDetectionCalib")
     599        tableName = "StackDetectionCalib"
     600        # insert all detections into table
     601        sql = "INSERT INTO " + tableName + " ( \
     602               objID \
     603               ,stackDetectID \
     604               ,ippObjID \
     605               ,ippDetectID \
     606               ,filterID \
     607               ,surveyID \
     608               ) \
     609               SELECT \
     610               objID \
     611               ,stackDetectID \
     612               ,ippObjID \
     613               ,ippDetectID \
     614               ,filterID \
     615               ,surveyID \
     616               FROM StackDetection"
     617        self.scratchDb.execute(sql)
     618        # insert calibration information from dvoDetections into the Table
     619        sql = "UPDATE " + tableName + " AS a, "  + self.scratchDb.dvoDetectionTable + " AS b \
     620            SET a.ra = b.ra, \
     621            a.dec = b.dec_, \
     622            a.raErr = b.raErr, \
     623            a.decErr = b.decErr, \
     624            a.zp = b.zp, \
     625            a.zpErr = b.zpErr, \
     626            a.expTime = b.expTime, \
     627            a.airMass = b.airMass   \
     628            WHERE a.stackDetectID = b.detectID"
     629        self.scratchDb.execute(sql)
     630        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
     631       
     632   
     633
     634
    589635    '''
    590636    Populates the ObjectCalColor table
     
    620666        self.scratchDb.createIndex("StackModelFit", "ippDetectID")
    621667
     668        # dec is reserved in MySQL, so STILTS replaces if with dec_, which is not the name of
     669        # the column in PSPS
     670        self.scratchDb.execute("ALTER TABLE StackDetectionCalib CHANGE dec_ `dec` double")
     671
    622672        return True
    623673
     
    645695        sql = "UPDATE " + table + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b SET \
    646696               a.ippObjID = b.ippObjID, \
    647                a.stackDetectID = 10 * b.detectID + " + str(self.filterID) + ", \
     697               a.stackDetectID = b.detectID, \
    648698               a.objID = b.objID \
    649699               WHERE a.ippDetectID = b.ippDetectID \
    650700               AND b.imageID = " + str(imageID)
    651        
    652         self.scratchDb.execute(sql)
    653        
     701        self.scratchDb.execute(sql)
     702   
     703    '''
     704    Updates Flags
     705    '''
     706    def updateDvoIDsAndFlags(self, table):
     707        self.logger.infoPair("getting","imageID")
     708        imageID = self.scratchDb.getImageIDFromExternID(self.header['IMAGEID'])
     709        self.logger.infoPair("obtained","imageID")
     710        self.logger.debug("Updating table '" + table + "' with DVO IDs...")
     711        sql = "UPDATE " + table + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b SET \
     712               a.ippObjID = b.ippObjID, \
     713               a.stackDetectID = b.detectID, \
     714               a.objID = b.objID, \
     715               a.infoFlag = b.flags << 45 | a.infoFlag \
     716               WHERE a.ippDetectID = b.ippDetectID \
     717               AND b.imageID = " + str(imageID)
     718        self.scratchDb.execute(sql)
     719   
     720   
    654721    '''
    655722    Does the processing, i.e. pulling stuff from IPP tables into PSPS tables
     
    660727            if not self.getIDsFromDVO():
    661728                return False
    662 
     729        #self.logger.infoPair("populating","StackMeta")   
    663730        self.populateStackMeta()
     731        #self.logger.infoPair("populating","StackDetection")
    664732        self.populateStackDetection()
    665 
     733       
    666734        if self.stackType != "NIGHTLY_STACK":
     735            #self.logger.infoPair("populating","StackModelFit")
    667736            self.populateStackModelFit()
     737            #self.logger.infoPair("populating","StackApFlx")
    668738            self.populateStackApFlx()
    669    
     739        #self.logger.infoPair("populating","StackToImage")
    670740        self.populateStackToImage()
     741        #self.logger.infoPair("populating","SkinnyObject")
    671742        self.populateSkinnyObject()
     743        #self.logger.infoPair("populating","ObjectCalColor")
    672744        self.populateObjectCalColor()
     745        #self.logger.infoPair("populating","StackDetectionCalib")
     746        self.populateStackDetectionCalib()
    673747
    674748        self.setMinMaxObjID(["StackDetection"])
  • branches/eam_branches/ipp-20120905/ippToPsps/src/Dvo.c

    r33765 r34735  
    9090            }
    9191            else {
     92                Average *ave  = &dvoDetections[i].ave;
     93                Measure *meas = &dvoDetections[i].meas;
     94                PhotCode *code = GetPhotcodebyCode(meas->photcode);
    9295                sprintf(sql,
    93                         "INSERT INTO dvoDetection (imageID, ippDetectID, detectID, ippObjID, objID, flags) VALUES (%d, %u, %lu, %lu, %lu, %u)",
     96                        "INSERT INTO dvoDetection (imageID, ippDetectID, detectID, ippObjID, objID, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES (%d, %u, %lu, %lu, %lu, %u, %f, %f, %f, %f, %lf, %lf, %f %f)",
    9497                        image->imageID,    // imageID
    95                         dvoDetections[i].meas.detID,   // ippDetectID
    96                         dvoDetections[i].meas.extID,   // detectID
    97                         (uint64_t)dvoDetections[i].ave.catID*1000000000 + (uint64_t)dvoDetections[i].ave.objID, // ippObjID
    98                         dvoDetections[i].ave.extID, // objID
    99                         dvoDetections[i].meas.dbFlags); // flags
     98                        meas->detID,   // ippDetectID
     99                        meas->extID,   // detectID
     100                        (uint64_t)ave->catID*1000000000 + (uint64_t)ave->objID, // ippObjID
     101                        dvoDetections[i].ave.extID,   // objID
     102                        meas->dbFlags,                // flags
     103                        code->C * 0.001 + code->K * (meas->airmass - 1) - meas->Mcal,   // zp
     104                        meas->dMcal,                  // zpErr
     105                        meas->airmass,
     106                        pow(10.0, 0.4 * meas->dt),    // expTime
     107                        ave->R - meas->dR / 3600.,    // ra
     108                        ave->D - meas->dR / 3600.,    // dec
     109                        meas->dXccd * meas->pltscale, // estimate of raErr
     110                        meas->dYccd * meas->pltscale  // estimate of decErr
     111                        );
    100112
    101113                mysql_query(this->mysql, sql);
  • branches/eam_branches/ipp-20120905/ippTools/share/bgtool_towarp.sql

    r28551 r34735  
    1 SELECT
     1SELECT DISTINCT
    22    warpBackgroundRun.*,
    33    warpRun.tess_id,
  • branches/eam_branches/ipp-20120905/ippTools/share/camtool_find_pendingimfile.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/ippTools/share/chiptool_setimfiletoupdate.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/ippTools/share/magicdstool_torevert_camera.sql

    r30668 r34735  
    2323    JOIN rawExp using(exp_id)
    2424WHERE magicDSRun.stage = 'camera'
     25    AND camProcessedExp.fault = 0
     26    AND camRun.state = 'full'
    2527    AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0)
    2628         OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored')
  • branches/eam_branches/ipp-20120905/ippTools/share/pxadmin_create_tables.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/ippTools/share/regtool_processedexp.sql

    • Property svn:mime-type deleted
  • branches/eam_branches/ipp-20120905/ippTools/share/staticskytool_result.sql

    r33919 r34735  
    77    stackRun.skycell_id,
    88    count(stackRun.filter) AS num_filters,
     9    TRUNCATE(skycell.radeg/15., 4) AS rahours,
     10    skycell.radeg,
     11    skycell.decdeg,
    912    skycell.glong,
    1013    skycell.glat
  • branches/eam_branches/ipp-20120905/ippTools/share/staticskytool_todo.sql

    r33034 r34735  
    77    stackRun.tess_id,
    88    stackRun.skycell_id,
     9    TRUNCATE(skycell.radeg/15., 4) as rahours,
     10    skycell.radeg,
     11    skycell.decdeg,
     12    skycell.glong,
     13    skycell.glat,
    914    IFNULL(Label.priority, 10000) AS priority
    1015FROM staticskyRun
    1116JOIN staticskyInput USING (sky_id)
    1217JOIN stackRun USING (stack_id)
     18JOIN skycell USING(tess_id, skycell_id)
    1319LEFT JOIN staticskyResult USING(sky_id)
    1420LEFT JOIN Label ON staticskyRun.label = Label.label
  • branches/eam_branches/ipp-20120905/ippTools/share/warptool_towarped.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/ippTools/src

  • branches/eam_branches/ipp-20120905/ippTools/src/camtool.c

    r34566 r34735  
    970970    psFree(where);
    971971
     972    int numDeleted = psDBAffectedRows(config->dbh);
    972973    if (!psDBCommit(config->dbh)) {
    973974        psError(PS_ERR_UNKNOWN, false, "database error");
    974975        return false;
    975976    }
    976     int numUpdated = psDBAffectedRows(config->dbh);
    977     psLogMsg("camtool", PS_LOG_INFO, "Updated %d camProcessedExps", numUpdated);
     977    psLogMsg("camtool", PS_LOG_INFO, "Deleted %d camProcessedExps", numDeleted);
    978978
    979979    return true;
  • branches/eam_branches/ipp-20120905/ippTools/src/magictool.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/ippTools/src/stacktool.c

    r34566 r34735  
    11151115    PXOPT_COPY_STR(config->args, where, "-skycell_id", "stackRun.skycell_id", "==");
    11161116    PXOPT_COPY_STR(config->args, where, "-filter", "stackRun.filter", "LIKE");
     1117    PXOPT_COPY_STR(config->args, where, "-state", "stackRun.state", "==");
    11171118    pxAddLabelSearchArgs(config, where, "-label", "stackRun.label", "LIKE");
    11181119    pxAddLabelSearchArgs(config, where, "-data_group", "stackRun.data_group", "LIKE");
  • branches/eam_branches/ipp-20120905/ippTools/src/stacktoolConfig.c

    r34566 r34735  
    206206    psMetadataAddF64(sumskyfileArgs, PS_LIST_TAIL, "-mjd_obs_begin",  0,      "search by mjd_obs (average mjd_obs of inputs <=)", NAN);
    207207    psMetadataAddF64(sumskyfileArgs, PS_LIST_TAIL, "-mjd_obs_end",  0,      "search by mjd_obs (average mjd_obs of inputs>=)", NAN);
     208    psMetadataAddStr(sumskyfileArgs, PS_LIST_TAIL, "-state", 0,             "search by state", NULL);
    208209    psMetadataAddS16(sumskyfileArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
    209210    psMetadataAddU64(sumskyfileArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
  • branches/eam_branches/ipp-20120905/ippconfig

  • branches/eam_branches/ipp-20120905/ippconfig/recipes/nightly_science.config

    r34566 r34735  
    7979  DIFFABLE  BOOL FALSE
    8080  DIST      S16  30
     81  # bump the retention times for the time being
     82  CHIP S16 60
     83  WARP S16 60
     84  DIFF S16 60
     85  CHIPBG S16 60
     86  WARPBG S16 60
    8187END
    8288TARGETS METADATA
     
    211217  REDUCTION STR STS_DATASET
    212218  # bump the retention times for the time being
    213   CHIP S16 7
    214   WARP S16 7
    215   DIFF S16 7
     219  CHIP S16 60
     220  WARP S16 60
     221  DIFF S16 60
    216222END
    217223TARGETS METADATA
  • branches/eam_branches/ipp-20120905/ippconfig/recipes/ppSub.config

    r33550 r34735  
    9090# Recipe overrides for DIFF
    9191DIFF    METADATA
     92        DUAL            BOOL    TRUE    # Dual convolution?
     93        INVERSE         BOOL    TRUE    # Generate inverse subtraction?
     94        PHOTOMETRY      BOOL    TRUE    # Perform photometry?
     95
     96        # penalty of 1.0
     97        # DUAL convolution is more sensitive to the number of kernels
     98        # do not provide as many orders as for SINGLE
     99        # @ISIS.WIDTHS  F32     2.4  5.0  10.0  # Gaussian kernel FWHM values
     100        @ISIS.WIDTHS    F32     1.5  3.0  6.0   # Gaussian kernel FWHM values
     101        # @ISIS.WIDTHS  F32     2.0  3.0  5.0   # Gaussian kernel FWHM values
     102        # @ISIS.WIDTHS  F32     2.1  4.2  8.4   # Gaussian kernel FWHM values
     103        @ISIS.ORDERS    S32     2    2    2     # Polynomial orders for ISIS kernels
     104
     105        SCALE.REF       F32     5.0             # FWHM reference for kernel parameter scaling
     106        KERNEL.SIZE     S32     15              # Kernel half-size (pixels)
     107        STAMP.FOOTPRINT S32     15              # Size of stamps (pixels)
    92108END
    93109
  • branches/eam_branches/ipp-20120905/ippconfig/recipes/psphot.config

    r34566 r34735  
    558558DIFF    METADATA
    559559  DIFF_STATS                        BOOL TRUE          # Calculate diff-specific stats
    560   OUTPUT.FORMAT                     STR  PS1_DV2       # Format of output file
     560  OUTPUT.FORMAT                     STR  PS1_DV3       # Format of output file
    561561
    562562  # Extended source fit parameters
     
    575575  PEAKS_NSIGMA_LIMIT_2                F32   4.0             # peak significance threshold 
    576576  DIFF_STATS                        BOOL TRUE          # Calculate diff-specific stats
    577   OUTPUT.FORMAT                     STR  PS1_DV2       # Format of output file
     577  OUTPUT.FORMAT                     STR  PS1_DV3       # Format of output file
    578578
    579579  # Extended source fit parameters
  • branches/eam_branches/ipp-20120905/ippconfig/recipes/reductionClasses.mdc

    r34575 r34735  
    260260        STACK_PSPHOT      STR     STACK
    261261        DIFF_PPSUB        STR     DIFF
     262        DIFF_PSPHOT       STR     SSTF_DIFF
     263        JPEG_BIN1         STR     PPIMAGE_J1
     264        JPEG_BIN2         STR     PPIMAGE_J2
     265        FAKEPHOT          STR     FAKEPHOT
     266        ADDSTAR           STR     ADDSTAR
     267        PSASTRO           STR     DEFAULT_RECIPE
     268        STACKPHOT_PSPHOT  STR     STACKPHOT
     269        STACKPHOT_PPSUB   STR     STACKPHOT
     270        STACKPHOT_PPSTACK STR     STACKPHOT
     271        STACKPHOT_SINGLE_PSPHOT  STR     STACKPHOT_SINGLE
     272        BACKGROUND_PPBACKGROUND STR     BACKGROUND
     273        BACKGROUND_PSWARP       STR     BACKGROUND
     274        PSVIDEOPHOT             STR     PSVIDEOPHOT
     275END
     276
     277# Sweetspot reduction class
     278SWEETSPOT_WS            METADATA
     279        CHIP_PPIMAGE      STR     CHIP
     280        CHIP_PSPHOT       STR     CHIP
     281        WARP_PSWARP       STR     WARP
     282        STACK_PPSTACK     STR     QUICKSTACK
     283        STACK_PPSUB       STR     STACK
     284        STACK_PSPHOT      STR     STACK
     285        DIFF_PPSUB        STR     WARPSTACK
    262286        DIFF_PSPHOT       STR     SSTF_DIFF
    263287        JPEG_BIN1         STR     PPIMAGE_J1
  • branches/eam_branches/ipp-20120905/ppImage/src

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/ppTranslate/documentation/ICD/Makefile

    r34566 r34735  
    1 SOURCE=PSDC-940-005
     1SOURCE  = PSDC-940-005
     2
     3FIGURES = figures/exposure_ota.eps \
     4        figures/ext_theta.eps \
     5        figures/ipp_workflow.eps
    26
    37RM=/bin/rm -f
    48
    5 all:
     9figures/%.eps: figures/%.fig
     10        fig2dev -L eps $< $@
     11
     12all: figures
     13        latex $(SOURCE).tex
     14        bibtex $(SOURCE)
    615        latex $(SOURCE).tex
    716        latex $(SOURCE).tex
     
    1221        @echo
    1322
     23figures: $(FIGURES)
     24
    1425clean:
    15         $(RM) *.aux *.dvi *.out *.pdf *.toc *.log *~
     26        $(RM) *.aux *.dvi *.out *.pdf *.toc *.log *~ *.blg *.bbl
     27        $(RM) $(FIGURES)
  • branches/eam_branches/ipp-20120905/ppTranslate/documentation/ICD/PSDC-940-005.tex

    r34566 r34735  
    22\documentclass[panstarrs,spec]{panstarrs}
    33\usepackage{nonfloat}
    4 
    5 \newcommand{\sccomment}[1]{%
    6   \textcolor{green}{SC: #1}}
     4\usepackage{caption}
     5
     6\usepackage{etoolbox}
     7\patchcmd{\thebibliography}{\chapter*}{\subsection*}{}{}
     8
    79\newcommand{\outformatversion}{%
    810  \texttt{PS1\_DV3}}
     11
     12\newcommand{\commentFrom}[4]{%
     13  \mbox{ }\\\null\hfill\begin{tabular}{|p{4in}}
     14    \hline
     15    \emph{Comment from {#1} (#2)}: {#3}\\
     16    \hline
     17    Answer: {#4}\\
     18    \hline
     19  \end{tabular}}
     20
     21\newcommand{\commentFromSC}[3]{%
     22  \commentFrom{SC}{#1}{#2}{#3}}
    923
    1024% basic document variables
     
    1226\subtitle{Pan-STARRS IPP-MOPS ICD for PS-1}
    1327\shorttitle{IPP-MOPS ICD}
    14 \author{Eugene Magnier, Larry Denneau, Jr., Robert Jedicke}
     28\author{\parbox{3in}{Serge Chastel; Larry Denneau, Jr.; Denver Green; Robert Jedicke; Eugene Magnier}}
    1529\audience{Pan-STARRS PMO}
    1630\group{Pan-STARRS IPP \& MOPS}
     
    2640\RevisionsStart
    2741% version  Date            Description
    28 03 & 2012 Oct 04 & \texttt{PS1\_DV3}: Fitted trails, new parameters\\
    29 \hline
    30 02 & 2011 Apr 19 & Synchronization with "ICD Lite" wiki page \\
    31 \hline
    32 01 & 2010 Oct 27 & New CMF Parameters \\
    33 \hline
    34 00 & 2006 Mar 01 & Initial version \\ \hline
     4204 & 2012 Nov 20  & Modifications integrating DG comments/questions \\
     43\hline
     4403 & 2012 Oct 04  & \texttt{PS1\_DV3}: Fitted trails, new parameters\\
     45\hline
     4602 & 2011 Apr 19  & Synchronization with "ICD Lite" wiki page \\
     47\hline
     4801 & 2010 Oct 27  & New CMF Parameters \\
     49\hline
     5000 & 2006 Mar 01  & Initial version \\
     51\hline
    3552\RevisionsEnd
    3653
    3754%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     55
     56\bibliographystyle{amsplain}
     57\bibliography{icd}
    3858
    3959\DocumentsInternal
     
    116136\DocumentsEnd
    117137
     138\subsection{Acronyms}
     139
     140\begin{table}
     141  \small
     142  \caption{Acronyms used in this document\label{table-acronyms}}
     143  \begin{tabular}{ll}
     144    \hline
     145    {\bf Acronym}            & {\bf Definition} \\
     146    \hline
     147    ADU & Analog to Digital Units (counts in an image) \\
     148    ICRS  & International Celestial Reference System \\
     149    IPP   & Pan-STARRS Image Processing Pipeline \\
     150    FPA   & Focal Plane Array \\
     151    MOPS  & Pan-STARRS Moving Object Processing System \\
     152    MPC   & Center for Astrophysics Minor Planet Center \\
     153    TTI   & Transient-Time Interval (about 60 minutes) \\
     154    \hline
     155  \end{tabular}
     156\end{table}
     157
    118158\section{Interface Overview}
    119159
     
    144184
    145185This document discusses the software interface between IPP and MOPS.
    146 IPP must send transient detection descriptions to the MOPS; MOPS
    147 must be able to query the IPP regarding whether a particular (RA,
    148 Dec) pair could have been detected in a particular focal plane array (FPA).  This document
    149 defines the data to be transferred between IPP and MOPS and the
    150 mechanisms to be used for that interchange.  These interfaces are
    151 identified as \#005 in Figure~\ref{fig:overview}.  The Interfaces
     186IPP must send transient detection descriptions to the MOPS; MOPS must
     187be able to query the IPP regarding whether a particular (RA, Dec) pair
     188could have been detected in a particular focal plane array (FPA).
     189This document defines the data to be transferred between IPP and MOPS
     190and the mechanisms to be used for that interchange.  These interfaces
     191are identified as \#005 in Figure~\ref{fig:overview}.  The Interfaces
    152192addressed by this document are marked in the table.
    153193
     
    235275Though efforts have been made to avoid this from occurring, where
    236276header keyword names are longer than the usual 8 character maximum,
    237 the HIERARCH convention will be used.
     277the HIERARCH convention will be used (see the NASA webpages:
     278\htmladdnormallink{Registered FITS
     279  Convention}{http://fits.gsfc.nasa.gov/registry/hierarch_keyword.html}
     280and \htmladdnormallink{4.12.4 HIERARCH Convention for Extended Keyword
     281  Names}{http://heasarc.nasa.gov/docs/software/fitsio/c/f_user/node28.html}).
    238282
    239283\subsection{IPP-MOPS Exchange}
     
    241285MOPS requires from the IPP a stream of transient detections and their
    242286FPA metadata obtained from processing of difference images acquired by
    243 the PS-1 camera.  IPP is additionally required by MOPS to be able to
    244 indicate whether a set of detections (with RA, Dec, flux, length,
    245 orientation, etc.) on a previously acquired FPA was detectable by the
    246 PS-1 telescope.
     287the PS-1 camera.
     288
     289IPP is additionally required by MOPS to be able to indicate whether a
     290set of detections (with RA, Dec, flux, length, orientation, etc.) on a
     291previously acquired FPA was detectable by the PS-1 telescope. This
     292functionality is provided through the detectability server.
    247293
    248294\subsubsection{Conventions}
     
    305351
    306352\begin{itemize}
    307 \item{EXTNAME} - Giving a unique name for the metadata table. Such a
    308   name shall contain only the characters a-z, and ``\_''.
    309 \item{CMFVERSION} - A string specifying the version of the table
    310   description file for this table.
     353\item{EXTNAME} - A \emph{string} giving a unique name for the metadata
     354  table. Such a name shall contain only the characters a-z, A-Z, and
     355  ``\_''.
     356\item{CMFVERSION} - A \emph{string} specifying the version of the
     357  table description file for this table.
    311358\end{itemize}
    312359
     
    389436exposure.
    390437
    391 In addition to the required BINTABLE extension header keywords
    392 described above, the FITS header shall include the keywords shown in
    393 table \ref{trans-keywords}.  The subsequent FITS table, with EXTNAME
    394 of \code{MOPS_TRANSIENT_DETECTIONS}, shall include columns whose
    395 definitions are listed in table \ref{trans-table}.
    396 
    397438{\centering%
    398   \tabcaption{IPP-MOPS Transient Detection Keywords\label{trans-keywords}}
    399   \begin{longtable}{|lcp{0.5in}p{3in}|}
    400     \hline \hline {\bf FITS Keyword}
    401     & \parbox{0.5in}{\textbf{Version}}
    402     & {\bf Precision} & {\bf Description}\\
    403     \hline \hline
    404     \multicolumn{4}{|l|}{\null\hspace{10mm}\textbf{Version Information}}\\
    405     \hline
    406     SWSOURCE & 1+ & string & source of software (e.g., "60eb6cdc-a59c-4636-a4e0-dba66a9721fd")\\
    407     \hline
    408     SWVERSN & 1+ & string & version of software (e.g., "trunk/ppMops@24658")\\
    409     \hline
    410     HIERARCH\_CMFVERSION & 2+ & char(7) & PS1\_DV1 or PS1\_DV2 or PS1\_DV3 \\
    411     \hline
    412     \multicolumn{4}{|l|}{\null\hspace{10mm}\textbf{Provenance Information}}\\
    413     \hline
    414     EXP\_NAME & 1+ & string & Exposure name (e.g., "o1234g5678")\\
    415     \hline
    416     EXP\_ID & 1+ & S64 & Exposure identifier \\
    417     \hline
    418     CHIP\_ID & 1+ & S64 & Chip stage identifier \\
    419     \hline
    420     CAM\_ID & 1+ & S64 & Camera stage identifier \\
    421     \hline
    422     FAKE\_ID & 1+ & S64 & Fake stage identifier \\
    423     \hline
    424     WARP\_ID  & 1+ & S64 & Warp stage identifier \\
    425     \hline
    426     DIFF\_ID & 1+ & S64 & Diff stage \\
    427     \hline
    428     DIFF\_POS & 1+ & boolean & Sense of subtraction; T for forward, F for backward\\
    429     \hline
    430     \multicolumn{4}{|l|}{\null\hspace{10mm}\textbf{Exposure Details}}\\
    431     \hline MJD-OBS & 0+
    432     & F64 & midpoint time of the exposure as a MJD and day fraction \\
    433     \hline
    434     RA & 0+
    435     & {\tiny HH:MM:SS.SSS} & field center RA at exposure midpoint, string \\
    436     \hline
    437     DEC & 0+ &
    438     {\tiny sDD:MM:SS}& (s is + or -) field center declination at exposure midpoint, string \\
    439     \hline
    440     EXPTIME & 0+
    441     & F64 & exposure time in seconds \\
    442     \hline
    443     ROTANGLE & 0+
    444     & F64 & image rotation of the y-axis in degrees, from local N toward E \\
    445     \hline
    446     FILTER & 0+ & char(3) & effective filter used for the exposure,
    447     one of g, r, i, z, y, B, V, w
    448     appended with '.00000'\\
    449     \hline
    450     AIRMASS & 0+ & F64
    451     & airmass at exposure midpoint \\
    452     \hline
    453     OBSCODE & 0+ & char(5) & MPC three-character observatory code \\
    454     \hline
    455     TEL\_ALT & 0+ & F64 & telescope altitude at exposure midpoint, in degrees \\
    456     \hline
    457     TEL\_AZ & 0+ & F64 & telescope azimuth at exposure midpoint, in degrees \\
    458     \hline
    459     SEEING & 1+ & F32 & Measured seeing at diff stage, arcsec \\
    460     \hline
    461     MAGZP & 1+ & F32 & Magnitude zero point \\
    462     \hline
    463     MAGZPERR & 1+ & F32 & Error in magnitude zero point \\
    464     \hline
    465     ASTRORMS & 1+ & F32 & RMS of astrometric fit, arcsec \\
    466     \hline
    467     COMMENT & 3+ & String & Comment associated to the exposure\\
    468     \hline
    469     OBS\_MODE & 3+ & String & Observation mode (e.g. MD, 3PI...)\\
    470     \hline
    471     DIFFTYPE & 3+ & String & Difference type: WW (Warp-Warp Difference), WS (Warp-Stack Difference)\\
    472     \hline
    473     SKY  & 3+ & F64 & Exposure average sky background \\
    474     \hline
    475     SHUTOUTC & 3+ & String & Camera exposure shutter open (UTC) \\
    476     \hline
     439  \tabcaption{IPP-MOPS Data Types Definition\label{table-datatypes}}
     440  \begin{longtable}{|cp{5in}|}
     441    \hline
     442    \textbf{Alias} & \textbf{Description} \\
     443    \texttt{bool} & (Not a FITS type) An enumerated type defining a Boolean
     444    value, either \texttt{true} or \texttt{false}\\
     445    \texttt{char($n$)} & (Not a FITS type) A sequence of exactly $n$ bytes that
     446    can be interpreted
     447    as a sequence of ASCII characters\\
     448    \texttt{HH:MM:SS.sss} & (Not a FITS type) a \texttt{char(12)} encoding
     449    a time or an angle: (1) the hours \texttt{HH} are encoded with two
     450    decimal figures; (2) a separator \texttt{:} between the hours and
     451    the minutes; (3) the minutes \texttt{MM} are encoded with two
     452    decimal figures; (4) a separator \texttt{:} between the minutes
     453    and the seconds; (5) the seconds \texttt{SS} are encoded with two
     454    decimal figures; (6) a separator \texttt{.} between the seconds
     455    and the milli(arc)seconds; (7)
     456    the milli(arc)seconds \texttt{ss} are encoded with three decimal figures; \\
     457    \texttt{sDD:MM:SS} & (Not a FITS type) a \texttt{char(9)} encoding an
     458    angle. (1) \texttt{s} is either the \texttt{+} or \texttt{-} sign;
     459    (2) \texttt{DD} is the number of degrees encoded with two decimal
     460    figures; (3) a separator \texttt{:} between the degrees and the
     461    minutes; (4) the minutes \texttt{MM} are encoded with two decimal
     462    figures; (5) a separator \texttt{:} between the minutes and the
     463    seconds; (6) the
     464    seconds \texttt{SS} are encoded with two decimal figures;\\
     465    \texttt{enum} & (Not a FITS type) a \texttt{string} having a fixed number of
     466    different values. The explicit set of values shall be expressed in
     467    this ICD.\\
     468    \texttt{F32} & (FITS type) IEEE 32-bit single precision floating point real numbers \\
     469    \texttt{F64} & (FITS type) IEEE 64-bit double precision floating point real numbers \\
     470    \texttt{S16} & (FITS type) 16-bit signed integer \\
     471    \texttt{S32} & (FITS type) 32-bit signed integer \\
     472    \texttt{S64} & (FITS type) 64-bit signed integer \\
     473    \texttt{string} & (Not a FITS type) Sequence of bytes of arbitrary length
     474    usually interpreted as a sequence of ASCII characters \\
     475    \texttt{U16} & (FITS type) 16-bit unsigned integer \\
     476    \texttt{U32} & (FITS type) 32-bit unsigned integer \\
    477477    \hline
    478478  \end{longtable}
    479479}
    480480
    481 {\centering
    482   \tabcaption{IPP-MOPS Transient Detection Table Columns\label{trans-table}}
    483   \begin{longtable}{|lclp{3.5in}|}
     481In addition to the required BINTABLE extension header keywords
     482described above (TODO: Where? What?), the FITS header shall include the
     483keywords shown in tables relative to versioning
     484\ref{table-keywords-versioning}, data provenance
     485\ref{table-keywords-provenance}, and exposure
     486\ref{table-keywords-exposure}. The subsequent FITS table, with EXTNAME
     487of \code{MOPS_TRANSIENT_DETECTIONS}, shall include columns whose
     488definitions are listed in table \ref{table-detections} and, when trail
     489fitting has been succesfully performed, \ref{table-detections-ext}.
     490
     491\begin{center}
     492  \begin{longtable}{|lcp{0.5in}p{3in}|}
     493    \caption{IPP-MOPS Transient Detection Keywords:\\ Version Information}\label{table-keywords-versioning}\\
     494    \hline\hline
     495    \multicolumn{4}{|l|}{\null\hspace*{1in}\textbf{Version Information}}\\
     496    \hline\hline
     497    {\bf FITS Keyword}
     498    & \parbox{0.5in}{\textbf{Version}}
     499    & {\bf Precision}
     500    & {\bf Description} \\
     501    \hline
     502    SWSOURCE & 1+ & \texttt{string} & source of software (e.g., "60eb6cdc-a59c-4636-a4e0-dba66a9721fd") \\
     503    \hline
     504    SWVERSN & 1+ & \texttt{string} & version of software (e.g., "trunk/ppMops@24658") \\
     505    \hline
     506    HIERARCH CMFVERSION & 2+ & \texttt{enum} & \texttt{PS1\_DV3} \\
     507    \hline\hline
     508  \end{longtable}
     509\end{center}
     510
     511\begin{center}
     512  \begin{longtable}{|lcp{0.5in}p{3in}|}
     513    \caption{IPP-MOPS Transient Detection Keywords:\\ Provenance Information}\label{table-keywords-provenance}\\
     514    \hline\hline
     515    \multicolumn{4}{|l|}{\null\hspace{10mm}\textbf{Provenance Information}}\\
    484516    \hline \hline
    485     {\bf Column} & \textbf{Version} & {\bf Precision} & {\bf Description} \\
    486     \hline
    487     RA & 1+ & F64 & detection center coordinates in degrees\\
    488     \hline
    489     RA\_ERR & 1+ & F64 & error in the detection center, in degrees \\
    490     \hline
    491     DEC & 1+  & F64 & detection center coordinates in degrees \\
    492     \hline
    493     DEC\_ERR & 1+ & F64 & error in the detection center, in degrees \\
    494     \hline
    495     MAG & 1+ & F32 & Magnitude \\
    496     \hline
    497     MAG\_ERR & 1+ & F32 & Magnitude error \\
    498     \hline
    499     PSF\_CHI2 & 1+ & F32 & $\chi^2$ of PSF fit \\
    500     \hline
    501     PSF\_DOF & 1+ & S32 & Degrees of freedom of PSF fit \\
    502     \hline
    503     CR\_SIGNIFICANCE & 1+ & F32 & Significance of Cosmic Ray \\
    504     \hline
    505     EXT\_SIGNIFICANCE & 1+ & F32 & Significance of extendedness \\
    506     \hline
    507     PSF\_MAJOR & 1+ & F32 & PSF major axis (pixels) \\
    508     \hline
    509     PSF\_MINOR & 1+ & F32 & PSF minor axis (pixels) \\
    510     \hline
    511     PSF\_THETA & 1+ & F32 & PSF position angle (deg on chip) \\
    512     \hline
    513     PSF\_QUALITY & 1+ & F32 & PSF quality factor \\
    514     \hline
    515     PSF\_NPIX & 1+ & S32 & Number of pixels in PSF \\
    516     \hline
    517     MOMENTS\_XX & 1+ & F32 & xx moment \\
    518     \hline
    519     MOMENTS\_XY & 1+ & F32 & xy moment \\
    520     \hline
    521     MOMENTS\_YY & 1+ & F32 & yy moment \\
    522     \hline
    523     N\_POS & 1+ & S32 & Number of positive pixels \\
    524     \hline
    525     F\_POS & 1+ & F32 & Fraction of positive pixels \\
    526     \hline
    527     RATIO\_BAD & 1+ & F32 & Ratio of positive pixels to negative \\
    528     \hline
    529     RATIO\_MASK & 1+ & F32 & Ratio of positive pixels to masked \\
    530     \hline
    531     RATIO\_ALL & 1+ & F32 & Ratio of positive pixels to all \\
    532     \hline
    533     FLAGS & 1+ & U32 & Detection bit flags\footnote{See \htmladdnormallink{http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PSPSFlags\#StackDetectionFull.infoFlagsFLAGS232FLAGS}{http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PSPSFlags\#StackDetectionFull.infoFlagsFLAGS232FLAGS} for the meaning of each bit}\\
    534     \hline
    535     DIFF\_SKYFILE\_ID & 1+ & S64 & Identifier for diff skyfile. A
    536     diff\_id (for Warp-Warp difference) or a stack\_id
    537     (for Warp-Stack difference) \\
    538     \hline
    539     IPP\_IDET & 2+ & U32 & IPP detection identifier index \\
    540     \hline
    541     PSF\_INST\_FLUX & 2+ & F32 & PSF fit instrumental magnitude \\
    542     \hline
    543     PSF\_INST\_FLUX\_SIG & 2+ & F32 & Sigma of PSF instrumental magnitude \\
    544     \hline
    545     AP\_MAG & 2+ & F32 & magnitude in standard aperture \\
    546     \hline
    547     AP\_MAG\_RAW & 2+ & F32 & magnitude in real aperture \\
    548     \hline
    549     AP\_MAG\_RADIUS & 2+ & F32 & radius used for aperture mags \\
    550     \hline
    551     AP\_FLUX & 2+ & F32 & instrumental flux in standard aperture \\
    552     \hline
    553     AP\_FLUX\_SIG & 2+ & F32 & aperture flux error \\
    554     \hline
    555     PEAK\_FLUX\_AS\_MAG & 2+ & F32 & Peak flux expressed as magnitude \\
    556     \hline
    557     CAL\_PSF\_MAG & 2+ & F32 & PSF Magnitude using supplied calibration \\
    558     \hline
    559     CAL\_PSF\_MAG\_SIG & 2+ & F32 & measured scatter of zero point calibration \\
    560     \hline
    561     SKY & 2+ & F32 & Sky level \\
    562     \hline
    563     SKY\_SIGMA & 2+ & F32 & Sigma of sky level \\
    564     \hline
    565     PSF\_QF\_PERFECT & 2+ & F32 & PSF coverage/quality factor (poor) \\
    566     \hline
    567     MOMENTS\_R1 & 2+ & F32 & first radial moment \\
    568     \hline
    569     MOMENTS\_RH & 2+ & F32 & half radial moment \\
    570     \hline
    571     KRON\_FLUX & 2+ & F32 & Kron Flux (in 2.5 R1) \\
    572     \hline
    573     KRON\_FLUX\_ERR & 2+ & F32 & Kron Flux Error \\
    574     \hline
    575     KRON\_FLUX\_INNER & 2+ & F32 & Kron Flux (in 1.0 R1) \\
    576     \hline
    577     KRON\_FLUX\_OUTER & 2+ & F32 & Kron Flux (in 4.0 R1) \\
    578     \hline
    579     DIFF\_R\_P & 2+ & F32 & distance to positive match source \\
    580     \hline
    581     DIFF\_SN\_P & 2+ & F32 & signal-to-noise of pos match src \\
    582     \hline
    583     DIFF\_R\_M & 2+ & F32 & distance to negative match source \\
    584     \hline
    585     DIFF\_SN\_M & 2+ & F32 & signal-to-noise of neg match src \\
     517    {\bf FITS Keyword}
     518    & \parbox{0.5in}{\textbf{Version}}
     519    & {\bf Precision}
     520    & {\bf Description} \\
     521    \hline
     522    EXP\_NAME & 1+ & \texttt{string} & Exposure name (e.g., "o1234g5678")\\
     523    \hline
     524    EXP\_ID & 1+ & \texttt{S64} & Exposure identifier \\
     525    \hline
     526    CHIP\_ID & 1+ & \texttt{S64} & Chip stage identifier \\
     527    \hline
     528    CAM\_ID & 1+ & \texttt{S64} & Camera stage identifier \\
     529    \hline
     530    FAKE\_ID & 1+ & \texttt{S64} & Fake stage identifier \\
     531    \hline
     532    WARP\_ID  & 1+ & \texttt{S64} & Warp stage identifier \\
     533    \hline
     534    DIFF\_ID & 1+ & \texttt{S64} & Diff stage \\
     535    \hline
     536    DIFF\_POS & 1+ & \texttt{bool} & Sense of subtraction; \texttt{true} for forward,
     537    \texttt{false} for backward\\
     538    \hline
     539  \end{longtable}
     540\end{center}
     541 
     542\begin{center}
     543  \begin{longtable}{|lcp{0.5in}p{3in}c|}
     544    \caption{IPP-MOPS Transient Detection Keywords:\\ Exposure Details}\label{table-keywords-exposure}\\
     545    \hline \hline
     546    \multicolumn{5}{|l|}{\null\hspace{10mm}\textbf{Exposure Details}}\\
     547    \hline \hline {\bf FITS Keyword}
     548    & \parbox{0.5in}{\textbf{Version}} & {\bf Precision} & {\bf
     549      Description}
     550    & \textbf{Units}\\
     551    \hline MJD-OBS & 0+ & \texttt{F64} & midpoint time of the exposure
     552    as a MJD and day fraction
     553    & N/A\\
     554    \hline RA & 0+ & {\tiny \texttt{HH:MM:SS.SSS}}
     555    & Field center RA at exposure midpoint & N/A \\
     556    \hline DEC & 0+ & {\tiny \texttt{sDD:MM:SS}} &
     557    (s is + or -) Field center declination at exposure midpoint & N/A \\
     558    \hline EXPTIME & 0+ & \texttt{F64}
     559    & Exposure time & seconds \\
     560    \hline ROTANGLE & 0+ & \texttt{F64}
     561    & Image rotation of the y-axis from local N toward E & degrees \\
     562    \hline FILTER & 0+ & \texttt{char(7)} & Effective filter used for
     563    the exposure, one of \texttt{g}, \texttt{r}, \texttt{i},
     564    \texttt{z}, \texttt{y}, \texttt{B},
     565    \texttt{V}, \texttt{w} appended with '.00000' & N/A \\
     566    \hline AIRMASS & 0+ & \texttt{F64}
     567    & Airmass at exposure midpoint & N/A\\
     568    \hline OBSCODE & 0+ & char(5) &
     569    MPC 3-character observatory code (F51 for PS1) & N/A \\
     570    \hline TEL\_ALT & 0+ & \texttt{F64} &
     571    Telescope altitude at exposure midpoint & degrees \\
     572    \hline TEL\_AZ & 0+ & \texttt{F64}
     573    & Telescope azimuth at exposure midpoint & degrees \\
     574    \hline SEEING & 1+ & \texttt{F32} &
     575    Measured seeing at diff stage & arcsec \\
     576    \hline MAGZP & 1+ & \texttt{F32} &
     577    Magnitude zero point & N/A \\
     578    \hline MAGZPERR & 1+ & \texttt{F32} &
     579    Error in magnitude zero point & N/A \\
     580    \hline ASTRORMS & 1+ & \texttt{F32} &
     581    RMS of astrometric fit & arcsec \\
     582    \hline CMMTOBS & 3+ & \texttt{string} &
     583    Comment associated to the exposure & N/A\\
     584    \hline OBS\_MODE & 3+ & \texttt{enum} & Observation modes list:
     585    3PI, CNP, ESS, M31, MD, MSS, OSS, PI, STD (Note: The exposures
     586    having the following PS1 observation modes are not used by MOPS:
     587    CAL, PR201108, SAS2, SS, STS, STS2A, STS2B) & N/A\\
     588    \hline DIFFTYPE & 3+ & \texttt{enum} &
     589    Difference type: \texttt{WW} (Warp-Warp Difference), \texttt{WS} (Warp-Stack Difference) & N/A\\
     590    \hline SKY & 3+ & \texttt{F64} &
     591    Exposure average sky background & counts/pixel \\
     592    \hline SHUTOUTC & 3+ & \texttt{string} &
     593    Camera exposure shutter open (UTC) & N/A \\
     594    \hline \hline
     595  \end{longtable}
     596\end{center}
     597
     598\begin{center}
     599  \begin{longtable}{|lclp{3.5in}c|}
     600    \caption{IPP-MOPS Transient Detection Table Columns:\\ Detection Details}\label{table-detections}\\
     601    \hline \hline
     602    \multicolumn{5}{|l|}{\null\hspace{10mm}\textbf{Detection Details}}\\
     603    \hline \hline
     604    {\bf Column} & \textbf{Version} & {\bf Precision} & {\bf Description} & \textbf{Units}\\
     605    \hline
     606    RA & 1+ & F64 & Detection center coordinates & degrees\\
     607    \hline
     608    RA\_ERR & 1+ & F64 & Error in the detection center & degrees \\
     609    \hline
     610    DEC & 1+ & F64 & Detection center coordinates & degrees \\
     611    \hline
     612    DEC\_ERR & 1+ & F64 & Error in the detection center & degrees \\
     613    \hline
     614    MAG & 1+ & F32 & Filter magnitude & N/A \\
     615    \hline
     616    MAG\_ERR & 1+ & F32 & Filter magnitude error & N/A  \\
     617    \hline
     618    PSF\_CHI2 & 1+ & F32 & $\chi^2$ of PSF fit & N/A \\
     619    \hline
     620    PSF\_DOF & 1+ & S32 & Degrees of freedom of PSF fit & N/A  \\
     621    \hline
     622    CR\_SIGNIFICANCE & 1+ & F32 & Significance of cosmic ray (source: \emph{src/psphot/psphotSourceSize.c}) & N/A  \\
     623    \hline
     624    EXT\_SIGNIFICANCE & 1+ & F32 & Significance of extendedness (source: \emph{src/psphot/psphotSourceSize.c}) & N/A  \\
     625    \hline
     626    PSF\_MAJOR & 1+ & F32 & PSF major axis & pixels \\
     627    \hline
     628    PSF\_MINOR & 1+ & F32 & PSF minor axis & pixels \\
     629    \hline
     630    PSF\_THETA & 1+ & F32 & PSF position angle on chip & degrees \\
     631    \hline
     632    PSF\_QUALITY & 1+ & F32 & PSF quality factor & N/A \\
     633    \hline
     634    PSF\_NPIX & 1+ & S32 & Number of pixels in PSF & N/A \\
     635    \hline
     636    MOMENTS\_XX & 1+ & F32 & xx moment & N/A \\
     637    \hline
     638    MOMENTS\_XY & 1+ & F32 & xy moment & N/A \\
     639    \hline
     640    MOMENTS\_YY & 1+ & F32 & yy moment & N/A \\
     641    \hline
     642    N\_POS & 1+ & S32 & Number of positive pixels & N/A \\
     643    \hline
     644    F\_POS & 1+ & F32 & Fraction of positive pixels & N/A \\
     645    \hline
     646    RATIO\_BAD & 1+ & F32 & Ratio of positive pixels to negative & N/A \\
     647    \hline
     648    RATIO\_MASK & 1+ & F32 & Ratio of positive pixels to masked & N/A \\
     649    \hline
     650    RATIO\_ALL & 1+ & F32 & Ratio of positive pixels to all & N/A \\
     651    \hline
     652    FLAGS & 1+ & U32 & Detection bit flags\footnote{See \htmladdnormallink{http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PSPSFlags\#StackDetectionFull.infoFlagsFLAGS232FLAGS}{http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PSPSFlags\#StackDetectionFull.infoFlagsFLAGS232FLAGS} for the meaning of each bit}. The PM\_SOURCE\_MODE\_EXTENDED\_FIT flag (at position 0x00800000) is set when the Trail Fitting is attempted. It does not mean that the Trail Fitting is successful. \\
     653    \hline DIFF\_SKYFILE\_ID & 1+ & S64 & Identifier for diff
     654    skyfile. Either a diff\_id (for Warp-Warp difference) or a
     655    stack\_id
     656    (for Warp-Stack difference) & N/A \\
     657    \hline
     658    IPP\_IDET & 2+ & U32 & IPP detection identifier index & N/A \\
     659    \hline
     660    PSF\_INST\_FLUX & 2+ & F32 & PSF fit instrumental magnitude & N/A \\
     661    \hline
     662    PSF\_INST\_FLUX\_SIG & 2+ & F32 & Sigma of PSF instrumental magnitude & N/A \\
     663    \hline
     664    AP\_MAG & 2+ & F32 & magnitude in standard aperture (i.e. 25 pixels radius) & N/A \\
     665    \hline
     666    AP\_MAG\_RAW & 2+ & F32 & magnitude in real aperture & N/A \\
     667    \hline
     668    AP\_MAG\_RADIUS & 2+ & F32 & radius used for aperture mags & pixels \\
     669    \hline
     670    AP\_FLUX & 2+ & F32 & instrumental flux in standard aperture & ADU \\
     671    \hline
     672    AP\_FLUX\_SIG & 2+ & F32 & aperture flux error & N/A \\
     673    \hline
     674    PEAK\_FLUX\_AS\_MAG & 2+ & F32 & Peak flux expressed as magnitude & N/A \\
     675    \hline
     676    CAL\_PSF\_MAG & 2+ & F32 & PSF Magnitude using supplied calibration & N/A \\
     677    \hline
     678    CAL\_PSF\_MAG\_SIG & 2+ & F32 & Measured standard-deviation of zero point calibration & N/A \\
     679    \hline
     680    SKY & 2+ & F32 & Sky level & counts/pixel \\
     681    \hline
     682    SKY\_SIGMA & 2+ & F32 & Sigma of sky level  & counts/pixel\\
     683    \hline PSF\_QF\_PERFECT & 2+ & F32 & PSF coverage/quality factor
     684    (poor): PSF value weighted by unmasked pixels
     685    (source: psmodules/src/objects/pmSourcePhotometry.c) & N/A \\
     686    \hline
     687    MOMENTS\_R1 & 2+ & F32 & first radial moment & N/A \\
     688    \hline
     689    MOMENTS\_RH & 2+ & F32 & half radial moment & N/A \\
     690    \hline
     691    KRON\_FLUX & 2+ & F32 & Kron Flux (that is, flux in 2.5 $\times$ first radial moment) & N/A \\
     692    \hline
     693    KRON\_FLUX\_ERR & 2+ & F32 & Kron Flux Error & N/A \\
     694    \hline
     695    KRON\_FLUX\_INNER & 2+ & F32 & Inner Kron Flux (that is, flux in 1.0 $\times$ first radial moment) & N/A \\
     696    \hline
     697    KRON\_FLUX\_OUTER & 2+ & F32 & Outer Kron Flux (that is, flux in 4.0 $\times$ first radial moment) & N/A \\
     698    \hline
     699    DIFF\_R\_P & 2+ & F32 & distance from detection to positive matching source & pixels \\
     700    \hline
     701    DIFF\_SN\_P & 2+ & F32 & signal-to-noise of pos match src & N/A \\
     702    \hline
     703    DIFF\_R\_M & 2+ & F32 & distance from detectionto negative match source & pixels \\
     704    \hline
     705    DIFF\_SN\_M & 2+ & F32 & signal-to-noise of neg match src & N/A \\
    586706    \hline
    587707    FLAGS2 & 2+ & U32 & psphot analysis flags (group 2)\footnote{See \htmladdnormallink{http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PSPSFlags\#StackDetectionFull.infoFlagsFLAGS232FLAGS}{http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PSPSFlags\#StackDetectionFull.infoFlagsFLAGS232FLAGS} for the meaning of each bit}\\
    588708    \hline
    589     N\_FRAMES & 2+ & U16 & Number of frames overlapping source center \\
     709    N\_FRAMES & 2+ & U16 & Number of exposures overlapping source center \\
    590710    \hline
    591711    PADDING & 2+ & S16 & padding \\
    592     \hline
    593     \multicolumn{4}{|c|}{\textbf{Extended (trail fitting) parameters}}\\
    594     \multicolumn{4}{|c|}{Values like \texttt{NaN} mean that the extended parameters are undefined for the detection}\\
    595     \hline
    596     X\_EXT & 2+ & F32 & Extended model X coordinate \\
    597     \hline
    598     Y\_EXT & 2+ & F32 & Extended model Y coordinate \\
    599     \hline
    600     X\_EXT\_SIG & 2+ & F32 & Sigma in extended model X coordinate \\
    601     \hline
    602     Y\_EXT\_SIG & 2+ & F32 & Sigma in extended model Y coordinate \\
    603     \hline
    604     EXT\_INST\_MAG & 2+ & F32 & Extended fit instrumental magnitude \\
    605     \hline
    606     EXT\_INST\_SIG\_MAG & 2+ & F32 & Sigma of extended fit instrumental magnitude \\
    607     \hline
    608     NPARAMS & 2+ & F32 & Number of model parameters \\
    609     \hline
    610     EXT\_WIDTH\_MAJ & 2+ & F32 & EXT width (major axis), length for trail \\
    611     \hline
    612     EXT\_WIDTH\_MIN & 2+ & F32 & EXT width (minor axis), sigma for trail \\
    613     \hline
    614     EXT\_THETA & 2+ & F32 & EXT orientation angle\\
    615     \hline
    616     EXT\_WIDTH\_MAJ\_ERR & 2+ & F32 & EXT width error (major axis)\\
    617     \hline
    618     EXT\_WIDTH\_MIN\_ERR & 2+ & F32 & EXT width error (minor axis)\\
    619     \hline
    620     EXT\_THETA\_ERR & 2+ & F32 & EXT orientation angle (error)\\
    621     \hline
    622     RA\_EXT & 3+ & F32 & Fitted centroid RA \\
    623     \hline
    624     RA\_EXT\_SIGMA & 3+ & F32 & Fitted RA sigma \\
    625     \hline
    626     DEC\_EXT & 3+ & F32 & Fitted centroid DEC \\
    627     \hline
    628     DEC\_EXT\_SIGMA & 3+ & F32 & Fitted DEC sigma \\
    629     \hline
    630     POSANG\_EXT & 3+ & F32 & Fitted position angle \\
    631     \hline
    632     PLTSCALE\_EXT & 3+ & F32 & Plate scale at centroid \\
    633     \hline
    634     EXT\_FLUX & 3+ & F32 & Fitted flux \\
    635     \hline
    636     EXT\_CAL\_MAG & 3+ & F32 & Calibrated magnitude \\
    637     \hline
    638     EXT\_MAG\_SIG & 3+ & F32 & Sigma of calibrated magnitude \\
    639     \hline
    640     EXT\_CHISQ & 3+ & F32 & $\chi^2$ of fit \\
    641     \hline
    642     EXT\_NDOF & 3+ & S32 & Fit degrees of freedom \\
    643     \hline
     712    \hline \hline
    644713  \end{longtable}
    645 }
     714\end{center}
     715
     716\begin{center}
     717  \begin{longtable}{|lclp{3.5in}c|}
     718    \caption{IPP-MOPS Transient Detection Table Columns:\\ Extended (Trail Fitting) Details}\label{table-detections-ext}\\
     719    \hline \hline
     720    \multicolumn{5}{|c|}{\textbf{Extended (trail fitting) parameters}}\\
     721    \multicolumn{5}{|c|}{Values like \texttt{NaN} mean that the extended parameters are undefined for the detection}\\
     722    \hline
     723    X\_EXT & 2+ & F32 &
     724    Extended model X coordinate & pixels\\
     725    \hline
     726    Y\_EXT & 2+ & F32 &
     727    Extended model Y coordinate & pixels \\
     728    \hline
     729    X\_EXT\_SIG & 2+ & F32 &
     730    Sigma in extended model X coordinate & pixels \\
     731    \hline
     732    Y\_EXT\_SIG & 2+ & F32 &
     733    Sigma in extended model Y coordinate & pixels \\
     734    \hline
     735    EXT\_INST\_MAG & 2+ & F32 &
     736    Extended fit instrumental magnitude & N/A \\
     737    \hline
     738    EXT\_INST\_SIG\_MAG & 2+ & F32 &
     739    Sigma of extended fit instrumental magnitude & N/A \\
     740    \hline
     741    NPARAMS & 2+ & S32 &
     742    Number of model parameters (see \cite{VerJedDen2012IAAaPwTF}) & N/A \\
     743    \hline
     744    EXT\_WIDTH\_MAJ & 2+ & F32 & % The name is weird but it's because of normalization
     745    Length of trail & pixels \\  % in the IPP: Check if MOPS want to change it
     746    \hline
     747    EXT\_WIDTH\_MIN & 2+ & F32 &  % The name is weird but it's because of normalization
     748    Sigma of trail & pixels \\    % in the IPP: Check if MOPS want to change it
     749    \hline
     750    EXT\_THETA & 2+ & F32 & EXT orientation angle & radians \\
     751    \hline
     752    EXT\_WIDTH\_MAJ\_ERR & 2+ & F32 & EXT width error (major axis) & pixels \\
     753    \hline
     754    EXT\_WIDTH\_MIN\_ERR & 2+ & F32 & EXT width error (minor axis) & pixels \\
     755    \hline
     756    EXT\_THETA\_ERR & 2+ & F32 & EXT orientation angle (error) & radians \\
     757    \hline
     758    RA\_EXT & 3+ & F32 & Fitted centroid RA & degrees \\
     759    \hline
     760    RA\_EXT\_SIGMA & 3+ & F32 & Fitted RA sigma & degrees? \\
     761    \hline
     762    DEC\_EXT & 3+ & F32 & Fitted centroid DEC & degrees \\
     763    \hline
     764    DEC\_EXT\_SIGMA & 3+ & F32 & Fitted DEC sigma & degrees? \\
     765    \hline
     766    POSANG\_EXT & 3+ & F32 & Fitted position angle & degrees \\
     767    \hline
     768    PLTSCALE\_EXT & 3+ & F32 & Plate scale at centroid & arcsec/pixel \\
     769    \hline
     770    EXT\_FLUX & 3+ & F32 & Fitted flux & ADU \\
     771    \hline
     772    EXT\_CAL\_MAG & 3+ & F32 & Calibrated magnitude & N/A \\
     773    \hline
     774    EXT\_MAG\_SIG & 3+ & F32 & Sigma of calibrated magnitude & N/A \\
     775    \hline
     776    EXT\_CHISQ & 3+ & F32 & $\chi^2$ of fit & N/A \\
     777    \hline
     778    EXT\_NDOF & 3+ & S32 & Fit degrees of freedom & N/A \\
     779    \hline
     780  \end{longtable}
     781\end{center}
    646782
    647783\subsection{MOPS Detectability Query}
     
    764900
    765901\pagebreak
     902
     903\section{Changes}
     904
     905\subsection{Changes in PS1\_DV3 from PS1\_DV2}
     906
     907\subsubsection{New Keywords}
     908
     909\paragraph{Per Exposure (in FITS header)}
     910\begin{itemize}
     911\item CMMTOBS
     912\item OBS\_MODE
     913\item DIFFTYPE
     914\item SKY
     915\item SHUTOUTC
     916\end{itemize}
     917
     918\paragraph{Per Detection (in FITS extension)}
     919\begin{itemize}
     920\item RA\_EXT
     921\item RA\_EXT\_SIGMA
     922\item DEC\_EXT
     923\item DEC\_EXT\_SIGMA
     924\item POSANG\_EXT
     925\item PLTSCALE\_EXT
     926\item EXT\_FLUX
     927\item EXT\_CAL\_MAG
     928\item EXT\_MAG\_SIG
     929\item EXT\_CHISQ
     930\item EXT\_NDOF
     931\end{itemize}
     932
     933\subsubsection{Removed Keywords}
     934
     935None
     936
     937\subsubsection{Datatypes}
     938\begin{itemize}
     939\item NPARAMS is now a S32 and no more a F32.
     940\end{itemize}
     941
     942\subsubsection{Known Bugs and Associated Fix}
     943
     944\begin{itemize}
     945\item None
     946\end{itemize}
     947
     948\newpage
     949
    766950\appendix
    767951
    768 \section{Appendix}
     952\section{The IPP Data Workflow}
     953
     954The objective of this section is to provide some details about the IPP
     955Workflow. It is intentionnally MOPS oriented in the sense that some
     956details have been voluntarily omitted.
     957
     958\begin{minipage}{0.65\linewidth}
     959  The IPP receives "exposures" from the telescope. An "exposure" is an
     960  image of 60 OTAs (see figure~\ref{fig-exposure-otas}) taken by the
     961  GPC1 camera and its associated metadata. All science exposures
     962  (which are interesting MOPS) are processed in the IPP according to
     963  the following stages.
     964
     965  The first stage is the CHIP stage. Detrending and objects detections
     966  are performed on each OTA at this stage.
     967
     968  The second stage is the CAMERA stage. Calibration and astrometry are
     969  performed on the exposure at this stage.
     970
     971  The third stage is the WARP stage\footnote{For simplicity and since
     972    nothing is performed in this stage, the FAKE stage has been
     973    ommitted.}. The image pixels are warped to fit a predefined sky
     974  tessellation (it is actually a covering). Cells of the tessellation
     975  are called \emph{skycells} and each pixel in a skycell has a size of
     976  $0.25" \times 0.25"$. The skycell is oriented so that increasing X
     977  (wrt Y) pixel coordinate corresponds to a move toward the West (wrt
     978  North).
     979
     980  The fourth stage is the DIFF stage. The difference between two
     981  skycells having the same spatial coordinates but being distant in
     982  time (by less than the TTI) is computed. To avoid deconvolution,
     983  the image difference can be performed in bothways When the newer
     984  image is diffed with the older image, the difference image is called
     985  the \emph{positive} image. When the older image is diffed with the
     986  newer image, the difference image is called the \emph{negative}
     987  image.
     988
     989  Another stage is executed in parallel of the fourth stage: the STACK
     990  stage. Its products (the stacks, that is, "average" observations in
     991  a skycell) can be used in the DIFF stage to compute WARP-STACK
     992  differences (e.g for MD observations). STACK-WARP are not computed
     993  (so far).
     994
     995  The fifth and last stage is the PPMOPS stage. The exposure is
     996  rebuilt from the differences obtained in each skycell of the DIFF
     997  stage. For detections falling in areas covered by two or more
     998  skycells, the data of the detection being the nearest to a skycell
     999  center are taken.
     1000\end{minipage}\hfill\begin{minipage}{0.3\linewidth}
     1001  \begin{center}
     1002    \includegraphics[width=\linewidth]{figures/ipp_workflow.eps}
     1003    \captionof{figure}{Caption for figure}
     1004    \label{fig-ipp-workflow}
     1005  \end{center}
     1006\end{minipage}
     1007
     1008\begin{center}
     1009  \includegraphics[width=4in]{figures/exposure_ota.eps}
     1010  \captionof{figure}{Exposure / OTA TODO + Move somewhere else}
     1011  \label{fig-exposure-otas}
     1012\end{center}
     1013
     1014%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1015\newpage
     1016\section{\texttt{ppMops} Implementation Details}
     1017\label{sec-ppmops}
     1018
     1019\subsection{Source Code}
     1020\label{sec-ppmops-sourcecode}
     1021
     1022The \texttt{ppMops} source code can be found at
     1023\url{https://svn.pan-starrs.ifa.hawaii.edu/repo/ipp/trunk/ppTranslate}. The
     1024SVN revision of the analyzed code as well as the corresponding
     1025software version depends on the version of this document and can be
     1026found in the History subsection (see subsection
     1027\ref{sec-ppmops-sourcecodehistory}).
     1028
     1029\subsection{Source Code Analysis History}
     1030\label{sec-ppmops-sourcecodehistory}
     1031\begin{tabular}{|c|c|c|p{2in}|c|c|}
     1032  \hline
     1033  \parbox{.5in}{Doc Version} & Date & Author & Description & SVN Rev. & \parbox{.5in}{Software Version}\\
     1034  \hline
     1035  \hline
     1036  --- & 2012-09-14 & SC & Creation & 34439 & 3\footnotemark{}\\
     1037  \hline
     1038\end{tabular}\footnotetext{Modified version 3}
     1039
     1040\subsection{Main}
     1041Source code: \texttt{src/ppMops.c}.
     1042
     1043\texttt{ppMops} can be run on the command line independently from the
     1044IPP framework. It is functionnally made of four parts:
     1045\begin{enumerate}
     1046\item Analyzing the command-line arguments (see subsection
     1047  \ref{sec-implementation-args});
     1048\item Reading the detections from the input diff files and the exposure
     1049  parameters (see subsection \ref{sec-implementation-read});
     1050\item Removing the duplicated detections (see subsection
     1051  \ref{sec-implementation-merge});
     1052\item Writing the products (see subsection
     1053  \ref{sec-implementation-write});
     1054\end{enumerate}
     1055
     1056\subsection{Command-Line Arguments Analysis}
     1057\label{sec-implementation-args}
     1058
     1059Source code: \texttt{src/ppMopsArguments.c}.
     1060
     1061\subsubsection{Parameters}
     1062
     1063There are only two mandatory arguments:
     1064\begin{enumerate}
     1065\item The first argument is a filename. The associated file contains
     1066  the list of the names of all the diff files that will be used as
     1067  input. For simplicity, we will identify that list by:
     1068  \texttt{list\_of\_diffs\_inputs}.
     1069\item The second argument is the name of the output file. We will call
     1070  it \texttt{output\_file\_name}.
     1071\end{enumerate}
     1072
     1073The following parameters can be taken from the command line arguments
     1074options (if they are provided, otherwise they take the default value):
     1075\begin{itemize}
     1076\item \texttt{exp\_name}: exposure name (default: NULL);
     1077\item \texttt{exp\_id}: Exposure identifier (IPP internal; default: 0);
     1078\item \texttt{chip\_id}: Chip stage identifier (IPP internal; default: 0);
     1079\item \texttt{cam\_id}: Camera stage identifier (IPP internal; default: 0);
     1080\item \texttt{fake\_id}: Fake stage identifier (IPP internal; default: 0);
     1081\item \texttt{warp\_id}: Warp stage identifier (IPP internal; default: 0);
     1082\item \texttt{diff\_id}: Diff stage identifier (IPP internal; default: 0);
     1083\item \texttt{inverse}: Inverse subtraction (boolean; default: false);
     1084\item \texttt{zp}: Magnitude zero point (default: NAN);
     1085\item \texttt{zp\_error}: Error in magnitude zero point (default: NAN);
     1086\item \texttt{astrom\_rms}: Astrometric solution RMS (default: NAN);
     1087\item \texttt{version}: CMF file version (default: 0);
     1088\end{itemize}
     1089
     1090\subsubsection{Parameters Values Validation}
     1091\begin{itemize}
     1092\item If the list of input file names is empty, an error is displayed
     1093  and \texttt{ppMops} exits.
     1094\item There is no check on the validity of the different parameters
     1095  (values, files existence...).
     1096\end{itemize}
     1097
     1098\subsection{Reading Detections}
     1099\label{sec-implementation-read}
     1100
     1101Source code: \texttt{src/ppMopsRead.c}.
     1102
     1103Each file from the \texttt{list\_of\_diffs\_inputs} is opened. A
     1104\texttt{ppMopsDetections} object is populated from the data that are
     1105read from that file. The set (namely a \texttt{psArray}) of all the
     1106valid \texttt{ppMopsDetections} objects is the product of this part.
     1107
     1108The data which are extracted from each file are the following:
     1109\begin{itemize}
     1110\item From the header are extracted:
     1111  \begin{itemize}
     1112  \item \texttt{diffSkyfileId}: Its value is
     1113    associated to the keyword \texttt{IMAGEID}. If not present or 0, the
     1114    program exits with an error.
     1115  \item The current diff version is derived from the value associated
     1116    to EXTTYPE. If the \texttt{version} has not already been set, it
     1117    is set to the value which has just been read. If it was set at
     1118    some point (either through the command line, or from a previous
     1119    input), the current diff version value is checked against the
     1120    \texttt{version}. Different values will produce warning messages.
     1121  \item \texttt{raBoresight} is given the value associated to
     1122    \texttt{FPA.RA};
     1123  \item \texttt{decBoresight} is given the value associated to
     1124    \texttt{FPA.DEC};
     1125  \item \texttt{filter} is given the value associated to
     1126    \texttt{FPA.FILTER};
     1127  \item \texttt{airmass} is given the value associated to
     1128    \texttt{AIRMASS};
     1129  \item \texttt{exptime} is given the value associated to
     1130    \texttt{EXPTIME};
     1131  \item \texttt{posangle} is given the value associated to
     1132    \texttt{FPA.POSANGLE};
     1133  \item \texttt{alt} is given the value associated to
     1134    \texttt{FPA.ALT};
     1135  \item \texttt{az} is given the value associated to
     1136    \texttt{FPA.AZ};
     1137  \item \texttt{mjd} is computed from the \texttt{mjdobs} value
     1138    associated to \texttt{MJD-OBS} by: \[\mathtt{mjd} = \mathtt{mjdobs} +
     1139    \frac{\mathtt{exptime}}{2*3600*24}\]
     1140  \item \texttt{seeing} is initialized (note that it is modified in
     1141    the loop over the valid detections) using
     1142    $\mathtt{fwhm}_\mathtt{maj}$ (wrt $\mathtt{fwhm}_\mathtt{min}$)
     1143    associated to the keyword \texttt{FWHM\_MAJ} (wrt
     1144    \texttt{FWHM\_MIN});
     1145  \item \texttt{naxis1} is set to the value associated to
     1146    \texttt{IMNAXIS1}, that is the number of columns of the original
     1147    image;
     1148  \item \texttt{naxis2} is set to the value associated to
     1149    \texttt{IMNAXIS2}, that is the number of rows of the original
     1150    image;
     1151  \end{itemize}
     1152\item From the \texttt{SkyChip.psf} extension:
     1153  \begin{itemize}
     1154  \item This extension contains all the detections. One row is
     1155    associated to each detection.
     1156  \item A detection is rejected if at least one of the following
     1157    parameters has an non-finite value: \texttt{x}, \texttt{y},
     1158    \texttt{ra}, \texttt{dec}, \texttt{mag}, \texttt{magErr},
     1159    \texttt{xErr}, \texttt{yErr}, \texttt{scale}, \texttt{angle}.
     1160  \item A detection is rejected if its associated \texttt{flags}
     1161    matches:
     1162    {\small
     1163    \texttt{PM\_SOURCE\_MODE\_FAIL | PM\_SOURCE\_MODE\_BADPSF |
     1164      PM\_SOURCE\_MODE\_SATURATED | PM\_SOURCE\_MODE\_CR\_LIMIT |
     1165      PM\_SOURCE\_MODE\_SKY\_FAILURE}}
     1166  \item \texttt{x} is associated to the \texttt{X\_PSF} keyword;
     1167  \item \texttt{y} is associated to the \texttt{Y\_PSF} keyword;
     1168  \item \texttt{ra} is associated to the \texttt{RA\_PSF} keyword. It
     1169    is converted to radians;
     1170  \item \texttt{dec} is associated to the \texttt{DEC\_PSF} keyword. It
     1171    is converted to radians;
     1172  \item \texttt{mag} is computed from the value associated the
     1173    \texttt{PSF\_INST\_MAG} keyword, namely:
     1174    \[
     1175    \mathtt{mag} = \mathtt{PSF\_INST\_MAG} + \mathtt{zp}
     1176    \]
     1177    where \texttt{zp} is defined in the arguments list (see subsection
     1178    \ref{sec-implementation-args});
     1179  \item \texttt{magErr} is associated to the
     1180    \texttt{PSF\_INST\_MAG\_SIG} keyword;
     1181  \item \texttt{xErr} is associated to the \texttt{X\_PSF\_SIG}
     1182    keyword;
     1183  \item \texttt{yErr} is associated to the \texttt{Y\_PSF\_SIG}
     1184    keyword;
     1185  \item \texttt{scale} is associated to the \texttt{PLTSCALE}
     1186    keyword;
     1187  \item \texttt{angle} is associated to the \texttt{POSANGLE}
     1188    keyword;
     1189  \item \texttt{flags} is associated to the \texttt{FLAGS} keyword;
     1190  \item \texttt{raErr} is defined by:
     1191    \[
     1192    \mathtt{raErr} = \frac{\mathtt{scale}}{3600}
     1193    \sqrt{\cos^2(\mathtt{angle}) \mathtt{xErr}^2 +
     1194      \sin^2(\mathtt{angle}) \mathtt{yErr}^2}
     1195    \]
     1196  \item \texttt{decErr} is defined by:
     1197    \[
     1198    \mathtt{decErr} = \frac{\mathtt{scale}}{3600}
     1199    \sqrt{\sin^2(\mathtt{angle}) \mathtt{xErr}^2 +
     1200      \cos^2(\mathtt{angle}) \mathtt{yErr}^2}
     1201    \]
     1202  \end{itemize}
     1203\item \texttt{seeing} is defined as the product of the mean of
     1204  $\mathtt{fwhm}_\mathtt{maj}$ and $\mathtt{fwhm}_\mathtt{min}$ by the
     1205  mean of the \texttt{scale} values for valid detections, that is:
     1206  \[
     1207  \mathtt{seeing} = \frac{\mathtt{fwhm}_\mathtt{maj} +
     1208    \mathtt{fwhm}_\mathtt{min}}{2} \times \frac{\sum_{\mathtt{valid\
     1209        detections}}(scale)}{\#(\mathtt{valid\ detections})}
     1210  \]
     1211\item The number of valid detections is also kept (but not used).
     1212\item For each row of the \texttt{SkyChip.xfit} extension:
     1213  \begin{itemize}
     1214  \item This extension contains only a subset of the detections. Each
     1215    row contains the index of the current detection which is the value
     1216    associated to the keyword \texttt{IPP\_IDET};
     1217  \item Note that detections parameters whose index could not be found
     1218    in the \texttt{SkyChip.xfit} extension are set to NaN.
     1219  \item The following columns are extracted \texttt{X\_EXT},
     1220    \texttt{Y\_EXT}, \texttt{X\_EXT\_SIG}, \texttt{Y\_EXT\_SIG},
     1221    \texttt{EXT\_INST\_MAG}, \texttt{EXT\_INST\_MAG\_SIG},
     1222    \texttt{NPARAMS}, \texttt{EXT\_WIDTH\_MAJ}, \texttt{EXT\_WIDTH\_MIN},
     1223    \texttt{EXT\_THETA}, \texttt{EXT\_WIDTH\_MAJ\_ERR},
     1224    \texttt{EXT\_WIDTH\_MIN\_ERR}, and \texttt{EXT\_THETA\_ERR}. No check is
     1225    performed on them at this stage.
     1226  \end{itemize}
     1227\end{itemize}
     1228
     1229At the end of this stage, all input files have been used to populate a
     1230collection of sets of detections. Let us call that collection $({\cal
     1231  D}_{i})_{i \in \{1..n\}}$. Each of those sets contains data read
     1232from one file and it is important to note that only a few checks have
     1233been performed on the data (more precisely, only non-masked detections
     1234which have defined values have been inserted). The following cases can
     1235therefore happen: (1) Any ${\cal D}_i$ can be "empty", that is, does
     1236not contain any valdiated detection; (2) Some parameters like
     1237\texttt{seeing} can have an undefined value (e.g. \texttt{NaN}).
     1238
     1239\subsection{Merging Detections}
     1240\label{sec-implementation-merge}
     1241
     1242Source code: \texttt{src/ppMopsMerge.c}.
     1243
     1244That part of the code essentially uses a kd-tree implementation to
     1245compare distances between detections. The collection of sets of
     1246detections will be called $({\cal D}_{i})_{i \in \{1..n\}}$ (see
     1247previous section).
     1248
     1249\subsubsection{Checks}
     1250\label{sec-implementation-merge-checks}
     1251
     1252Checks are performed on data that have been extracted from FITS files
     1253headers. Namely, they are:
     1254\begin{itemize}
     1255\item \texttt{raBoresight} constancy across all the detections;
     1256\item \texttt{decBoresight} constancy across all the detections;
     1257\item \texttt{filter} constancy across all the detections;
     1258\item \texttt{airmass} constancy across all the detections;
     1259\item \texttt{exptime} constancy across all the detections;
     1260\item \texttt{posangle} constancy across all the detections;
     1261\item \texttt{alt} constancy across all the detections;
     1262\item \texttt{az} constancy across all the detections;
     1263\item \texttt{mjd} constancy across all the detections;
     1264\end{itemize}
     1265
     1266Any inconsistency displays an error and the program exits.
     1267
     1268\subsubsection{kd-Tree Merging}
     1269\label{sec-implementation-merge-kdtree}
     1270
     1271All valid detections are inserted into a kd-tree (using the
     1272\texttt{psTree} implementation). \texttt{ra} and \texttt{dec} are used
     1273as keys for the nearest neighbor search. An iteration over all valid
     1274detections is then performed.
     1275
     1276The detection in a 1 arcsec neighborhood around the current valid
     1277detection which is the closest to the image center is chosen as the
     1278best candidate for the source. Then, the best of the candidates is
     1279chosen as the source. All other detections are considered duplicates,
     1280and marked as invalid, then removed from the detections set to which
     1281they belong.
     1282
     1283Note that \texttt{numGood} which is supposed to give the number of
     1284valid detections is not updated.
     1285
     1286\subsection{Writing Final Product}
     1287\label{sec-implementation-write}
     1288
     1289Source code: \texttt{src/ppMopsWrite.c}.
     1290
     1291To resolve any ambiguity, we will note the parameter named
     1292\texttt{param} which was built for the set of detections ${\cal
     1293  D}_{i}$ will be denoted by ${\cal D}_{i}(\mathtt{param})$.
     1294
     1295Note that, except for the parameters that have been checked at the
     1296merge stage (see paragraph~\ref{sec-implementation-merge-checks}),
     1297there is no guarantee that ${\cal D}_{i}(\mathtt{param}) = {\cal
     1298  D}_{j}(\mathtt{param})$ when $i \neq j$. There is no guarantee to
     1299that ${\cal D}_{i}(\mathtt{param})$ is defined (in the mathematical
     1300sense), e.g. it could be \texttt{NaN}...
     1301
     1302%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1303\subsubsection{Exposure Parameters: Header Details}
     1304\label{sec-implementation-write-header}
     1305
     1306The first set of detections among the $({\cal D}_{i})_i$ that contains
     1307at least one valid detection is chosen. To fix ideas, let us denote
     1308it by ${\cal D}_{i_0}$.
     1309
     1310The following parameters are written to the product FITS header:
     1311
     1312\begin{itemize}
     1313\item \texttt{SWSOURCE} (Software source): Constructed from the SVN
     1314  repository value. Generated when compiled.
     1315\item \texttt{SWVERSN} (Software version): Constructed from the SVN
     1316  version value. Generated when compiled.
     1317\item \texttt{EXP\_NAME} (Exposure name): Set by \texttt{exp\_name}
     1318  argument value;
     1319\item \texttt{EXP\_ID} (Exposure identifier): Set by \texttt{exp\_id}
     1320  argument value;
     1321\item \texttt{CHIP\_ID} (Chip stage identifier): Set by
     1322  \texttt{chip\_id} argument value;
     1323\item \texttt{CAM\_ID} (Cam stage identifier): Set by \texttt{cam\_id}
     1324  argument value;
     1325\item \texttt{FAKE\_ID} (Fake stage identifier): Set by
     1326  \texttt{fake\_id} argument value;
     1327\item \texttt{WARP\_ID} (Warp stage identifier): Set by
     1328  \texttt{warp\_id} argument value;
     1329\item \texttt{DIFF\_ID} (Diff stage identifier): Set by
     1330  \texttt{diff\_id} argument value;
     1331\item \texttt{DIFF\_POS} (Positive subtraction): Set by
     1332  \texttt{inverse} argument value;
     1333\item \texttt{MJD-OBS} (MJD of exposure midpoint): Set by ${\cal
     1334    D}_{i_0}(\mathtt{mjd})$. Uniqueness guaranteed by
     1335  \ref{sec-implementation-merge-checks};
     1336\item \texttt{RA} (Right Ascension of boresight): Set by ${\cal
     1337    D}_{i_0}(\mathtt{raBoresight})$. Uniqueness guaranteed by
     1338  \ref{sec-implementation-merge-checks};
     1339\item \texttt{DEC} (Declination of boresight): Set by ${\cal
     1340    D}_{i_0}(\mathtt{decBoresight})$. Uniqueness guaranteed by
     1341  \ref{sec-implementation-merge-checks};
     1342\item \texttt{TEL\_ALT} (Telescope altitude): Set by ${\cal
     1343    D}_{i_0}(\mathtt{alt})$. Uniqueness guaranteed by
     1344  \ref{sec-implementation-merge-checks};
     1345\item \texttt{TEL\_AZ} (Telescope azimuth): Set by ${\cal
     1346    D}_{i_0}(\mathtt{az})$. Uniqueness guaranteed by
     1347  \ref{sec-implementation-merge-checks};
     1348\item \texttt{EXPTIME} (Exposure time (sec)): Set by ${\cal
     1349    D}_{i_0}(\mathtt{exptime})$. Uniqueness guaranteed by
     1350  \ref{sec-implementation-merge-checks};
     1351\item \texttt{ROTANGLE} (Rotator position angle): Set by ${\cal
     1352    D}_{i_0}(\mathtt{rotangle})$. Uniqueness guaranteed by
     1353  \ref{sec-implementation-merge-checks};
     1354\item \texttt{FILTER} (Filter name): Set by ${\cal
     1355    D}_{i_0}(\mathtt{filter})$. Uniqueness guaranteed by
     1356  \ref{sec-implementation-merge-checks};
     1357\item \texttt{AIRMASS} (Airmass of exposure): Set by ${\cal
     1358    D}_{i_0}(\mathtt{airmass})$. Uniqueness guaranteed by
     1359  \ref{sec-implementation-merge-checks};
     1360\item \texttt{SEEING} (Mean seeing): Set by the median of defined (not
     1361  \texttt{NaN}, not \texttt{Infinity}) of $({\cal
     1362    D}_{i}(\mathtt{seeing}))_i$;
     1363  \commentFromSC{2012-09-18}{Check if it is what we
     1364    really expect. Take the example of 3 set of detections for which
     1365    \texttt{seeing} is defined, assuming the first one contains 1000
     1366    detections with a \texttt{seeing} of 1.0, the second one contains
     1367    10 detections with a \texttt{seeing} of 2.0, the third one 10
     1368    detections with a \texttt{seeing} of 3.0. Do we really want the
     1369    global \texttt{seeing} value to be 2.0?}{}
     1370\item \texttt{OBSCODE} (IAU Observatory code): Hard-coded value
     1371  defined in \texttt{src/ppMops.h} (value \texttt{F51});
     1372  \commentFromSC{2012-09-18}{I'm surprised that it's defined locally
     1373    and not in some high-level project header file}{}
     1374\item \texttt{MAGZP} (Magnitude zero point): Set by \texttt{zp}
     1375  argument value;
     1376\item \texttt{MAGZPERR} (Error in magnitude zero point): Set by
     1377  \texttt{zp\_error} argument value;
     1378\item \texttt{ASTRORMS} (Error in magnitude zero point): Set by
     1379  \texttt{astrom\_rms} argument value;
     1380\item \texttt{CMFVERSION} (CMF version): Set by \texttt{version}
     1381  argument value but possibly modified by first \texttt{EXTTYPE}
     1382  value;
     1383  \commentFromSC{2012-09-18}{Depends on the order of the input FITS
     1384    file and their \texttt{EXTTYPE} value (e.g. if \texttt{-version 0}
     1385    is used as argument and two files are used, one with
     1386    \texttt{EXTTYPE} of 1, the other with \texttt{EXTTYPE} of
     1387    2). However we do not expect to have different values for
     1388    \texttt{EXTTYPE}, do we?}{}
     1389\end{itemize}
     1390
     1391%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1392\subsubsection{Detection Parameters: Extension Details}
     1393\label{sec-implementation-write-detection}
     1394
     1395If no detection is present in any detections set, an extension is
     1396still created and contains exactly one row of undefined values
     1397(\texttt{NaN} for floating-point data, 0 for integral types).
     1398
     1399To resolve any ambiguity, we will note the parameter named
     1400\texttt{param} which was built for the detection $j$ in the set of
     1401detections ${\cal D}_{i}$ will be denoted by ${\cal
     1402  D}_{ij}(\mathtt{param})$ where \texttt{param} was defined in
     1403paragraph~\ref{sec-implementation-read}. When the \texttt{param}
     1404parameter is the exact copy of the value associated to the keyword
     1405\texttt{INPUT\_KEY}, we will write it as ${\cal
     1406  D}_{ij}(\mathtt{INPUT\_KEY})$ (note the use of the uppercase
     1407letters).
     1408
     1409For each detection $j$ in each detections set ${\cal D}_{i}$, the
     1410following products are written to the output FITS file:
     1411\begin{itemize}
     1412\item \texttt{RA} associated to ${\cal D}_{ij}(\mathtt{ra})$ (which is
     1413  identical to ${\cal D}_{ij}(\mathtt{RA\_PSF})$);
     1414\item \texttt{RA\_ERR} associated to ${\cal D}_{ij}(\mathtt{raErr})$;
     1415\item \texttt{DEC} associated to ${\cal D}_{ij}(\mathtt{dec})$ (which
     1416  is identical to ${\cal D}_{ij}(\mathtt{DEC\_PSF})$);
     1417\item \texttt{DEC\_ERR} associated to ${\cal
     1418    D}_{ij}(\mathtt{decErr})$;
     1419\item \texttt{MAG} associated to ${\cal D}_{ij}(\mathtt{mag})$;
     1420\item \texttt{MAG\_ERR} associated to ${\cal D}_{ij}(\mathtt{magErr})$
     1421  (which is identical to ${\cal
     1422    D}_{ij}(\mathtt{PSF\_INST\_MAG\_SIG})$);
     1423\item \texttt{PSF\_CHI2} associated to ${\cal
     1424    D}_{ij}(\mathtt{PSF\_CHISQ})$;
     1425\item \texttt{PSF\_DOF} associated to ${\cal
     1426    D}_{ij}(\mathtt{PSF\_NDOF})$;
     1427\item \texttt{CR\_SIGNIFICANCE} associated to ${\cal
     1428    D}_{ij}(\mathtt{CR\_NSIGMA})$;
     1429\item \texttt{EXT\_SIGNIFICANCE} associated to ${\cal
     1430    D}_{ij}(\mathtt{EXT\_NSIGMA})$;
     1431\item \texttt{PSF\_MAJOR} associated to ${\cal
     1432    D}_{ij}(\mathtt{PSF\_MAJOR})$;
     1433\item \texttt{PSF\_MINOR} associated to ${\cal
     1434    D}_{ij}(\mathtt{PSF\_MINOR})$;
     1435\item \texttt{PSF\_THETA} associated to ${\cal
     1436    D}_{ij}(\mathtt{PSF\_THETA})$;
     1437\item \texttt{PSF\_QUALITY} associated to ${\cal
     1438    D}_{ij}(\mathtt{PSF\_QF})$;
     1439\item \texttt{PSF\_NPIX} associated to ${\cal
     1440    D}_{ij}(\mathtt{PSF\_NPIX})$;
     1441\item \texttt{MOMENTS\_XX} associated to ${\cal
     1442    D}_{ij}(\mathtt{MOMENTS\_XX})$;
     1443\item \texttt{MOMENTS\_XY} associated to ${\cal
     1444    D}_{ij}(\mathtt{MOMENTS\_XY})$;
     1445\item \texttt{MOMENTS\_YY} associated to ${\cal
     1446    D}_{ij}(\mathtt{MOMENTS\_YY})$;
     1447\item \texttt{N\_POS} associated to ${\cal
     1448    D}_{ij}(\mathtt{DIFF\_NPOS})$;
     1449\item \texttt{F\_POS} associated to ${\cal
     1450    D}_{ij}(\mathtt{DIFF\_FRATIO})$;
     1451\item \texttt{RATIO\_BAD} associated to ${\cal
     1452    D}_{ij}(\mathtt{DIFF\_NRATIO\_BAD})$;
     1453\item \texttt{RATIO\_MASK} associated to ${\cal
     1454    D}_{ij}(\mathtt{DIFF\_NRATIO\_MASK})$;
     1455\item \texttt{RATIO\_ALL} associated to ${\cal
     1456    D}_{ij}(\mathtt{DIFF\_NRATIO\_ALL})$;
     1457\item \texttt{FLAGS} associated to ${\cal D}_{ij}(\mathtt{FLAGS})$;
     1458\item \texttt{DIFF\_SKYFILE\_ID} associated to ${\cal
     1459    D}_{i}(\mathtt{diffSkyfileId})$ (that is, the \texttt{diff\_id} of
     1460  the file which was used to compute the difference);
     1461\item \texttt{IPP\_IDET} associated to ${\cal
     1462    D}_{ij}(\mathtt{IPP\_DET})$ (since it is the position of the
     1463  detection if the $i$th diff file, it is not very useful. However
     1464  gaps in the numbering show that detections have been removed.
     1465\item \texttt{PSF\_INST\_FLUX} associated to ${\cal
     1466    D}_{ij}(\mathtt{PSF\_INST\_FLUX})$;
     1467\item \texttt{PSF\_INST\_FLUX\_SIG} associated to ${\cal
     1468    D}_{ij}(\mathtt{PSF\_INST\_FLUX\_SIG})$;
     1469\item \texttt{AP\_MAG} associated to ${\cal D}_{ij}(\mathtt{AP\_MAG})$;
     1470\item \texttt{AP\_MAG\_RAW} associated to ${\cal
     1471    D}_{ij}(\mathtt{AP\_MAG\_RAW})$;
     1472\item \texttt{AP\_MAG\_RADIUS} associated to ${\cal
     1473    D}_{ij}(\mathtt{AP\_MAG\_RADIUS})$;
     1474\item \texttt{AP\_FLUX} associated to ${\cal D}_{ij}(\mathtt{AP\_FLUX})$;
     1475\item \texttt{AP\_FLUX\_SIG} associated to ${\cal
     1476    D}_{ij}(\mathtt{AP\_FLUX\_SIG})$;
     1477\item \texttt{PEAK\_FLUX\_AS\_MAG} associated to ${\cal
     1478    D}_{ij}(\mathtt{PEAK\_FLUX\_AS\_MAG})$;
     1479\item \texttt{CAL\_PSF\_MAG} associated to ${\cal
     1480    D}_{ij}(\mathtt{CAL\_PSF\_MAG})$;
     1481\item \texttt{CAL\_PSF\_MAG\_SIG} associated to ${\cal
     1482    D}_{ij}(\mathtt{CAL\_PSF\_MAG\_SIG})$;
     1483\item \texttt{SKY} associated to ${\cal D}_{ij}(\mathtt{SKY})$;
     1484\item \texttt{SKY\_SIGMA} associated to ${\cal D}_{ij}(\mathtt{SKY\_SIGMA})$;
     1485\item \texttt{PSF\_QF\_PERFECT} associated to ${\cal
     1486    D}_{ij}(\mathtt{PSF\_QF\_PERFECT})$;
     1487\item \texttt{MOMENTS\_R1} associated to ${\cal D}_{ij}(\mathtt{MOMENTS\_R1})$;
     1488\item \texttt{MOMENTS\_RH} associated to ${\cal D}_{ij}(\mathtt{MOMENTS\_RH})$;
     1489\item \texttt{KRON\_FLUX} associated to ${\cal D}_{ij}(\mathtt{KRON\_FLUX})$;
     1490\item \texttt{KRON\_FLUX\_ERR} associated to ${\cal
     1491    D}_{ij}(\mathtt{KRON\_FLUX\_ERR})$;
     1492\item \texttt{KRON\_FLUX\_INNER} associated to ${\cal
     1493    D}_{ij}(\mathtt{KRON\_FLUX\_INNER})$;
     1494\item \texttt{KRON\_FLUX\_OUTER} associated to ${\cal
     1495    D}_{ij}(\mathtt{KRON\_FLUX\_OUTER})$;
     1496\item \texttt{DIFF\_R\_P} associated to ${\cal
     1497    D}_{ij}(\mathtt{DIFF\_R\_P})$;
     1498\item \texttt{DIFF\_SN\_P} associated to ${\cal
     1499    D}_{ij}(\mathtt{DIFF\_SN\_P})$;
     1500\item \texttt{DIFF\_R\_M} associated to ${\cal
     1501    D}_{ij}(\mathtt{DIFF\_R\_M})$;
     1502\item \texttt{DIFF\_SN\_M} associated to ${\cal
     1503    D}_{ij}(\mathtt{DIFF\_SN\_M})$;
     1504\item \texttt{FLAGS2} associated to ${\cal D}_{ij}(\mathtt{FLAGS2})$;
     1505\item \texttt{N\_FRAMES} associated to ${\cal
     1506    D}_{ij}(\mathtt{N\_FRAMES})$;
     1507\item \texttt{PADDING} associated to ${\cal
     1508    D}_{ij}(\mathtt{PADDING})$;
     1509\item \texttt{X\_EXT} associated to ${\cal D}_{ij}(\mathtt{X\_EXT})$;
     1510\item \texttt{Y\_EXT} associated to ${\cal D}_{ij}(\mathtt{Y\_EXT})$;
     1511\item \texttt{X\_EXT\_SIG} associated to ${\cal
     1512    D}_{ij}(\mathtt{X\_EXT\_SIG})$;
     1513\item \texttt{Y\_EXT\_SIG} associated to ${\cal
     1514    D}_{ij}(\mathtt{Y\_EXT\_SIG})$;
     1515\item \texttt{EXT\_INST\_MAG} associated to ${\cal
     1516    D}_{ij}(\mathtt{EXT\_INST\_MAG})$;
     1517\item \texttt{EXT\_INST\_MAG\_SIG} associated to ${\cal
     1518    D}_{ij}(\mathtt{EXT\_INST\_MAG\_SIG})$;
     1519\item \texttt{NPARAMS} associated to ${\cal
     1520    D}_{ij}(\mathtt{NPARAMS})$;
     1521\item \texttt{EXT\_WIDTH\_MAJ} associated to ${\cal
     1522    D}_{ij}(\mathtt{EXT\_WIDTH\_MAJ})$;
     1523\item \texttt{EXT\_WIDTH\_MIN} associated to ${\cal
     1524    D}_{ij}(\mathtt{EXT\_WIDTH\_MIN})$;
     1525\item \texttt{EXT\_THETA} associated to ${\cal
     1526    D}_{ij}(\mathtt{EXT\_THETA})$;
     1527\item \texttt{EXT\_WIDTH\_MAJ\_ERR} associated to ${\cal
     1528    D}_{ij}(\mathtt{EXT\_WIDTH\_MAJ\_ERR})$;
     1529\item \texttt{EXT\_WIDTH\_MIN\_ERR} associated to ${\cal
     1530    D}_{ij}(\mathtt{EXT\_WIDTH\_MIN\_ERR})$;
     1531\item \texttt{EXT\_THETA\_ERR} associated to ${\cal
     1532    D}_{ij}(\mathtt{EXT\_THETA\_ERR})$;
     1533\end{itemize}
     1534
     1535\subsection{Testing}
     1536\label{sec-implementation-test}
     1537
     1538No test data have been provided.
     1539
     1540\commentFromSC{2012-09-18}{No data exists to test the software. It
     1541  would be good to make sure that the products are consistent at least
     1542  (1) From one software release to another; (2) From one software
     1543  execution to another; (3) To check if the product depends one the
     1544  order in which the input data are ingested and processed. Stress
     1545  tests could also be imagined, e.g. involving large data sets}{ }
     1546
     1547%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1548\newpage
     1549\section{Obsolete Stuff?}
     1550
     1551TODO (SC): The following stuff seems obsolete. Tell me if I can remove it.
    7691552
    7701553\subsection{IPP to MOPS}
     
    7971580\hline
    7981581Detectability Query         & \code{MOPS_DETECTABILITY_QUERY} & table of detectability query tuples (RA, Dec, FPA) \\
    799 \end{tabular}
    800 \end{center}
    801 \end{table}
    802 
    803 \subsection{Acronyms}
    804 
    805 \begin{table}[htbp]
    806 \begin{center}
    807 \small
    808 \caption{Acronyms used in this document\label{table-acronyms}}
    809 \begin{tabular}{ll}
    810 \hline
    811 \hline
    812 {\bf Acronym}            & {\bf Definition} \\
    813 \hline
    814 MOPS     & Pan-STARRS Moving Object Processing System \\
    815 IPP      & Pan-STARRS Image Processing Pipeline \\
    816 FPA      & Focal plane array \\
    817 MPC      & Center for Astrophysics Minor Planet Center \\
    818 \hline
    8191582\end{tabular}
    8201583\end{center}
     
    8411604\end{itemize}
    8421605
    843 \subsection{Example}
    844 \label{sec-example}
    845 
    846 \begin{verbatim}
    847 XTENSION= 'BINTABLE'           / binary table extension
    848 BITPIX  =                    8 / 8-bit bytes
    849 NAXIS   =                    2 / 2-dimensional binary table
    850 NAXIS1  =                  120 / width of table in bytes
    851 NAXIS2  =                42032 / number of rows in table
    852 PCOUNT  =                    0 / size of special data area
    853 GCOUNT  =                    1 / one data group (required keyword)
    854 TFIELDS =                   25 / number of fields in each row
    855 TTYPE1  = 'RA      '           / label for field   1
    856 TFORM1  = '1D      '           / data format of field: 8-byte DOUBLE
    857 TTYPE2  = 'RA_ERR  '           / label for field   2
    858 TFORM2  = '1D      '           / data format of field: 8-byte DOUBLE
    859 TTYPE3  = 'DEC     '           / label for field   3
    860 TFORM3  = '1D      '           / data format of field: 8-byte DOUBLE
    861 TTYPE4  = 'DEC_ERR '           / label for field   4
    862 TFORM4  = '1D      '           / data format of field: 8-byte DOUBLE
    863 TTYPE5  = 'MAG     '           / label for field   5
    864 TFORM5  = '1E      '           / data format of field: 4-byte REAL
    865 TTYPE6  = 'MAG_ERR '           / label for field   6
    866 TFORM6  = '1E      '           / data format of field: 4-byte REAL
    867 TTYPE7  = 'PSF_CHI2'           / label for field   7
    868 TFORM7  = '1E      '           / data format of field: 4-byte REAL
    869 TTYPE8  = 'PSF_DOF '           / label for field   8
    870 TFORM8  = '1J      '           / data format of field: 4-byte INTEGER
    871 TTYPE9  = 'CR_SIGNIFICANCE'    / label for field   9
    872 TFORM9  = '1E      '           / data format of field: 4-byte REAL
    873 TTYPE10 = 'EXT_SIGNIFICANCE'   / label for field  10
    874 TFORM10 = '1E      '           / data format of field: 4-byte REAL
    875 TTYPE11 = 'PSF_MAJOR'          / label for field  11
    876 TFORM11 = '1E      '           / data format of field: 4-byte REAL
    877 TTYPE12 = 'PSF_MINOR'          / label for field  12
    878 TFORM12 = '1E      '           / data format of field: 4-byte REAL
    879 TTYPE13 = 'PSF_THETA'          / label for field  13
    880 TFORM13 = '1E      '           / data format of field: 4-byte REAL
    881 TTYPE14 = 'PSF_QUALITY'        / label for field  14
    882 TFORM14 = '1E      '           / data format of field: 4-byte REAL
    883 TTYPE15 = 'PSF_NPIX'           / label for field  15
    884 TFORM15 = '1J      '           / data format of field: 4-byte INTEGER
    885 TTYPE16 = 'MOMENTS_XX'         / label for field  16
    886 TFORM16 = '1E      '           / data format of field: 4-byte REAL
    887 TTYPE17 = 'MOMENTS_XY'         / label for field  17
    888 TFORM17 = '1E      '           / data format of field: 4-byte REAL
    889 TTYPE18 = 'MOMENTS_YY'         / label for field  18
    890 TFORM18 = '1E      '           / data format of field: 4-byte REAL
    891 TTYPE19 = 'N_POS   '           / label for field  19
    892 TFORM19 = '1J      '           / data format of field: 4-byte INTEGER
    893 TTYPE20 = 'F_POS   '           / label for field  20
    894 TFORM20 = '1E      '           / data format of field: 4-byte REAL
    895 TTYPE21 = 'RATIO_BAD'          / label for field  21
    896 TFORM21 = '1E      '           / data format of field: 4-byte REAL
    897 TTYPE22 = 'RATIO_MASK'         / label for field  22
    898 TFORM22 = '1E      '           / data format of field: 4-byte REAL
    899 TTYPE23 = 'RATIO_ALL'          / label for field  23
    900 TFORM23 = '1E      '           / data format of field: 4-byte REAL
    901 TTYPE24 = 'FLAGS   '           / label for field  24
    902 TFORM24 = '1J      '           / data format of field: 4-byte INTEGER
    903 TZERO24 =           2147483648 / offset for unsigned integers
    904 TSCAL24 =                    1 / data are not scaled
    905 TTYPE25 = 'DIFF_SKYFILE_ID'    / label for field  25
    906 TFORM25 = '1K      '           / data format of field: 8-byte INTEGER
    907 SWSOURCE= '60eb6cdc-a59c-4636-a4e0-dba66a9721fd' / Software source
    908 SWVERSN = 'branches/pap_mops/ppMops@25227' / Software version
    909 HISTORY ppMops at 2009-09-02T03:48:46.695783
    910 HISTORY psLib version: branches/pap_mops/psLib@25227
    911 HISTORY psLib source: 60eb6cdc-a59c-4636-a4e0-dba66a9721fd
    912 HISTORY ppMops version: branches/pap_mops/ppMops@25227
    913 HISTORY ppMops source: 60eb6cdc-a59c-4636-a4e0-dba66a9721fd
    914 EXP_NAME= 'o4995g0129o'        / Exposure name
    915 EXP_ID  =                77164 / Exposure identifier
    916 CHIP_ID =                24019 / Chip stage identifier
    917 CAM_ID  =                17726 / Cam stage identifier
    918 FAKE_ID =                10227 / Fake stage identifier
    919 WARP_ID =                 8842 / Warp stage identifier
    920 DIFF_ID =                19219 / Diff stage identifier
    921 DIFF_POS=                    F / Positive subtraction?
    922 MJD-OBS =     54995.4740598313 / MJD of exposure midpoint
    923 RA      = '18:25:01.988'       / Right Ascension of boresight
    924 DEC     = '-17:20:40.069'      / Declination of boresight
    925 TEL_ALT =            51.951873 / Telescope altitude
    926 TEL_AZ  =           179.483883 / Telescope azimuth
    927 EXPTIME =                  38. / Exposure time (sec)
    928 ROTANGLE=             333.1039 / Rotator position angle
    929 FILTER  = 'r.00000 '           / Filter name
    930 AIRMASS =                1.269 / Airmass of exposure
    931 OBSCODE = 'F51     '           / IAU Observatory code
    932 SEEING  =             1.678401 / Mean seeing
    933 MAGZP   =             28.65226 / Magnitude zero point
    934 MAGZPERR=             0.353063 / Error in magnitude zero point
    935 ASTRORMS=            0.3111496 / RMS of astrometric fit
    936 EXTNAME = 'MOPS_TRANSIENT_DETECTIONS'
    937 \end{verbatim}
    938 
    939 
    9401606\end{document}
    9411607
  • branches/eam_branches/ipp-20120905/ppTranslate/src/ppMops.h

    r34566 r34735  
    5959  psVector *raExtErr, *decExtErr;     // Error in sky coordinates for RA_EXT and DEC_EXT
    6060  psVector *mask;                     // Mask for detections
     61    float platescale; //Plate scale at centroid
    6162} ppMopsDetections;
    6263
  • branches/eam_branches/ipp-20120905/ppTranslate/src/ppMopsRead.c

    r34566 r34735  
    1 /*
    2  *
    3  *
    4  *
    5  *
    6  *
    7  *
    8  *
    9  *
    10  *
    11  *
    12  *
    13  *
    14  *
    15  *
    16  *
    17  *
    18  *
    19  *
    20  *
    21  *
    22  *
    23  *
    24  *
    25  *
    26  *
    27  *
    28  *
    29  *
    30  * THIS CODE CONTAINS DIRTY BUG FIXES!
    31  *
    32  *
    33  *
    34  *
    35  *
    36  *
    37  *
    38  * Look for "DIRTY_BUG_FIX" to know where
    39  *
    40  * and set the following to 0 to change the code
    41  */
    42 #define DIRTY_BUG_FIX 1
    43 /*
    44  *
    45  *
    46  *
    47  *
    48  *
    49  *
    50  *
    51  *
    52  *
    53  *
    54  *
    55  *
    56  *
    57  *
    58  *
    59  *
    60  *
    61  *
    62  *
    63  *
    64  *
    65  *
    66  *
    67  *
    68  *
    69  *
    70  *
    71  *
    72  *
    73  *
    74  *
    75  *
    76  *
    77  */
     1#define DIRTY_BUG_FIX 0
    782
    793#ifdef HAVE_CONFIG_H
     
    9014static void replaceDummyValuesS32(const char* colName, psMetadata* source, psMetadata* target, psVector* indexes);
    9115static void renameDummyValuesF32(const char* colNameSource, psMetadata* source, const char* colNameTarget, psMetadata* target, psVector* indexes);
    92 #if DIRTY_BUG_FIX
    93 static psVector* createDummyF32_default(long size, float default_value);
    94 #endif
    9516
    9617/*
     
    14566    if (skyChipPsfVersion != args->version) {
    14667      if (skyChipPsfVersion > args->version) {
    147         psWarning("The FITS data will be downgraded from PS1_DV%d to PS1_DV%d\n",
    148                   skyChipPsfVersion, args->version);
     68        psWarning("The FITS data will be downgraded from PS1_DV%d to PS1_DV%d\n",
     69                  skyChipPsfVersion, args->version);
    14970      } else { // Necessarily: skyChipPsfVersion > args->version
    150         psWarning("The FITS data will be upgraded from PS1_DV%d to PS1_DV%d (new values set to default 0, NaN...)\n",
    151                   skyChipPsfVersion, args->version);
     71        psWarning("The FITS data will be upgraded from PS1_DV%d to PS1_DV%d (new values set to default 0, NaN...)\n",
     72                  skyChipPsfVersion, args->version);
    15273      }
    15374    }
     
    199120      addDummyValues(det->table, size, args->version);
    200121      if (!psFitsMoveExtName(fits, "SkyChip.xfit")) {
    201         psTrace("ppMops.read", 3, "No fitted trails extension");
     122        psTrace("ppMops.read", 3, "No fitted trails extension");
    202123      } else {
    203         psTrace("ppMops.read", 3, "Fitted trails extension found\n");
    204         psTrace("ppMops.read", 10, "Getting size?\n");
    205         int fittedTrailsSize = psFitsTableSize(fits);
    206         psTrace("ppMops.read", 10, "size = %d\n", fittedTrailsSize);
    207         if (fittedTrailsSize <= 0) {
    208           psErrorStackPrint(stderr, "Unable to determine size of fitted trails extension table %d", i);
    209           psTrace("ppMops.read", 3, "No entry in fitted trails extension!!!!\n");
    210           psErrorClear();
    211         } else {
    212           psTrace("ppMops.read", 10, "Reading table of interest?\n");
    213           psMetadata* fittedTrails = psFitsReadTableAllColumns(fits); // Table of interest
    214           psTrace("ppMops.read", 10, "OK for table of interest\n");
    215           if (!fittedTrails) {
    216             psError(PS_ERR_IO, false, "Unable to read fittedTrails table in file %d", i);
    217             return NULL;
    218           }
    219           //Iterate on the different names and types expected in the fittedTrails parameters
    220           psTrace("ppMops.read", 10, "Getting IPP_IDET\n");
    221           psVector* idet = psMetadataLookupVector(NULL, fittedTrails, "IPP_IDET");
    222           replaceDummyValuesF32("X_EXT", fittedTrails, det->table, idet);
    223           replaceDummyValuesF32("Y_EXT", fittedTrails, det->table, idet);
    224           replaceDummyValuesF32("X_EXT_SIG", fittedTrails, det->table, idet);
    225           replaceDummyValuesF32("Y_EXT_SIG", fittedTrails, det->table, idet);
    226           replaceDummyValuesF32("EXT_INST_MAG",  fittedTrails, det->table, idet);
    227           replaceDummyValuesF32("EXT_INST_MAG_SIG",  fittedTrails, det->table, idet);
    228           replaceDummyValuesS32("NPARAMS",  fittedTrails, det->table, idet);
    229           replaceDummyValuesF32("EXT_WIDTH_MAJ",  fittedTrails, det->table, idet);
    230           replaceDummyValuesF32("EXT_WIDTH_MIN",  fittedTrails, det->table, idet);
    231           replaceDummyValuesF32("EXT_THETA",  fittedTrails, det->table, idet);
    232           replaceDummyValuesF32("EXT_WIDTH_MAJ_ERR",  fittedTrails, det->table, idet);
    233           // EXT_WIDTH_MIN_ERR is actually undefined but set to 0. in CMF files
    234           // We explicitely let it set to NaN, hence the commented out
    235           // following line
    236           //replaceDummyValuesF32("EXT_WIDTH_MIN_ERR",  fittedTrails, det->table, idet);
    237           replaceDummyValuesF32("EXT_THETA_ERR",  fittedTrails, det->table, idet);
    238           psTrace("ppMops.read", 10, "Got all version 2 values\n");
    239           if (skyChipPsfVersion >= 3) {
    240             psTrace("ppMops.read", 10, "Getting PS1_DV3 data\n");
    241             replaceDummyValuesF32("RA_EXT",  fittedTrails, det->table, idet);
    242             // Note: RA_EXT_SIGMA is computed (see det->raExtErr)
    243             replaceDummyValuesF32("DEC_EXT",  fittedTrails, det->table, idet);
    244             // Note: DEC_EXT_SIGMA is computed (see det->decExtErr)
    245             //Note: POSANG_EXT is POSANGLE in xfit
    246 #if DIRTY_BUG_FIX
    247 #else
    248             renameDummyValuesF32("POSANGLE",  fittedTrails, "POSANG_EXT", det->table, idet);
    249 #endif   
    250             //Note: PLTSCALE_EXT in xfit is PLTSCALE
    251             renameDummyValuesF32("PLTSCALE", fittedTrails, "PLTSCALE_EXT", det->table, idet);
    252             renameDummyValuesF32("EXT_INST_FLUX", fittedTrails, "EXT_FLUX", det->table, idet);
    253             replaceDummyValuesF32("EXT_CAL_MAG", fittedTrails, det->table, idet);
    254             renameDummyValuesF32("EXT_INST_MAG_SIG", fittedTrails, "EXT_MAG_SIG", det->table, idet);
    255             replaceDummyValuesF32("EXT_CHISQ", fittedTrails, det->table, idet);
    256             replaceDummyValuesS32("EXT_NDOF", fittedTrails, det->table, idet);
    257             psTrace("ppMops.read", 10, "Got all version 3 values\n");
    258           }
    259         }
     124        psTrace("ppMops.read", 3, "Fitted trails extension found\n");
     125        psTrace("ppMops.read", 10, "Getting size?\n");
     126        int fittedTrailsSize = psFitsTableSize(fits);
     127        psTrace("ppMops.read", 10, "size = %d\n", fittedTrailsSize);
     128        if (fittedTrailsSize <= 0) {
     129          psErrorStackPrint(stderr, "Unable to determine size of fitted trails extension table %d", i);
     130          psTrace("ppMops.read", 3, "No entry in fitted trails extension!!!!\n");
     131          psErrorClear();
     132        } else {
     133          psTrace("ppMops.read", 10, "Reading table of interest?\n");
     134          psMetadata* fittedTrails = psFitsReadTableAllColumns(fits); // Table of interest
     135          psTrace("ppMops.read", 10, "OK for table of interest\n");
     136          if (!fittedTrails) {
     137            psError(PS_ERR_IO, false, "Unable to read fittedTrails table in file %d", i);
     138            return NULL;
     139          }
     140          //Iterate on the different names and types expected in the fittedTrails parameters
     141          psTrace("ppMops.read", 10, "Getting IPP_IDET\n");
     142          psVector* idet = psMetadataLookupVector(NULL, fittedTrails, "IPP_IDET");
     143          replaceDummyValuesF32("X_EXT", fittedTrails, det->table, idet);
     144          replaceDummyValuesF32("Y_EXT", fittedTrails, det->table, idet);
     145          replaceDummyValuesF32("X_EXT_SIG", fittedTrails, det->table, idet);
     146          replaceDummyValuesF32("Y_EXT_SIG", fittedTrails, det->table, idet);
     147          replaceDummyValuesF32("EXT_INST_MAG",  fittedTrails, det->table, idet);
     148          replaceDummyValuesF32("EXT_INST_MAG_SIG",  fittedTrails, det->table, idet);
     149          replaceDummyValuesS32("NPARAMS",  fittedTrails, det->table, idet);
     150          replaceDummyValuesF32("EXT_WIDTH_MAJ",  fittedTrails, det->table, idet);
     151          replaceDummyValuesF32("EXT_WIDTH_MIN",  fittedTrails, det->table, idet);
     152          replaceDummyValuesF32("EXT_THETA",  fittedTrails, det->table, idet);
     153          replaceDummyValuesF32("EXT_WIDTH_MAJ_ERR",  fittedTrails, det->table, idet);
     154          // EXT_WIDTH_MIN_ERR is actually undefined but set to 0. in CMF files
     155          // We explicitely let it set to NaN, hence the commented out
     156          // following line
     157          //replaceDummyValuesF32("EXT_WIDTH_MIN_ERR",  fittedTrails, det->table, idet);
     158          replaceDummyValuesF32("EXT_THETA_ERR",  fittedTrails, det->table, idet);
     159          psTrace("ppMops.read", 10, "Got all version 2 values\n");
     160          if (skyChipPsfVersion >= 3) {
     161            psTrace("ppMops.read", 10, "Getting PS1_DV3 data\n");
     162            replaceDummyValuesF32("RA_EXT",  fittedTrails, det->table, idet);
     163            // Note: RA_EXT_SIGMA is computed (see det->raExtErr)
     164            replaceDummyValuesF32("DEC_EXT",  fittedTrails, det->table, idet);
     165            // Note: DEC_EXT_SIGMA is computed (see det->decExtErr)
     166            //Note: POSANG_EXT is POSANGLE in xfit
     167            renameDummyValuesF32("POSANGLE",  fittedTrails, "POSANG_EXT", det->table, idet);
     168            //Not written anymore but still used in computation
     169            renameDummyValuesF32("PLTSCALE", fittedTrails, "PLTSCALE_EXT", det->table, idet);
     170            renameDummyValuesF32("EXT_INST_FLUX", fittedTrails, "EXT_FLUX", det->table, idet);
     171            replaceDummyValuesF32("EXT_CAL_MAG", fittedTrails, det->table, idet);
     172            renameDummyValuesF32("EXT_INST_MAG_SIG", fittedTrails, "EXT_MAG_SIG", det->table, idet);
     173            replaceDummyValuesF32("EXT_CHISQ", fittedTrails, det->table, idet);
     174            replaceDummyValuesS32("EXT_NDOF", fittedTrails, det->table, idet);
     175            psTrace("ppMops.read", 10, "Got all version 3 values\n");
     176          }
     177        }
    260178      }
    261179    }
     
    264182    if (args->version == 0) {
    265183      if (skyChipPsfVersion < 2) {
    266         // XXX: TODO: Do we need to add dummy vectors for the missing columns?
     184        // XXX: TODO: Do we need to add dummy vectors for the missing columns?
    267185      }
    268186    }
     
    324242      psU32 flags = flagsV->data.U32[row]; // psFitsTableGetU32(NULL, table, row, "FLAGS");
    325243      if (flags & SOURCE_MASK) {
    326         psTrace("ppMops.read", 10, "Discarding row %ld from input %d because of flags: %ud", row, i, flags);
    327         det->mask->data.U8[row] = 0xFF;
    328         continue;
     244        psTrace("ppMops.read", 10, "Discarding row %ld from input %d because of flags: %ud", row, i, flags);
     245        det->mask->data.U8[row] = 0xFF;
     246        continue;
    329247      }
    330248
     
    333251      double yErr = yErrV->data.F32[row];
    334252      double scale = scaleV->data.F32[row];
    335 #if DIRTY_BUG_FIX
    336       double angle = 0. * angleV->data.F32[row];
    337 #else
    338253      double angle = angleV->data.F32[row];
    339 #endif
    340 
    341254      if (!isfinite(det->x->data.F32[row]) || !isfinite(det->y->data.F32[row]) ||
    342           !isfinite(det->ra->data.F64[row]) || !isfinite(det->dec->data.F64[row]) ||
    343           !isfinite(mag->data.F32[row]) || !isfinite(magErr->data.F32[row]) ||
    344           !isfinite(xErr) || !isfinite(yErr) || !isfinite(scale) || !isfinite(angle)) {
    345         psTrace("ppMops.read", 10,
    346                 "Discarding row %ld from input %d because of non-finite values: "
    347                 "%f %f %lf %lf %f %f %f %f %f %f",
    348                 row, i,
    349                 det->x->data.F32[row], det->y->data.F32[row],
    350                 det->ra->data.F64[row], det->dec->data.F64[row],
    351                 mag->data.F32[row], magErr->data.F32[row],
    352                 xErr, yErr, scale, angle);
    353         det->mask->data.U8[row] = 0xFF;
    354         continue;
     255          !isfinite(det->ra->data.F64[row]) || !isfinite(det->dec->data.F64[row]) ||
     256          !isfinite(mag->data.F32[row]) || !isfinite(magErr->data.F32[row]) ||
     257          !isfinite(xErr) || !isfinite(yErr) || !isfinite(scale) || !isfinite(angle)) {
     258        psTrace("ppMops.read", 10,
     259                "Discarding row %ld from input %d because of non-finite values: "
     260                "%f %f %lf %lf %f %f %f %f %f %f",
     261                row, i,
     262                det->x->data.F32[row], det->y->data.F32[row],
     263                det->ra->data.F64[row], det->dec->data.F64[row],
     264                mag->data.F32[row], magErr->data.F32[row],
     265                xErr, yErr, scale, angle);
     266        det->mask->data.U8[row] = 0xFF;
     267        continue;
    355268      }
    356269
     
    364277      det->mask->data.U8[row] = 0;
    365278      plateScale += scale;
     279      //Update the platescale value (should be a constant)
     280      if (isfinite(scale)) {
     281          det->platescale = scale;
     282      }
    366283      numGood++;
    367284
    368285      // Same for EXT data if version permits
    369286      if (skyChipPsfVersion >= 3) {
    370         xErr = xExtErrV->data.F32[row];
    371         yErr = yExtErrV->data.F32[row];
    372         scale = scaleExtV->data.F32[row]/3600.;
    373 #if DIRTY_BUG_FIX
    374         angle = 0.;
    375 #else
    376         angle = angleExtV->data.F32[row];
    377 #endif
    378         cosAngle = cos(angle);
    379         sinAngle = sin(angle);
    380         cosAngle2 = PS_SQR(cosAngle);
    381         sinAngle2 = PS_SQR(sinAngle);
    382         xErr2 = PS_SQR(xErr);
    383         yErr2 = PS_SQR(yErr);
    384         errScale = scale / 3600.0;
    385         det->raExtErr->data.F64[row] = errScale * sqrt(cosAngle2 * xErr2 + sinAngle2 * yErr2);
    386         det->decExtErr->data.F64[row] = errScale * sqrt(sinAngle2 * xErr2 + cosAngle2 * yErr2);
     287        xErr = xExtErrV->data.F32[row];
     288        yErr = yExtErrV->data.F32[row];
     289        scale = scaleExtV->data.F32[row]/3600.;
     290        angle = angleExtV->data.F32[row];
     291        cosAngle = cos(angle);
     292        sinAngle = sin(angle);
     293        cosAngle2 = PS_SQR(cosAngle);
     294        sinAngle2 = PS_SQR(sinAngle);
     295        xErr2 = PS_SQR(xErr);
     296        yErr2 = PS_SQR(yErr);
     297        errScale = scale / 3600.0;
     298        det->raExtErr->data.F64[row] = errScale * sqrt(cosAngle2 * xErr2 + sinAngle2 * yErr2);
     299        det->decExtErr->data.F64[row] = errScale * sqrt(sinAngle2 * xErr2 + cosAngle2 * yErr2);
    387300      }
    388301    }
     
    406319  return dummy;
    407320}
    408 #if DIRTY_BUG_FIX
    409 static psVector* createDummyF32_default(long size, float default_value) {
    410   psVector* dummy = psVectorAlloc(size, PS_TYPE_F32);
    411   psVectorInit(dummy, default_value);
    412   return dummy;
    413 }
    414 #endif
     321
    415322static psVector* createDummyS32(long size) {
    416323  psVector* dummy = psVectorAlloc(size, PS_TYPE_S32);
    417   psVectorInit(dummy, NAN);
     324  psVectorInit(dummy, 0);
    418325  return dummy;
    419326}
     
    439346    psMetadataAdd(md, PS_LIST_TAIL, "DEC_EXT",  PS_DATA_VECTOR, "Fitted centroid DEC", createDummyF32(size));
    440347/*     psMetadataAdd(md, PS_LIST_TAIL, "DEC_EXT_SIGMA",  PS_DATA_VECTOR, "Fitted DEC sigma", createDummyF32(size)); *\/ */
    441 #if DIRTY_BUG_FIX
    442     psMetadataAdd(md, PS_LIST_TAIL, "POSANG_EXT",  PS_DATA_VECTOR, "Fitted position angle", createDummyF32_default(size, 0.));
    443 #else
    444348    psMetadataAdd(md, PS_LIST_TAIL, "POSANG_EXT",  PS_DATA_VECTOR, "Fitted position angle", createDummyF32(size));
    445 #endif
    446349    psMetadataAdd(md, PS_LIST_TAIL, "PLTSCALE_EXT",  PS_DATA_VECTOR, "Plate scale at centroid", createDummyF32(size));
    447350    psMetadataAdd(md, PS_LIST_TAIL, "EXT_FLUX",  PS_DATA_VECTOR, "Fitted flux", createDummyF32(size));
  • branches/eam_branches/ipp-20120905/ppTranslate/src/ppMopsWrite.c

    r34566 r34735  
    4848    }
    4949  }
    50   //Get the SEEING weighted mean
     50  //Get the SEEING weighted mean. Update the PLTSCALE value
    5151  float seeing = 0.;
    5252  int totalGood = 0;
     
    5555      seeing += ((ppMopsDetections*) detections->data[d])->seeing;
    5656      totalGood += 1;
    57     }
    58   }
     57      if (isfinite(((ppMopsDetections*) detections->data[d])->platescale)) {
     58          det->platescale = ((ppMopsDetections*) detections->data[d])->platescale;
     59      }
     60    }
     61  }
     62  printf("plate-scale = [%g]\n", det->platescale);
    5963  seeing /= (float) totalGood;
    6064  if (det != NULL) {
     
    8084  psMetadataAddF32(header, PS_LIST_TAIL, "MAGZPERR", 0, "Error in magnitude zero point", args->zpErr);
    8185  psMetadataAddF32(header, PS_LIST_TAIL, "ASTRORMS", 0, "RMS of astrometric fit", args->rmsAstrom);
    82   psMetadataAddStr(header, PS_LIST_TAIL, "COMMENT", 0, "Exposure comment", args->comment);
     86  psMetadataAddStr(header, PS_LIST_TAIL, "CMMTOBS", 0, "Exposure comment", args->comment);
    8387  psMetadataAddStr(header, PS_LIST_TAIL, "OBS_MODE", 0, "Exposure observation mode", args->obsMode);
    8488  psMetadataAddStr(header, PS_LIST_TAIL, "DIFFTYPE", 0, "WW: Warp-Warp diff / WS: Warp-Stack diff / SW: Stack-Warp diff", args->difftype);
    8589  psMetadataAddF32(header, PS_LIST_TAIL, "SKY", 0, "Exposure avg sky background", args->sky);
    8690  psMetadataAddStr(header, PS_LIST_TAIL, "SHUTOUTC", 0, "Camera exposure shutter open (UTC)", args->shutoutc);
     91  psMetadataAddF32(header, PS_LIST_TAIL, "PLTSCALE_EXT", 0, "Plate scale at centroid", det->platescale);
     92  psMetadataAddF32(header, PS_LIST_TAIL, "PLTSCALE", 0, "Plate scale at centroid", det->platescale);
    8793
    8894  //field in header that tells about the CMF version
     
    9298
    9399  // Find the total number of detections
    94 
    95100  long total = 0;
    96101  for (long i=0; i<detections->n; i++) {
     
    191196                     0);
    192197      if (args->version == 3) {
    193         // Write data of version 3 (see ICD)
    194         psMetadataAdd (row, PS_LIST_TAIL, "RA_EXT",         PS_DATA_F32, "Fitted centroid RA",
    195                        0);
    196         psMetadataAdd (row, PS_LIST_TAIL, "RA_EXT_SIGMA",   PS_DATA_F32, "Fitted RA sigma",
    197                        0);
    198         psMetadataAdd (row, PS_LIST_TAIL, "DEC_EXT",        PS_DATA_F32, "Fitted centroid DEC",
    199                        0);
    200         psMetadataAdd (row, PS_LIST_TAIL, "DEC_EXT_SIGMA",  PS_DATA_F32, "Fitted DEC sigma",
    201                        0);
    202         psMetadataAdd (row, PS_LIST_TAIL, "POSANG_EXT",     PS_DATA_F32, "Fitted position angle",
    203                        0);
    204         psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE_EXT",   PS_DATA_F32, "Plate scale at centroid",
    205                        0);
    206         psMetadataAdd (row, PS_LIST_TAIL, "EXT_FLUX",       PS_DATA_F32, "Fitted flux",
    207                        0);
    208         psMetadataAdd (row, PS_LIST_TAIL, "EXT_CAL_MAG",    PS_DATA_F32, "Calibrated mag",
    209                        0);
    210         psMetadataAdd (row, PS_LIST_TAIL, "EXT_MAG_SIG",    PS_DATA_F32, "Mag sigma",
    211                        0);
    212         psMetadataAdd (row, PS_LIST_TAIL, "EXT_CHISQ",      PS_DATA_F32, "Chi^2 of fit",
    213                        0);
    214         psMetadataAdd (row, PS_LIST_TAIL, "EXT_NDOF",       PS_DATA_F32, "Fit degrees of freedom",
    215                        0);
     198// Write data of version 3 (see ICD)
     199        psMetadataAdd (row, PS_LIST_TAIL, "RA_EXT",         PS_DATA_F32, "Fitted centroid RA",
     200                       0);
     201        psMetadataAdd (row, PS_LIST_TAIL, "RA_EXT_SIGMA",   PS_DATA_F32, "Fitted RA sigma",
     202                       0);
     203        psMetadataAdd (row, PS_LIST_TAIL, "DEC_EXT",        PS_DATA_F32, "Fitted centroid DEC",
     204                       0);
     205        psMetadataAdd (row, PS_LIST_TAIL, "DEC_EXT_SIGMA",  PS_DATA_F32, "Fitted DEC sigma",
     206                       0);
     207        psMetadataAdd (row, PS_LIST_TAIL, "POSANG_EXT",     PS_DATA_F32, "Fitted position angle",
     208                       0);
     209        psMetadataAdd (row, PS_LIST_TAIL, "EXT_FLUX",       PS_DATA_F32, "Fitted flux",
     210                       0);
     211        psMetadataAdd (row, PS_LIST_TAIL, "EXT_CAL_MAG",    PS_DATA_F32, "Calibrated mag",
     212                       0);
     213        psMetadataAdd (row, PS_LIST_TAIL, "EXT_MAG_SIG",    PS_DATA_F32, "Mag sigma",
     214                       0);
     215        psMetadataAdd (row, PS_LIST_TAIL, "EXT_CHISQ",      PS_DATA_F32, "Chi^2 of fit",
     216                       0);
     217        psMetadataAdd (row, PS_LIST_TAIL, "EXT_NDOF",       PS_DATA_F32, "Fit degrees of freedom",
     218                       0);
    216219      }
    217220    }
     
    308311      addColumn("DEC_EXT_SIGMA", NULL, 0);
    309312      addColumn("POSANG_EXT", NULL, 0);
    310       addColumn("PLTSCALE_EXT", NULL, 0);
    311313      addColumn("EXT_FLUX", NULL, 0);
    312314      addColumn("EXT_CAL_MAG", NULL, 0);
  • branches/eam_branches/ipp-20120905/psLib/share/tai_utc.dat

    r22679 r34735  
    1212#          JD           TAI-UTC    Const 1       Const 2
    1313#        (days)          (sec)      (none)       (none)
    14 #          psF64                 psF64      psF64         psF64
     14#         psF64         psF64      psF64         psF64
    1515        2437300.5      1.4228180    37300.0     0.0012960
    1616        2437512.5      1.3728180    37300.0     0.0012960
     
    5151        2453736.5     33.0000000    41317.0     0.0000000
    5252        2454832.5     34.0000000    41317.0     0.0000000
     53        2456109.5     35.0000000    41317.0     0.0000000
  • branches/eam_branches/ipp-20120905/psLib/share/tai_utc.raw

    r22679 r34735  
    3737 2006 JAN  1 =JD 2453736.5  TAI-UTC=  33.0       S + (MJD - 41317.) X 0.0      S
    3838 2009 JAN  1 =JD 2454832.5  TAI-UTC=  34.0       S + (MJD - 41317.) X 0.0      S
     39 2012 JUL  1 =JD 2456109.5  TAI-UTC=  35.0       S + (MJD - 41317.) X 0.0      S
  • branches/eam_branches/ipp-20120905/psLib/src/imageops/psImageConvolve.c

    r33089 r34735  
    605605    PS_ASSERT_IMAGE_NON_NULL(image, false);
    606606
     607    if (sigma < 0.25) {
     608        psTrace("psLib.imageops", 5, "sigma: %f < 0.25 skipping smoothing", sigma);
     609        return true;
     610    }
     611
    607612    // relevant terms
    608613    int Nrange = sigma*Nsigma + 0.5;    // Number of pixels either side for convolution kernel
     614    if (Nrange < 1) {
     615        // using zero will cause an arithmetic exception in the loop
     616        psTrace("psLib.imageops", 5, "Nrange %d for smoothing too small skipping smoothing", Nrange);
     617        return true;
     618    }
    609619    int Nx = image->numCols;            // Number of columns
    610620    int Ny = image->numRows;            // Number of rows
  • branches/eam_branches/ipp-20120905/psLib/src/math/psHistogram.c

    r27553 r34735  
    5858    psTrace("psLib.math", 3, "---- %s() begin  ----\n", __func__);
    5959    psTrace("psLib.math", 5, "(lower, upper, n) is (%f, %f, %d)\n", lower, upper, n);
    60     psAssert(n > 0, "Number of bins must be positive");
     60    psAssert(n > 0, "Number of bins must be positive not %d", n);
    6161    psAssert(upper >= lower, "Bounds must be sensical");
    6262
  • branches/eam_branches/ipp-20120905/psLib/src/math/psStats.c

    r31152 r34735  
    764764            goto escape;
    765765        }
     766        if (!isfinite(max - min)) {
     767            COUNT_WARNING(10, 100, "Range of of the input vector is too large: %lf.\n", (double)max - (double) min);
     768            goto escape;
     769        }
    766770        psTrace(TRACE, 6, "Data min/max is (%.2f, %.2f)\n", min, max);
    767771
     
    802806        psTrace(TRACE, 6, "Numbins is %ld\n", numBins);
    803807        psTrace(TRACE, 6, "Creating a robust histogram from data range (%.2f - %.2f)\n", min, max);
     808
     809        // We are sometimes causing psHistogramAlloc to assert.
     810        // Assert here so we can get more information about what is going wrong.
     811        psAssert(numBins > 0, "Invalid numBins: %ld max: %f min: %f binSize: %f", numBins, max, min, binSize);
     812       
    804813        // Generate the histogram
    805814        histogram = psHistogramAlloc(min - 2.0*binSize, max + 2.0*binSize, numBins);
     
    858867            // if we did not mask anything, give up.
    859868        }
     869
     870        // We were causing psHistogramAlloc to assert.
     871        // Assert here so we can get more information about what is going wrong.
     872        psAssert(numBins > 0, "Invalid numBins %ld max: %f min: %f binSize: %f", numBins, max, min, binSize);
    860873
    861874        // ADD step 1: Convert the specific histogram to a cumulative histogram
  • branches/eam_branches/ipp-20120905/psModules

  • branches/eam_branches/ipp-20120905/psModules/src/objects

    • Property svn:ignore
      •  

        old new  
        77pmSourceIO_CMF_PS1_V1.c
        88pmSourceIO_CMF_PS1_V2.c
         9pmSourceIO_CMF_PS1_V2.v1.c
        910pmSourceIO_CMF_PS1_V3.c
         11pmSourceIO_CMF_PS1_V3.v1.c
         12pmSourceIO_CMF_PS1_V1.v1.c
        1013pmSourceIO_CMF_PS1_V4.c
        1114pmSourceIO_CMF_PS1_SV1.c
         
        1417pmSourceIO_CMF_PS1_DV2.c
        1518pmSourceIO_CMF_PS1_DV3.c
         19
  • branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceIO.c

    r34568 r34735  
    10281028        if (strcmp (xtension, "BINTABLE")) {
    10291029            psWarning ("no binary table in extension %s, skipping\n", dataname);
     1030            psFree(tableHeader);
    10301031            return false;
    10311032        }
     
    12421243    if (!xtension) psAbort("cannot read table type");
    12431244    if (strcmp (xtension, "BINTABLE")) {
     1245        psFree(tableHeader);
    12441246        psWarning ("no binary table in extension %s, skipping\n", xsrcname);
    12451247        return false;
     
    12811283    if (strcmp (xtension, "BINTABLE")) {
    12821284        psWarning ("no binary table in extension %s, skipping\n", extname);
     1285        psFree(tableHeader);
    12831286        return false;
    12841287    }
     
    13181321    if (strcmp (xtension, "BINTABLE")) {
    13191322        psWarning ("no binary table in extension %s, skipping\n", extname);
     1323        psFree(tableHeader);
    13201324        return false;
    13211325    }
  • branches/eam_branches/ipp-20120905/psphot

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

  • branches/eam_branches/ipp-20120905/psphot/src/psphotDeblendSatstars.c

    r34570 r34735  
    498498    psStatsInit (fluxStats);
    499499
    500     while (logR->data.F32[bin] < lRmax) {
     500    while (bin < logR->n && logR->data.F32[bin] < lRmax) {
    501501      if (isfinite(flux->data.F32[bin])) {
    502502          psVectorAppend (fluxVals, flux->data.F32[bin]);
  • branches/eam_branches/ipp-20120905/psphot/src/psphotReplaceUnfit.c

    r34570 r34735  
    3535    // loop over the available readouts
    3636    for (int i = 0; i < num; i++) {
    37         if (!psphotReplaceAllSourcesReadout (config, view, filerule, i, recipe, ignoreState)) {
    38             psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for %s entry %d", filerule, i);
    39             return false;
    40         }
     37        // ignore return value. False means "sources not subtracted", not a failure condition
     38        (void) psphotReplaceAllSourcesReadout (config, view, filerule, i, recipe, ignoreState);
    4139    }
    4240    return true;
  • branches/eam_branches/ipp-20120905/psphot/src/psphotStackImageLoop.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/psphot/src/psphotStackMatchPSFs.c

    r34404 r34735  
    108108    bool notMatched = psMetadataLookupBool(NULL, readoutOut->analysis, "NOT.PSF.MATCHED");
    109109    if (notMatched) {
    110         if (!readoutOut->image) {
    111             // our images got freed in the matching process. Recreate them so that they
    112             // are available when sources are copied to this readout.
    113             readoutOut->image = psImageCopy(NULL, readoutSrc->image, PS_TYPE_F32);
    114             if (readoutSrc->variance) {
    115                 psFree(readoutOut->variance);
    116                 readoutOut->variance = psImageCopy(NULL, readoutSrc->variance, PS_TYPE_F32);
    117             }
    118             if (readoutSrc->mask) {
    119                 psFree(readoutOut->mask);
    120                 readoutOut->mask = psImageCopy(NULL, readoutSrc->mask, PS_TYPE_IMAGE_MASK);
    121             }
     110        psFree(readoutOut->image);
     111        readoutOut->image = psImageCopy(NULL, readoutSrc->image, PS_TYPE_F32);
     112        psFree(readoutOut->variance);
     113        if (readoutSrc->variance) {
     114            readoutOut->variance = psImageCopy(NULL, readoutSrc->variance, PS_TYPE_F32);
     115        }
     116        psFree(readoutOut->mask);
     117        if (readoutSrc->mask) {
     118            readoutOut->mask = psImageCopy(NULL, readoutSrc->mask, PS_TYPE_IMAGE_MASK);
    122119        }
    123120    }
  • branches/eam_branches/ipp-20120905/psphot/src/psphotStackMatchPSFsUtils.c

    r34352 r34735  
    303303        if (!pmSubtractionMatch(NULL, readoutOut, fake, readoutSrc, footprint, stride, regionSize, spacing, threshold, stampSources, stampsName, type, size, order, widthsCopy, orders, inner, ringsOrder, binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej, normFrac, sysError, skyErr, kernelError, covarFrac, maskVal, maskBad, maskPoor, poorFrac, badFrac, PM_SUBTRACTION_MODE_2)) {
    304304            int errorCode = psErrorCodeLast();
    305             if (errorCode == PM_ERR_SMALL_AREA) {
     305            if (errorCode == PM_ERR_SMALL_AREA || errorCode == PM_ERR_STAMPS) {
    306306                // failed to match but, don't fault. Just drop this input from measurements that need the
    307307                // matched readout.
     308                psErrorClear();
    308309                rejectReadout = true;
    309                 psLogMsg("psphot", PS_LOG_WARN, "PSF match failed for input %d. Too few pixels.", index);
     310                if (errorCode == PM_ERR_SMALL_AREA) {
     311                    psLogMsg("psphot", PS_LOG_WARN, "PSF match failed for input %d. Too few pixels.", index);
     312                } else if (errorCode == PM_ERR_STAMPS) {
     313                    psLogMsg("psphot", PS_LOG_WARN, "PSF match failed for input %d. Failed to find stamps.", index);
     314                }
    310315            } else {
    311316                psError(psErrorCodeLast(), false, "Unable to match images.");
     
    324329   
    325330    if (rejectReadout) {
     331        psMetadataAddBool(readoutSrc->analysis, PS_LIST_TAIL, "NOT.PSF.MATCHED", PS_META_REPLACE, "", true);
    326332        psMetadataAddBool(readoutOut->analysis, PS_LIST_TAIL, "NOT.PSF.MATCHED", PS_META_REPLACE, "", true);
    327333    } else {
     334        psMetadataAddBool(readoutSrc->analysis, PS_LIST_TAIL, "NOT.PSF.MATCHED", PS_META_REPLACE, "", false);
    328335        psMetadataAddBool(readoutOut->analysis, PS_LIST_TAIL, "NOT.PSF.MATCHED", PS_META_REPLACE, "", false);
    329336    }
  • branches/eam_branches/ipp-20120905/psphot/src/psphotStackReadout.c

    r34570 r34735  
    409409            }
    410410        }
     411        // mark any inputs that we want to skip the matched apertures for
     412        psphotStackSetInputsToSkip(config, view, STACK_CNV, true);
     413        psphotStackSetInputsToSkip(config, view, STACK_OUT, true);
    411414        psphotRadialApertures (config, view, STACK_CNV, 0); // entry 0 == unmatched
    412415        psMemDump("extmeas");
    413416
    414         // mark any inputs that we want to skip the matched apertures for
    415         psphotStackSetInputsToSkip(config, view, STACK_OUT, true);
    416417
    417418        int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT);
     
    439440        }
    440441    }
     442    psphotStackSetInputsToSkip(config, view, STACK_CNV, false);
    441443    psphotStackSetInputsToSkip(config, view, STACK_OUT, false);
    442444
  • branches/eam_branches/ipp-20120905/pstamp/scripts

  • branches/eam_branches/ipp-20120905/pstamp/scripts/psmkreq

    r34466 r34735  
    5252my $comment;
    5353
    54 my $survey_name = 'null';
    55 my $release = 'null';
    56 my $stack_type = 'null';
    57 my $bgrestore;
    58 my $jpeg;
    59 my $nocompress;
    60 
    6154my $missing_tools;
    6255my $pstamp_request_file  = can_run('pstamp_request_file')  or (warn "Can't find required program pstamp_request_file"  and $missing_tools = 1);
     
    7568    'width=i'           => \$width,
    7669    'height=i'          => \$height,
    77 # pixcenter is deprecated
    78 #    'pixcenter'         => \$pixcenter,
     70    'pixcenter'         => \$pixcenter,
    7971    'arcseconds'        => \$arcseconds,
    8072    'coord_mask=i'      => \$coord_mask,
     
    9587    'comment=s'         => \$comment,
    9688
    97     # new columns for version 2
    98     'survey=s'          => \$survey_name,
    99     'release=s'         => \$release,
    100     'stack_type'        => \$stack_type,
    101 
    10289    'option_mask=i'     => \$option_mask,
    10390    'image'             => \$image,
    10491    'mask'              => \$mask,
    10592    'variance'          => \$variance,
    106     'sources'           => \$cmf,
     93    'cmf'               => \$cmf,
    10794    'psf'               => \$psf,
    10895    'backmdl'           => \$backmdl,
     
    11299    'do_not_wait'       => \$no_wait,
    113100
    114     # new options for version 2
    115     'no_compress'       => \$nocompress,
    116     'bgrestore'         => \$bgrestore,
    117 
    118101    'verbose'           => \$verbose,
    119102    'save-temps'        => \$save_temps,
     
    127110
    128111pod2usage( -msg => "Invalid job_type: $job_type", -exitval =>1 )
    129         unless ($job_type eq 'stamp' or $job_type eq 'get_image' or $job_type eq 'listtargets');
    130 
    131 if (($job_type eq 'stamp') or ($job_type eq 'listtargets')) {
     112        unless ($job_type eq 'stamp' or $job_type eq 'get_image');
     113
     114if ($job_type eq 'stamp') {
    132115    if (defined $list) {
    133116        pod2usage( -msg => "--ra --dec --x --y are not used with --list", -exitval =>1 )
     
    169152$id = 0 if !$id;
    170153
    171 
    172 unless (($job_type eq 'listtargets' and $stage eq 'exposure') or $stage eq 'raw' or $stage eq 'chip' or $stage eq 'warp' or $stage eq 'diff' or $stage eq 'stack') {
    173     die "$stage is not a valid stage for $job_type jobs\n";
     154unless ($stage eq 'raw' or $stage eq 'chip' or $stage eq 'warp' or $stage eq 'diff' or $stage eq 'stack') {
     155    die "$stage is not a valid value for stage\n";
    174156}
    175157
     
    225207} else {
    226208    $rows = [];
    227     push @$rows, buildRow("", $comment, $x, $y, $filter, $mjd_min, $mjd_max, $survey_name, $release, $stack_type);
     209    push @$rows, buildRow("", $comment, $x, $y, $filter, $mjd_min, $mjd_max);
    228210}
    229211
    230212my ($tdf, $table_def_name) = tempfile ("/tmp/tabledef.XXXX", UNLINK => !$save_temps);
    231 print $tdf "$req_name 2\n";
     213print $tdf "$req_name 1\n";
    232214my $rownum = 0;
    233215foreach my $row (@$rows) {
    234216    $rownum++;
    235217    my $line = "$rownum $row->{ra}\t$row->{dec}\t$width $height"
    236         . " $coord_mask $job_type $option_mask $project $row->{survey_name} $row->{release} $req_type"
     218        . " $coord_mask $job_type $option_mask $project $req_type"
    237219        . " $stage $id $tess_id $component $data_group"
    238         . " $row->{filter} $row->{mjd_min} $row->{mjd_max} $row->{stack_type}";
     220        . " $row->{filter} $row->{mjd_min} $row->{mjd_max}";
    239221
    240222    if ($row->{comment} and $row->{comment} ne '') {
     
    248230}
    249231close $tdf;
    250 
    251 system "cat $table_def_name";
    252 #exit 0;
    253232
    254233{
     
    298277    $row->{dec}     = checkDEC($vals[1], $linenumber);
    299278    $row->{filter}  = checkFilter($vals[2], $filter, $linenumber);
    300     $row->{mjd_min} = checkMJD($vals[3], $mjd_min, $linenumber);
    301     $row->{mjd_max} = checkMJD($vals[4], $mjd_max, $linenumber);
    302     $row->{survey_name}  = $vals[5];
    303     $row->{release} = $vals[6];
    304     $row->{stack_type} = $vals[7];
     279    $row->{mjd_min} = checkMJD($vals[3], $mjd_min, $linenumber);;
     280    $row->{mjd_max} = checkMJD($vals[4], $mjd_max, $linenumber);;
    305281    $row->{comment} = $comment;
    306282
  • branches/eam_branches/ipp-20120905/pstamp/scripts/pstamp_checkdependent.pl

    r34466 r34735  
    262262        } elsif ($chip->{state} eq 'goto_cleaned') {
    263263
    264             if ($chip->{data_state} eq 'full') {
    265                 # cleanup has been queued, but has not yet finished. (cleanup pantasks is probably stopped)
    266                 # Since this chip is in full go ahead and set the run to state update and change the label.
     264            # we don't need to check for full data_state
     265            # if ($chip->{data_state} eq 'full') {
     266            {
     267                # cleanup must not be running. Set state to update. If this chip is not 'full' it will be
     268                # set to be updated the next time this script is invoked
    267269                # XXX: In the very rare case that this chip run is actually in the running cleanup pantasks
    268270                # queue things may get confused but we can live with that
     
    341343    }
    342344}
     345
     346    my $tess_id = $metadata->{tess_id};
     347    if ($tess_id eq 'RINGS.V0') {
     348        # we have stopped updating data from RINGS.V0
     349        return $PSTAMP_GONE
     350    }
    343351    if (($state =~ /error/) or ($state =~ /purged/) or ($state =~ /scrubbed/) or ($state eq 'drop') or
    344352         ($data_state =~ /error/) or ($data_state =~ /purged/) or ($data_state =~ /scrubbed/) or ($data_state eq 'drop')) {
     
    365373    my $skycell = $metadata;
    366374
    367     if ($skycell->{state} eq 'goto_cleaned' and $skycell->{data_state} eq 'full') {
    368         # cleanup has been queued, but hasn't been done. it's "safe" to set the state back to full
    369         # XXX: seem comments in check_states_chip
     375    # if ($skycell->{state} eq 'goto_cleaned' and $skycell->{data_state} eq 'full') {
     376    if ($skycell->{state} eq 'goto_cleaned') {
     377        # cleanup has been queued, but hasn't finished, probably due to an error or cleanup is not running.
     378        # It's "safe" to set the state to update. If the skycell is not full it will be set to update
     379        # the next time this task runs
    370380        my $command = "$warptool -updaterun -set_state update -warp_id $warp_id";
    371381        $command .= " -set_label $rlabel" if $rlabel;
     
    468478    my $skycell_id = $skycell->{skycell_id};
    469479
    470     if ($metadata->{state} eq 'goto_cleaned' and $metadata->{data_state} eq 'full') {
     480    # if ($metadata->{state} eq 'goto_cleaned' and $metadata->{data_state} eq 'full') {
     481    if ($metadata->{state} eq 'goto_cleaned') {
     482        # cleanup must not be running. Set state to update. If the skycell is not 'full' it will be
     483        # set to be updated the next time this script is invoked
    471484        print "changing state of diffRun $diff_id from goto_cleaned to update. skycell $skycell_id is full\n";
    472485        my $command = "$difftool -updaterun -set_state update -diff_id $diff_id";
  • branches/eam_branches/ipp-20120905/pstamp/src/ppstampArguments.c

    r33504 r34735  
    2525    fprintf(stderr, "   [-mask   mk_image]    : mask image\n");
    2626    fprintf(stderr, "   [-variance var_image] : variance image\n");
     27    fprintf(stderr, "   [-sources sources]    : sources cmf (ignored for chip stage)\n");
    2728    fprintf(stderr, "   [-stage stage]        : stage of input image (raw, chip, warp, stack, diff)\n");
    2829    fprintf(stderr, "   [-write_jpeg]         : write a JPEG  format of the image stamp\n");
     30    fprintf(stderr, "   [-write_cmf]          : create an output cmf with the sources overlapping the stamp\n");
     31    fprintf(stderr, "   [-wholefile]          : ignore the region of interest and process the entire input image\n");
    2932    // fprintf(stderr, "   [-no_censor_masked]   : do not set masked pixels to NAN\n");
    3033    fprintf(stderr, "\n");
     
    9295        options->stage = psStringCopy(argv[argnum]);
    9396        psArgumentRemove(argnum, &argc, argv);
     97    } else {
     98        // Should we require this?
     99        options->stage = psStringCopy("unknown");
    94100    }
    95101    if ((argnum = psArgumentGet(argc, argv, "-write_jpeg"))) {
    96102        psArgumentRemove(argnum, &argc, argv);
    97103        options->writeJPEG = true;
    98     } else {
    99         options->writeJPEG = false;
     104    }
     105    if ((argnum = psArgumentGet(argc, argv, "-write_cmf"))) {
     106        psArgumentRemove(argnum, &argc, argv);
     107        options->writeCMF = true;
    100108    }
    101109
    102     pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM", "-astrom", "-astromlist");
     110    // XXX: Note: the various list options have never been tested with ppstamp to my knowledge
     111    bool gotAstrom = false;
     112    if ((argnum = psArgumentGet(argc, argv, "-astrom"))) {
     113        gotAstrom = true;
     114        pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM", "-astrom", "-astromlist");
     115    }
    103116    pmConfigFileSetsMD(config->arguments, &argc, argv, "MASK",   "-mask", "-masklist");
    104117    pmConfigFileSetsMD(config->arguments, &argc, argv, "VARIANCE", "-variance", "-variancelist");
    105118
    106     // the input file is a required argument; if not found, we will exit
     119    if ((argnum = psArgumentGet(argc, argv, "-sources"))) {
     120        pmConfigFileSetsMD(config->arguments, &argc, argv, "SOURCES", "-sources", "-sourceslist");
     121        // supplying a sources file implies that we want to save the output
     122        options->writeCMF = true;
     123    } else if (options->writeCMF && !gotAstrom) {
     124        // if we didn't get a sources file but the user wanted us to write the sources we must
     125        // have an astrometry file supplied
     126        // XXX: Is this too restrictive? Could the sources be contained in say the input file?
     127        psError(PSTAMP_ERR_ARGUMENTS, true, "cannot write cmf file unless input sources are supplied\n");
     128        usage();
     129    }
     130
     131    // the input image file is a required argument; if not found, we will exit
    107132    bool status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
    108133    if (!status) {
     
    126151    }
    127152
    128     // finally the output file
     153    // finally the only argument left must be output outroot
    129154    if (argc < 2) {
    130155        psError(PSTAMP_ERR_ARGUMENTS, true, "must specify OUTPUT\n");
     
    135160    }
    136161
    137     // Add the output image (which remains on the command-line) to the arguments list
    138162    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[1]);
    139 
    140     // psMetadataPrint(stdout, config->arguments,0);
    141163
    142164    return config;
  • branches/eam_branches/ipp-20120905/pstamp/src/ppstampMakeStamp.c

    r33504 r34735  
    1919static void chipToSky(pmAstromObj *pt, pmFPA *fpa, pmChip *chip);
    2020static bool setMaskedToNAN(pmConfig *config, psImage *image, psImage *mask, psImage *variance);
     21static bool copySources(pmReadout *outputReadout, pmReadout *inputReadout, pmReadout *astromReadout, psRegion extractRegion);
    2122
    2223// convert the input chip's transforms to the output
     
    8081}
    8182
    82 static bool copyMetadata(pmFPAfile *output, pmFPAfile *input, pmChip *inChip, ppstampOptions *options, pmAstromObj *center)
     83static bool copyMetadata(pmFPAfile *output, pmFPAfile *input, pmChip *inChip, ppstampOptions *options, pmAstromObj *center, pmFPAfile *astrom, pmFPAview *inView)
    8384{
    8485    pmChip    *outChip;
    85     pmFPAview *view = pmFPAviewAlloc(0);
     86    pmFPAview *outView = pmFPAviewAlloc(0);
    8687
    8788    // our output file has a single chip
    88     view->chip = 0;
    89     outChip = pmFPAviewThisChip(view, output->fpa);
    90     psFree(view);
    91 
    92     // copy data from the input chip header to the output.
     89    outView->chip = 0;
     90    outChip = pmFPAviewThisChip(outView, output->fpa);
     91    psFree(outView);
     92    pmHDU *outHDU = pmHDUGetHighest(output->fpa, outChip, NULL);
     93
     94    // copy data from the input's chip header to the output.
    9395    // since some of the keywords might be duplicated we may not want to copy both
    9496
    95     pmHDU *inHDU  = pmHDUFromChip(inChip);
    96     pmHDU *outHDU = pmHDUGetHighest(output->fpa, outChip, NULL);
     97    pmHDU *inHDU  = NULL;
     98    if (strcmp(options->stage, "raw") && input != astrom) {
     99        // Copy the header from the astrometry file since it contains the psphot and psastro results
     100        pmChip *astromChip = pmFPAviewThisChip(inView, astrom->fpa);
     101        inHDU  = pmHDUFromChip(astromChip);
     102    } else {
     103        inHDU  = pmHDUFromChip(inChip);
     104    }
    97105
    98106    if (inHDU->header) {
     
    102110    }
    103111
    104     // copy the fpa concepts
     112    // copy the fpa and chip concepts
    105113    pmConceptsCopyFPA(output->fpa, input->fpa, false, false);
     114    // Needed to preserve FPA.ZP
    106115    pmConceptsCopyChip(outChip, inChip, false);
     116
     117    // copy the cell concepts (needed to get CELL.EXPOSURE which gets used to set EXPTIME)
    107118    pmCell *outCell = outChip->cells->data[0]; // The only output cell
    108119
     
    122133    }
    123134
    124     // If input had WCS convert it for stamp
     135    // If input had WCS convert it for the new image coordinate system of our stamp
    125136    if (input->fpa->toSky) {
    126137        // copy the input fpa's transforms
     
    135146        }
    136147    } else {
    137         psWarning("No WCS present in input\n");
    138     }
    139 
     148        psLogMsg("ppstampMakeStamp", PS_LOG_WARN, "No WCS present in input.");
     149    }
     150
     151    // Save our specific metadata
    140152    psMetadataAddF64(outHDU->header, PS_LIST_TAIL, "RA_DEG", PS_META_REPLACE, "Right Ascension of stamp center", RAD_TO_DEG(center->sky->r));
    141153    psMetadataAddF64(outHDU->header, PS_LIST_TAIL, "DEC_DEG", PS_META_REPLACE, "Declination of stamp center", RAD_TO_DEG(center->sky->d));
     154
     155    // XXX: TODO: save the region of interest boundary and the offset to be applied.
     156    // XXX: Gene thinks that there may be a way to handle this in the WCS
     157
     158    // Now a few sanity checks
     159    // Make sure zero point in the fpa concepts matches the observed value in the input header
     160    bool status;
     161    float zpt_obs = psMetadataLookupF32(&status, outHDU->header, "ZPT_OBS");
     162    if (status) {
     163        psMetadataAddF32(output->fpa->concepts, PS_LIST_TAIL, "FPA.ZP", PS_META_REPLACE, "Magnitude zero point", zpt_obs);
     164    }
    142165
    143166    ppstampVersionMetadata(outHDU->header, options);
     
    324347
    325348            if (options->censorMasked && !setMaskedToNAN(config, outReadout->image, outReadout->mask, outReadout->variance)) {
    326                  psError(PS_ERR_UNKNOWN, false, "failed to create postage stamp mask image\n");
    327                  status = false;
    328                  break;
     349                psError(PS_ERR_UNKNOWN, false, "failed to create postage stamp mask image\n");
     350                status = false;
     351                break;
    329352            }
    330353        }
     
    335358        status = true;
    336359
     360        if (options->writeCMF) {
     361            pmReadout *astromReadout = NULL;
     362            if (astrom->fpa != input->fpa) {
     363                astromReadout = pmFPAviewThisReadout(srcView, astrom->fpa);
     364            }
     365            if (!copySources(outReadout, astromReadout, astromReadout, extractRegion)) {
     366                psError(PS_ERR_UNKNOWN, false, "failed to extract sources from region of interest.\n");
     367                status = false;
     368                break;
     369            }
     370        }
     371
    337372        psFree(outReadout); // drop reference
    338373    }
     
    341376
    342377    if (status) {
    343         status = copyMetadata(output, input, inChip, options, center);
     378        // For raw stage we need to do more work to build a proper header
     379        status = copyMetadata(output, input, inChip, options, center, astrom, view);
    344380    }
    345381    return status ? PS_EXIT_SUCCESS : PS_EXIT_UNKNOWN_ERROR;
     
    428464    double dy = 0.5 * options->roip.dDEC / fpa->toSky->Ys;
    429465
    430     if (dx > 5000) {
    431         fprintf(stderr, "requested width %f too large reducing to 5000\n", dx);
    432         dx = 5000;
    433     }
    434     if (dy > 5000) {
    435         fprintf(stderr, "requested height %f too large reducing to 5000\n", dy);
    436         dy = 5000;
     466    // XXX: why do we limit this?
     467    if (dx > 8000) {
     468        psWarning( "requested width %f too large reducing to 8000\n", dx);
     469        dx = 8000;
     470    }
     471    if (dy > 8000) {
     472        psWarning( "requested height %f too large reducing to 8000\n", dy);
     473        dy = 8000;
    437474    }
    438475
     
    480517    ppstampOverlap   returnval = PPSTAMP_OFF;
    481518
    482 //    fprintf(stderr, "ppstampChipBounds: %s\n", psRegionToString(*chipBounds));
    483 
    484519    // set up the astrometry
    485520    pmHDU *hdu = pmFPAviewThisHDU(view, astrom->fpa);
     
    498533        }
    499534    } else {
    500         // we use a default FPA pixel scale of 1.0
    501535        if (!pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0) && mustHaveAstrometry) {
    502536            psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for input FPA.");
     
    537571            center->chip->yErr = 0;
    538572            onChip = true;
    539             chipToSky(center, input->fpa, chip);
     573            if (input->fpa->toSky) {
     574                chipToSky(center, input->fpa, chip);
     575            }
    540576        }
    541577    }
     
    550586                int width  = options->roip.dX;
    551587                int height = options->roip.dY;
    552                 if (width > 7000) {
    553                     fprintf(stderr, "requested width %d too large reducing to 7000\n", width);
    554                     width = 7000;
     588                if (width > 8000) {
     589                    psWarning( "requested width %d too large reducing to 8000\n", width);
     590                    width = 8000;
    555591                }
    556                 if (height > 7000) {
    557                     fprintf(stderr, "requested height %d too large reducing to 7000\n", height);
    558                     height = 7000;
     592                if (height > 8000) {
     593                    psWarning( "requested height %d too large reducing to 8000\n", height);
     594                    height = 8000;
    559595                }
    560596
     
    675711
    676712    if (!foundOverlap && (returnval == PS_EXIT_SUCCESS)) {
    677         fprintf(stderr, "ROI not found in input\n");
     713        psWarning( "ROI not found in input\n");
    678714        returnval = PSTAMP_NO_OVERLAP;
    679715    }
     
    739775    }
    740776
    741     // XXX: this shouldn't be a fprintf
    742     fprintf(stderr, "Censored %ld masked pixels\n", numCensored);
     777    psLogMsg("ppstamp", PS_LOG_DETAIL, "Censored %ld masked pixels\n", numCensored);
    743778
    744779    return true;
    745780}
     781
     782static bool copySources(pmReadout *outReadout, pmReadout *inReadout, pmReadout *astromReadout, psRegion extractRegion) {
     783    bool status;
     784
     785    // first look for detections in the input readout. Those would have come from the -sources file
     786    pmDetections *inDetections = psMetadataLookupPtr (&status, inReadout->analysis, "PSPHOT.DETECTIONS");
     787    if (!inDetections) {
     788        // No detections on the input readout. Try the astrometry readout if supplied.
     789        if (astromReadout) {
     790            inDetections = psMetadataLookupPtr (&status, astromReadout->analysis, "PSPHOT.DETECTIONS");
     791            if (!inDetections) {
     792                psLogMsg("ppstampMakeStamp", PS_LOG_WARN, "no detections found on input or astrometry readout\n");
     793                return false;
     794            } else {
     795                psLogMsg("ppstampMakeStamp", PS_LOG_INFO, "using detections from astrom file\n");
     796            }
     797        } else {
     798            psLogMsg("ppstampMakeStamp", PS_LOG_WARN, "no detections found on input readout\n");
     799            return false;
     800        }
     801    }
     802    if (!inDetections->allSources) {
     803        psLogMsg("ppstampMakeStamp", PS_LOG_WARN, "no sources array found on detections structure\n");
     804        return false;
     805    }
     806
     807    // Ok we have sources, allocate a detections structure and copy them to the output readout
     808    psArray *inSources = inDetections->allSources;
     809
     810    pmDetections *outDetections = pmDetectionsAlloc();
     811    psMetadataAddPtr (outReadout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN,
     812        "psphot detections", outDetections);
     813
     814    psArray *outSources = outDetections->allSources = psArrayAllocEmpty( 100 );
     815
     816    // include sources that are off the stamp by just a little bit
     817    #define EXPAND_SIZE 16
     818    psRegion sourceRegion = extractRegion;
     819    sourceRegion.x0 -= EXPAND_SIZE;
     820    sourceRegion.y0 -= EXPAND_SIZE;
     821    sourceRegion.x1 += EXPAND_SIZE;
     822    sourceRegion.y1 += EXPAND_SIZE;
     823
     824    for (int i = 0; i < inSources->n; i++ ) {
     825        pmSource *src = inSources->data[i];
     826
     827        float x = src->peak->xf;
     828        float y = src->peak->yf;
     829        if (x < sourceRegion.x0 || x > sourceRegion.x1 ||
     830            y < sourceRegion.y0 || y > sourceRegion.y1) {
     831            continue;
     832        }
     833        psArrayAdd(outSources, 100, src);
     834    }
     835
     836    return true;
     837}
  • branches/eam_branches/ipp-20120905/pstamp/src/ppstampOptions.c

    r33504 r34735  
    3232    options->censorMasked = false;
    3333    options->writeJPEG = false;
     34    options->writeCMF = false;
    3435    options->nocompress = false;
    3536    options->wholeFile = false;
  • branches/eam_branches/ipp-20120905/pstamp/src/ppstampOptions.h

    r33504 r34735  
    1414    bool        censorMasked;
    1515    bool        writeJPEG;
     16    bool        writeCMF;
    1617    bool        nocompress;
    1718    //
  • branches/eam_branches/ipp-20120905/pstamp/src/ppstampParseCamera.c

    r33504 r34735  
    120120    }
    121121
     122    // Set up the input and output sources files if needed
     123    if (options->writeCMF) {
     124        bool status;
     125
     126        // see if -sources file was supplied.
     127        // If so define the file.
     128        psPtr sourcesFile = psMetadataLookupStr(&status, config->arguments, "SOURCES");
     129        if (sourcesFile) {
     130            pmFPAfile *sources = pmFPAfileBindFromArgs(&status, input, config, "PPSTAMP.INPUT.SOURCES", "SOURCES");
     131            if (!status) {
     132                psError(psErrorCodeLast(), false, "Failed to load file definition for PPSTAMP.INPUT.SOURCES");
     133                return false;
     134            }
     135            if (!sources && !astrom) {
     136                psError(psErrorCodeLast(), false, "Failed to define input sources file");
     137                return false;
     138            }
     139        } else {
     140            psLogMsg ("ppstamp", PS_LOG_INFO, "output sources file requested but no input supplied. Will try the supplied astrometry file.\n");
     141        }
     142       
     143        pmFPAfile *outputSources = NULL;
     144        outputSources = pmFPAfileDefineSkycell(config, output->fpa, "PPSTAMP.OUTPUT.SOURCES");
     145        if (!outputSources) {
     146            psError(psErrorCodeLast(), false, "Failed to define output sources file");
     147            return false;
     148        }
     149        outputSources->save = true;
     150    }
     151
    122152    pmFPAfile *chipImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PPSTAMP.CHIP");
    123153    if (!chipImage) {
  • branches/eam_branches/ipp-20120905/pstamp/src/pstamp.h

    r28291 r34735  
    2626
    2727// values for options mask.
    28 #define PSTAMP_SELECT_IMAGE      1
    29 #define PSTAMP_SELECT_MASK       2
    30 #define PSTAMP_SELECT_WEIGHT     4
    31 #define PSTAMP_SELECT_CMF        8
    32 #define PSTAMP_SELECT_PSF       16
    33 #define PSTAMP_SELECT_BACKMDL   32
    34 #define PSTAMP_SELECT_INVERSE 1024
    35 #define PSTAMP_SELECT_UNCONV  2048
    36 #define PSTAMP_USE_IMFILE_ID 16384
     28#define PSTAMP_SELECT_IMAGE         1
     29#define PSTAMP_SELECT_MASK          2
     30#define PSTAMP_SELECT_WEIGHT        4
     31#define PSTAMP_SELECT_SOURCES       8
     32#define PSTAMP_SELECT_CMF           8
     33#define PSTAMP_SELECT_PSF           16
     34#define PSTAMP_SELECT_BACKMDL       32
     35#define PSTAMP_SELECT_JPEG          64
     36// unused                           128
     37// unused                           256
     38#define PSTAMP_SELECT_UNCOMPRESSED  512
     39#define PSTAMP_SELECT_INVERSE       1024
     40#define PSTAMP_SELECT_UNCONV        2048
     41#define PSTAMP_RESTORE_BACKGROUND   4096
     42// unused                           8192
     43#define PSTAMP_USE_IMFILE_ID        16384
    3744
    38 #define PSTAMP_NO_WAIT_FOR_UPDATE 32768
     45#define PSTAMP_NO_WAIT_FOR_UPDATE   32768
     46#define PSTAMP_REQUEST_UNCENSORED  0x10000
     47#define PSTAMP_REQUIRE_UNCENSORED  0x20000
    3948
    4049#define PSTAMP_CENTER_IN_PIXELS 1
  • branches/eam_branches/ipp-20120905/psvideophot

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20120905/tools/fixburntool

    r34364 r34735  
    66use strict;
    77use warnings;
     8
    89use Carp;
    910use IPC::Cmd 0.36 qw( can_run run );
     
    2829my $class_id;
    2930my $dbname = 'gpc1';
    30 my $verbose = 1;
     31my $verbose = 0;
    3132GetOptions(
    3233    'exp_id|e=s'    => \$exp_id,
     
    3536) or pod2usage( 2 );
    3637
    37 die "usage: $0 (exp_id) (class_id)\n" unless $class_id and $exp_id;
     38die "usage: $0 --exp_id (exp_id) --class_id (class_id)\n" unless $class_id and $exp_id;
    3839
    3940$regtool  .= " -dbname gpc1 -exp_id $exp_id -class_id $class_id";
     
    4546    my $command = "$regtool -processedimfile";
    4647    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    47         run(command => $command, verbose => 0);
     48        run(command => $command, verbose => $verbose);
    4849    unless ($success) {
    4950        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     
    6869    my $command = "neb-stat $table";
    6970    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    70         run(command => $command, verbose => 0);
     71        run(command => $command, verbose => $verbose);
    7172    if ($success) {
    7273        $table_exists = 1;
     
    9697# print "$left $num $end\n";
    9798
    98 
    9999my $prev = $num - 1;
    100100my $prev_name = sprintf "$left%04d$end", $prev;
     
    105105# print "$prev_name $prev_uri\n";
    106106
    107 
    108107{
    109108    my $command = "$burntool --continue 10 --exp_id $exp_id --class_id $class_id --this_uri $uri --previous_uri $prev_uri";
    110109    print "$command\n";
    111110    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    112         run(command => $command, verbose => 0);
     111        run(command => $command, verbose => 1);
    113112    unless ($success) {
    114113        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
  • branches/eam_branches/ipp-20120905/tools/runwarpskycell.pl

    r33923 r34735  
    1616
    1717my $dbname = "gpc1";
    18 my ($warp_id, $skycell_id, $threads, $update, $redirect, $pretend, $save_temps);
     18my ($warp_id, $skycell_id, $threads, $update, $redirect, $pretend, $save_temps, $outdir);
    1919my $zaplog;
    2020
     
    2626    'zaplog'            => \$zaplog,
    2727    'redirect-output'   => \$redirect,
     28    'outdir=s'          => \$outdir,
    2829    'update'            => \$update,
    2930    'dbname=s'          => \$dbname,
     
    7475} else {
    7576    die "unexpected warpRun.state found: $state\n";
     77}
     78
     79if ($outdir) {
     80    my $base = basename($path_base);
     81    $path_base = "$outdir/$base";
     82    print "changing path_base to $path_base\n";
    7683}
    7784
Note: See TracChangeset for help on using the changeset viewer.