IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 19, 2007, 12:02:37 PM (19 years ago)
Author:
Paul Price
Message:

Playing with file activation to get things to write out at the appropriate times.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarpLoop.c

    r14874 r14891  
    33
    44#define WCS_NONLIN_TOL 0.001            // Non-linear tolerance for header WCS
     5
     6// Lists of file rules for the detectors and skycells, and an independent list of everything else
     7// Lists must end with a NULL
     8static char *detectorFiles[] = { "PSWARP.INPUT", "PSWARP.MASK", "PSWARP.WEIGHT", NULL };
     9static char *skycellFiles[] = { "PSWARP.OUTPUT", "PSWARP.OUTPUT.MASK", "PSWARP.OUTPUT.WEIGHT",
     10                                "PSPHOT.OUTPUT", "PSPHOT.BACKMDL", "PSPHOT.BACKMDL.STDEV", "PSPHOT.BACKGND",
     11                                "PSPHOT.BACKSUB", "PSPHOT.PSF.SAVE", "SOURCE.PLOT.MOMENTS",
     12                                "SOURCE.PLOT.PSFMODEL", "SOURCE.PLOT.APRESID", NULL };
     13static char *independentFiles[] = { "PSWARP.ASTROM", // Read independently from the input pixels
     14                                    "PSWARP.SKYCELL", // Don't care about the skycell once we have its WCS
     15                                    "PSPHOT.INPUT", // This is just a pointer to PSWARP.OUTPUT
     16                                    "PSWARP.OUTPUT.SOURCES", // Save these independently so we can do the PSF
     17                                    NULL };
     18
     19// Activate a list of files
     20static void fileActivation(pmConfig *config, // Configuration
     21                           char **files, // Files to turn on/off
     22                           bool state   // Activation state
     23    )
     24{
     25    for (int i = 0; files[i] != NULL; i++) {
     26        pmFPAfileActivate(config->files, state, files[i]);
     27    }
     28    return;
     29}
     30
    531
    632// Loop over the inputs, warp them to the output skycell and then write out the output.
     
    5783    }
    5884
     85    // Turn all skycell files on to generate them, and then turn them off for the loop over the input images
     86    // the input, which is in a different format.
     87    {
     88        fileActivation(config, detectorFiles, false);
     89        fileActivation(config, independentFiles, false);
     90        fileActivation(config, skycellFiles, true);
     91
     92        pmFPAview *view = pmFPAviewAlloc(0);
     93        pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     94        // They should all be defined at the FPA level, so that should be enough
     95        psFree(view);
     96
     97        fileActivation(config, skycellFiles, false);
     98    }
     99
     100
    59101    // Read the input astrometry
    60102    {
    61         pmFPAfileActivate(config->files, false, "PSWARP.INPUT");
    62         pmFPAfileActivate(config->files, false, "PSWARP.MASK");
    63         pmFPAfileActivate(config->files, false, "PSWARP.WEIGHT");
    64103        pmFPAfileActivate(config->files, true, "PSWARP.ASTROM");
    65         pmFPAfileActivate(config->files, false, "PSWARP.OUTPUT");
    66         pmFPAfileActivate(config->files, false, "PSWARP.OUTPUT.MASK");
    67         pmFPAfileActivate(config->files, false, "PSWARP.OUTPUT.WEIGHT");
    68         pmFPAfileActivate(config->files, false, "PSWARP.OUTPUT.SOURCES");
    69         pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     104
    70105        pmChip *chip;
    71106        pmFPAview *view = pmFPAviewAlloc(0);
     107        pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    72108        while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
    73109            psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     
    83119        psFree(view);
    84120
    85         pmFPAfileActivate(config->files, true, "PSWARP.INPUT");
    86         pmFPAfileActivate(config->files, true, "PSWARP.MASK");
    87         pmFPAfileActivate(config->files, true, "PSWARP.WEIGHT");
     121        fileActivation(config, detectorFiles, true);
    88122        pmFPAfileActivate(config->files, false, "PSWARP.ASTROM");
    89         pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT");
    90         pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.MASK");
    91         pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.WEIGHT");
    92         pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.SOURCES");
    93     }
    94 
     123    }
     124
     125    // Turn on the source output --- we need to get rid of these so that we can measure the PSF
     126    pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.SOURCES");
     127
     128    // Don't care about the skycell anymore --- we've read it, and that's all we need to do.
    95129    pmFPAfileActivate(config->files, false, "PSWARP.SKYCELL");
    96130    view = pmFPAviewAlloc(0);
     
    198232    }
    199233
     234    pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
     235
     236    // Done with the detector side of things
     237    fileActivation(config, detectorFiles, false);
     238    fileActivation(config, independentFiles, false);
     239    fileActivation(config, skycellFiles, true);
     240
    200241    // We need a new PSF model for the warped frame
    201242    // It would be good to generate this analytically, but that's going to be tricky.
     
    214255                         "Break point for psphot operations", "PSFMODEL");
    215256
     257        // Get rid of the transformed sources so that we can measure the PSF
     258        psMetadataRemoveKey(output->analysis, "PSPHOT.SOURCES");
     259
     260#if 0
    216261        pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT");
    217262        pmFPACopy(photFile->fpa, outFPA);
     263#endif
    218264
    219265        pmFPAview *view = pmFPAviewAlloc(0); // View into skycell
     266        view->chip = view->cell = view->readout = 0;
    220267        if (!psphotReadout(config, view)) {
    221268            psError(psErrorCodeLast(), false, "Unable to determine PSF for warped image.\n");
     
    225272        psFree(view);
    226273
    227         pmFPAfileActivate(config->files, false, "PSPHOT.INPUT");
     274        pmFPAfileActivate(config->files, true, "PSPHOT.INPUT");
     275        pmFPAfileActivate(config->files, true, "PSPHOT.PSF.SAVE");
    228276    }
    229277
     
    264312    psFree(headerName);
    265313
    266     pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
    267     psFree (view);
     314    // Ensure everything is written out, at every level
     315    view->chip = view->cell = view->readout = 0;
     316    pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
     317    view->readout = -1;
     318    pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
     319    view->cell = -1;
     320    pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
     321    view->chip = -1;
     322    pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
     323    psFree(view);
     324    // Now done with the skycell side of things
    268325
    269326    // Write out summary statistics
Note: See TracChangeset for help on using the changeset viewer.