IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 8, 2014, 9:27:56 AM (12 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20140423: add Koppehoefer correction; make sure psastro failures are noted clearl in the output header; do not load the model if we choose skipastro

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroDefineFiles.c

    r36441 r36837  
    4343        if (!psastroDefineFile (config, input->fpa, "PSASTRO.MODEL", "ASTROM.MODEL", PM_FPA_FILE_ASTROM_MODEL, PM_DETREND_TYPE_ASTROM)) {
    4444            psError (PS_ERR_IO, false, "Can't find an astrometry model file");
    45             return NULL;
    46         }
    47     }
     45            return false;
     46        }
     47    }
     48
     49    bool KHapply = psMetadataLookupBool (&status, recipe, "KH.CORRECT.APPLY");
     50    if (KHapply) {
     51        // Get the time from FPA.TIME
     52        psTime *time = psMetadataLookupPtr(NULL, input->fpa->concepts, "FPA.TIME");
     53        if (time->sec == 0 && time->nsec == 0) {
     54            psError (PM_ERR_CONFIG, false, "KH.CORRECT.APPLY requested, but date/time of exposure not found");
     55            return false;
     56        }
     57        // what is the appropriate date range for the correction
     58        char *KHendDate = psMetadataLookupStr (&status, recipe, "KH.CORRECT.ENDDATE");
     59        if (!KHendDate) {
     60            psError (PM_ERR_CONFIG, false, "KH.CORRECT.APPLY requested, but KH.CORRECT.ENDDATE not in recipe");
     61            return false;
     62        }
     63        psTime *endtime = psTimeFromString (KHendDate, PS_TIME_TAI);
     64        if (!endtime) {
     65            psError (PM_ERR_CONFIG, false, "KH.CORRECT.APPLY requested, KH.CORRECT.ENDDATE has an invalid date/time");
     66            return false;
     67        }
     68        if (psTimeDelta (endtime, time) < 0) {
     69            KHapply = false;
     70            psLogMsg ("psastro", PS_LOG_INFO, "Koppenhoefer correction requested, but exposure after end date, correction skipped");
     71        } else {
     72            psLogMsg ("psastro", PS_LOG_INFO, "Koppenhoefer correction requested, exposure in valid date range, correction may be applied");
     73        }   
     74        psFree (endtime);
     75    }
     76    if (KHapply) {
     77        if (!psastroDefineFile (config, input->fpa, "PSASTRO.KH.CORRECT", "KH.CORRECT", PM_FPA_FILE_KH_CORRECT, PM_DETREND_TYPE_KH_CORRECT)) {
     78            psError (PS_ERR_IO, false, "Can't find a Koppenhoefer Correction file");
     79            return NULL;
     80        }
     81    }
     82    // the bool above in the recipe says "apply generally for this camera".  here we are asserting that
     83    // we can and should apply for this exposure XXX change the name?
     84    psMetadataAddBool (recipe, PS_LIST_TAIL, "KH.CORRECT.APPLY.EXP", PS_META_REPLACE, "", KHapply);
    4885
    4986    // this step is optional
Note: See TracChangeset for help on using the changeset viewer.