IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23592


Ignore:
Timestamp:
Mar 29, 2009, 4:04:51 PM (17 years ago)
Author:
eugene
Message:

extract ghosts in first pass, extract pixels along with stars

Location:
trunk/psastro/src
Files:
3 edited

Legend:

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

    r23591 r23592  
    5151    psFree(refs);
    5252
     53    // convert star positions to ghost positions and add to the readout->analysis data
     54    psastroExtractGhosts (config);
     55
    5356    psastroExtractStars (config);
    54     psastroExtractGhosts (config);
    5557    return true;
    5658}
  • trunk/psastro/src/psastroExtractGhosts.c

    r23591 r23592  
    2929    pmReadout *readout = NULL;
    3030    float zeropt, exptime;
    31     char extname[81];
    3231
    33     psLogMsg ("psastro", PS_LOG_INFO, "extracting bright-star subrasters");
     32    psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions");
    3433
    3534    // select the current recipe
     
    5352    pmFPA *fpa = astrom->fpa;
    5453
    55     // select the input data sources
    56     pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.EXTRACT.INPUT");
    57     if (!input) {
    58         psError(PSASTRO_ERR_CONFIG, true, "Can't find input data");
    59         return false;
    60     }
    61 
    62     // only load data from INPUT
    63     pmFPAfileActivate(config->files, false, NULL);
    64     pmFPAfileActivate(config->files, true, "PSASTRO.EXTRACT.INPUT");
    65 
    6654    // really error-out here?  or just skip?
    6755    if (!psastroZeroPointFromRecipe (&zeropt, &exptime, fpa, recipe)) {
     
    7563    EXTRACT_MAX_MAG += MagOffset;
    7664
    77     int nExt = 0;
    78 
    79     // open the output file handle: we are just saving a series of extensions to this file
    80     char *fileroot = psMetadataLookupStr (&status, config->arguments, "OUTPUT");
    81     if (!fileroot) {
    82         psLogMsg ("psastro", PS_LOG_INFO, "output filename not supplied");
    83         return false;
    84     }
    85     char *filename = NULL;
    86     psStringAppend (&filename, "%s.gh.fits", fileroot);
    87 
    88     psFits *outStars = psFitsOpen (filename, "w");
    89     if (!outStars) {
    90         psError(PS_ERR_IO, false, "error opening file %s\n", filename);
    91         return false;
    92     }
    93 
    9465    pmFPAview *view = pmFPAviewAlloc (0);
    95 
    96     // generate a (very) basic header:
    97     psMetadata *phu = psMetadataAlloc ();
    98     // select the filter; default to fixed photcode and mag limit otherwise
    99     char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID");
    100     if (!status) ESCAPE("missing FPA.FILTER in concepts");
    101 
    102     psMetadataAddStr (phu, PS_LIST_TAIL, "FILTER",  0, "filter", filter);
    103     psMetadataAddF32 (phu, PS_LIST_TAIL, "EXPTIME", 0, "exptime", exptime);
    104     psMetadataAddF32 (phu, PS_LIST_TAIL, "ZEROPT",  0, "zeropt", zeropt);
    105     psFitsWriteBlank (outStars, phu, NULL);
    106     psFree (phu);
    107 
    108     // open/load files as needed
    109     if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE("failed on FPA BEFORE");
    11066
    11167    // this loop selects the matched stars for all chips
     
    11470        if (!chip->process || !chip->file_exists) { continue; }
    11571        if (!chip->fromFPA) { continue; }
    116 
    117         if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE("failed on Chip BEFORE");
    11872
    11973        while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
     
    150104                    if (!ghostReadout) continue;
    151105
    152                     // XXX box size needs to be larger...
    153                     psImage *subraster = psastroExtractStar (ghostReadout->image, xChip, yChip, 200.0, 200.0);
    154                     if (!subraster) continue;
     106                    psArray *ghosts = psMetadataLookupPtr (&status, ghostReadout->analysis, "PSASTRO.GHOSTS");
     107                    if (ghosts == NULL) {
     108                        ghosts = psArrayAllocEmpty (100);
     109                        psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.GHOSTS", PS_DATA_ARRAY, "astrometry matches", ghosts);
     110                        psFree (ghosts);
     111                    }
     112
     113                    pmAstromObj *ghost = pmAstromObjAlloc ();
     114                    ghost->FP->x   = xFPA;
     115                    ghost->FP->y   = yFPA;
     116                    ghost->chip->x = xChip;
     117                    ghost->chip->y = yChip;
     118                    ghost->TP->x   = ref->FP->x; // XXX this is a bit of sleazy over-loading
     119                    ghost->TP->y   = ref->FP->y;
     120                    ghost->Mag     = ref->Mag;
    155121                   
    156                     // generate a (very) basic header:
    157                     psMetadata *header = psMetadataAlloc ();
    158                     psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_X",  0, "chip coordinate",        ref->chip->x);
    159                     psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_Y",  0, "chip coordinate",        ref->chip->y);
    160                     psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_X",   0, "focal-plane coordinate", ref->FP->x);
    161                     psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y",   0, "focal-plane coordinate", ref->FP->y);
    162                     psMetadataAddF32 (header, PS_LIST_TAIL, "MAG",     0, "magnitude",              ref->Mag);
     122                    psArrayAdd (ghosts, 100, ghost);
     123                    psFree (ghost);
     124                }
     125            }
     126        }
     127    }
    163128
    164                     snprintf (extname, 80, "extname.%05d", nExt);
    165                     psFitsWriteImage (outStars, header, subraster, 0, extname);
    166                     nExt ++;
    167                    
    168                     psFree (header);
    169                     psFree (subraster);
    170                 }
    171                 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on Readout AFTER");;
    172             }
    173             if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on Cell AFTER");;
    174         }
    175         if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on Chip AFTER");;
    176     }
    177     if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on FPA AFTER");;
    178 
    179     psFitsClose (outStars);
    180     psFree (filename);
    181129    psFree (view);
    182130    return true;
  • trunk/psastro/src/psastroExtractStars.c

    r23591 r23592  
    8383        return false;
    8484    }
     85
    8586    char *filename = NULL;
    8687    psStringAppend (&filename, "%s.st.fits", fileroot);
    87 
    8888    psFits *outStars = psFitsOpen (filename, "w");
    8989    if (!outStars) {
     
    9191        return false;
    9292    }
     93    psFree (filename);
     94
     95    filename = NULL;
     96    psStringAppend (&filename, "%s.gh.fits", fileroot);
     97    psFits *outGhosts = psFitsOpen (filename, "w");
     98    if (!outGhosts) {
     99        psError(PS_ERR_IO, false, "error opening file %s\n", filename);
     100        return false;
     101    }
     102    psFree (filename);
    93103
    94104    pmFPAview *view = pmFPAviewAlloc (0);
     
    103113    psMetadataAddF32 (phu, PS_LIST_TAIL, "EXPTIME", 0, "exptime", exptime);
    104114    psMetadataAddF32 (phu, PS_LIST_TAIL, "ZEROPT",  0, "zeropt", zeropt);
     115
    105116    psFitsWriteBlank (outStars, phu, NULL);
     117    psFitsWriteBlank (outGhosts, phu, NULL);
    106118    psFree (phu);
    107119
     
    145157                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y",   0, "focal-plane coordinate", ref->FP->y);
    146158                    psMetadataAddF32 (header, PS_LIST_TAIL, "MAG",     0, "magnitude",              ref->Mag);
     159
     160                    snprintf (extname, 80, "extname.%05d", nExt);
     161                    psFitsWriteImage (outStars, header, subraster, 0, extname);
     162                    nExt ++;
     163                   
     164                    psFree (header);
     165                    psFree (subraster);
     166                }
     167
     168                // select the raw objects for this readout (loaded in psastroExtract.c)
     169                psArray *ghosts = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.GHOSTS");
     170                if (ghosts == NULL) { continue; }
     171
     172                // identify the bright stars of interest
     173                for (int i = 0; i < ghosts->n; i++) {
     174                    pmAstromObj *ghost = ghosts->data[i];
     175
     176                    pmReadout *inReadout = pmFPAviewThisReadout (view, input->fpa);
     177                    psImage *subraster = psastroExtractStar (inReadout->image, ghost->chip->x, ghost->chip->y, 200.0, 200.0);
     178                    if (!subraster) continue;
     179                   
     180                    // generate a (very) basic header:
     181                    psMetadata *header = psMetadataAlloc ();
     182                    psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_X",  0, "chip coordinate",        ghost->chip->x);
     183                    psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_Y",  0, "chip coordinate",        ghost->chip->y);
     184                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_X",   0, "focal-plane coordinate", ghost->FP->x);
     185                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y",   0, "focal-plane coordinate", ghost->FP->y);
     186                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_X0",  0, "star focal-plane coordinate", ghost->TP->x); // note : over-loaded value
     187                    psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y0",  0, "star focal-plane coordinate", ghost->TP->y); // note : over-loaded value
     188                    psMetadataAddF32 (header, PS_LIST_TAIL, "MAG",     0, "magnitude",              ghost->Mag);
    147189
    148190                    snprintf (extname, 80, "extname.%05d", nExt);
Note: See TracChangeset for help on using the changeset viewer.