IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 15, 2009, 12:45:01 PM (17 years ago)
Author:
Paul Price
Message:

Merging branches/pap (detection efficiency development) into trunk.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psModules/src/objects/pmSourceIO.c

    r24694 r25383  
    4242#include "pmSource.h"
    4343#include "pmModelClass.h"
     44#include "pmDetEff.h"
    4445#include "pmSourceIO.h"
    4546
    4647#define BLANK_HEADERS "BLANK.HEADERS"   // Name of metadata in camera configuration containing header names
    4748                                        // for putting values into a blank PHU
     49
     50// lookup the EXTNAME values used for table data and image header segments
     51static bool sourceExtensions(psString *headname, // Extension name for header
     52                             psString *dataname, // Extension name for data
     53                             psString *deteffname, // Extension name for detection efficiency
     54                             psString *xsrcname, // Extension name for extended sources
     55                             psString *xfitname, // Extension name for extended fits
     56                             const pmFPAfile *file, // File of interest
     57                             const pmFPAview *view // View to level of interest
     58                             )
     59{
     60    bool status;                        // Status of MD lookup
     61
     62    // Menu of EXTNAME rules
     63    psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES");
     64    if (!menu) {
     65        psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config");
     66        return false;
     67    }
     68
     69    // EXTNAME for image header
     70    if (headname) {
     71        const char *rule = psMetadataLookupStr(&status, menu, "CMF.HEAD");
     72        if (!rule) {
     73            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.HEAD in EXTNAME.RULES in camera.config");
     74            return false;
     75        }
     76        *headname = pmFPAfileNameFromRule(rule, file, view);
     77    }
     78
     79    // EXTNAME for table data
     80    if (dataname) {
     81        const char *rule = psMetadataLookupStr(&status, menu, "CMF.DATA");
     82        if (!rule) {
     83            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DATA in EXTNAME.RULES in camera.config");
     84            return false;
     85        }
     86        *dataname = pmFPAfileNameFromRule(rule, file, view);
     87    }
     88
     89    // EXTNAME for detection efficiency
     90    if (deteffname) {
     91        const char *rule = psMetadataLookupStr(&status, menu, "CMF.DETEFF");
     92        if (!rule) {
     93            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.DETEFF in EXTNAME.RULES in camera.config");
     94            return false;
     95        }
     96        *deteffname = pmFPAfileNameFromRule(rule, file, view);
     97    }
     98
     99    // EXTNAME for extended source data table
     100    if (xsrcname) {
     101        const char *rule = psMetadataLookupStr(&status, menu, "CMF.XSRC");
     102        if (!rule) {
     103            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XSRC in EXTNAME.RULES in camera.config");
     104            return false;
     105        }
     106        *xsrcname = pmFPAfileNameFromRule (rule, file, view);
     107    }
     108
     109    if (xfitname) {
     110        // EXTNAME for extended source data table
     111        const char *rule = psMetadataLookupStr(&status, menu, "CMF.XFIT");
     112        if (!rule) {
     113            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config");
     114            return false;
     115        }
     116        *xfitname = pmFPAfileNameFromRule (rule, file, view);
     117    }
     118
     119    return true;
     120}
     121
    48122
    49123// translations between psphot object types and dophot object types
     
    271345
    272346    char *exttype  = NULL;
    273     char *dataname = NULL;
    274     char *xsrcname = NULL;
    275     char *xfitname = NULL;
    276     char *headname = NULL;
    277347
    278348    // if sources is NULL, write out an empty table
     
    354424
    355425        // 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             }
     426        psString headname = NULL;
     427        psString dataname = NULL;
     428        psString deteffname = NULL;
     429        psString xsrcname = NULL;
     430        psString xfitname = NULL;
     431        if (!sourceExtensions(&headname, &dataname, &deteffname, XSRC_OUTPUT ? &xsrcname : NULL,
     432                              XFIT_OUTPUT ? &xfitname : NULL, file, view)) {
     433            return false;
    401434        }
    402435
     
    480513
    481514            // XXX these are case-sensitive since the EXTYPE is case-sensitive
    482             status = false;
     515            status = true;
    483516            if (!strcmp (exttype, "SMPDATA")) {
    484                 status = pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
     517                status &= pmSourcesWrite_SMPDATA (file->fits, sources, file->header, outhead, dataname);
    485518            }
    486519            if (!strcmp (exttype, "PS1_DEV_0")) {
    487                 status = pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
     520                status &= pmSourcesWrite_PS1_DEV_0 (file->fits, sources, file->header, outhead, dataname);
    488521            }
    489522            if (!strcmp (exttype, "PS1_DEV_1")) {
    490                 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname);
     523                status &= pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname);
    491524            }
    492525            if (!strcmp (exttype, "PS1_CAL_0")) {
    493                 status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname);
     526                status &= pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname);
    494527            }
    495528            if (!strcmp (exttype, "PS1_V1")) {
    496                 status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname);
     529                status &= pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname);
    497530            }
    498531            if (!strcmp (exttype, "PS1_V2")) {
    499                 status = pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname);
    500             }
     532                status &= pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname);
     533            }
     534
     535            if (deteffname) {
     536                status &= pmReadoutWriteDetEff(file->fits, readout, outhead, deteffname);
     537            }
     538
    501539            if (xsrcname) {
    502540              if (!strcmp (exttype, "PS1_DEV_1")) {
    503                   status = pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe);
     541                  status &= pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe);
    504542              }
    505543              if (!strcmp (exttype, "PS1_CAL_0")) {
    506                   status = pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
     544                  status &= pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
    507545              }
    508546              if (!strcmp (exttype, "PS1_V1")) {
    509                   status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);
     547                  status &= pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);
    510548              }
    511549              if (!strcmp (exttype, "PS1_V2")) {
    512                   status = pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe);
     550                  status &= pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe);
    513551              }
    514552            }
    515553            if (xfitname) {
    516554              if (!strcmp (exttype, "PS1_DEV_1")) {
    517                   status = pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
     555                  status &= pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
    518556              }
    519557              if (!strcmp (exttype, "PS1_CAL_0")) {
    520                   status = pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);
     558                  status &= pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);
    521559              }
    522560              if (!strcmp (exttype, "PS1_V1")) {
    523                   status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);
     561                  status &= pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);
    524562              }
    525563              if (!strcmp (exttype, "PS1_V2")) {
    526                   status = pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname);
     564                  status &= pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname);
    527565              }
    528566            }
     
    572610    // not needed if only one chip
    573611    if (file->fpa->chips->n == 1) {
    574         pmSourceIO_WriteMatchedRefs (file->fits, file->fpa, config);
    575         return true;
     612        pmSourceIO_WriteMatchedRefs (file->fits, file->fpa, config);
     613        return true;
    576614    }
    577615
     
    885923        hdu = pmFPAviewThisHDU (view, file->fpa);
    886924
    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);
     925        // define the EXTNAME values for the different data segments:
     926        psString headname = NULL;
     927        psString dataname = NULL;
     928        psString deteffname = NULL;
     929        if (!sourceExtensions(&headname, &dataname, &deteffname, NULL, NULL, file, view)) {
     930            return false;
     931        }
    909932
    910933        // advance to the IMAGE HEADER extension
     
    958981                sources = pmSourcesRead_CMF_PS1_V2 (file->fits, hdu->header);
    959982            }
     983
     984            if (!pmReadoutReadDetEff(file->fits, readout, deteffname)) {
     985                psError(PS_ERR_IO, false, "Unable to read detection efficiency");
     986                return false;
     987            }
    960988        }
    961989
     
    10701098}
    10711099
    1072    
     1100
Note: See TracChangeset for help on using the changeset viewer.