IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 20, 2005, 6:48:16 PM (21 years ago)
Author:
eugene
Message:

alternative clipping for pmPSFtryMetric

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotOutput.c

    r5073 r5084  
    2626
    2727    if (!strcasecmp (outputMode, "OBJ")) {
    28         pmSourcesWriteOBJ (imdata, outputFile, sources, psf, sky);
     28        pmSourcesWriteOBJ (imdata, config, outputFile, sources, psf, sky);
    2929        return;
    3030    }
     
    3636 
    3737    if (!strcasecmp (outputMode, "CMP")) {
    38         pmSourcesWriteCMP (imdata, outputFile, sources, psf, sky);
     38        pmSourcesWriteCMP (imdata, config, outputFile, sources, psf, sky);
    3939        return;
    4040    }
    4141 
    4242    if (!strcasecmp (outputMode, "CMF")) {
    43         pmSourcesWriteCMF (imdata, outputFile, sources, psf, sky);
     43        pmSourcesWriteCMF (imdata, config, outputFile, sources, psf, sky);
    4444        return;
    4545    }
     
    6868
    6969// dophot-style output list with fixed line width
    70 bool pmSourcesWriteOBJ (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
     70bool pmSourcesWriteOBJ (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
    7171
    7272    int i, type, status;
     
    7474    psF32 *PAR, *dPAR;
    7575    float sky, dmag, apMag, fitMag;
     76    float x, y, rflux;
     77    bool result;
    7678
    7779    psLine *line = psLineAlloc (104);  // 104 is dophot-defined line length
     
    8284        return false;
    8385    }
     86
     87    float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
    8488
    8589    // write sources with models first
     
    296300
    297301// elixir-style pseudo FITS table (header + ascii list)
    298 bool pmSourcesWriteCMP (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
     302bool pmSourcesWriteCMP (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
    299303
    300304    int i, type, status;
    301305    pmModel *model;
     306    psMetadataItem *mdi;
    302307    psF32 *PAR, *dPAR;
    303     float sky, dmag, apMag, fitMag, lsky, Theta;
     308    float sky, dmag, apMag, fitMag, lsky;
     309    float x, y, rflux;
     310    bool result;
    304311
    305312    // create file, write-out header
    306313    unlink (filename);
    307314    psFits *fits = psFitsAlloc (filename);
     315
     316    // set NAXIS to 0 : CFITSIO requires isolated header to have NAXIS = 0
     317    mdi = psMetadataLookup (imdata->header, "NAXIS");
     318    mdi->data.S32 = 0;
     319    mdi->type = PS_META_S32;
     320
     321    // psMetadataAdd (imdata->header, PS_LIST_HEAD, "NAXIS", PS_META_S32 | PS_META_REPLACE, "", 0);
    308322    psFitsWriteHeader (imdata->header, fits);
    309323    psFree (fits);
     
    317331    fseek (f, 0, SEEK_END);
    318332
    319     psLine *line = psLineAlloc (66);  // 66 is imclean-defined line length
     333    psLine *line = psLineAlloc (67);  // 66 is imclean-defined line length
     334
     335    float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
     336
     337    // XXX EAM : need to add these concepts to the header (from psf and config)
     338    // fits_modify (header, "ZERO_PT", "%lf", 1, ZERO_POINT);
     339    // fits_modify (header, "FWHM_X", "%lf", 1, FWHMx);
     340    // fits_modify (header, "FWHM_Y", "%lf", 1, FWHMy);
     341    // fits_modify (header, "ANGLE", "%lf", 1, angle);
     342    // fits_modify (header, "FSATUR", "%lf", 1, saturate);  // can use 0.0
     343    // fits_modify (header, "FLIMIT", "%lf", 1, complete);  // can use 0.0
     344    // fits_modify (header, "NSTARS", "%d", 1, N);
    320345
    321346    // write sources with models first
     
    404429        psLineAdd (line, "%6.2f ", PAR[4]);  // should be 'FHWM x'
    405430        psLineAdd (line, "%6.2f ", PAR[5]);  // should be 'FHWM y'
    406         psLineAdd (line, "%5.1f\n", Theta);   // should be theta
     431        psLineAdd (line, "%5.1f\n", 0);   // should be theta
    407432        fwrite (line->line, 1, line->Nline, f);
    408433    }
     
    414439// this format consists of a header derived from the image header
    415440// followed by a zero-size matrix, followed by the table data
    416 bool pmSourcesWriteCMF (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
     441bool pmSourcesWriteCMF (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
    417442
    418443    psArray *table;
     444    psMetadataItem *mdi;
    419445    psMetadata *row;
    420446    psMetadata *theader;
     447    int i, type, status;
     448    pmModel *model;
     449    psF32 *PAR, *dPAR;
     450    float sky, dmag, apMag, fitMag;
     451    float x, y, rflux, lsky;
     452    bool result;
    421453
    422454    // set NAXIS to 0
    423     psMetadataAdd (header, PS_LIST_HEAD, "NAXIS", PS_META_S32 | PS_META_REPLACE, "", 0);
     455    fprintf (stderr, "setting naxis\n");
     456    mdi = psMetadataLookup (imdata->header, "NAXIS");
     457    mdi->data.S32 = 0;
     458    mdi->type = PS_META_S32;
     459
     460    // psMetadataAdd (imdata->header, PS_LIST_HEAD, "NAXIS", PS_META_S32 | PS_META_REPLACE, "", 0);
    424461
    425462    table = psArrayAlloc (sources->n);
    426463    sources->n = 0;
     464
     465    float RADIUS = psMetadataLookupF32 (&result, config, "PSF_FIT_RADIUS");
    427466
    428467    for (i = 0; i < sources->n; i++) {
     
    499538        lsky = (PAR[0] < 1.0) ? 0.0 : log10(PAR[0]);
    500539
    501         table = psMetdataAlloc ();
    502         psMetadataAdd (table, PS_LIST_HEAD, "X_PIX",   PS_META_F32, "", PAR[2]);
    503         psMetadataAdd (table, PS_LIST_HEAD, "Y_PIX",   PS_META_F32, "", PAR[3]);
    504         psMetadataAdd (table, PS_LIST_HEAD, "MAG_RAW", PS_META_F32, "", fitMag + 25.0);
    505         psMetadataAdd (table, PS_LIST_HEAD, "MAG_ERR", PS_META_F32, "", (int)(1000*dmag));
    506         psMetadataAdd (table, PS_LIST_HEAD, "MAG_GAL", PS_META_F32, "", type);
    507         psMetadataAdd (table, PS_LIST_HEAD, "MAG_AP",  PS_META_F32, "", lsky);
    508         psMetadataAdd (table, PS_LIST_HEAD, "LOG_SKY", PS_META_F32, "", 32.0);    // should be 'Mgal'
    509         psMetadataAdd (table, PS_LIST_HEAD, "FWHM_X",  PS_META_F32, "", apMag + 25.0); // 25.0 should come from config
    510         psMetadataAdd (table, PS_LIST_HEAD, "FWHM_Y",  PS_META_F32, "", PAR[4]);  // should be 'FHWM x'
    511         psMetadataAdd (table, PS_LIST_HEAD, "THETA",   PS_META_F32, "", PAR[5]);  // should be 'FHWM y'
    512         psMetadataAdd (table, PS_LIST_HEAD, "DOPHOT",  PS_META_S8,  "", Theta);   // should be theta
     540        row = psMetadataAlloc ();
     541        psMetadataAdd (row, PS_LIST_HEAD, "X_PIX",   PS_META_F32, "", PAR[2]);
     542        psMetadataAdd (row, PS_LIST_HEAD, "Y_PIX",   PS_META_F32, "", PAR[3]);
     543        psMetadataAdd (row, PS_LIST_HEAD, "MAG_RAW", PS_META_F32, "", fitMag + 25.0);
     544        psMetadataAdd (row, PS_LIST_HEAD, "MAG_ERR", PS_META_F32, "", (int)(1000*dmag));
     545        psMetadataAdd (row, PS_LIST_HEAD, "MAG_GAL", PS_META_F32, "", type);
     546        psMetadataAdd (row, PS_LIST_HEAD, "MAG_AP",  PS_META_F32, "", lsky);
     547        psMetadataAdd (row, PS_LIST_HEAD, "LOG_SKY", PS_META_F32, "", 32.0);    // should be 'Mgal'
     548        psMetadataAdd (row, PS_LIST_HEAD, "FWHM_X",  PS_META_F32, "", apMag + 25.0); // 25.0 should come from config
     549        psMetadataAdd (row, PS_LIST_HEAD, "FWHM_Y",  PS_META_F32, "", PAR[4]);  // should be 'FHWM x'
     550        psMetadataAdd (row, PS_LIST_HEAD, "THETA",   PS_META_F32, "", PAR[5]);  // should be 'FHWM y'
     551        psMetadataAdd (row, PS_LIST_HEAD, "DOPHOT",  PS_TYPE_S8,  "", 0);   // should be theta
    513552        // psMetadataAdd (header, PS_LIST_HEAD, "DUMMY",   PS_META_STR, "", NULL);
    514553   
     
    517556    }
    518557
    519     image = psImageAlloc (0, 0, PS_TYPE_F32);
    520     theader = psFitsHeaderFromTable (NULL, table, "SMPFILE");
     558    // psAbort ("psphotOutput", "FITS table output not finished");
     559
     560    psImage *image = psImageAlloc (1, 1, PS_TYPE_F32);
     561    // XXX missing: theader = psFitsHeaderFromTable (NULL, table, "SMPFILE");
     562
     563    theader = psMetadataAlloc ();
     564    psMetadataAdd (theader, PS_LIST_HEAD, "EXTNAME", PS_META_STR, "extension name", "SMPFILE");
    521565
    522566    unlink (filename);
    523567    psFits *fits = psFitsAlloc (filename);
    524     psFitsWriteImage (fits, header, image, 0, NULL);
     568    psFitsWriteImage (fits, imdata->header, image, 0);
    525569    psFitsWriteTable (fits, theader, table);
    526570    psFree (fits);
Note: See TracChangeset for help on using the changeset viewer.