IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27685


Ignore:
Timestamp:
Apr 14, 2010, 3:55:17 PM (16 years ago)
Author:
rhenders
Message:

Changes for improved error handling; better handling of bug concerning missing chips in source smf FITS file; more debug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/src/ippToPspsBatchDetection.c

    r27683 r27685  
    3535  Loop loads the data from the input smf file(s), consults the DVO database, then prepares an output FITS format suitable for PSPS.
    3636  */
    37 bool ippToPsps_batchDetection(IppToPsps *this) {
    38 
    39     if (this->numOfInputFiles < 1) return false;
     37int ippToPsps_batchDetection(IppToPsps *this) {
     38
     39    if (this->numOfInputFiles < 1) return PS_EXIT_DATA_ERROR;
    4040
    4141    int status = 0;
     
    4646
    4747        fits_report_error(stderr, status);
    48         return false;
     48        return PS_EXIT_SYS_ERROR;
    4949    }
    5050
     
    9898    int numDvoDetections = -1;
    9999    Image *pImage = NULL;
    100 
    101     bool ret = true;
    102100
    103101    // stuff for detections table
     
    171169            sprintf(ccdNumber, "%d%d", x, y);
    172170
     171            // check we can move to detections table in smf
     172            sprintf(extensionName, "XY%s.psf", ccdNumber);
     173            status=0;
     174            if (fits_movnam_hdu(fitsIn, BINARY_TBL, extensionName, 0, &status)) {
     175                psError(PS_ERR_IO, false, "Can't move to extension: %s skipping this chip\n", extensionName);
     176                continue;
     177            }
     178
     179            // move to header extension
    173180            sprintf(extensionName, "XY%s.hdr", ccdNumber);
    174181            status=0;
    175182            if (fits_movnam_hdu(fitsIn, IMAGE_HDU, extensionName, 0, &status)) {
    176                 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping\n", extensionName);
     183                psError(PS_ERR_IO, false, "Can't move to extension: %s skipping this chip\n", extensionName);
    177184                continue;
    178185            }
     
    190197            skylist = dvoSkyListByExternID(this->dvoConfig, sourceId, imageId, &pImage);
    191198            if (skylist == NULL) {
    192                 psError(PS_ERR_IO, false, "Can't find SkyList for sourceId='%d' imageId='%d' (CCD = XY%s): skipping\n", sourceId, imageId, ccdNumber);
     199                psError(PS_ERR_IO, false, "DVO: can't find SkyList for sourceId='%d' imageId='%d' (CCD = XY%s): skipping\n", sourceId, imageId, ccdNumber);
    193200                continue;
    194201            }
     
    201208            numDvoDetections = dvoGetDetections(skylist, pImage->imageID, &dvoDetections, &maxDvoDetId);
    202209
    203 
    204             // keep a running count of 'images' we find in order to write total to FrameMeta at the end
    205             nOta++;
    206 
    207210            // TODO check nDet < MAXDETECT
    208             // move to detections table in smf
    209             sprintf(extensionName, "XY%s.psf", ccdNumber);
    210             status=0;
    211             if (fits_movnam_hdu(fitsIn, BINARY_TBL, extensionName, 0, &status)) {
    212                 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping\n", extensionName);
    213                 continue;
    214             }
    215211
    216212            // create ImageMeta
     
    222218            fits_write_col(this->fitsOut, TSHORT, IMAGEMETA_CCDID, 1, 1, 1, &pImage->ccdnum, &status);
    223219            // fits_write_col(this->fitsOut, TLONG, IMAGEMETA_PHOTOCALID, 1, 1, 1, &pImage->photcode, &status); TODO
    224             psLogMsg("ippToPsps", PS_LOG_INFO, "photocode %d", pImage->photcode);
    225220            fits_write_col(this->fitsOut, TBYTE, IMAGEMETA_FILTERID, 1, 1, 1, &filterID, &status);
    226221            fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOSCAT, 1, 1, 1, &zptObs, &status);
     
    228223            fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_MOMENTFWHM, 1, 1, 1, &momentFwhm, &status);
    229224            fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOZERO, 1, 1, 1, &zptObs, &status);
     225
     226            // now move BACK to detections table in smf
     227            sprintf(extensionName, "XY%s.psf", ccdNumber);
     228            status=0;
     229            if (fits_movnam_hdu(fitsIn, BINARY_TBL, extensionName, 0, &status)) {
     230                psError(PS_ERR_IO, false, "Can't move to extension: %s skipping\n", extensionName);
     231                continue;
     232            }
     233
     234            // keep a running count of 'images' we find in order to write total to FrameMeta at the end
     235            nOta++;
    230236
    231237            long nDet = 0;
     
    346352
    347353    // write number of images we have found into FrameMeta table
     354    status=0;
    348355    if (fits_movnam_hdu(this->fitsOut, BINARY_TBL, "FrameMeta", 0, &status))
    349         fits_report_error(stderr, status);
     356            psError(PS_ERR_IO, false, "Can't move back to FrameMeta extension to write number of OTAs\n");
    350357    else
    351358        fits_write_col(this->fitsOut, TSHORT, FRAMEMETA_NOTA, 1, 1, 1, &nOta, &status);
    352359
     360    status=0;
    353361    if (fits_close_file(fitsIn, &status)) fits_report_error(stderr, status);
    354362
     
    362370    }
    363371
    364     return ret;
     372    psLogMsg("ippToPsps", PS_LOG_INFO, "Data written for a total of %d chips/OTAs", nOta);
     373
     374    return PS_EXIT_SUCCESS;
    365375}
    366376
Note: See TracChangeset for help on using the changeset viewer.