IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

splitting extended model fits and extended parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/unlabeled-1.8.4/psModules/src/objects/pmSourceIO_PS1_DEV_1.c

    r16294 r16658  
    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.4.1 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2008-02-25 18:03:34 $
    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.