IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23584


Ignore:
Timestamp:
Mar 29, 2009, 1:47:03 PM (17 years ago)
Author:
eugene
Message:

updates for mef output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroExtractAnalysis.c

    r23412 r23584  
    1313# include "psastroInternal.h"
    1414
    15 # define ESCAPE {                                                       \
    16         psError(PS_ERR_UNKNOWN, false, "I/O failure in psastroMaskUpdate"); \
     15# define ESCAPE(MSG) {                                                  \
     16        psError(PS_ERR_UNKNOWN, false, "I/O failure in psastroMaskUpdate: %s", MSG); \
    1717        psFree (view);                                                  \
    1818        return false;                                                   \
    1919    }
    2020
    21 # define TEST_OUTPUT 1
     21# define TEST_OUTPUT 0
    2222
    2323psImage *psastroExtractStar (psImage *input, float x, float y, float dX, float dY);
     
    117117    pmFPAview *view = pmFPAviewAlloc (0);
    118118
     119    // generate a (very) basic header:
     120    psMetadata *phu = psMetadataAlloc ();
     121    // select the filter; default to fixed photcode and mag limit otherwise
     122    char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID");
     123    if (!status) ESCAPE("missing FPA.FILTER in concepts");
     124
     125    psMetadataAddStr (phu, PS_LIST_TAIL, "FILTER",  0, "filter", filter);
     126    psMetadataAddF32 (phu, PS_LIST_TAIL, "EXPTIME", 0, "exptime", exptime);
     127    psMetadataAddF32 (phu, PS_LIST_TAIL, "ZEROPT",  0, "zeropt", zeropt);
     128    psFitsWriteBlank (outStars, phu, NULL);
     129    psFree (phu);
     130
    119131    // open/load files as needed
    120     if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     132    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE("failed on FPA BEFORE");
    121133
    122134    // this loop selects the matched stars for all chips
     
    126138        if (!chip->fromFPA) { continue; }
    127139
    128         if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     140        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE("failed on Chip BEFORE");
    129141
    130142        // text output file for testing
     
    164176
    165177                    pmReadout *inReadout = pmFPAviewThisReadout (view, input->fpa);
    166                     psImage *subraster = psastroExtractStar (inReadout->image, ref->chip->x, ref->chip->y, 100.0, 100.0);
     178                    psImage *subraster = psastroExtractStar (inReadout->image, ref->chip->x, ref->chip->y, 200.0, 200.0);
    167179                    if (!subraster) continue;
    168180                   
     181                    // generate a (very) basic header:
     182                    psMetadata *header = psMetadataAlloc ();
     183                    psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_X",  0, "chip coordinate",        ref->chip->x);
     184                    psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_Y",  0, "chip coordinate",        ref->chip->y);
     185                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_X",   0, "focal-plane coordinate", ref->FP->x);
     186                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y",   0, "focal-plane coordinate", ref->FP->y);
     187                    psMetadataAddF32 (header, PS_LIST_TAIL, "MAG",     0, "magnitude",              ref->Mag);
     188
    169189                    snprintf (extname, 80, "extname.%05d", nExt);
    170                     psFitsWriteImage (outStars, NULL, subraster, 0, extname);
     190                    psFitsWriteImage (outStars, header, subraster, 0, extname);
    171191                    nExt ++;
    172192                   
     193                    psFree (header);
    173194                    psFree (subraster);
    174195                }
    175                 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     196                if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on Readout AFTER");;
    176197            }
    177             if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     198            if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on Cell AFTER");;
    178199        }
    179         if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    180 
    181         fclose (f);
    182     }
    183     if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     200        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on Chip AFTER");;
     201
     202        if (f) fclose (f);
     203    }
     204    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on FPA AFTER");;
    184205
    185206    psFitsClose (outStars);
Note: See TracChangeset for help on using the changeset viewer.