IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36677


Ignore:
Timestamp:
Apr 20, 2014, 5:52:37 PM (12 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20140402
Files:
48 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140402

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

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

    r36168 r36677  
    468468            $skycell_id = $component;
    469469            $choose_components = 1;
     470            if ($req_type eq 'byskycell' and $skycenter) {
     471                # Add a wide coordinate cut to the releasetool command.
     472                # This greatly speeds up the query by reducing the number of exposures considered
     473                # to those near the region of interest.
     474                # The actual radius value that we use is not critical because the skycell cut does the relevant
     475                # selection.
     476                $command .= " -ra $row->{CENTER_X} -decl $row->{CENTER_Y} -radius 5.0";
     477            }
    470478        } else {
    471479            $command = "$warptool -pstamp_order -dbname $imagedb";
     
    10941102            setErrorCodes($rowList, $PSTAMP_NO_IMAGE_MATCH);
    10951103        } else {
    1096             # XXX: We are not applying the fwhm cuts
     1104            # XXX: We are not applying the fwhm cuts unless we use releasetool
    10971105            foreach my $skycell (@$skycells) {
    10981106                my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $stage, undef,
  • branches/eam_branches/ipp-20140402/ippScripts/scripts/dist_defineruns.pl

    r36633 r36677  
    4242
    4343# Parse the command-line arguments
    44 my ($stage, $stage_limit, $dist_root, $workdir, $no_magic);
     44my ($stage, $stage_limit, $dist_root, $workdir, $no_magic, $rerun);
    4545my ($dbname, $save_temps, $verbose, $no_update, $logfile);
    4646my @labels;
     
    5151           'workdir=s'      => \$workdir,     # workdir
    5252           'stage_limit=s'  => \$stage_limit,# maximum number of runs queued for each stage
     53           'rerun'          => \$rerun,      # queue new runs even if one exists
    5354#           'dist_root=s'    => \$dist_root,  # root of distribution work area
    5455           'no_magic'       => \$no_magic,   # queue runs without requiring magic (for testing only)
     
    5657           'verbose'        => \$verbose,    # Print stuff?
    5758           'no-update'      => \$no_update,  # Don't update the database
     59           'pretend'        => \$no_update,  # Don't update the database
    5860           'save-temps'     => \$save_temps, # Save temporary files?
    5961           'logfile=s'      => \$logfile,
     
    104106        $command .= " -singlefilter" if $single;
    105107        $command .= " -no_magic" if $no_magic;
     108        $command .= " -rerun" if $rerun;
    106109        $command .= " -pretend" if $no_update;
    107110        $command .= " -limit $stage_limit" if $stage_limit;
  • branches/eam_branches/ipp-20140402/ippScripts/scripts/ipp_apply_burntool_single.pl

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

    r36633 r36677  
    8585    my $results;
    8686    {
    87         my $command = "$fftool -result -ff_id $ff_id";
     87        my $command = "$fftool -result -ff_id $ff_id -quality 0";
    8888        $command .= " -dbname $dbname" if defined $dbname;
    8989        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
  • branches/eam_branches/ipp-20140402/ippScripts/scripts/publish_file.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20140402/ippTasks/pstamp.pro

    r36634 r36677  
    951951    # overloading nfs
    952952
    953     npending    10
     953    npending    5
    954954
    955955    task.exec
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_SSdiff.sql

    r26997 r36677  
    2222      AND distTarget.state = 'enabled'
    2323      AND rcInterest.state = 'enabled'
    24       AND distRun.dist_id IS NULL
    25 
    2624      AND ((diffRun.state = 'full') OR (distTarget.clean AND diffRun.state = 'cleaned'))
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_camera.sql

    r26519 r36677  
    2121WHERE distTarget.state = 'enabled'
    2222    AND rcInterest.state = 'enabled'
    23     AND distRun.dist_id IS NULL      -- no existing distRun
    2423    AND ((camRun.state = 'full') OR (distTarget.clean AND camRun.state = 'cleaned'))
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_chip_bg.sql

    r28536 r36677  
    2323WHERE distTarget.state = 'enabled'
    2424    AND rcInterest.state = 'enabled'
    25     AND distRun.dist_id IS NULL      -- no existing distRun
    2625    AND ((chipBackgroundRun.state = 'full') OR (distTarget.clean AND chipBackgroundRun.state = 'cleaned'))
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_diff.sql

    r26519 r36677  
    2525WHERE  distTarget.state = 'enabled'
    2626    AND rcInterest.state = 'enabled'
    27     AND distRun.dist_id IS NULL
    2827    AND ((diffRun.state = 'full') OR (distTarget.clean AND diffRun.state = 'cleaned'))
    2928
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_fake.sql

    r26519 r36677  
    2020WHERE  distTarget.state = 'enabled'
    2121    AND rcInterest.state = 'enabled'
    22     AND distRun.dist_id IS NULL
    2322    AND ((fakeRun.state = 'full') OR (distTarget.clean AND fakeRun.state = 'cleaned'))
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_ff.sql

    r36555 r36677  
    2121WHERE  distTarget.state = 'enabled'
    2222    AND rcInterest.state = 'enabled'
    23     AND distRun.dist_id IS NULL
    2423    AND fullForceRun.state = 'full'
    2524    AND stackRun.filter = distTarget.filter
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_raw.sql

    r27456 r36677  
    1616JOIN rcInterest USING(target_id)
    1717LEFT JOIN distRun ON distRun.stage_id = exp_id AND distRun.target_id = distTarget.target_id
    18 WHERE distRun.dist_id IS NULL           -- no existing distRun for this exposure
    19     AND distTarget.state = 'enabled'    -- target and intrest are enabled
     18WHERE distTarget.state = 'enabled'    -- target and intrest are enabled
    2019    AND rcInterest.state = 'enabled'
    2120    AND magicDSRun.state = 'full'       -- destreaked files are available
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_sky.sql

    r35953 r36677  
    2323    AND rcInterest.state = 'enabled'
    2424    AND distTarget.filter = 'multi'
    25     AND distRun.dist_id IS NULL
    2625    AND ((staticskyRun.state = 'full') OR (distTarget.clean AND staticskyRun.state = 'cleaned'))
    2726    -- we shouldn't need to check fault. If faulted it shouldn't be full
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_sky_singlefilter.sql

    r32696 r36677  
    2222WHERE  distTarget.state = 'enabled'
    2323    AND rcInterest.state = 'enabled'
    24     AND distRun.dist_id IS NULL
    2524    AND ((staticskyRun.state = 'full') OR (distTarget.clean AND staticskyRun.state = 'cleaned'))
    2625    AND stackRun.filter = distTarget.filter
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_skycal.sql

    r35955 r36677  
    1 SELECT
     1SELECT DISTINCT
    22    'skycal' as stage,
    33    skycalRun.skycal_id AS stage_id,
     
    2121WHERE  distTarget.state = 'enabled'
    2222    AND rcInterest.state = 'enabled'
    23     AND distRun.dist_id IS NULL
    2423    AND ((skycalRun.state = 'full') OR (distTarget.clean AND skycalRun.state = 'cleaned'))
    2524    AND stackRun.filter = distTarget.filter
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_stack.sql

    r26519 r36677  
    2121WHERE  distTarget.state = 'enabled'
    2222    AND rcInterest.state = 'enabled'
    23     AND distRun.dist_id IS NULL
    2423    AND ((stackRun.state = 'full') OR (distTarget.clean AND stackRun.state = 'cleaned'))
    2524    -- we shouldn't need to check fault. If faulted it shouldn't be full
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_warp.sql

    r26519 r36677  
    2222WHERE  distTarget.state = 'enabled'
    2323    AND rcInterest.state = 'enabled'
    24     AND distRun.dist_id IS NULL
    2524    AND ((warpRun.state = 'full') OR (distTarget.clean AND warpRun.state = 'cleaned'))
    2625
  • branches/eam_branches/ipp-20140402/ippTools/share/disttool_definebyquery_warp_bg.sql

    r28536 r36677  
    2424WHERE  distTarget.state = 'enabled'
    2525    AND rcInterest.state = 'enabled'
    26     AND distRun.dist_id IS NULL
    2726    AND ((warpBackgroundRun.state = 'full') OR (distTarget.clean AND warpBackgroundRun.state = 'cleaned'))
    2827
  • branches/eam_branches/ipp-20140402/ippTools/share/warptool_warped.sql

    r35901 r36677  
    44    warpRun.workdir,
    55    warpRun.label,
     6    warpRun.data_group,
    67    warpImfile.warp_skyfile_id,
    78    rawExp.exp_id,
  • branches/eam_branches/ipp-20140402/ippTools/src/fftool.c

    r36633 r36677  
    498498    PXOPT_COPY_STR(config->args, where, "-filter",      "stackRun.filter", "LIKE");
    499499    PXOPT_COPY_S16(config->args, where, "-fault",      "fullForceResult.fault", "==");
     500    PXOPT_COPY_S16(config->args, where, "-quality",    "fullForceResult.quality", "==");
    500501    pxskycellAddWhere(config, where);
    501502
  • branches/eam_branches/ipp-20140402/ippTools/src/fftoolConfig.c

    r36633 r36677  
    116116    psMetadataAddStr(resultArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL);
    117117    psMetadataAddStr(resultArgs, PS_LIST_TAIL, "-data_group", 0, "search by data_group (LIKE comparison)", NULL);
     118    psMetadataAddS16(resultArgs, PS_LIST_TAIL, "-quality", 0, "search by quality value", 0);
    118119    pxskycellAddArguments(resultArgs);
    119120    psMetadataAddS16(resultArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0);
  • branches/eam_branches/ipp-20140402/ippconfig

    • Property svn:mergeinfo deleted
  • branches/eam_branches/ipp-20140402/ippconfig/gpc1/ppStack.config

    r36183 r36677  
    167167    PSF.TARGET.AS.MAX  BOOL  TRUE
    168168    PSF.TARGET.AS.MAX.EPSILON F32 0.1
     169    THRESHOLD.MASK  F32     0.01             # Threshold for mask deconvolution (0..1)
     170    COMBINE.ITER    F32     0.5             # Number of rejection iterations per input
     171    COMBINE.REJ     F32     2.5             # Rejection threshold in combination (sigma)
     172    COMBINE.SYS     F32     0.1             # Relative systematic error in combination
     173    COMBINE.DISCARD F32     0.2             # Discard fraction for Olympic weighted mean
     174    IMAGE.REJ       F32     0.1             # Rejected pixel fraction threshold for rejecting entire image
    169175END
    170176
     
    183189    PSF.TARGET.AS.MAX  BOOL  TRUE
    184190    PSF.TARGET.AS.MAX.EPSILON F32 0.1
     191    THRESHOLD.MASK  F32     0.5             # Threshold for mask deconvolution (0..1)
     192    COMBINE.ITER    F32     0.5             # Number of rejection iterations per input
     193    COMBINE.REJ     F32     3.5             # Rejection threshold in combination (sigma)
     194    COMBINE.SYS     F32     0.1             # Relative systematic error in combination
     195    COMBINE.DISCARD F32     0.2             # Discard fraction for Olympic weighted mean
     196    IMAGE.REJ       F32     0.1             # Rejected pixel fraction threshold for rejecting entire image
     197END
     198
     199STACK_MDTHREEPI_DEEP_1DG     METADATA   ## revised config for MD+3PI
     200    OUTPUT.NOCOMP           BOOL  TRUE
     201    OUTPUT.LOGFLUX          BOOL  FALSE
     202    OUTPUT.REPLICATE        BOOL  TRUE
     203    STACK.TYPE              STR   DEEP_STACK
     204    PSF.INPUT.CLIP.SIMPLE   BOOL  True
     205    PSF.INPUT.MAX           F32   10.0    #
     206    PSF.INPUT.CLIP.NSIGMA   F32   100.0
     207    PSF.INPUT.THRESH        F32   NAN
     208    PSF.INPUT.ASYMMETRY     F32   NAN
     209    MATCH.REJ               F32   4.0     # need ot tune?
     210    SAFE                    BOOL  FALSE
     211    PSF.TARGET.AS.MAX  BOOL  TRUE
     212    PSF.TARGET.AS.MAX.EPSILON F32 0.1
     213    THRESHOLD.MASK  F32     0.01             # Threshold for mask deconvolution (0..1)
     214    COMBINE.ITER    F32     0.5             # Number of rejection iterations per input
     215    COMBINE.REJ     F32     2.5             # Rejection threshold in combination (sigma)
     216    COMBINE.SYS     F32     0.1             # Relative systematic error in combination
     217    COMBINE.DISCARD F32     0.2             # Discard fraction for Olympic weighted mean
     218    IMAGE.REJ       F32     0.1             # Rejected pixel fraction threshold for rejecting entire image
    185219END
    186220
  • branches/eam_branches/ipp-20140402/ippconfig/recipes/nightly_science.config

    r36037 r36677  
    33  MODE           STR CHIP
    44  COMMAND        STR chiptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -data_group @DATA_GROUP@
    5   RETENTION_TIME U16 7
     5  RETENTION_TIME U16 5
    66END
    77CLEAN_MODES METADATA
     
    99  COMMAND        STR warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -data_group @DATA_GROUP@
    1010#  COMMAND        STR true
    11   RETENTION_TIME U16 7
     11  RETENTION_TIME U16 5
    1212END
    1313CLEAN_MODES METADATA
    1414  MODE           STR DIFF
    1515  COMMAND        STR difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -data_group @DATA_GROUP@
    16   RETENTION_TIME S16 7
     16  RETENTION_TIME S16 5
    1717END
    1818CLEAN_MODES METADATA
  • branches/eam_branches/ipp-20140402/ippconfig/recipes/ppStack.config

    r35964 r36677  
    189189END
    190190
     191STACK_MDTHREEPI_DEEP_1DG   METADATA
     192END
     193
    191194
    192195
  • branches/eam_branches/ipp-20140402/ippconfig/recipes/ppSub.config

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20140402/ippconfig/recipes/psphot.config

    r36633 r36677  
    491491  PEAKS_NMAX_TOTAL                    S32   0 # set this to limit the allowed number of peaks - Yields fault instead of avoid memory explosion
    492492
    493   EXT_MODEL_TYPE_FOR_CFF              STR   PS_MODEL_DEV
     493#  EXT_MODEL_TYPE_FOR_CFF              STR   PS_MODEL_DEV
    494494
    495495  SAVE.RESID                          BOOL  TRUE
  • branches/eam_branches/ipp-20140402/ippconfig/recipes/reductionClasses.mdc

    r36644 r36677  
    663663      STACKPHOT_SINGLE_PSPHOT STR     STACKPHOT_SINGLE
    664664      STATICSKY_CALIBRATION   STR     STATICSKY_DEEPCAL
     665END
     666
     667MDTHREEPI_DEEP_STACK_1DG            METADATA
     668      STACK_PPSTACK           STR     STACK_MDTHREEPI_DEEP_1DG
     669      STACK_PPSUB             STR     STACK_1DG
     670      STACK_PSPHOT            STR     STACK
     671      STACKPHOT_PSPHOT        STR     STACKPHOT
     672      STACKPHOT_PPSUB         STR     STACKPHOT_1DG
     673      STACKPHOT_PPSTACK       STR     STACKPHOT
     674      STACKPHOT_SINGLE_PSPHOT STR     STACKPHOT_SINGLE
     675      STATICSKY_CALIBRATION   STR     STATICSKY_DEEPCAL
    665676END
    666677
  • branches/eam_branches/ipp-20140402/ppBackground/src/ppBackgroundStack.h

    r36635 r36677  
    2323
    2424  psImageMap *modelMap;
     25  psS32 model_iteration;
    2526  // These are the full extent of the input data
    2627  psF32 ra_min;
  • branches/eam_branches/ipp-20140402/ppBackground/src/ppBackgroundStackCamera.c

    r36635 r36677  
    114114        }
    115115      }
    116 
    117 /*       psMemStats(0,&A,&P); */
    118 /*       fprintf(stderr,"fpa %ld %ld\n",A,P); */
     116     
     117      psF32 exptime = 1.0;
     118      exptime = psMetadataLookupF32(NULL, phu->header, "EXPTIME");
    119119
    120120      pmChip *chip;                       // Chip from FPA
     
    197197            decim->data.F32[v][u] = tp->y;
    198198            model->data.F32[v][u] = 0.0;
    199 
     199            image->data.F32[v][u] /= exptime;
    200200            // Check the bounds so we'll know how large of an area to model in the map
    201201            if (tp->x < data->ra_min) { data->ra_min = tp->x; }
     
    277277          }
    278278        }
    279 
    280        
    281 /*      psMemStats(0,&A,&P); */
    282 /*      fprintf(stderr,"chip2 %ld %ld\n",A,P); */
    283279      } // end chip loop
    284280
     
    290286                       "N", PS_META_REPLACE,
    291287                       "counter", i);
    292       // data->models->name->XY__->{image/ra/dec/calibrated/offset/scale}
    293       // data->models->counter->XY__->{image/ra/dec/calibrated/offset/scale}
    294 
    295      
    296288     
    297289      if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
  • branches/eam_branches/ipp-20140402/ppBackground/src/ppBackgroundStackData.c

    r36615 r36677  
    5050
    5151    data->modelMap = NULL;
     52    data->model_iteration = 0;
    5253    data->ra_min   = 1e9;
    5354    data->ra_max   = -1e9;
  • branches/eam_branches/ipp-20140402/ppBackground/src/ppBackgroundStackLoop.c

    r36635 r36677  
    99
    1010#include "ppBackgroundStack.h"
     11
     12#define WCS_TOLERANCE 0.001             // Tolerance for WCS
     13
    1114
    1215bool ppBackgroundStackLoop(ppBackgroundStackData *data // Run-time data
     
    7679      pmFPAview *view = pmFPAviewAlloc(0);
    7780
     81      //      pmHDU *phu = pmFPAviewThisPHU(view, stack->fpa);
     82      psF32 exptime = 1.0;
     83      exptime = psMetadataLookupF32(NULL, stack->fpa->hdu->header, "EXPTIME");
     84     
    7885      // PART 1:
    7986      // Determine the extent of the model map for this stack
     
    116123      if (tp->y > data->y_max) { data->y_max = tp->y; }
    117124
    118 /*       data->x_min -= data->ra_min; */
    119 /*       data->x_max -= data->ra_min; */
    120 /*       data->y_min -= data->dec_min; */
    121 /*       data->y_max -= data->dec_min; */
    122      
    123      
    124125      psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV);
    125126      psImageBinning *binning = psImageBinningAlloc();
    126       binning->nXruff = 15; // Number of samples
    127       binning->nYruff = 15;
    128       //    binning->nXfine = ceil(data->ra_max - data->ra_min) + 1; // This is the range we're looking at
    129       //    binning->nYfine = ceil(data->dec_max - data->dec_min) + 1;
     127      binning->nXruff = 13; // Number of samples
     128      binning->nYruff = 13;
    130129      binning->nXfine = ceil(data->x_max - data->x_min) + 1;
    131130      binning->nYfine = ceil(data->y_max - data->y_min) + 1;
     
    142141      P_PSIMAGE_SET_ROW0(sizeImage, data->y_min);
    143142      data->modelMap = psImageMapAlloc(sizeImage,binning,stats);
    144 /*       psFree(sizeImage); */
    145 /*       data->modelMap = psImageMapNoImageAlloc( binning,stats); */
    146 /*       P_PSIMAGE_SET_COL0(data->modelMap->map, (data->x_min - binning->nXskip) / binning->nXbin); */
    147 /*       P_PSIMAGE_SET_ROW0(data->modelMap->map, (data->y_min - binning->nYskip) / binning->nYbin); */
    148 
    149       // force col0/row0
    150 /*       data->modelMap->map->col0 = data->modelMap->binning->nXskip; */
    151 /*       data->modelMap->map->row0 = data->modelMap->binning->nYskip; */
    152143     
    153144      // PART 2:
     
    169160
    170161      // This is where an iterative solution loop would likely start.
    171       {
     162      for (int iterator = 0; iterator < 4; iterator++) {
    172163        // Construct the offset information
    173164        printf("Model fit!\n");
     
    298289                psPlaneTransformApply(tp, stack->fpa->toTPA, pix);
    299290               
    300                 model->image->data.F32[y][x] = psImageMapEval(data->modelMap,tp->x,tp->y);
     291                model->image->data.F32[y][x] = exptime * psImageMapEval(data->modelMap,tp->x,tp->y);
    301292                corr->image->data.F32[y][x] = readout->image->data.F32[y][x] + model->image->data.F32[y][x];
    302293               
     
    306297            psFree(fp);
    307298            psFree(tp);
     299
     300            // Copy WCS (from ppStackUpdateHeader)
     301            pmHDU *inHDU = pmHDUFromCell(readout->parent);
     302            model->parent->hdu = pmHDUAlloc(NULL);
     303            corr->parent->hdu = pmHDUAlloc(NULL);
     304            pmHDU *modHDU= pmHDUFromCell(model->parent);
     305            pmHDU *corHDU= pmHDUFromCell(corr->parent);
     306
     307            if (!modHDU || !inHDU) {
     308              psWarning("Unable to find HDU at FPA level to copy wcs!");
     309            }
     310            else {
     311              if (!pmAstromReadWCS(stack_model->fpa,model_cell->parent,inHDU->header,1.0)) {
     312                psErrorClear();
     313                psWarning("Unable to read WCS astrometry from input FPA!");
     314              }
     315              else {
     316                if (!modHDU->header) {
     317                  modHDU->header = psMetadataAlloc();
     318                }
     319                if (!pmAstromWriteWCS(modHDU->header, stack_model->fpa,model_cell->parent, WCS_TOLERANCE)) {
     320                  psErrorClear();
     321                  psWarning("Unable to read WCS astrometry from input FPA!");
     322                }
     323              }
     324              if (!pmAstromReadWCS(stack_corr->fpa,corr_cell->parent,inHDU->header,1.0)) {
     325                psErrorClear();
     326                psWarning("Unable to read WCS astrometry from input FPA!");
     327              }
     328              else {
     329                if (!corHDU->header) {
     330                  corHDU->header = psMetadataAlloc();
     331                }
     332                if (!pmAstromWriteWCS(corHDU->header, stack_corr->fpa,corr_cell->parent, WCS_TOLERANCE)) {
     333                  psErrorClear();
     334                  psWarning("Unable to read WCS astrometry from input FPA!");
     335                }
     336              }
     337            } // End WCS saving.
     338
     339           
    308340          } // Close readout
    309341          printf("    I'm done with that readout\n");
     
    335367      psFree(view);
    336368      psFree(data->modelMap);
     369      psFree(sizeImage);
    337370    }
    338371               
  • branches/eam_branches/ipp-20140402/ppBackground/src/ppBackgroundStackMath.c

    r36635 r36677  
    5555          }
    5656          psMetadata *chipData = psMetadataLookupPtr(NULL, expItem->data.md, workingChip);
     57          if (!chipData) { continue; }
    5758          psImage *image      = psMetadataLookupPtr(NULL, chipData, "bkg image");
     59          if (!image) { continue; }
    5860          psVectorAppend(tmp,image->data.F32[v][u]);
    5961        } // End loop over exposures
     
    6365
    6466        psFree(expIter);
     67        psFree(tmp);
    6568      } // End u
    6669    } // End v
     70    // Remove the median value from this data.  We just want the tilts, not the offsets
     71    psStatsInit(stats);
     72    psImageStats(stats,solution,NULL,0);
     73    for (v = 0; v < solution->numRows; v++) {
     74      for (u = 0; u < solution->numCols; u++) {
     75        solution->data.F32[v][u] -= stats->robustMedian;
     76      }
     77    }
     78   
     79   
    6780  } // End working chip scan
    6881
     
    90103    psMetadataItem *chipItem;
    91104    while ((chipItem = psMetadataGetAndIncrement(chipIter))) {
     105      //      const char *chipName = chipItem->name;
     106     
    92107      psImage *image = psMetadataLookupPtr(NULL, chipItem->data.md, "bkg image");
    93108      psImage *ra    = psMetadataLookupPtr(NULL, chipItem->data.md, "bkg ra");
    94109      psImage *dec   = psMetadataLookupPtr(NULL, chipItem->data.md, "bkg dec");
    95      
     110      //      psImage *camera= psMetadataLookupPtr(NULL, data->OTA_solutions, chipName);     
    96111      psVector *obs  = psVectorAllocEmpty(image->numRows, PS_TYPE_F32);
    97112      psVector *model= psVectorAllocEmpty(image->numRows, PS_TYPE_F32);
    98      
     113
     114      int j = 0;
     115      int used = 0;
    99116      for (v = 0; v < image->numRows; v++) {
    100117        for (u = 0; u < image->numCols; u++) {
    101118          if ((ra->data.F32[v][u] < data->x_min)||(ra->data.F32[v][u] > data->x_max)||
    102               (dec->data.F32[v][u] < data->y_min)||(dec->data.F32[v][u] > data->y_max)) { continue; }
    103           psVectorAppend(obs,image->data.F32[v][u]);
     119              (dec->data.F32[v][u] < data->y_min)||(dec->data.F32[v][u] > data->y_max)) { j++; continue; }
     120          psVectorAppend(obs,image->data.F32[v][u]);// - camera->data.F32[v][u]);
    104121          psVectorAppend(model, psImageMapEval(data->modelMap,ra->data.F32[v][u],dec->data.F32[v][u]));
    105           //      obs->data.F32[v * image->numCols + u] = image->data.F32[v][u];
    106           //      model->data.F32[v * image->numCols + u] = psImageMapEval(data->modelMap,ra->data.F32[v][u],dec->data.F32[v][u]);
    107         }
    108       }
    109 
    110       psPolynomial1D *poly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD,1);
    111       int status = psVectorFitPolynomial1D(poly,NULL,0,model,NULL,obs);
    112       if (!status) {
    113         psMetadataAddF32(chipItem->data.md,PS_LIST_TAIL,"bkg offset", PS_META_REPLACE, "background offset for this exposure/ota pair", poly->coeff[0]);
    114         psMetadataAddF32(chipItem->data.md,PS_LIST_TAIL,"bkg scale", PS_META_REPLACE, "background scale for this exposure/ota pair", poly->coeff[1]);
    115       }
    116       psFree(poly);
     122          j++;
     123          used++;
     124        }
     125      }
     126
     127      if (used > 0) {
     128
     129        psPolynomial1D *poly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD,1);
     130        int status = psVectorFitPolynomial1D(poly,NULL,0,model,NULL,obs);
     131        printf("in model fit loop: %d %d %d %f %f\n",status,j,used,poly->coeff[0],poly->coeff[1]);
     132        if (status && (poly->coeff[1] != 0.0)) {
     133          psMetadataAddF32(chipItem->data.md,PS_LIST_TAIL,"bkg offset", PS_META_REPLACE, "background offset for this exposure/ota pair", poly->coeff[0]);
     134          psMetadataAddF32(chipItem->data.md,PS_LIST_TAIL,"bkg scale", PS_META_REPLACE, "background scale for this exposure/ota pair", poly->coeff[1]);
     135        }
     136        psFree(poly);
     137      }
    117138    } // End OTA loop
    118139    psFree(chipIter);
     
    155176              (dec->data.F32[v][u] < data->y_min)||(dec->data.F32[v][u] > data->y_max)) { continue; }
    156177
    157           model->data.F32[v][u] = scale * image->data.F32[v][u] - offset - camera->data.F32[v][u];
     178          model->data.F32[v][u] = scale * image->data.F32[v][u] + offset - camera->data.F32[v][u];
    158179        }
    159180      }
     
    170191// This "averaging" is done using the psImageMapClipFit.
    171192bool ppBackgroundStackModelFit(ppBackgroundStackData *data) {
    172   long j;
    173   int u,v;
    174 
    175   long used;
     193  long j = 0;
     194  int u,v;
     195
     196  long used = 0;
    176197  psS16 N = psMetadataLookupS16(NULL, data->models, "N");
    177198  psVector *X = psVectorAllocEmpty(N * 13 * 13,PS_TYPE_F32);
     
    197218      psImage *ra    = psMetadataLookupPtr(NULL, chipItem->data.md, "bkg ra");
    198219      psImage *dec   = psMetadataLookupPtr(NULL, chipItem->data.md, "bkg dec");
    199       //      psImage *model = psMetadataLookupPtr(NULL, chipItem->data.md, "bkg image");
     220#define DUMP_DATA 0
     221#if DUMP_DATA
     222      psImage *model = psMetadataLookupPtr(NULL, chipItem->data.md, "bkg image");
     223
     224      psF32 offset = psMetadataLookupF32(NULL,chipItem->data.md,"bkg offset");
     225      psF32 scale  = psMetadataLookupF32(NULL,chipItem->data.md,"bkg scale");
     226
     227#endif
    200228      for (v = 0; v < calib->numRows; v++) {
    201229        for (u = 0; u < calib->numCols; u++) {
     
    216244          used++;
    217245          j++;
    218          
    219 /*        printf("DATA %ld %ld %f %f %f %f\n", */
    220 /*               j,used, */
    221 /*               ra->data.F32[v][u], */
    222 /*               dec->data.F32[v][u], */
    223 /*               calib->data.F32[v][u], */
    224 /*               model->data.F32[v][u]); */
    225                  
     246#if DUMP_DATA
     247          printf("DATA %d %ld %ld %f %f %f %f %f %f\n",
     248                 data->model_iteration,j,used,
     249                 offset,scale,
     250                 ra->data.F32[v][u],
     251                 dec->data.F32[v][u],
     252                 calib->data.F32[v][u],
     253                 model->data.F32[v][u]);
     254#endif
    226255        }
    227256      }
     
    232261  bool fitStatus;
    233262  bool status = psImageMapClipFit(&fitStatus,data->modelMap,stats, mask, 1, X, Y, Z, E);
    234 
     263  data->model_iteration++;
    235264  psFree(expIter);
    236265  psFree(X);
  • branches/eam_branches/ipp-20140402/ppSkycell/src/ppSkycellLoop.c

    r36360 r36677  
    125125        for (int j = 0; j < numProj && !found; j++) {
    126126            if (wcs->crval1 == crval1->data.F64[j] && wcs->crval2 == crval2->data.F64[j] &&
    127                 wcs->cdelt1 == cdelt1->data.F64[j] && wcs->cdelt2 == cdelt1->data.F64[j]) {
     127                wcs->cdelt1 == cdelt1->data.F64[j] && wcs->cdelt2 == cdelt2->data.F64[j]) {
    128128              //                regionMinMax(projRegions->data[j], region);
    129129              psRegion *proj = projRegions->data[j];
  • branches/eam_branches/ipp-20140402/psModules/src/imcombine/pmStack.c

    r35455 r36677  
    4343// #define TEST_X 972
    4444// #define TEST_Y 3213
    45 #define TEST_X 3289
    46 #define TEST_Y 4810
    47 #define TEST_RADIUS 0.5                 // Radius to examine
     45//#define TEST_X 3289
     46//#define TEST_Y 4810
     47//#define TEST_RADIUS 0.5                 // Radius to examine
     48//MEH -- streak-like junk md04s065i
     49#define TEST_X 1129
     50#define TEST_Y 4256
     51#define TEST_RADIUS 2.0                 // Radius to examine
    4852# endif
    4953
     
    108112
    109113// KMM functions to do bimodality rejection of pixels
    110 float gaussian(float x, float m, float s) {
     114double gaussian(float x, float m, float s) {
    111115  return(pow(s * sqrt(2 * M_PI),-1) * exp(-0.5 * pow( (x - m) / s, 2)));
    112116}
     
    116120                         float *mU, float *sU,
    117121                         float *pi1, float *m1, float *s1,
    118                          float *pi2, float *m2, float *s2) {
     122                         float *pi2, float *m2, float *s2,
     123                         int xyrdebug) {
    119124  assert(values);
    120125  assert(values->type.type == PS_TYPE_F32);
     
    151156  }
    152157
     158  if (xyrdebug == 1) {
     159      fprintf(stderr,"KMM uni: %d %f %d (%f %f)\n",
     160              xyrdebug,logL_unimodal,discrepant_index,
     161              *mU,*sU);
     162  }
     163
    153164  // Do EM loop
    154165  float dL = 0;
     
    186197  *pi2 = 0.5;
    187198
    188   float g1,g2,norm;
     199  //MEH -- need to be double to help avoid 0 in norm
     200  double g1,g2,norm;
    189201  float w1,w2;
    190202
     
    203215/*            *m2,*s2,*pi2); */
    204216/*     } */
     217
     218    if (xyrdebug == 1) {
     219        fprintf(stderr,"KMM EM iter: %d %f %f %f %f (%f %f %e) (%f %f %e)\n",
     220                *iter,logL_unimodal,logL_bimodal,oldL,dL,
     221                *m1,*s1,*pi1,
     222                *m2,*s2,*pi2);
     223    }
     224
    205225    // Expectation/P-stage
    206226    for (i = 0; i < values->n; i++) { // Calculate probabilities for each mode
     
    208228      g2 = gaussian(values->data.F32[i],*m2,*s2);
    209229      norm = (*pi1 * g1 + *pi2 * g2);
    210       P1->data.F32[i] = (*pi1 * g1) / norm;
    211       P2->data.F32[i] = (*pi2 * g2) / norm;
     230      //MEH -- must protect denom from norm=0
     231      if (norm > 0) {
     232          P1->data.F32[i] = (*pi1 * g1) / norm;
     233          P2->data.F32[i] = (*pi2 * g2) / norm;
     234      } else {
     235          P1->data.F32[i] = 0.0;
     236          P2->data.F32[i] = 0.0;
     237      } 
     238 
     239      if (xyrdebug == 1) {
     240          fprintf(stderr,"KMM EM-P loop: %d %d %le %le %le\n",
     241                         *iter,i,norm,g1,g2);
     242      }
     243
    212244    }
    213245    // Maximization/M-stage
     
    231263      w1 += P1->data.F32[i];
    232264      w2 += P2->data.F32[i];
     265
     266      if (xyrdebug == 1) {
     267          fprintf(stderr,"KMM EM-M loop: %d %d (%f %f %f %e) (%f %f %f %e)\n",
     268                         *iter,i,*m1,values->data.F32[i],w1,P1->data.F32[i],*m2,values->data.F32[i],w2,P2->data.F32[i]);
     269      }
     270
    233271    }
    234272    *m1 /= w1;
     
    250288      *pi2 = 0.0;
    251289    }
    252     if (*s1 == 0) { // sigma may not be zero
    253       *s1 = KMM_SMALL_NUMBER * *m1;
    254     }
    255     if (*s2 == 0) { // sigma may not be zero
    256       *s2 = KMM_SMALL_NUMBER * *m2;
    257     }
     290    if (*s1 == 0) { // sigma may not be zero -- MEH -- nor <0 and need additive offset if m~0
     291      *s1 = fabsf(KMM_SMALL_NUMBER * *m1) + KMM_SMALL_NUMBER;
     292    }
     293    if (*s2 == 0) { // sigma may not be zero
     294      *s2 = fabsf(KMM_SMALL_NUMBER * *m2) + KMM_SMALL_NUMBER;
     295    }
     296
     297    if (xyrdebug == 1) {
     298        fprintf(stderr,"KMM EM end: %d %f %f %f %f (%f %e %e %f) (%f %e %e %f)\n",
     299                *iter,logL_unimodal,logL_bimodal,oldL,dL,
     300                *m1,*s1,*pi1,w1,
     301                *m2,*s2,*pi2,w2);
     302    }
     303
    258304  } // End EM phase
    259305
     
    267313    *Punimodal = 1.0;
    268314  }
     315
     316  if (xyrdebug == 1) {
     317      fprintf(stderr,"KMM calc Puni: %d %f %d %f\n",
     318              xyrdebug,lambda,df,*Punimodal);
     319  }
     320
    269321  psFree(P1);
    270322  psFree(P2);
    271323}
    272324
    273 static void KMMFindPopular(const psVector *values, float *Punimodal, float *mean, float *sigma, float *pi) {
     325static void KMMFindPopular(const psVector *values, float *Punimodal, float *mean, float *sigma, float *pi, int xyrdebug) {
    274326  float KMM_MINIMUM_PVALUE = 0.05; // Should be an option.
    275327  float mU,sU;
     
    283335               &mU,&sU,
    284336               &pi1,&m1,&s1,
    285                &pi2,&m2,&s2);
     337               &pi2,&m2,&s2,xyrdebug);
    286338/*   fprintf(stdout,"%g %g : %g %g %g : %g %g %g : %g %d\t", */
    287339/*        mU,sU, */
     
    898950    psVector *pixelSuspects = buffer->suspects; // Is the pixel suspect?
    899951    psVector *pixelLimits = buffer->limits; // Is the pixel suspect?
     952    //MEH -- adding a debug option for TESTING xyr position but could be better..
     953    int xyrdebug = 0;
    900954
    901955    // KMM values;
     
    917971        // This should probably be an option
    918972        if (useKMM) {
    919           KMMFindPopular(pixelData,&Punimodal,&KMMmean,&KMMsigma,&KMMpi);
     973#ifdef TESTING
     974            if (PS_SQR(x - TEST_X) + PS_SQR(y - TEST_Y) <= PS_SQR(TEST_RADIUS)) {
     975                xyrdebug = 1;
     976            }
     977# endif
     978          KMMFindPopular(pixelData,&Punimodal,&KMMmean,&KMMsigma,&KMMpi,xyrdebug);
    920979          CHECKPIX(x,y,"KMM Popularity Contest: (%d,%d) Puni: %g Mean: %f Sigma %f Pi: %f\n",
    921980                   x,y,Punimodal,KMMmean,KMMsigma,KMMpi);
  • branches/eam_branches/ipp-20140402/psModules/src/imcombine/pmSubtraction.c

    r35771 r36677  
    3737#define USE_KERNEL_ERR                  // Use kernel error image?
    3838#define NUM_COVAR_POS 5                 // Number of positions for covariance calculation
     39//MEH -- this is causing diffim fault 5 -- seems not as robust
    3940#define USE_LOGFIT_REJECT
    4041
  • branches/eam_branches/ipp-20140402/psModules/src/objects/pmPSFtryFitPSF.c

    r36623 r36677  
    125125
    126126    if (Npsf == 0) {
     127#if 0
    127128        // DEBUG code: save the PSF model fit data in detail
    128129
     
    143144
    144145            pmSource *source = psfTry->sources->data[i];
     146
     147            if (!source->modelPSF) continue;
    145148
    146149            float par7 = (source->modelPSF->params->n == 7) ? -100 : source->modelPSF->params->data.F32[PM_PAR_7];
     
    155158        }
    156159        fclose (f);
    157 
     160#endif
    158161        psError(PS_ERR_UNKNOWN, false, "No sources with good PSF fits after model is built.");
    159162        return false;
  • branches/eam_branches/ipp-20140402/psastro/src/psastroLoadCrosstalk.c

    r33851 r36677  
    108108  SPIKE_MAX_MAG = psMetadataLookupF32(&status, recipe, "REFSTAR_MASK_BLEED_MAG_MAX");
    109109  SPIKE_MAX_MAG += MagOffset;
    110  
     110  //  psTraceSetLevel("psastro.crosstalk",2); 
    111111  psTrace("psastro.crosstalk",2,"%f %f %f %f\n",zeropt,exptime,MAX_MAG,MagOffset);
    112112
     
    147147          // Check each reference star
    148148          for (int i = 0; i < refstars->n; i++) {
     149            // This is the source of the ct.
    149150            pmAstromObj *ref = refstars->data[i];
    150151
     
    174175
    175176            float x_t_chip,y_t_chip;
    176 
     177            int faint_ct = 0;
    177178            pmCellCoordsForChip(&x_cell,&y_cell,CTsourceCell,ref->chip->x,ref->chip->y);
    178179
     
    180181            y_t_cell = y_cell;
    181182
     183            // 2014-04-15 CZW: Here are the list of known cross talks:
     184            // Inter-chip
     185            // OTA2yXY3v <=> OTA3yXY3v
     186            // OTA4yXY3v <=> OTA5yXY3v
     187            // Intra-chip
     188            // OTA2yXY5v <=> OTA2yXY6v
     189            // OTA5yXY5v <=> OTA5yXY6v
     190            // One way fainter
     191            // OTA2yXY7v => OTA3yXY2v
     192            // OTA5yXY7v => OTA4yXY2v
    182193            // Determine if this combination of chip and cell produces a crosstalk artifact
    183             if ((X == 2)&&(! ((U == 3)||(U == 5)||(U == 6)))) {
     194            if ((X == 2)&&(! ((U == 3)||(U == 5)||(U == 6)||(U == 7)))) {
    184195              psTrace ("psastro.crosstalk",2,"Cell (%d%d) on chip (%d%d) not a known crosstalk source.",U,V,X,Y);
     196              psTrace ("psastro.crosstalk",2,"t1: %d t2: %d",
     197                       (X == 2),
     198                       (! ((U == 3)||(U == 5)||(U == 6)||(U == 7))));
    185199              continue;
    186200            }
     
    193207              continue;
    194208            }
    195             if ((X == 5)&&(! ((U == 3)||(U == 5)||(U == 6)))) {
     209            if ((X == 5)&&(! ((U == 3)||(U == 5)||(U == 6)||(U == 7)))) {
    196210              psTrace ("psastro.crosstalk",2,"Cell (%d%d) on chip (%d%d) not a known crosstalk source.",U,V,X,Y);
    197211              continue;
     
    212226                Ut = 5;
    213227              }
     228              if (U == 7) {
     229                Xt = 3;
     230                Ut = 2;
     231                faint_ct = 1;
     232              }
    214233            }
    215234            else if (X == 3) {
     
    229248                Ut = 5;
    230249              }
     250              if (U == 7) {
     251                Xt = 4;
     252                Ut = 2;
     253                faint_ct = 1;
     254              }
    231255            }
    232256
     
    284308
    285309            // Determine if we need to add a spike mask.
     310            // CZW 2014-04-15 I'm not adding the new faint CT to this operation.  There's no evidence they produce such things.
    286311/*          psWarning("BLAH: %g %g %g\n",ref->Mag,MagOffset,SPIKE_MAX_MAG); */
    287312            if (ref->Mag < SPIKE_MAX_MAG) {
  • branches/eam_branches/ipp-20140402/psphot/src

  • branches/eam_branches/ipp-20140402/psphot/src/psphotFullForceReadout.c

    r36633 r36677  
    7878    psphotMergeSources (config, view, filerule);
    7979
    80 
    8180    // generate a psf model for any readouts which need one
    8281    // psphotFullForcePSF (config, view, filerule);
     
    8483    // sources; we should mark with a flag bit the ones we actually want to use as PSF
    8584    // stars (this means we need to supply this info in the load).
    86     psphotChoosePSF (config, view, filerule, false);
     85    if (!psphotChoosePSF (config, view, filerule, false)) {
     86        // PSPHOT_ERR_DATA causes this program to exit gracefully
     87        psError (PSPHOT_ERR_DATA, false, "failed to construct psf model");
     88        return  psphotReadoutCleanup (config, view, filerule);
     89    }
    8790
    8891    // Construct an initial model for each object, set the radius to fitRadius, set circular
  • branches/eam_branches/ipp-20140402/psphot/src/psphotFullForceSummary.c

    r36633 r36677  
    193193        if (ID >= sortedTable->n) {
    194194            sortedTable = psArrayRealloc(sortedTable, 2*ID);
     195            // Why doesn't psArrayRealloc do this?????
     196            sortedTable->n = sortedTable->nalloc;
    195197        }
    196198        if (sortedTable->data[ID]) {
  • branches/eam_branches/ipp-20140402/psphot/src/psphotLensing.c

    r36623 r36677  
    193193    // set the max order (0 = constant) which the number of psf stars can support:
    194194    // we require only 3 stars for n = 0, increase stars / cell for higher order
     195    if (Npsf < 3) {
     196        psLogMsg ("psphot", PS_LOG_INFO, "no sources passed selection criteria, skipping lensing psf trends");
     197        return true;
     198    }
    195199    int LensingTrendOrder = 0;
    196200    if (Npsf >=  16) LensingTrendOrder = 1; // 4 cells
  • branches/eam_branches/ipp-20140402/psphot/src/psphotStackImageLoop.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20140402/pstamp/scripts/pstamp_save_server_status.pl

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

    r35585 r36677  
    99Step Four: run gene.relastro.part2
    1010
    11 Step Five: run gene.relphot
     11Step Five: run gene.relphot.3pinew or run gene.relphot.mdnew (depends on tess)
    1212
Note: See TracChangeset for help on using the changeset viewer.