IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16659


Ignore:
Timestamp:
Feb 25, 2008, 8:13:08 AM (18 years ago)
Author:
eugene
Message:

splitting ext fit measurements and aperture measurements

Location:
branches/eam_branch_20080225/psModules/src/objects
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080225/psModules/src/objects/pmSource.h

    r16066 r16659  
    33 * @author EAM, IfA; GLG, MHPCC
    44 *
    5  * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2008-01-15 02:48:28 $
     5 * @version $Revision: 1.22.8.1 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2008-02-25 18:13:08 $
    77 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    88 */
     
    5757 *  simplest measurement of a source is the location and flux of the peak pixel
    5858 *  associated with the source:
     59 *
     60 *  XXX do I have to re-organize this (again!) to allow an arbitrary set of extended model fits??
    5961 *
    6062 */
  • branches/eam_branch_20080225/psModules/src/objects/pmSourceIO.c

    r15562 r16659  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-11-10 01:09:20 $
     5 *  @version $Revision: 1.53.10.1 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2008-02-25 18:13:08 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    254254    char *dataname = NULL;
    255255    char *xsrcname = NULL;
     256    char *xfitname = NULL;
    256257    char *headname = NULL;
    257258
     
    319320        // if this is not TRUE, the output files only contain the psf measurements.
    320321        bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "SAVE.XSRC");
     322        bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "SAVE.XFIT");
    321323
    322324        // define the EXTNAME values for the different data segments:
     
    356358              }
    357359              xsrcname = pmFPAfileNameFromRule (rule, file, view);
     360            }
     361            if (XFIT_OUTPUT) {
     362              // EXTNAME for extended source data table
     363              rule = psMetadataLookupStr(&status, menu, "CMF.XFIT");
     364              if (!rule) {
     365                psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config");
     366                return false;
     367              }
     368              xfitname = pmFPAfileNameFromRule (rule, file, view);
    358369            }
    359370        }
     
    405416            psFree (exttype);
    406417
     418            // if we request XSRC output, add the XSRC name to this header
     419            if (xsrcname) {
     420              psMetadataAddStr (outhead, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
     421            }
     422            if (xfitname) {
     423              psMetadataAddStr (outhead, PS_LIST_TAIL, "XFITNAME", PS_META_REPLACE, "name of XFIT table extension", xfitname);
     424            }
     425
    407426            // XXX these are case-sensitive since the EXTYPE is case-sensitive
    408427            status = false;
     
    416435                status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname, xsrcname);
    417436            }
     437            if (xsrcname) {
     438              if (!strcmp (exttype, "PS1_DEV_1")) {
     439                status = pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname);
     440              }
     441            }
     442            if (xfitname) {
     443              if (!strcmp (exttype, "PS1_DEV_1")) {
     444                status = pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
     445              }
     446            }
    418447            if (!status) {
    419448                psError(PS_ERR_IO, false, "writing CMF data to %s with format %s\n", file->filename, exttype);
  • branches/eam_branch_20080225/psModules/src/objects/pmSourceIO_PS1_DEV_1.c

    r16294 r16659  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2008-02-03 22:04:47 $
     5 *  @version $Revision: 1.8.6.1 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2008-02-25 18:13:08 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6161    psF32 xPos, yPos;
    6262    psF32 xErr, yErr;
    63 
    64     // if we request XSRC output, add the XSRC name to this header
    65     if (xsrcname) {
    66       psMetadataAddStr (tableHeader, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
    67     }
    6863
    6964    // let's write these out in S/N order
     
    155150    psFree (table);
    156151
    157     if (xsrcname) {
    158       pmSourcesWrite_PS1_DEV_1_XSRC (fits, sources, xsrcname);
    159     }
    160 
    161152    return true;
    162153}
     
    284275    // we write out all sources, regardless of quality.  the source flags tell us the state
    285276    for (i = 0; i < sources->n; i++) {
    286         // source->seq is set during the PSF output step, which must be called
    287         // XXX test here if seq is set?
    288 
    289277        // skip source if it is not a ext sourc
    290278        // XXX we have two places that extended source parameters are measured:
     
    305293        if (source->extpars == NULL) continue;
    306294
     295        // XXX I need to split the extended models from the extended aperture measurements
    307296        PAR = model->params->data.F32;
    308297        dPAR = model->dparams->data.F32;
     
    312301        yErr = dPAR[PM_PAR_YPOS];
    313302
     303        // XXX for the aperture values, I probably can / should just refer to the psf position and not write any of this
    314304        axes = pmPSF_ModelToAxes (PAR, 20.0);
    315305
     
    329319        psMetadataAdd (row, PS_LIST_TAIL, "EXT_THETA",        PS_DATA_F32, "EXT orientation angle",                      axes.theta);
    330320
    331         // XXX at the moment, this will be a fixed size table, but perhaps have multiple output formats depending on what is measured?
     321        // XXX at the moment, this will be a fixed sized table, but perhaps have multiple output formats depending on what is measured?
    332322
    333323        // other values that I need to report:
     
    401391    return true;
    402392}
     393
     394bool pmSourcesWrite_PS1_DEV_1_XFIT (psFits *fits, psArray *sources, char *extname)
     395{
     396
     397    psArray *table;
     398    psMetadata *row;
     399    int i;
     400    psF32 *PAR, *dPAR;
     401    psEllipseAxes axes;
     402    psF32 xPos, yPos;
     403    psF32 xErr, yErr;
     404
     405    // create a header to hold the output data
     406    psMetadata *outhead = psMetadataAlloc ();
     407
     408    // write the links to the image header
     409    psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "xsrc table extension", extname);
     410
     411    // let's write these out in S/N order
     412    sources = psArraySort (sources, pmSourceSortBySN);
     413
     414    table = psArrayAllocEmpty (sources->n);
     415
     416    // we write out all sources, regardless of quality.  the source flags tell us the state
     417    for (i = 0; i < sources->n; i++) {
     418        // skip source if it is not a ext sourc
     419        // XXX we have two places that extended source parameters are measured:
     420        // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models,
     421        // psphotFitEXT, which does the simple extended source model fit (not psf-convolved)
     422        // should we require both?
     423
     424        pmSource *source = sources->data[i];
     425
     426        // XXX need to have an array of model fits; loop over the array and write out all
     427        // which we calculated
     428
     429        // choose the convolved EXT model, if available, otherwise the simple one
     430        // XXX should not need to choose: write both out
     431        pmModel *model = source->modelConv;
     432        if (model == NULL) {
     433            model = source->modelEXT;
     434        }
     435        if (model == NULL) continue;
     436
     437        PAR = model->params->data.F32;
     438        dPAR = model->dparams->data.F32;
     439        xPos = PAR[PM_PAR_XPOS];
     440        yPos = PAR[PM_PAR_YPOS];
     441        xErr = dPAR[PM_PAR_XPOS];
     442        yErr = dPAR[PM_PAR_YPOS];
     443
     444        axes = pmPSF_ModelToAxes (PAR, 20.0);
     445
     446        row = psMetadataAlloc ();
     447        // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)
     448        psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET",         PS_DATA_U32, "IPP detection identifier index",             source->seq);
     449        psMetadataAdd (row, PS_LIST_TAIL, "X_EXT",            PS_DATA_F32, "EXT model x coordinate",                     xPos);
     450        psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT",            PS_DATA_F32, "EXT model y coordinate",                     yPos);
     451        psMetadataAdd (row, PS_LIST_TAIL, "X_EXT_SIG",        PS_DATA_F32, "Sigma in EXT x coordinate",                  xErr);
     452        psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT_SIG",        PS_DATA_F32, "Sigma in EXT y coordinate",                  yErr);
     453        psMetadataAdd (row, PS_LIST_TAIL, "EXT_INST_MAG",     PS_DATA_F32, "EXT fit instrumental magnitude",             source->extMag);
     454        psMetadataAdd (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->errMag);
     455
     456        // XXX these should be major and minor, not 'x' and 'y'
     457        psMetadataAdd (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ",    PS_DATA_F32, "EXT width in x coordinate",                  axes.major);
     458        psMetadataAdd (row, PS_LIST_TAIL, "EXT_WIDTH_MIN",    PS_DATA_F32, "EXT width in y coordinate",                  axes.minor);
     459        psMetadataAdd (row, PS_LIST_TAIL, "EXT_THETA",        PS_DATA_F32, "EXT orientation angle",                      axes.theta);
     460
     461        // XXX other parameters which may be set.
     462        // XXX flag / value to define the model
     463
     464        psArrayAdd (table, 100, row);
     465        psFree (row);
     466    }
     467
     468    if (table->n == 0) {
     469        psFitsWriteBlank (fits, outhead, extname);
     470        psFree (table);
     471        return true;
     472    }
     473
     474    psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname);
     475    if (!psFitsWriteTable (fits, outhead, table, extname)) {
     476        psError(PS_ERR_IO, false, "writing ext data %s\n", extname);
     477        psFree(table);
     478        return false;
     479    }
     480    psFree (table);
     481
     482    return true;
     483}
Note: See TracChangeset for help on using the changeset viewer.