IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 10, 2020, 9:40:15 AM (6 years ago)
Author:
eugene
Message:

gDiff now runs and does not crash on forced photometry

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/gDiff.20200202/src/gDiffCamera.c

    r41260 r41413  
     1/** @file gDiffCamera.c
     2 *  @brief: image subtraction based on matched Gaussians profiles
     3 *  @author Eugene Magnier @ IfA
     4 *  @version $Revision: 1.12 $
     5 *  @date $Date: 2020-01-25 $
     6 *  Copyright 2020 Institute for Astronomy, University of Hawaii
     7 */
     8
    19#include "gDiff.h"
    210
     
    207215    }
    208216
     217    /* in ppSub, there is a recipe value 'PHOTOMETRY' which is supposed to enable / disable photometry analysis.
     218       This is set to FALSE in the recipes by default.
     219
     220       In the script diff_skycell.pl, there is a global variable 'do_photom' which is TRUE by default,
     221       but is set to FALSE if a) the reduction class is NOCONVDIFF or b) the run_state is not new (i.e, 'update' mode)
     222       (the script changes the call in an inconsistent way, if do_photom is true, it appends -photometry, but
     223       if it is false, it appends -Db PHOTOMETRY FALSE.  this could be made consistent.
     224       (also note that it is bad practice to have hard-wired reduction classes)
     225
     226       But both of these situations are ignored because the test in ppSubCamera for data->photometry
     227       (set if PHOTOMETRY is true or -photometry is supplied) is ignored and the photometric analysis
     228       is always performed.
     229
     230     */
     231
    209232    // Now that the camera has been determined, we can read the recipe
    210233    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, GDIFF_RECIPE); // Recipe for ppSim
     
    380403    }
    381404
    382     // psPhot input
    383     if (data->photometry || 1) {
    384         psphotModelClassInit();        // load implementation-specific models
    385 
    386         pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
    387         if (!psphot) {
    388             psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.INPUT");
    389             return false;
    390         }
    391         if (psphot->type != PM_FPA_FILE_IMAGE) {
    392             psError(psErrorCodeLast(), true, "PSPHOT.INPUT is not of type IMAGE");
    393             return false;
    394         }
    395         pmFPAfileActivate(config->files, false, "PSPHOT.INPUT");
    396 
    397         // Internal file for getting the PSF from the minuend
    398         pmFPAfile *psf = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.PSF.LOAD");
    399         if (!psf) {
    400             psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.PSF.LOAD");
    401             return false;
    402         }
    403         if (psf->type != PM_FPA_FILE_PSF) {
    404             psError(psErrorCodeLast(), true, "PSPHOT.PSF.LOAD is not of type PSF");
    405             return false;
    406         }
    407         pmFPAfileActivate(config->files, false, "PSPHOT.PSF.LOAD");
    408 
    409         if (!psphotDefineFiles(config, psphot)) {
    410             psError(psErrorCodeLast(), false, "Unable to set up psphot files.");
    411             return false;
    412         }
    413 
    414         // Deactivate psphot output sources --- we want to define output source files of our own
    415         pmFPAfile *psphotOutput = pmFPAfileSelectSingle(config->files, "PSPHOT.OUTPUT", 0);
    416         psphotOutput->save = false;  // this one should NOT be set
    417 
    418         pmFPAfile *outSources = defineOutputFile(config, output, false, "GDIFF.OUTPUT.SOURCES",
    419                                                  PM_FPA_FILE_CMF);
    420         if (!outSources) {
    421             psError(psErrorCodeLast(), false, "Unable to set up output source file.");
    422             return false;
    423         }
    424         checkFileruleFileSave(outSources, config);
    425 
    426         if (data->inverse) {
    427             pmFPAfile *invSources = defineOutputFile(config, inverse, false, "GDIFF.INVERSE.SOURCES",
    428                                                      PM_FPA_FILE_CMF);
    429             if (!invSources) {
    430                 psError(psErrorCodeLast(), false, "Unable to set up inverse source file.");
    431                 return false;
    432             }
    433             checkFileruleFileSave(invSources, config);
    434         }
    435 
    436         // files need to do the forced photometry on the positions of sources in the positive images
    437         if (data->forcedPhot1) {
    438             // this pmFPAfile is used to carry sources detected in the positive image #1
    439             pmFPAfile *posSources1 = defineOutputFile(config, input, true, "GDIFF.POS1.SOURCES", PM_FPA_FILE_CMF);
    440             if (!posSources1) {
    441                 psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
    442                 return false;
    443             }
    444             checkFileruleFileSave(posSources1, config);
    445 
    446             // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #1
    447             pmFPAfile *frcSources1 = defineOutputFile(config, input, true, "GDIFF.FORCED1.SOURCES", PM_FPA_FILE_CMF);
    448             if (!frcSources1) {
    449                 psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
    450                 return false;
    451             }
    452             checkFileruleFileSave(frcSources1, config);
     405    /* in ppSub, there is a recipe value 'PHOTOMETRY' which is supposed to enable / disable photometry analysis.
     406       This is set to FALSE in the recipes by default.
     407
     408       In the script diff_skycell.pl, there is a global variable 'do_photom' which is TRUE by default,
     409       but is set to FALSE if a) the reduction class is NOCONVDIFF or b) the run_state is not new (i.e, 'update' mode)
     410       (the script changes the call in an inconsistent way, if do_photom is true, it appends -photometry, but
     411       if it is false, it appends -Db PHOTOMETRY FALSE.  this could be made consistent.
     412       (also note that it is bad practice to have hard-wired reduction classes)
     413
     414       But both of these situations are ignored because the test in ppSubCamera for data->photometry
     415       (set if PHOTOMETRY is true or -photometry is supplied) is ignored and the photometric analysis
     416       is always performed.
     417
     418       Should we rationalize this?
     419     */
     420
     421    // define the psphot I/O files
     422    psphotModelClassInit();        // load implementation-specific models
     423
     424    pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
     425    if (!psphot) {
     426        psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.INPUT");
     427        return false;
     428    }
     429    if (psphot->type != PM_FPA_FILE_IMAGE) {
     430        psError(psErrorCodeLast(), true, "PSPHOT.INPUT is not of type IMAGE");
     431        return false;
     432    }
     433    pmFPAfileActivate(config->files, false, "PSPHOT.INPUT");
     434
     435    // Internal file for getting the PSF from the minuend
     436    pmFPAfile *psf = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.PSF.LOAD");
     437    if (!psf) {
     438        psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.PSF.LOAD");
     439        return false;
     440    }
     441    if (psf->type != PM_FPA_FILE_PSF) {
     442        psError(psErrorCodeLast(), true, "PSPHOT.PSF.LOAD is not of type PSF");
     443        return false;
     444    }
     445    pmFPAfileActivate(config->files, false, "PSPHOT.PSF.LOAD");
     446
     447    if (!psphotDefineFiles(config, psphot)) {
     448        psError(psErrorCodeLast(), false, "Unable to set up psphot files.");
     449        return false;
     450    }
     451
     452    // Deactivate psphot output sources --- we want to define output source files of our own
     453    pmFPAfile *psphotOutput = pmFPAfileSelectSingle(config->files, "PSPHOT.OUTPUT", 0);
     454    psphotOutput->save = false;  // this one should NOT be set
     455
     456    pmFPAfile *outSources = defineOutputFile(config, output, false, "GDIFF.OUTPUT.SOURCES",
     457                                             PM_FPA_FILE_CMF);
     458    if (!outSources) {
     459        psError(psErrorCodeLast(), false, "Unable to set up output source file.");
     460        return false;
     461    }
     462    checkFileruleFileSave(outSources, config);
     463
     464    if (data->inverse) {
     465        pmFPAfile *invSources = defineOutputFile(config, inverse, false, "GDIFF.INVERSE.SOURCES",
     466                                                 PM_FPA_FILE_CMF);
     467        if (!invSources) {
     468            psError(psErrorCodeLast(), false, "Unable to set up inverse source file.");
     469            return false;
    453470        }
    454 
    455         if (data->forcedPhot2) {
    456             // this pmFPAfile is used to carry sources detected in the positive image #2
    457             pmFPAfile *posSources2 = defineOutputFile(config, ref, true, "GDIFF.POS2.SOURCES", PM_FPA_FILE_CMF);
    458             if (!posSources2) {
    459                 psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
    460                 return false;
    461             }
    462             checkFileruleFileSave(posSources2, config);
    463 
    464             // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #2
    465             pmFPAfile *frcSources2 = defineOutputFile(config, ref, true, "GDIFF.FORCED2.SOURCES", PM_FPA_FILE_CMF);
    466             if (!frcSources2) {
    467                 psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
    468                 return false;
    469             }
    470             checkFileruleFileSave(frcSources2, config);
    471         }
     471        checkFileruleFileSave(invSources, config);
     472    }
     473
     474    // files need to do the forced photometry on the positions of sources in the positive images
     475    if (data->forcedPhot1) {
     476        // this pmFPAfile is used to carry sources detected in the positive image #1
     477        pmFPAfile *posSources1 = defineOutputFile(config, input, true, "GDIFF.POS1.SOURCES", PM_FPA_FILE_CMF);
     478        if (!posSources1) {
     479            psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
     480            return false;
     481        }
     482        checkFileruleFileSave(posSources1, config);
     483
     484        // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #1
     485        pmFPAfile *frcSources1 = defineOutputFile(config, input, true, "GDIFF.FORCED1.SOURCES", PM_FPA_FILE_CMF);
     486        if (!frcSources1) {
     487            psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
     488            return false;
     489        }
     490        checkFileruleFileSave(frcSources1, config);
     491    }
     492
     493    if (data->forcedPhot2) {
     494        // this pmFPAfile is used to carry sources detected in the positive image #2
     495        pmFPAfile *posSources2 = defineOutputFile(config, ref, true, "GDIFF.POS2.SOURCES", PM_FPA_FILE_CMF);
     496        if (!posSources2) {
     497            psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
     498            return false;
     499        }
     500        checkFileruleFileSave(posSources2, config);
     501
     502        // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #2
     503        pmFPAfile *frcSources2 = defineOutputFile(config, ref, true, "GDIFF.FORCED2.SOURCES", PM_FPA_FILE_CMF);
     504        if (!frcSources2) {
     505            psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
     506            return false;
     507        }
     508        checkFileruleFileSave(frcSources2, config);
    472509    }
    473510
Note: See TracChangeset for help on using the changeset viewer.