IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 21, 2009, 12:42:47 PM (17 years ago)
Author:
eugene
Message:

change EXTTYPE of DETEFF tables to DETEFF (was colliding with detection tables)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSourceIO.c

    r25754 r25907  
    342342    pmHDU *hdu;
    343343    psMetadata *updates;
    344     psMetadata *outhead;
    345 
    346     char *exttype  = NULL;
    347344
    348345    // if sources is NULL, write out an empty table
     
    368365        break;
    369366
    370       case PM_FPA_FILE_CMP:
    371         // a SPLIT format : only one header and object table per file
    372         hdu = pmFPAviewThisHDU (view, fpa);
    373         if (!hdu) {
    374             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU to write sources.");
    375             return false;
    376         }
    377 
    378         // copy the header to an output header, add the output header data
    379         outhead = psMetadataCopy (NULL, hdu->header);
    380 
    381         // copy over the entries saved by PSPHOT
    382         updates = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.HEADER");
    383         if (updates) {
    384             psMetadataCopy (outhead, updates);
    385         }
    386 
    387         // copy over the entries saved by PSASTRO
    388         updates = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.HEADER");
    389         if (updates) {
    390             psMetadataCopy (outhead, updates);
    391         }
    392 
    393         bool status = pmSourcesWriteCMP (sources, file->filename, outhead);
    394         psFree (outhead);
    395 
    396         if (!status) {
    397             psError(PS_ERR_IO, false, "Failed to write CMP file\n");
    398             return false;
    399         }
    400         break;
    401 
    402       case PM_FPA_FILE_CMF:
     367      case PM_FPA_FILE_CMP: {
     368          // a SPLIT format : only one header and object table per file
     369          hdu = pmFPAviewThisHDU (view, fpa);
     370          if (!hdu) {
     371              psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU to write sources.");
     372              return false;
     373          }
     374
     375          // copy the header to an output header, add the output header data
     376          psMetadata *outhead = psMetadataCopy (NULL, hdu->header);
     377
     378          // copy over the entries saved by PSPHOT
     379          updates = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.HEADER");
     380          if (updates) {
     381              psMetadataCopy (outhead, updates);
     382          }
     383
     384          // copy over the entries saved by PSASTRO
     385          updates = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.HEADER");
     386          if (updates) {
     387              psMetadataCopy (outhead, updates);
     388          }
     389
     390          bool status = pmSourcesWriteCMP (sources, file->filename, outhead);
     391          psFree (outhead);
     392
     393          if (!status) {
     394              psError(PS_ERR_IO, false, "Failed to write CMP file\n");
     395              return false;
     396          }
     397          break;
     398      }
     399
     400      case PM_FPA_FILE_CMF:
    403401        // write a header? (only if this is the first readout for cell)
    404402        //   note that the file->header is set to track the last hdu->header written
     
    415413        psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
    416414        if (!status) {
    417           psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
    418           return false;
     415            psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
     416            return false;
    419417        }
    420418
     
    429427        psString xsrcname = NULL;
    430428        psString xfitname = NULL;
    431         if (!sourceExtensions(&headname, &dataname, &deteffname, XSRC_OUTPUT ? &xsrcname : NULL,
    432                               XFIT_OUTPUT ? &xfitname : NULL, file, view)) {
     429        if (!sourceExtensions(&headname, &dataname, &deteffname,
     430                              XSRC_OUTPUT ? &xsrcname : NULL,
     431                              XFIT_OUTPUT ? &xfitname : NULL,
     432                              file, view)) {
    433433            return false;
    434434        }
     
    489489        }
    490490
    491         // write out the TABLE data segment
     491        // write out the Object TABLE data segment(s)
    492492        {
    493493            // create a header to hold the output data
    494             outhead = psMetadataAlloc ();
    495 
    496             exttype = psMemIncrRefCounter (psMetadataLookupStr(&status, recipe, "OUTPUT.FORMAT"));
     494            psMetadata *outhead = psMetadataAlloc ();
     495           
     496            char *exttype = psMemIncrRefCounter (psMetadataLookupStr(&status, recipe, "OUTPUT.FORMAT"));
    497497            if (!exttype) {
    498498                exttype = psStringCopy ("SMPDATA");
     
    502502            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTHEAD", PS_META_REPLACE, "name of image extension w/", headname);
    503503            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", exttype);
    504             psFree (exttype);
    505504
    506505            // if we request XSRC output, add the XSRC name to this header
    507506            if (xsrcname) {
    508               psMetadataAddStr (outhead, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
     507                psMetadataAddStr (outhead, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
    509508            }
    510509            if (xfitname) {
    511               psMetadataAddStr (outhead, PS_LIST_TAIL, "XFITNAME", PS_META_REPLACE, "name of XFIT table extension", xfitname);
     510                psMetadataAddStr (outhead, PS_LIST_TAIL, "XFITNAME", PS_META_REPLACE, "name of XFIT table extension", xfitname);
    512511            }
    513512
     
    533532            }
    534533
    535             if (deteffname) {
    536                 status &= pmReadoutWriteDetEff(file->fits, readout, outhead, deteffname);
    537             }
    538 
    539534            if (xsrcname) {
    540               if (!strcmp (exttype, "PS1_DEV_1")) {
    541                   status &= pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe);
    542               }
    543               if (!strcmp (exttype, "PS1_CAL_0")) {
    544                   status &= pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
    545               }
    546               if (!strcmp (exttype, "PS1_V1")) {
    547                   status &= pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);
    548               }
    549               if (!strcmp (exttype, "PS1_V2")) {
    550                   status &= pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe);
    551               }
     535                if (!strcmp (exttype, "PS1_DEV_1")) {
     536                    status &= pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname, recipe);
     537                }
     538                if (!strcmp (exttype, "PS1_CAL_0")) {
     539                    status &= pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe);
     540                }
     541                if (!strcmp (exttype, "PS1_V1")) {
     542                    status &= pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe);
     543                }
     544                if (!strcmp (exttype, "PS1_V2")) {
     545                    status &= pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe);
     546                }
    552547            }
    553548            if (xfitname) {
    554               if (!strcmp (exttype, "PS1_DEV_1")) {
    555                   status &= pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
    556               }
    557               if (!strcmp (exttype, "PS1_CAL_0")) {
    558                   status &= pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);
    559               }
    560               if (!strcmp (exttype, "PS1_V1")) {
    561                   status &= pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);
    562               }
    563               if (!strcmp (exttype, "PS1_V2")) {
    564                   status &= pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname);
    565               }
    566             }
     549                if (!strcmp (exttype, "PS1_DEV_1")) {
     550                    status &= pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
     551                }
     552                if (!strcmp (exttype, "PS1_CAL_0")) {
     553                    status &= pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname);
     554                }
     555                if (!strcmp (exttype, "PS1_V1")) {
     556                    status &= pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname);
     557                }
     558                if (!strcmp (exttype, "PS1_V2")) {
     559                    status &= pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname);
     560                }
     561            }
     562            psFree (outhead);
     563            psFree (exttype);
     564
    567565            if (!status) {
    568566                psError(PS_ERR_IO, false, "writing CMF data to %s with format %s\n", file->filename, exttype);
    569                 psFree (headname);
    570                 psFree (dataname);
    571                 psFree (xsrcname);
    572                 psFree (xfitname);
    573                 psFree (outhead);
    574                 psFree (deteffname);
    575                 return false;
    576             }
    577         }
     567                goto escape;
     568            }
     569        }
     570
     571
     572        // write out the detection efficiency TABLE segments
     573        if (deteffname) {
     574            // create a header to hold the output data
     575            psMetadata *outhead = psMetadataAlloc ();
     576            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTHEAD", PS_META_REPLACE, "name of image extension w/", headname);
     577            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", "DETEFF");
     578
     579            status = pmReadoutWriteDetEff(file->fits, readout, outhead, deteffname);
     580            psFree (outhead);
     581
     582            if (!status) {
     583                psError(PS_ERR_IO, false, "writing DETEFF data to %s\n", file->filename);
     584                goto escape;
     585            }
     586        }
     587        psFree (headname);
     588        psFree (dataname);
     589        psFree (xsrcname);
     590        psFree (xfitname);
     591        psFree (deteffname);
    578592
    579593        psTrace ("pmFPAfile", 5, "wrote ext data %s (type: %d)\n", file->filename, file->type);
    580 
    581         psFree (headname);
    582         psFree (dataname);
    583         psFree (xsrcname);
    584         psFree (xfitname);
    585         psFree (outhead);
     594        break;
     595
     596      escape:
     597        psFree (headname);
     598        psFree (dataname);
     599        psFree (xsrcname);
     600        psFree (xfitname);
    586601        psFree (deteffname);
    587         break;
     602        return false;
    588603
    589604      default:
     
    592607    }
    593608    return true;
     609
    594610}
    595611// a MEF CMF file has: PHU, CELL-HEAD, TABLE, CELL-HEAD, TABLE, TABLE, TABLE...
Note: See TracChangeset for help on using the changeset viewer.