IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21488


Ignore:
Timestamp:
Feb 15, 2009, 9:54:28 AM (17 years ago)
Author:
eugene
Message:

adding new I/O format PS1_V1

Location:
branches/eam_branch_20090208/psModules/src/objects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20090208/psModules/src/objects/pmSourceIO.c

    r21448 r21488  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.69.12.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2009-02-12 04:42:05 $
     5 *  @version $Revision: 1.69.12.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2009-02-15 19:54:12 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    493493                status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname);
    494494            }
    495             if (!strcmp (exttype, "CMF_PS1_V1")) {
     495            if (!strcmp (exttype, "PS1_V1")) {
    496496                status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname);
    497497            }
     
    503503                  status = pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
    504504              }
    505               if (!strcmp (exttype, "CMF_PS1_V1")) {
     505              if (!strcmp (exttype, "PS1_V1")) {
    506506                  status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);
    507507              }
     
    514514                  status = pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);
    515515              }
    516               if (!strcmp (exttype, "CMF_PS1_V1")) {
     516              if (!strcmp (exttype, "PS1_V1")) {
    517517                  status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);
    518518              }
     
    938938                sources = pmSourcesRead_PS1_DEV_1 (file->fits, hdu->header);
    939939            }
    940             if (!strcmp (exttype, "PS1_CAL_0")) {
    941                 sources = pmSourcesRead_PS1_CAL_0 (file->fits, hdu->header);
     940            if (!strcmp (exttype, "PS1_V1")) {
     941                sources = pmSourcesRead_CMF_PS1_V1 (file->fits, hdu->header);
    942942            }
    943943        }
  • branches/eam_branch_20090208/psModules/src/objects/pmSourceIO_CMF_PS1_V1.c

    r21448 r21488  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2009-02-12 04:42:37 $
     5 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2009-02-15 19:54:28 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7575    }
    7676
    77     // let's write these out in S/N order
    78     sources = psArraySort (sources, pmSourceSortBySN);
     77    // if the sequence is defined, write these in seq order; otherwise
     78    // write them in S/N order:
     79    if (sources->n > 0) {
     80        pmSource *source = (pmSource *) sources->data[0];
     81        if (source->seq == -1) {
     82          // let's write these out in S/N order
     83          sources = psArraySort (sources, pmSourceSortBySN);
     84        } else {
     85          sources = psArraySort (sources, pmSourceSortBySeq);
     86        }
     87    }
    7988
    8089    table = psArrayAllocEmpty (sources->n);
    8190
    8291    // we write out PSF-fits for all sources, regardless of quality.  the source flags tell us the state
     92    // by the time we call this function, all values should be assigned.  let's use asserts to be sure in some cases.
    8393    for (i = 0; i < sources->n; i++) {
    8494        pmSource *source = (pmSource *) sources->data[i];
     95
     96        // If source->seq is -1, source was generated in this analysis.  If source->seq is
     97        // not -1, source was read from elsewhere: in the latter case, preserve the source
     98        // ID.  source.seq is used instead of source.id since the latter is a const
     99        // generated on Alloc, and would thus be wrong for read in sources.
    85100        if (source->seq == -1) {
    86             source->seq = i;
     101          source->seq = i;
    87102        }
    88103
     
    95110            xPos = PAR[PM_PAR_XPOS];
    96111            yPos = PAR[PM_PAR_YPOS];
    97             xErr = dPAR[PM_PAR_XPOS];
    98             yErr = dPAR[PM_PAR_YPOS];
     112            if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) {
     113              xErr = dPAR[PM_PAR_XPOS];
     114              yErr = dPAR[PM_PAR_YPOS];
     115            } else {
     116              // in linear-fit mode, there is no error on the centroid
     117              xErr = source->peak->dx;
     118              yErr = source->peak->dy;
     119            }         
    99120            if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) {
    100121                axes = pmPSF_ModelToAxes (PAR, 20.0);
     
    134155
    135156        row = psMetadataAlloc ();
    136         // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)
    137157        psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET",         PS_DATA_U32, "IPP detection identifier index",             source->seq);
    138158        psMetadataAdd (row, PS_LIST_TAIL, "X_PSF",            PS_DATA_F32, "PSF x coordinate",                           xPos);
     
    146166        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    147167        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        errMag);
    148         psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_STANDARD",  PS_DATA_F32, "magnitude in standard aperture",             source->apMag);
     168        psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG",           PS_DATA_F32, "magnitude in standard aperture",             source->apMag);
    149169        psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS",    PS_DATA_F32, "radius used for aperture mags",              apRadius);
    150170        psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",           peakMag);
     
    170190        psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_YY",        PS_DATA_F32, "second moments (Y*Y)",                      source->moments->Myy);
    171191
     192        psMetadataAdd (row, PS_LIST_TAIL, "FLAGS",            PS_DATA_U32, "psphot analysis flags",                      source->mode);
     193
    172194        // XXX not sure how to get this : need to load Nimages with weight?
    173195        psMetadataAdd (row, PS_LIST_TAIL, "N_FRAMES",         PS_DATA_U16, "Number of frames overlapping source center", nImageOverlap);
    174         psMetadataAdd (row, PS_LIST_TAIL, "FLAGS",            PS_DATA_U16, "psphot analysis flags",                      source->mode);
     196        psMetadataAdd (row, PS_LIST_TAIL, "PADDING",          PS_DATA_S16, "padding", 0);
    175197
    176198        psArrayAdd (table, 100, row);
     
    227249    psArray *sources = psArrayAlloc(numSources); // Array of sources, to return
    228250
    229     // convert the table to the pmSource entries
     251    // convert the table to the pmSource entriesa
    230252    for (int i = 0; i < numSources; i++) {
    231253        psMetadata *row = psFitsReadTableRow(fits, i); // Table row
     
    245267        dPAR[PM_PAR_XPOS] = psMetadataLookupF32 (&status, row, "X_PSF_SIG");
    246268        dPAR[PM_PAR_YPOS] = psMetadataLookupF32 (&status, row, "Y_PSF_SIG");
    247         axes.major        = psMetadataLookupF32 (&status, row, "PSF_WIDTH_X");
    248         axes.minor        = psMetadataLookupF32 (&status, row, "PSF_WIDTH_Y");
     269        axes.major        = psMetadataLookupF32 (&status, row, "PSF_MAJOR");
     270        axes.minor        = psMetadataLookupF32 (&status, row, "PSF_MINOR");
    249271        axes.theta        = psMetadataLookupF32 (&status, row, "PSF_THETA");
    250272
    251273        PAR[PM_PAR_SKY]   = psMetadataLookupF32 (&status, row, "SKY");
    252274        dPAR[PM_PAR_SKY]  = psMetadataLookupF32 (&status, row, "SKY_SIGMA");
    253         source->sky = PAR[PM_PAR_SKY];
    254         source->skyErr = dPAR[PM_PAR_SKY];
     275        source->sky       = PAR[PM_PAR_SKY];
     276        source->skyErr    = dPAR[PM_PAR_SKY];
    255277
    256278        // XXX use these to determine PAR[PM_PAR_I0]?
    257279        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    258280        source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     281        source->apMag     = psMetadataLookupF32 (&status, row, "AP_MAG");
    259282
    260283        // XXX this scaling is incorrect: does not include the 2 \pi AREA factor
     
    264287        pmPSF_AxesToModel (PAR, axes);
    265288
    266         float lflux = psMetadataLookupF32 (&status, row, "PEAK_FLUX_AS_MAG");
    267         float flux = (isfinite(lflux)) ? pow(10.0, -0.4*lflux) : NAN;
    268         source->peak = pmPeakAlloc(PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], flux, PM_PEAK_LONE);
    269         source->peak->flux = flux;
     289        float peakMag     = psMetadataLookupF32 (&status, row, "PEAK_FLUX_AS_MAG");
     290        float peakFlux    = (isfinite(peakMag)) ? pow(10.0, -0.4*peakMag) : NAN;
     291
     292        // recreate the peak to match (xPos, yPos) +/- (xErr, yErr)
     293        source->peak = pmPeakAlloc(PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], peakFlux, PM_PEAK_LONE);
     294        source->peak->flux = peakFlux;
     295        source->peak->dx   = dPAR[PM_PAR_XPOS];
     296        source->peak->dy   = dPAR[PM_PAR_YPOS];
    270297
    271298        source->pixWeight = psMetadataLookupF32 (&status, row, "PSF_QF");
    272 
    273         // note that some older versions used PSF_PROBABILITY: this was not well defined.
    274         model->chisq      = psMetadataLookupF32 (&status, row, "PSF_CHISQ");
    275299        source->crNsigma  = psMetadataLookupF32 (&status, row, "CR_NSIGMA");
    276300        source->extNsigma = psMetadataLookupF32 (&status, row, "EXT_NSIGMA");
    277301
    278         source->mode      = psMetadataLookupU16 (&status, row, "FLAGS");
     302        // note that some older versions used PSF_PROBABILITY: this was not well defined.
     303        model->chisq      = psMetadataLookupF32 (&status, row, "PSF_CHISQ");
     304        model->nDOF       = psMetadataLookupS32 (&status, row, "PSF_NDOF");
     305        model->nPix       = psMetadataLookupS32 (&status, row, "PSF_NPIX");
     306        model->radiusFit  = psMetadataLookupS32 (&status, row, "AP_MAG_RADIUS");
     307
     308        source->moments = pmMomentsAlloc ();
     309        source->moments->Mxx = psMetadataLookupF32 (&status, row, "MOMENTS_XX");
     310        source->moments->Mxy = psMetadataLookupF32 (&status, row, "MOMENTS_XY");
     311        source->moments->Myy = psMetadataLookupF32 (&status, row, "MOMENTS_YY");
     312
     313        source->mode = psMetadataLookupU32 (&status, row, "FLAGS");
    279314        assert (status);
    280315
Note: See TracChangeset for help on using the changeset viewer.