IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 10, 2013, 2:55:11 PM (12 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20130904

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psModules

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

    r35610 r36375  
    6969                        psString *xfitname,    // Extension name for extended fitted measurements
    7070                        psString *xradname,    // Extension name for radial apertures
     71                        psString *xgalname,    // Extension name for galaxy shapes
    7172                        const pmFPAfile *file, // File of interest
    7273                        const pmFPAview *view  // View to level of interest
     
    140141        }
    141142        *xradname = pmFPAfileNameFromRule (rule, file, view);
     143    }
     144
     145    // EXTNAME for radial apertures
     146    if (xgalname) {
     147        const char *rule = psMetadataLookupStr(&status, menu, "CMF.XGAL");
     148        if (!rule) {
     149            psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XGAL in EXTNAME.RULES in camera.config");
     150            return false;
     151        }
     152        *xgalname = pmFPAfileNameFromRule (rule, file, view);
    142153    }
    143154
     
    362373            status &= pmSourcesWrite_##TYPE##_XRAD (file->fits, readout, sources, file->header, xradname, recipe); \
    363374        }                                                               \
     375        if (xgalname) {                                                 \
     376            status &= pmSourcesWrite_##TYPE##_XGAL (file->fits, sources, xgalname, recipe); \
     377        }                                                               \
    364378    }
    365379
     
    464478        }
    465479
    466         // if this is not TRUE, the output files only contain the psf measurements.
    467         bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_ANALYSIS");
     480        // if none of these are TRUE, the output files only contain the psf measurements.
     481        bool doPetrosian = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN");
     482        bool doAnnuli    = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANNULI");
     483        bool XSRC_OUTPUT = doPetrosian || doAnnuli;
    468484        bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_FITS");
    469485        bool XRAD_OUTPUT = psMetadataLookupBool(&status, recipe, "RADIAL_APERTURES");
     486        bool XGAL_OUTPUT = psMetadataLookupBool(&status, recipe, "GALAXY_SHAPES");
    470487
    471488        // define the EXTNAME values for the different data segments:
     
    476493        psString xfitname = NULL;
    477494        psString xradname = NULL;
     495        psString xgalname = NULL;
    478496        if (!pmSourceIOextnames(&headname, &dataname, &deteffname,
    479497                                XSRC_OUTPUT ? &xsrcname : NULL,
    480498                                XFIT_OUTPUT ? &xfitname : NULL,
    481499                                XRAD_OUTPUT ? &xradname : NULL,
     500                                XGAL_OUTPUT ? &xgalname : NULL,
    482501                                file, view)) {
    483502            return false;
     
    563582                psMetadataAddStr (outhead, PS_LIST_TAIL, "XRADNAME", PS_META_REPLACE, "name of XRAD table extension", xradname);
    564583            }
     584            if (xgalname) {
     585                psMetadataAddStr (outhead, PS_LIST_TAIL, "XGALNAME", PS_META_REPLACE, "name of XGAL table extension", xgalname);
     586            }
    565587
    566588            // these are case-sensitive since the EXTYPE is case-sensitive
     
    609631        psFree (xfitname);
    610632        psFree (xradname);
     633        psFree (xgalname);
    611634        psFree (deteffname);
    612635
     
    620643        psFree (xfitname);
    621644        psFree (xradname);
     645        psFree (xgalname);
    622646        psFree (deteffname);
    623647        return false;
    624648
     649      case PM_FPA_FILE_CFF: {
     650        // determine the output table format
     651        psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
     652        if (!status) {
     653            psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
     654            return false;
     655        }
     656
     657        hdu = pmFPAviewThisHDU (view, fpa);
     658        pmConfigConformHeader(hdu->header, file->format);
     659        psFitsWriteBlank (file->fits, hdu->header, NULL);
     660        file->header = hdu->header;
     661        file->wrote_phu = true;
     662        if (!pmSourcesWrite_CFF(readout, file->fits, sources, hdu->header, recipe)) {
     663            psError(PS_ERR_UNKNOWN, false, "failed to write CFF");
     664            return false;
     665        }
     666        break;
     667      }
     668       
    625669      default:
    626670        fprintf (stderr, "warning: type mismatch\n");
     
    914958    psArray *sources = NULL;
    915959    pmHDU *hdu;
     960
     961    // define the EXTNAME values for the different data segments:
     962    psString headname = NULL;
     963    psString dataname = NULL;
     964    psString deteffname = NULL;
     965    psString xsrcname = NULL;
     966    psString xfitname = NULL;
     967    psString xradname = NULL;
     968    psString xgalname = NULL;
     969
     970    psMetadata *tableHeader = NULL;
     971    char *xtension = NULL;
    916972
    917973    switch (file->type) {
     
    9631019        hdu = pmFPAviewThisHDU (view, file->fpa);
    9641020
    965         // define the EXTNAME values for the different data segments:
    966         psString headname = NULL;
    967         psString dataname = NULL;
    968         psString deteffname = NULL;
    969         psString xsrcname = NULL;
    970         psString xfitname = NULL;
    971         psString xradname = NULL;
    972 
    9731021        // determine the output table format. Assume if we need to output extendend source
    9741022        // parameters that they may exist in the input.
     
    9811029        }
    9821030
    983         // if this is not TRUE, the output files only contain the psf measurements.
    984         bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_ANALYSIS");
     1031        // if none of these are TRUE, we only read the psf measurements
     1032        // XXX: shouldn't we look for these extensions and read the regardless of the recipe values?
     1033        bool doPetrosian = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_PETROSIAN");
     1034        bool doAnnuli    = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANNULI");
     1035        bool XSRC_OUTPUT = doPetrosian || doAnnuli;
    9851036        bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_FITS");
    9861037        bool XRAD_OUTPUT = psMetadataLookupBool(&status, recipe, "RADIAL_APERTURES");
     1038        bool XGAL_OUTPUT = false; // psMetadataLookupBool(&status, recipe, "GALAXY_SHAPES");
    9871039
    9881040        if (!pmSourceIOextnames(&headname, &dataname, &deteffname,
     
    9901042                XFIT_OUTPUT ? &xfitname : NULL,
    9911043                XRAD_OUTPUT ? &xradname : NULL,
     1044                XGAL_OUTPUT ? &xgalname : NULL,
    9921045                file, view)) {
    9931046            return false;
     
    10331086        }
    10341087
    1035         psMetadata *tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header
     1088        tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header
    10361089        if (!tableHeader) psAbort("cannot read table header");
    10371090
    1038         char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION");
     1091        xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION");
    10391092        if (!xtension) psAbort("cannot read table type");
    10401093        if (strcmp (xtension, "BINTABLE")) {
     
    11321185        break;
    11331186
     1187      case PM_FPA_FILE_CFF:
     1188        // read in header, if not yet loaded
     1189        hdu = pmFPAviewThisHDU (view, file->fpa);
     1190
     1191        // look these up in the camera config?
     1192        // headrule = {CHIP.NAME}.hdr
     1193        // datarule = {CHIP.NAME}.cff
     1194
     1195        // define the EXTNAME values for the different data segments:
     1196        headname = pmFPAfileNameFromRule("{CHIP.NAME}.hdr", file, view);
     1197        dataname = pmFPAfileNameFromRule("{CHIP.NAME}.cff", file, view);
     1198
     1199        // advance to the IMAGE HEADER extension
     1200        if (hdu->header == NULL) {
     1201            // if the IMAGE header does not exist, we have no data for this view
     1202            if (!psFitsMoveExtNameClean (file->fits, headname)) {
     1203                readout->data_exists = false;
     1204                psFree (headname);
     1205                psFree (dataname);
     1206                return true;
     1207            }
     1208            hdu->header = psFitsReadHeader (NULL, file->fits);
     1209        }
     1210
     1211        // advance to the table data extension
     1212        // since we have read the IMAGE header, the TABLE header should exist
     1213        if (!psFitsMoveExtName (file->fits, dataname)) {
     1214            psAbort("cannot find data extension %s in %s", dataname, file->filename);
     1215        }
     1216
     1217        tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header
     1218        if (!tableHeader) psAbort("cannot read table header");
     1219
     1220        // verify this is a binary table
     1221        char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION");
     1222        if (!xtension) psAbort("cannot read table type");
     1223        if (strcmp (xtension, "BINTABLE")) {
     1224            psWarning ("no binary table in extension %s, skipping\n", dataname);
     1225            psFree(tableHeader);
     1226            return false;
     1227        }
     1228
     1229        sources = pmSourcesRead_CFF(file->fits, hdu->header);
     1230
     1231        psTrace("psModules.objects", 6, "read CMF table from %s : %s : %s", file->filename, headname, dataname);
     1232        psFree (headname);
     1233        psFree (dataname);
     1234        psFree (tableHeader);
     1235        break;
     1236
    11341237      default:
    11351238        fprintf (stderr, "warning: type mismatch\n");
Note: See TracChangeset for help on using the changeset viewer.