IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:50:52 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/simtest_nebulous_branches
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/simtest_nebulous_branches

  • branches/simtest_nebulous_branches/psModules

  • branches/simtest_nebulous_branches/psModules/src/objects/pmSourceIO.c

    r24694 r27840  
    4040#include "pmPSF.h"
    4141#include "pmModel.h"
     42#include "pmDetections.h"
    4243#include "pmSource.h"
    4344#include "pmModelClass.h"
     45#include "pmDetEff.h"
    4446#include "pmSourceIO.h"
    4547
    4648#define BLANK_HEADERS "BLANK.HEADERS"   // Name of metadata in camera configuration containing header names
    4749                                        // for putting values into a blank PHU
     50
     51// lookup the EXTNAME values used for table data and image header segments
     52static bool sourceExtensions(psString *headname, // Extension name for header
     53                             psString *dataname, // Extension name for data
     54                             psString *deteffname, // Extension name for detection efficiency
     55                             psString *xsrcname, // Extension name for extended sources
     56                             psString *xfitname, // Extension name for extended fits
     57                             const pmFPAfile *file, // File of interest
     58                             const pmFPAview *view // View to level of interest
     59                             )
     60{
     61    bool status;                        // Status of MD lookup
     62
     63    // Menu of EXTNAME rules
     64    psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
     65    if (!menu) {
     66        psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
     67        return false;
     68    }
     69
     70    // EXTNAME for image header
     71    if (headname) {
     72        const char *rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
     73        if (!rule) {
     74            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
     75            return false;
     76        }
     77        *headname = pmFPAfileNameFromRule(rule, file, view);
     78    }
     79
     80    // EXTNAME for table data
     81    if (dataname) {
     82        const char *rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
     83        if (!rule) {
     84            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
     85            return false;
     86        }
     87        *dataname = pmFPAfileNameFromRule(rule, file, view);
     88    }
     89
     90    // EXTNAME for detection efficiency
     91    if (deteffname) {
     92        const char *rule = psMetadataLookupStr(&status, menu, "CMF.DETEFF");
     93        if (!rule) {
     94            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DETEFF in EXTNAME.RULES in camera.config");
     95            return false;
     96        }
     97        *deteffname = pmFPAfileNameFromRule(rule, file, view);
     98    }
     99
     100    // EXTNAME for extended source data table
     101    if (xsrcname) {
     102        const char *rule = psMetadataLookupStr(&status, menu, "CMF.XSRC");
     103        if (!rule) {
     104            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XSRC in EXTNAME.RULES in camera.config");
     105            return false;
     106        }
     107        *xsrcname = pmFPAfileNameFromRule (rule, file, view);
     108    }
     109
     110    if (xfitname) {
     111        // EXTNAME for extended source data table
     112        const char *rule = psMetadataLookupStr(&status, menu, "CMF.XFIT");
     113        if (!rule) {
     114            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config");
     115            return false;
     116        }
     117        *xfitname = pmFPAfileNameFromRule (rule, file, view);
     118    }
     119
     120    return true;
     121}
     122
    48123
    49124// translations between psphot object types and dophot object types
     
    268343    pmHDU *hdu;
    269344    psMetadata *updates;
    270     psMetadata *outhead;
    271 
    272     char *exttype  = NULL;
    273     char *dataname = NULL;
    274     char *xsrcname = NULL;
    275     char *xfitname = NULL;
    276     char *headname = NULL;
    277345
    278346    // if sources is NULL, write out an empty table
    279     // input / output sources are stored on the readout->analysis as "PSPHOT.SOURCES" -- a better name might be something like PM_SOURCE_DATA
    280     psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     347    // input / output sources are stored on the readout->analysis as "PSPHOT.DETECTIONS"
     348
     349    psArray *sources = NULL;
     350    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     351    if (detections) {
     352        sources = detections->allSources;
     353    }
    281354    if (!sources) {
     355        detections = pmDetectionsAlloc();
    282356        sources = psArrayAlloc(0);
    283         psMetadataAddArray(readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE, "Blank array of sources", sources);
    284         psFree(sources); // Held onto by the metadata, so we can continue to use
     357        detections->allSources = sources;
     358        psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_UNKNOWN | PS_META_REPLACE, "Blank array of sources", detections);
     359        psFree(detections); // Held onto by the metadata, so we can continue to use
    285360    }
    286361
     
    298373        break;
    299374
    300       case PM_FPA_FILE_CMP:
    301         // a SPLIT format : only one header and object table per file
    302         hdu = pmFPAviewThisHDU (view, fpa);
    303         if (!hdu) {
    304             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU to write sources.");
    305             return false;
    306         }
    307 
    308         // copy the header to an output header, add the output header data
    309         outhead = psMetadataCopy (NULL, hdu->header);
    310 
    311         // copy over the entries saved by PSPHOT
    312         updates = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.HEADER");
    313         if (updates) {
    314             psMetadataCopy (outhead, updates);
    315         }
    316 
    317         // copy over the entries saved by PSASTRO
    318         updates = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.HEADER");
    319         if (updates) {
    320             psMetadataCopy (outhead, updates);
    321         }
    322 
    323         bool status = pmSourcesWriteCMP (sources, file->filename, outhead);
    324         psFree (outhead);
    325 
    326         if (!status) {
    327             psError(PS_ERR_IO, false, "Failed to write CMP file\n");
    328             return false;
    329         }
    330         break;
    331 
    332       case PM_FPA_FILE_CMF:
     375      case PM_FPA_FILE_CMP: {
     376          // a SPLIT format : only one header and object table per file
     377          hdu = pmFPAviewThisHDU (view, fpa);
     378          if (!hdu) {
     379              psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU to write sources.");
     380              return false;
     381          }
     382
     383          // copy the header to an output header, add the output header data
     384          psMetadata *outhead = psMetadataCopy (NULL, hdu->header);
     385
     386          // copy over the entries saved by PSPHOT
     387          updates = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.HEADER");
     388          if (updates) {
     389              psMetadataCopy (outhead, updates);
     390          }
     391
     392          // copy over the entries saved by PSASTRO
     393          updates = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.HEADER");
     394          if (updates) {
     395              psMetadataCopy (outhead, updates);
     396          }
     397
     398          bool status = pmSourcesWriteCMP (sources, file->filename, outhead);
     399          psFree (outhead);
     400
     401          if (!status) {
     402              psError(PS_ERR_IO, false, "Failed to write CMP file\n");
     403              return false;
     404          }
     405          break;
     406      }
     407
     408      case PM_FPA_FILE_CMF:
    333409        // write a header? (only if this is the first readout for cell)
    334410        //   note that the file->header is set to track the last hdu->header written
     
    345421        psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
    346422        if (!status) {
    347           psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
    348           return false;
     423            psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
     424            return false;
    349425        }
    350426
     
    354430
    355431        // define the EXTNAME values for the different data segments:
    356         {
    357             // lookup the EXTNAME values used for table data and image header segments
    358             char *rule = NULL;
    359 
    360             // Menu of EXTNAME rules
    361             psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
    362             if (!menu) {
    363                 psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
    364                 return false;
    365             }
    366 
    367             // EXTNAME for image header
    368             rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
    369             if (!rule) {
    370                 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
    371                 return false;
    372             }
    373             headname = pmFPAfileNameFromRule (rule, file, view);
    374 
    375             // EXTNAME for table data
    376             rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
    377             if (!rule) {
    378                 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
    379                 return false;
    380             }
    381             dataname = pmFPAfileNameFromRule (rule, file, view);
    382 
    383             if (XSRC_OUTPUT) {
    384               // EXTNAME for extended source data table
    385               rule = psMetadataLookupStr(&status, menu, "CMF.XSRC");
    386               if (!rule) {
    387                 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XSRC in EXTNAME.RULES in camera.config");
    388                 return false;
    389               }
    390               xsrcname = pmFPAfileNameFromRule (rule, file, view);
    391             }
    392             if (XFIT_OUTPUT) {
    393               // EXTNAME for extended source data table
    394               rule = psMetadataLookupStr(&status, menu, "CMF.XFIT");
    395               if (!rule) {
    396                 psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config");
    397                 return false;
    398               }
    399               xfitname = pmFPAfileNameFromRule (rule, file, view);
    400             }
     432        psString headname = NULL;
     433        psString dataname = NULL;
     434        psString deteffname = NULL;
     435        psString xsrcname = NULL;
     436        psString xfitname = NULL;
     437        if (!sourceExtensions(&headname, &dataname, &deteffname,
     438                              XSRC_OUTPUT ? &xsrcname : NULL,
     439                              XFIT_OUTPUT ? &xfitname : NULL,
     440                              file, view)) {
     441            return false;
    401442        }
    402443
     
    456497        }
    457498
    458         // write out the TABLE data segment
     499        // write out the Object TABLE data segment(s)
    459500        {
    460501            // create a header to hold the output data
    461             outhead = psMetadataAlloc ();
    462 
    463             exttype = psMemIncrRefCounter (psMetadataLookupStr(&status, recipe, "OUTPUT.FORMAT"));
     502            psMetadata *outhead = psMetadataAlloc ();
     503           
     504            char *exttype = psMemIncrRefCounter (psMetadataLookupStr(&status, recipe, "OUTPUT.FORMAT"));
    464505            if (!exttype) {
    465506                exttype = psStringCopy ("SMPDATA");
     
    469510            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTHEAD", PS_META_REPLACE, "name of image extension w/", headname);
    470511            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", exttype);
    471             psFree (exttype);
    472512
    473513            // if we request XSRC output, add the XSRC name to this header
    474514            if (xsrcname) {
    475               psMetadataAddStr (outhead, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
     515                psMetadataAddStr (outhead, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
    476516            }
    477517            if (xfitname) {
    478               psMetadataAddStr (outhead, PS_LIST_TAIL, "XFITNAME", PS_META_REPLACE, "name of XFIT table extension", xfitname);
     518                psMetadataAddStr (outhead, PS_LIST_TAIL, "XFITNAME", PS_META_REPLACE, "name of XFIT table extension", xfitname);
    479519            }
    480520
    481521            // XXX these are case-sensitive since the EXTYPE is case-sensitive
    482             status = false;
     522            status = true;
    483523            if (!strcmp (exttype, "SMPDATA")) {
    484                 status = pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
     524                status &= pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
    485525            }
    486526            if (!strcmp (exttype, "PS1_DEV_0")) {
    487                 status = pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
     527                status &= pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
    488528            }
    489529            if (!strcmp (exttype, "PS1_DEV_1")) {
    490                 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname);
     530                status &= pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname);
    491531            }
    492532            if (!strcmp (exttype, "PS1_CAL_0")) {
    493                 status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname);
     533                status &= pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname);
    494534            }
    495535            if (!strcmp (exttype, "PS1_V1")) {
    496                 status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname);
     536                status &= pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname);
    497537            }
    498538            if (!strcmp (exttype, "PS1_V2")) {
    499                 status = pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname);
    500             }
     539                status &= pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname);
     540            }
     541            if (!strcmp (exttype, "PS1_DV1")) {
     542                status &= pmSourcesWrite_CMF_PS1_DV1 (file->fits, readout, sources, file->header, outhead, dataname);
     543            }
     544
    501545            if (xsrcname) {
    502               if (!strcmp (exttype, "PS1_DEV_1")) {
    503                   status = pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe);
    504               }
    505               if (!strcmp (exttype, "PS1_CAL_0")) {
    506                   status = pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
    507               }
    508               if (!strcmp (exttype, "PS1_V1")) {
    509                   status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);
    510               }
    511               if (!strcmp (exttype, "PS1_V2")) {
    512                   status = pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe);
    513               }
     546                if (!strcmp (exttype, "PS1_DEV_1")) {
     547                    status &= pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe);
     548                }
     549                if (!strcmp (exttype, "PS1_CAL_0")) {
     550                    status &= pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
     551                }
     552                if (!strcmp (exttype, "PS1_V1")) {
     553                    status &= pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
     554                }
     555                if (!strcmp (exttype, "PS1_V2")) {
     556                    status &= pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
     557                }
     558                if (!strcmp (exttype, "PS1_DV1")) {
     559                    status &= pmSourcesWrite_CMF_PS1_DV1_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
     560                }
    514561            }
    515562            if (xfitname) {
    516               if (!strcmp (exttype, "PS1_DEV_1")) {
    517                   status = pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
    518               }
    519               if (!strcmp (exttype, "PS1_CAL_0")) {
    520                   status = pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);
    521               }
    522               if (!strcmp (exttype, "PS1_V1")) {
    523                   status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);
    524               }
    525               if (!strcmp (exttype, "PS1_V2")) {
    526                   status = pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname);
    527               }
    528             }
     563                if (!strcmp (exttype, "PS1_DEV_1")) {
     564                    status &= pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
     565                }
     566                if (!strcmp (exttype, "PS1_CAL_0")) {
     567                    status &= pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);
     568                }
     569                if (!strcmp (exttype, "PS1_V1")) {
     570                    status &= pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, readout, sources, xfitname);
     571                }
     572                if (!strcmp (exttype, "PS1_V2")) {
     573                    status &= pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, readout, sources, xfitname);
     574                }
     575                if (!strcmp (exttype, "PS1_DV1")) {
     576                    status &= pmSourcesWrite_CMF_PS1_DV1_XFIT (file->fits, readout, sources, xfitname);
     577                }
     578            }
     579            psFree (outhead);
     580            psFree (exttype);
     581
    529582            if (!status) {
    530583                psError(PS_ERR_IO, false, "writing CMF data to %s with format %s\n", file->filename, exttype);
    531                 psFree (headname);
    532                 psFree (dataname);
    533                 psFree (xsrcname);
    534                 psFree (xfitname);
    535                 psFree (outhead);
    536                 return false;
    537             }
    538         }
     584                goto escape;
     585            }
     586        }
     587
     588
     589        // write out the detection efficiency TABLE segments
     590        if (deteffname) {
     591            // create a header to hold the output data
     592            psMetadata *outhead = psMetadataAlloc ();
     593            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTHEAD", PS_META_REPLACE, "name of image extension w/", headname);
     594            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", "DETEFF");
     595
     596            status = pmReadoutWriteDetEff(file->fits, readout, outhead, deteffname);
     597            psFree (outhead);
     598
     599            if (!status) {
     600                psError(PS_ERR_IO, false, "writing DETEFF data to %s\n", file->filename);
     601                goto escape;
     602            }
     603        }
     604        psFree (headname);
     605        psFree (dataname);
     606        psFree (xsrcname);
     607        psFree (xfitname);
     608        psFree (deteffname);
    539609
    540610        psTrace ("pmFPAfile", 5, "wrote ext data %s (type: %d)\n", file->filename, file->type);
    541 
    542         psFree (headname);
    543         psFree (dataname);
    544         psFree (xsrcname);
    545         psFree (xfitname);
    546         psFree (outhead);
    547611        break;
     612
     613      escape:
     614        psFree (headname);
     615        psFree (dataname);
     616        psFree (xsrcname);
     617        psFree (xfitname);
     618        psFree (deteffname);
     619        return false;
    548620
    549621      default:
     
    552624    }
    553625    return true;
     626
    554627}
    555628// a MEF CMF file has: PHU, CELL-HEAD, TABLE, CELL-HEAD, TABLE, TABLE, TABLE...
     
    572645    // not needed if only one chip
    573646    if (file->fpa->chips->n == 1) {
    574         pmSourceIO_WriteMatchedRefs (file->fits, file->fpa, config);
    575         return true;
     647        pmSourceIO_WriteMatchedRefs (file->fits, file->fpa, config);
     648        return true;
    576649    }
    577650
     
    885958        hdu = pmFPAviewThisHDU (view, file->fpa);
    886959
    887         // lookup the EXTNAME values used for table data and image header segments
    888         char *rule = NULL;
    889         // Menu of EXTNAME rules
    890         psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
    891         if (!menu) {
    892             psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
    893             return false;
    894         }
    895         // EXTNAME for image header
    896         rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
    897         if (!rule) {
    898             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
    899             return false;
    900         }
    901         char *headname = pmFPAfileNameFromRule (rule, file, view);
    902         // EXTNAME for table data
    903         rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
    904         if (!rule) {
    905             psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
    906             return false;
    907         }
    908         char *dataname = pmFPAfileNameFromRule (rule, file, view);
     960        // define the EXTNAME values for the different data segments:
     961        psString headname = NULL;
     962        psString dataname = NULL;
     963        psString deteffname = NULL;
     964        if (!sourceExtensions(&headname, &dataname, &deteffname, NULL, NULL, file, view)) {
     965            return false;
     966        }
    909967
    910968        // advance to the IMAGE HEADER extension
    911969        if (hdu->header == NULL) {
    912970            // if the IMAGE header does not exist, we have no data for this view
    913             if (!psFitsMoveExtName (file->fits, headname)) {
     971            if (!psFitsMoveExtNameClean (file->fits, headname)) {
    914972                readout->data_exists = false;
    915973                psFree (headname);
    916974                psFree (dataname);
     975                psFree (deteffname);
    917976                return true;
    918977            }
     
    938997        if (!tableHeader) psAbort("cannot read table header");
    939998
     999        char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION");
     1000        if (!xtension) psAbort("cannot read table type");
     1001        if (strcmp (xtension, "BINTABLE")) {
     1002            psWarning ("no binary table in extension %s, skipping\n", dataname);
     1003            return false;
     1004        }
     1005
    9401006        char *exttype = psMetadataLookupStr (NULL, tableHeader, "EXTTYPE");
    9411007        if (!exttype) psAbort("cannot read table type");
     
    9581024                sources = pmSourcesRead_CMF_PS1_V2 (file->fits, hdu->header);
    9591025            }
     1026            if (!strcmp (exttype, "PS1_DV1")) {
     1027                sources = pmSourcesRead_CMF_PS1_DV1 (file->fits, hdu->header);
     1028            }
     1029
     1030            if (!pmReadoutReadDetEff(file->fits, readout, deteffname)) {
     1031#if 0
     1032                psError(PS_ERR_IO, false, "Unable to read detection efficiency");
     1033                return false;
     1034#else
     1035                // No great loss
     1036                psErrorClear();
     1037#endif
     1038            }
    9601039        }
    9611040
     
    9631042        psFree (headname);
    9641043        psFree (dataname);
     1044        psFree (deteffname);
    9651045        psFree (tableHeader);
    9661046        break;
     
    9711051    }
    9721052    readout->data_exists = true;
    973     status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "input sources", sources);
    974     psFree (sources);
     1053
     1054    pmDetections *detections = pmDetectionsAlloc();
     1055    detections->allSources = sources;
     1056    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY, "input sources", detections);
     1057    psFree (detections);
    9751058    return true;
    9761059}
     
    10641147    bool status;
    10651148
    1066     // select the psf of interest
    1067     pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
    1068     if (!psf) return false;
    1069     return true;
    1070 }
    1071 
    1072    
     1149    // select the detections of interest
     1150    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     1151    if (!detections) return false;
     1152    if (!detections->allSources) return false;
     1153    return true;
     1154}
     1155
     1156
Note: See TracChangeset for help on using the changeset viewer.