IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6792


Ignore:
Timestamp:
Apr 5, 2006, 1:11:17 AM (20 years ago)
Author:
eugene
Message:

adding update pmFPAfile methods

Location:
trunk/psastro/src
Files:
1 added
4 edited

Legend:

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

    r6791 r6792  
    1616    psastroDataLoop (input, config);
    1717
    18     // simple layout interpretation, basic WCS conversion
    19     pmFPA *fpa = psastroBuildFPA (header, rawstars);
     18    // select astrometry stars from the psphot sources
     19    // limit fit to bright stars only
     20    psastroSelectAstromStars (config);
    2021
    21     // limit fit to bright stars only
    22     psastroSelectBrightStars (fpa, config);
     22    // load the reference stars overlapping the data stars
     23    psastroLoadReference (config);
    2324
    2425    // fpa and subset point to the same astrometry terms
    25     psastroChipAstrom (fpa, config);
     26    switch (mode) {
     27      case stack:
     28        psastroStackAstrom (config);
     29        break
     30      case mosaic:
     31        psastroMosaicAstrom (config);
     32        break
     33      case mosaic:
     34        psastroMosaicAstrom (config);
     35        break;
     36      default:
     37        break;
     38    }
    2639
    27     // write out data (cmp file)
    28     psastroWriteCMP (fpa, argv[3]);
     40    // perform the astrometric solution
     41    psastroDataSave (config);
    2942
    30     psLogMsg ("psphot", 3, "complete psphot run: %f sec\n", psTimerMark ("complete"));
     43    psLogMsg ("psphot", 3, "complete psastro run: %f sec\n", psTimerMark ("complete"));
    3144
    3245    psFree (config);
  • trunk/psastro/src/psastroArguments.c

    r6791 r6792  
    3535    psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "PSASTRO.OPTIONS",  PS_DATA_METADATA, "", options);
    3636
    37     // we load all input files onto a psArray, to be parsed later
    38     psArray *input = psArrayAlloc (16);
    39     input->n = 0;
    40 
    41     // load the list of filenames the supplied file (may be a glob: "file*.fits")
    42     if ((N = psArgumentGet (*argc, argv, "-file"))) {
    43         glob_t globList;
    44         psArgumentRemove (N, argc, argv);
    45         globList.gl_offs = 0;
    46         glob (argv[N], 0, NULL, &globList);
    47         for (int i = 0; i < globList.gl_pathc; i++) {
    48             char *filename = psStringCopy (globList.gl_pathv[i]);
    49             psArrayAdd (input, 16, filename);
    50         }
    51         psArgumentRemove (N, argc, argv);
    52     }
    53 
    54     // load the list from the supplied text file
    55     if ((N = psArgumentGet (*argc, argv, "-list"))) {
    56         int nItems;
    57         char line[1024]; // XXX limits the list lines to 1024 chars
    58         char word[1024];
    59         char *filename;
    60 
    61         psArgumentRemove (N, argc, argv);
    62         FILE *f = fopen (argv[N], "r");
    63         if (f == NULL) {
    64             psAbort ("psphot", "unable to open specified list file");
    65         }
    66         while (fgets (line, 1024, f) != NULL) {
    67             nItems = sscanf (line, "%s", word);
    68             switch (nItems) {
    69               case 0:
    70                 break;
    71               case 1:
    72                 filename = psStringCopy (word);
    73                 psArrayAdd (input, 16, filename);
    74                 break;
    75               default:
    76                 // rigid format, no comments allowed?
    77                 psAbort ("psphot", "error parsing input list file");
    78                 break;
    79             }
    80         }
    81         psArgumentRemove (N, argc, argv);
    82     }           
    83     if (input->n < 1) usage ();
    84 
    85     // input list gets places as an array on the config->arguements list
    86     psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "INPUT",  PS_DATA_ARRAY, "", input);
     37    status = pmConfigFileSetsMD (config->arguments, "INPUT", "-file", "-list");
     38    if (!status) { usage ();}
    8739
    8840    if (*argc != 2) usage ();
  • trunk/psastro/src/psastroDataLoop.c

    r6791 r6792  
    11# include "psastro.h"
    22
    3 bool psastroDataLoop (ppFile *file, ppConfig *config) {
     3// load the data from the files in this loop.
     4// we write out the result in a second loop
     5// at the end of this function, the complete stellar data is loaded
     6// into the correct fpa structure locations (readout.analysis:PSPHOT.SOURCES)
     7bool psastroDataLoop (pmConfig *config) {
    48
    5     bool status;
    6     ppImageLoadDepth imageLoadDepth;
    7 
    8     // determine the load depth
    9     const char *depth = psMetadataLookupStr(&status, config->recipe, "LOAD.DEPTH");
    10     if (! status || ! depth || strlen(depth) == 0) {
    11         psLogMsg("psastro", PS_LOG_ERROR, "LOAD.DEPTH not specified in recipe.");
    12         exit(EXIT_FAILURE);
    13     }
    14     imageLoadDepth = PP_LOAD_NONE;
    15     if (!strcasecmp(depth, "FPA")) imageLoadDepth = PP_LOAD_FPA;
    16     if (!strcasecmp(depth, "CHIP")) imageLoadDepth = PP_LOAD_CHIP;
    17     if (!strcasecmp(depth, "CELL")) imageLoadDepth = PP_LOAD_CELL;
    18     if (imageLoadDepth == PP_LOAD_NONE) {
    19         psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe is not FPA, CHIP or CELL.");
    20         exit(EXIT_FAILURE);
     9    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSASTRO.INPUT");
     10    if (!status) {
     11        psErrorStackPrint(stderr, "Can't find input data!\n");
     12        exit(EXIT_FAILURE);
    2113    }
    2214
    23     if (imageLoadDepth == PP_LOAD_FPA) {
    24         psTrace(__func__, 1, "data pixels for FPA...\n");
    25         psastroLoadSMF(file, config->database, -1, -1);
     15    pmFPAview *view = pmFPAviewAlloc (0);
     16
     17    // files associated with the science image
     18    pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
     19
     20    while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
     21        psLogMsg ("psphot", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     22        if (!chip->process || !chip->file_exists) { continue; }
     23        pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
     24
     25        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
     26            psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     27            if (!cell->process || !cell->file_exists) { continue; }
     28            pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
     29
     30            // process each of the readouts
     31            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
     32                pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
     33                if (! readout->data_exists) { continue; }
     34
     35                pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
     36            }
     37            pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
     38        }
     39        pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
    2640    }
    27 
    28     for (int i = 0; i < file->fpa->chips->n; i++) {
    29         pmChip *chip = file->fpa->chips->data[i]; // Chip of interest in input image
    30 
    31         psLogMsg ("psastro", 4, "Chip %d: %x %x\n", i, chip->exists, chip->process);
    32         if (! chip->process) { continue; }
    33 
    34         if (imageLoadDepth == PP_LOAD_CHIP) {
    35             psTrace(__func__, 1, "Loading pixels for chip %d...\n", i);
    36             psastroLoadSMF(file, config->database, i, -1);
    37         }
    38 
    39         for (int j = 0; j < chip->cells->n; j++) {
    40             pmCell *cell = chip->cells->data[j]; // Cell of interest in input image
    41 
    42             psLogMsg ("psastro", 4, "Cell %d: %x %x\n", j, cell->exists, cell->process);
    43             if (! cell->process) { continue; }
    44 
    45             if (imageLoadDepth == PP_LOAD_CELL) {
    46                 psTrace(__func__, 1, "Loading pixels for chip %d, cell %d...\n", i, j);
    47                 psastroLoadSMF(file, config->database, i, j);
    48             }
    49            
    50             // process each of the readouts
    51             for (int k = 0; k < cell->readouts->n; k++) {
    52                 pmReadout *readout = cell->readouts->data[k]; // Readout of interest in input image
    53 
    54                 // run a single-model test if desired
    55                 psphotModelTest (readout, config->arguments, config->recipe);
    56                 psphotReadout (readout, config->recipe);
    57                 psphotOutput (readout, config->arguments);
    58             }
    59         }
    60     }
     41    pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
    6142    return true;
    6243}
    63 
    64 /* this is currently written only for single-chip analysis */
  • trunk/psastro/src/psastroParseCamera.c

    r6791 r6792  
    11# include "psphot.h"
    22
    3 ppFile *psastroParseCamera (ppConfig *config) {
     3bool *psastroParseCamera (pmConfig *config) {
    44
    55    ppFile *input = ppFileAlloc ();
    66
    7     input->filename = psMetadataLookupStr(NULL, config->arguments, "INPUT_FILE");
    8     psMemCopy (input->filename); // keep for external use
    9 
    10     // Open the input image
    11     psLogMsg("psphot", PS_LOG_INFO, "Opening input image: %s\n", input->filename);
    12     input->fits = psFitsOpen (input->filename, "r"); // File handle for FITS file
    13     if (! input->fits) {
    14         psErrorStackPrint(stderr, "Can't open input image: %s\n", input->filename);
    15         exit(EXIT_FAILURE);
     7    // the input image(s) are required arguments; they define the camera
     8    input = pmFPAfileAddSource (config, "INPUT", "PSASTRO.INPUT", true);
     9    if (input == NULL) {
     10        psAbort (__func__, "missing INPUT entry");
    1611    }
    17     input->phu = psFitsReadHeader(NULL, input->fits); // FITS header
    18 
    19     // Get camera configuration from header if not already defined
    20     if (! config->camera) {
    21         config->camera = pmConfigCameraFromHeader(config->site, input->phu);
    22         if (! config->camera) {
    23              // There's no point in continuing if we can't recognize what we've got
    24             psErrorStackPrint(stderr, "Can't find camera configuration!\n");
    25             exit(EXIT_FAILURE);
    26         }
    27    } else if (! pmConfigValidateCamera(config->camera, input->phu)) {
    28        // There's no point in continuing if what we've got doesn't match what we've been told
    29         psError(PS_ERR_IO, true, "%s does not seem to be from the specified camera.\n",
    30                 input->filename);
    31         exit(EXIT_FAILURE);
    32     }
    33 
    34     // Determine the correct recipe to use (from camera or from user)
    35     // if config->recipe is not NULL, it is a user-supplied recipe
    36     if (!config->recipe) {
    37         config->recipe = pmConfigRecipeFromCamera(config->camera, PSPHOT_RECIPE);
    38         if (config->recipe == NULL) {
    39             psErrorStackPrint(stderr, "Can't find recipe configuration!\n");
    40             exit(EXIT_FAILURE);
    41         }
    42     }
    43 
    44     // recipe override values (command-line options):
    45     psMetadataItem *item = NULL;
    46     psMetadataIterator *iter = psMetadataIteratorAlloc (config->options, PS_LIST_HEAD, NULL);
    47     while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
    48         psMetadataAddItem (config->recipe, item, PS_LIST_TAIL, PS_META_REPLACE);
    49     }
    50     psFree (iter);
    5112
    5213    // set default recipe values here
     
    5415    psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default fitting mode", "NONE");
    5516
    56     // Chip selection: if we are using a single chip, select it for each FPA
    57     // Chip numbers to work on: -chip 1,2,3,5,8,10
    58     # if (0)
    59     char *chips = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS");
    60     if (chips != NULL) {
    61         char *p = chips;
    62         while (strlen(p)) {
    63             char *q = strchr (p, ',');
    64             if (q == NULL) {
    65                 q = p + strlen(p);
    66             } else {
    67                 *q = 0;
    68                 q = q + 1;
    69             }
    70             int chipNum = atoi(p);
    71             // XXX EAM : extend this to allow an array of selected chips (by name)
    72             if (! pmFPASelectChip(input->fpa, chipNum)) {
    73                 psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum);
    74                 exit(EXIT_FAILURE);
    75             }
    76             psLogMsg("psphot", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);
    77             p = q;
    78         }
    79     }
    80     # endif
    81 
    82     psTrace(__func__, 1, "Done with psphotParseCamera...\n");
    83     return input;
     17    psTrace(__func__, 1, "Done with psastroParseCamera...\n");
     18    return true;
    8419}
Note: See TracChangeset for help on using the changeset viewer.