IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 14, 2006, 11:58:44 AM (20 years ago)
Author:
eugene
Message:

renamed config to recipe in lower-level functions, added pixel weights to pmSource, other cleanups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotParseCamera.c

    r6851 r6862  
    11# include "psphot.h"
    22
     3// define the needed / desired I/O files
    34bool psphotParseCamera (pmConfig *config) {
    45
    5     bool status;
     6    bool status = false;
    67
    7     status = false;
    88    pmFPAfile *input = pmFPAfileFromArgs (&status, config, "PSPHOT.INPUT", "INPUT");
    9     if (!status) {
    10         psAbort (__func__, "missing INPUT entry");
    11     }
     9    if (!status) { psAbort (__func__, "missing INPUT entry"); }
    1210
    13     // recipe override values (command-line options):
     11    // select recipe options supplied on command line
     12    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes,   "PSPHOT");
    1413    psMetadata *options = psMetadataLookupPtr (&status, config->arguments, "PSPHOT.OPTIONS");
    15     psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
    16     psMetadataIterator *iter = psMetadataIteratorAlloc (options, PS_LIST_HEAD, NULL);
    17     psMetadataItem *item = NULL;
    18     while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
    19         psMetadataAddItem (recipe, item, PS_LIST_TAIL, PS_META_REPLACE);
    20     }
    21     psFree (iter);
     14    psMetadataCopy (recipe, options);
     15
     16    // set default recipe values here
     17    psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE",         PS_META_NO_REPLACE, "default fitting mode", "NONE");
     18    psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE",        PS_META_NO_REPLACE, "default photcode",     "NONE");
     19    psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT",     PS_META_NO_REPLACE, "default break point",  "NONE");
     20    psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT",         PS_META_NO_REPLACE, "default zero point",    25.00);
     21    psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.XBIN", PS_META_NO_REPLACE, "default binning",          64);
     22    psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.YBIN", PS_META_NO_REPLACE, "default binning",          64);
    2223
    2324    // these calls bind the I/O handle to the specified fpa
    2425    pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.OUTPUT");
    25     pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.RESID");
    2626
    27     // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_INPUT");
    28     // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_OUTPUT");
     27    // optionally save the residual image
     28    if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) {
     29        pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.RESID");
     30    }
     31
     32    int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
     33    int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
    2934
    3035    // these calls construct a new fpa for the I/O handle
    31     int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND_XBIN");
    32     if (!status) {DX = 64;}
    33     int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND_YBIN");
    34     if (!status) {DY = 64;}
    35     pmFPAfileFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL");
    36     pmFPAfileFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKGND");
    37     pmFPAfileFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKSUB");
     36
     37    // optionally save the background model (small FITS image)
     38    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
     39        pmFPAfileFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL");
     40    }
     41    // optionally save the full background image
     42    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) {
     43        pmFPAfileFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKGND");
     44    }
     45    // optionally save the background-subtracted image
     46    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) {
     47        pmFPAfileFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKSUB");
     48    }
     49    // optionally save the PSF Model
     50    if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) {
     51        pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.PSF.SAVE");
     52    }
     53    // optionally load the PSF Model
     54    if (psMetadataLookupBool(NULL, recipe, "LOAD.PSF")) {
     55        pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.PSF.LOAD");
     56    }
    3857
    3958    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE");
    4059
    41     // psphot is supplied with the output name
    42     // this needs to be better: supply to all output (WRITE) files?
     60    // supply the output name (from cmd-line) to all output (WRITE) files
    4361    char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
    4462    pmFPAfileAddFileNames (config->files, "OUTPUT", output, PM_FPA_MODE_WRITE);
    4563
    46     // set default recipe values here
    47     psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE", PS_META_NO_REPLACE, "default fitting mode", "NONE");
    48     psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_NO_REPLACE, "default photcode", "NONE");
    49     psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default break point", "NONE");
    50     psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT", PS_META_NO_REPLACE, "default zero point", 25.00);
    51 
    52     // Chip selection: if we are using a single chip, select it for each FPA
    53     // Chip numbers to work on: -chip 1,2,3,5,8,10
    54     # if (0)
    55     char *chips = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS");
    56     if (chips != NULL) {
    57         char *p = chips;
    58         while (strlen(p)) {
    59             char *q = strchr (p, ',');
    60             if (q == NULL) {
    61                 q = p + strlen(p);
    62             } else {
    63                 *q = 0;
    64                 q = q + 1;
    65             }
    66             int chipNum = atoi(p);
    67             // XXX EAM : extend this to allow an array of selected chips (by name)
    68             if (! pmFPASelectChip(input->fpa, chipNum)) {
     64    // Chip selection: turn on only the chips specified
     65    char *chipLine = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS");
     66    psArray *chips = psStringSplitArray (chipLine, ",");
     67    if (chips->n > 0) {
     68        pmFPASelectChip (input->fpa, -1, true); // deselect all chips
     69        for (int i = 0; i < chips->n; i++) {
     70            int chipNum = atoi(chips->data[i]);
     71            if (! pmFPASelectChip(input->fpa, chipNum, false)) {
    6972                psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum);
    7073                exit(EXIT_FAILURE);
    7174            }
    72             psLogMsg("psphot", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);
    73             p = q;
    7475        }
    7576    }
    76     # endif
    7777
    7878    psTrace(__func__, 1, "Done with psphotParseCamera...\n");
Note: See TracChangeset for help on using the changeset viewer.