IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 14, 2014, 2:28:47 PM (12 years ago)
Author:
bills
Message:

Iniital implementation of the full force stages to the pipeline.
Maginitude and galactic coordinate limits on extended source fits

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psModules

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

    r36375 r36441  
    6161static bool pmReadoutReadXFIT(pmFPAfile *file, pmReadout *readout, char * exttype, psMetadata *hduHeader, psString xfitname, psArray *sources, long *sourceIndex);
    6262static bool pmReadoutReadXRAD(pmFPAfile *file, pmReadout *readout, char * exttype, psMetadata *hduHeader, psString xfitname, psArray *sources, long *sourceIndex);
     63static bool pmReadoutReadXGAL(pmFPAfile *file, pmReadout *readout, char * exttype, psMetadata *hduHeader, psString xfitname, psArray *sources, long *sourceIndex);
    6364
    6465// lookup the EXTNAME values used for table data and image header segments
     
    374375        }                                                               \
    375376        if (xgalname) {                                                 \
    376             status &= pmSourcesWrite_##TYPE##_XGAL (file->fits, sources, xgalname, recipe); \
     377            status &= pmSourcesWrite_##TYPE##_XGAL (file->fits, readout, sources, xgalname, recipe); \
    377378        }                                                               \
    378379    }
     
    10361037        bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "EXTENDED_SOURCE_FITS");
    10371038        bool XRAD_OUTPUT = psMetadataLookupBool(&status, recipe, "RADIAL_APERTURES");
    1038         bool XGAL_OUTPUT = false; // psMetadataLookupBool(&status, recipe, "GALAXY_SHAPES");
     1039        bool XGAL_OUTPUT = psMetadataLookupBool(&status, recipe, "GALAXY_SHAPES");
    10391040
    10401041        if (!pmSourceIOextnames(&headname, &dataname, &deteffname,
     
    11221123
    11231124            long *sourceIndex = NULL;
    1124             if (XSRC_OUTPUT || XFIT_OUTPUT || XRAD_OUTPUT) {
     1125            if (XSRC_OUTPUT || XFIT_OUTPUT || XRAD_OUTPUT || XGAL_OUTPUT) {
     1126                // Build sourceIndex. Lookup table from source->seq to index in sources array.
     1127                // Consists of an array of length max(source->seq) + 1.
     1128
     1129                // find maximum sequence number
    11251130                long seq_max = -1;
    11261131                for (long i = sources->n -1; i >= 0; i--) {
     
    11351140                    }
    11361141                }
     1142                // allocate and initialize the index
    11371143                sourceIndex = psAlloc((seq_max + 1) * sizeof(long));
    11381144                for (long i = 0; i < seq_max; i++) {
    11391145                    sourceIndex[i] = -1;
    11401146                }
     1147                // populate the index
    11411148                for (long i = 0; i < sources->n; i++) {
    11421149                    pmSource *source = sources->data[i];
     
    11651172                psFree(xradname);
    11661173            }
     1174            if (XGAL_OUTPUT && xgalname) {
     1175                // a cmf file may have an XGAL extension, but it is not required
     1176                if (!pmReadoutReadXGAL(file, readout, exttype, hdu->header, xgalname, sources, sourceIndex)) {
     1177                    // do anything?
     1178                }
     1179                psFree(xgalname);
     1180            }
    11671181            psFree(sourceIndex);
    11681182
     
    14611475    return status;
    14621476}
     1477static bool pmReadoutReadXGAL(pmFPAfile *file, pmReadout *readout, char *exttype, psMetadata *hduHeader, psString xgalname, psArray *sources, long *sourceIndex)
     1478{
     1479    if (!psFitsMoveExtNameClean (file->fits, xgalname)) {
     1480        psTrace ("pmFPAfile", 1, "cannot find xgal extension %s in %s, skipping", xgalname, file->filename);
     1481        return false;
     1482    }
     1483
     1484    psMetadata *tableHeader = psFitsReadHeader(NULL, file->fits); // The FITS header
     1485    if (!tableHeader) psAbort("cannot read table header");
     1486
     1487    char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION");
     1488    if (!xtension) psAbort("cannot read table type");
     1489    if (strcmp (xtension, "BINTABLE")) {
     1490        psFree(tableHeader);
     1491        psWarning ("no binary table in extension %s, skipping\n", xgalname);
     1492        return false;
     1493    }
     1494
     1495# define PM_SOURCES_READ_XGAL(NAME,TYPE)                                \
     1496    if (!strcmp (exttype, NAME)) {                                      \
     1497        status = pmSourcesRead_##TYPE##_XGAL(file->fits, readout, hduHeader, tableHeader, sources, sourceIndex); \
     1498    }                                                                   
     1499
     1500    bool status = false;
     1501    if (file->type == PM_FPA_FILE_CMF) {
     1502        PM_SOURCES_READ_XGAL("PS1_V1",    CMF_PS1_V1);
     1503        PM_SOURCES_READ_XGAL("PS1_V2",    CMF_PS1_V2);
     1504        PM_SOURCES_READ_XGAL("PS1_V3",    CMF_PS1_V3);
     1505        PM_SOURCES_READ_XGAL("PS1_V4",    CMF_PS1_V4);
     1506        PM_SOURCES_READ_XGAL("PS1_SV1",   CMF_PS1_SV1);
     1507        PM_SOURCES_READ_XGAL("PS1_SV2",   CMF_PS1_SV2);
     1508        PM_SOURCES_READ_XGAL("PS1_DV1",   CMF_PS1_DV1);
     1509        PM_SOURCES_READ_XGAL("PS1_DV2",   CMF_PS1_DV2);
     1510        PM_SOURCES_READ_XGAL("PS1_DV3",   CMF_PS1_DV3);
     1511    }
     1512    psFree(tableHeader);
     1513    return status;
     1514}
Note: See TracChangeset for help on using the changeset viewer.