IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 7, 2010, 9:45:30 AM (16 years ago)
Author:
Paul Price
Message:

Split output tables into .hdr and .psf parts (like SMF), and add detection efficiencies. Looks like it's working well now. Sent example to Larry for approval.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppTranslate/src/ppMopsRead.c

    r28218 r28243  
    44
    55#include <stdio.h>
     6#include <string.h>
    67#include <pslib.h>
    78
     
    1617    psArray *detections = psArrayAlloc(num); // Array of detections, to return
    1718    for (int i = 0; i < num; i++) {
    18         psFits *fits = psFitsOpen(inNames->data[i], "r"); // FITS file
     19        const char *name = inNames->data[i]; // File name
     20        psFits *fits = psFitsOpen(name, "r"); // FITS file
    1921        if (!fits) {
    2022            psError(PS_ERR_IO, false, "Unable to open input %d", i);
     
    4143            continue;
    4244        }
    43         ppMopsDetections *det = ppMopsDetectionsAlloc();
     45        ppMopsDetections *det = detections->data[i] = ppMopsDetectionsAlloc();
     46        det->component = psStringNCopy(name, strrchr(name, '.') - name); // Strip off extension
    4447        det->header = header;
    4548        det->num = size;
     
    6164        det->naxis2 = psMetadataLookupS32(NULL, header, "IMNAXIS2");
    6265
     66        det->psfHeader = psFitsReadHeader(NULL, fits);
     67        if (!det->psfHeader) {
     68            psError(psErrorCodeLast(), false, "Unable to read header %d", i);
     69            return false;
     70        }
    6371        psMetadata *table = det->table = psFitsReadTableAllColumns(fits); // Table of interest
    6472        if (!table) {
     
    6674            return false;
    6775        }
    68         psFitsClose(fits);
    6976
    7077        psVector *ra = psMetadataLookupVector(NULL, table, "RA_PSF");
     
    8087        }
    8188
    82         psTrace("ppMops.read", 2, "Read %ld rows from %s\n", det->num, (const char*)inNames->data[i]);
     89        psTrace("ppMops.read", 2, "Read %ld rows from %s\n", det->num, det->component);
    8390
    84         detections->data[i] = det;
     91        if (!psFitsMoveExtName(fits, "SkyChip.deteff")) {
     92            psWarning("No detection efficiencies included in %s", det->component);
     93            psErrorStackPrint(stderr, "No detection efficiencies included in %s", det->component);
     94            psErrorClear();
     95            continue;
     96        }
     97
     98        det->deteffHeader = psFitsReadHeader(NULL, fits);
     99        if (!det->deteffHeader) {
     100            psWarning("Unable to read detection efficiency header in %s", det->component);
     101            psErrorClear();
     102            continue;
     103        }
     104        det->deteffTable = psFitsReadTableAllColumns(fits);
     105        if (!det->deteffTable) {
     106            psFree(det->deteffHeader);
     107            det->deteffHeader = NULL;
     108            psWarning("Unable to read detection efficiency table in %s", det->component);
     109            psErrorClear();
     110            continue;
     111        }
     112        psTrace("ppMops.read", 2, "Read detection efficiency from %s\n", det->component);
     113        psFitsClose(fits);
    85114    }
    86115
Note: See TracChangeset for help on using the changeset viewer.