IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7621


Ignore:
Timestamp:
Jun 21, 2006, 12:51:48 PM (20 years ago)
Author:
eugene
Message:

various fixes

Location:
trunk/ppImage/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImage.h

    r7592 r7621  
    3434bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem);
    3535
    36 bool ppImageRebinReadout (pmConfig *config, pmFPAview *view, char *filename);
     36bool ppImageRebinChip (pmConfig *config, pmFPAview *view, char *outName, char *inName);
     37bool ppImageRebinReadout (pmReadout *output, pmReadout *input, pmFPAfile *outFile);
    3738
    3839bool ppImagePhotom (pmConfig *config, pmFPAview *view);
    3940bool ppImageAstrom (pmConfig *config);
    4041
    41 bool ppImageMosaicChip (pmChip *chip, pmConfig *config, const pmFPAview *view);
     42bool ppImageMosaicChip (pmConfig *config, const pmFPAview *view, char *outFile, char *inFile);
     43bool ppImageMosaicFPA (pmConfig *config, char *outFile, char *inFile);
    4244
    4345#endif
  • trunk/ppImage/src/ppImageAstrom.c

    r7592 r7621  
    55    bool status;
    66
     7    // select recipe options supplied on command line
     8    // XXX move these options to the "PSASTRO" recipe?
     9    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, RECIPE_NAME);
     10
    711    // find or define a pmFPAfile PSPHOT.INPUT
    812    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSASTRO.INPUT");
    913    if (!status) {
    1014
    11         // psphotReadout requires a pmFPAfile supplied with the name PSPHOT.INPUT
    12         // create a pmFPAfile which points at PPIMAGE.OUTPUT
     15        // psphotReadout requires a pmFPAfile supplied with the name PSASTRO.INPUT
     16        // create a pmFPAfile which points at PSPHOT.OUTPUT
    1317        // mode is 'REFERENCE' to prevent double frees of the fpa
    1418        pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");
     
    1721
    1822        pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT");
    19 
    20         // supply the output name (from cmd-line) to all output (WRITE) files
    21         // XXX does this cause trouble with existing files?
    22         char *outname = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
    23         pmFPAfileAddFileNames (config->files, "OUTPUT", outname, PM_FPA_MODE_WRITE);
    2423    }
    25 
    26     // we only was to operate on PSPHOT pmFPAfiles here:
    27     pmFPAfileActivate (config->files, false, NULL);
    28     pmFPAfileActivate (config->files, true, "PSASTRO.INPUT");
    29     pmFPAfileActivate (config->files, true, "PSASTRO.OUTPUT");
    3024
    3125    // interpret the available initial astrometric information
     
    3832    psastroMosaicGetRefstars (config, refs);
    3933
    40     char *mosastro = psMetadataLookupStr (NULL, config->arguments, "MOSASTRO");
    41     if (mosastro == NULL) {
     34    if (psMetadataLookupBool (NULL, recipe, "ASTROM.CHIP")) {
    4235        psastroChipAstrom (config, refs);
    43     } else {
     36    }
     37    if (psMetadataLookupBool (NULL, recipe, "ASTROM.MOSAIC")) {
    4438        psastroMosaicAstrom (config, refs);
    4539    }
    4640
    47     psastroDataSave (config);
    48 
    49     // de-activate the PSPHOT image files, activate the PPIMAGE ones
    50     pmFPAfileActivate (config->files, false, NULL);
    51     pmFPAfileActivate (config->files, true, "PPIMAGE.INPUT");
    52     pmFPAfileActivate (config->files, true, "PPIMAGE.BIAS");
    53     pmFPAfileActivate (config->files, true, "PPIMAGE.DARK");
    54     pmFPAfileActivate (config->files, true, "PPIMAGE.MASK");
    55     pmFPAfileActivate (config->files, true, "PPIMAGE.FLAT");
    56     pmFPAfileActivate (config->files, true, "PPIMAGE.OUTPUT");
    57 
    58     pmFPAfileActivate (config->files, true, "PPIMAGE.BIN1");
    59     pmFPAfileActivate (config->files, true, "PPIMAGE.JPEG1");
    60     pmFPAfileActivate (config->files, true, "PPIMAGE.BIN2");
    61     pmFPAfileActivate (config->files, true, "PPIMAGE.JPEG2");
    62 
    6341    return true;
    6442}
  • trunk/ppImage/src/ppImageLoop.c

    r7592 r7621  
    3737                if (!ppImageDetrendReadout (config, options, view)) return false;
    3838
    39                 if (options->doBin1) ppImageRebinReadout (config, view, "PPIMAGE.BIN1");
    40                 if (options->doBin2) ppImageRebinReadout (config, view, "PPIMAGE.BIN2");
    41 
    4239                if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
    4340            }
     
    4542        }
    4643
    47         ppImageMosaicChip (chip, config, view);
     44        ppImageMosaicChip (config, view, "PPIMAGE.OUTPUT.CHIP", "PPIMAGE.OUTPUT");
     45        ppImageRebinChip (config, view, "PPIMAGE.BIN1", "PPIMAGE.OUTPUT.CHIP");
     46        ppImageRebinChip (config, view, "PPIMAGE.BIN2", "PPIMAGE.OUTPUT.CHIP");
    4847
    4948        // we perform photometry on the readouts of this chip in the output
     
    5352    }
    5453
     54    ppImageMosaicFPA (config, "PPIMAGE.OUTPUT.FPA1", "PPIMAGE.BIN1");
     55    ppImageMosaicFPA (config, "PPIMAGE.OUTPUT.FPA2", "PPIMAGE.BIN2");
     56
    5557    // we perform astrometry on all chips after sources have been detected
    56     if (options->doAstrom) ppImageAstrom (config);
     58    if (options->doAstromChip || options->doAstromMosaic) ppImageAstrom (config);
    5759   
    58     // ppImageFPAMosaic (config, view);
    59     // ppImageJpegFPA (config, view);
    60 
    6160    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
    6261
     
    6766// input image is: PPIMAGE.INPUT
    6867// output image is: PPIMAGE.OUTPUT
     68
     69// XXX need to be careful in ppImage in general about which pmFPAfiles are active and when.
     70// major phases:
     71// - detrend loop
     72// -
  • trunk/ppImage/src/ppImageMosaic.c

    r7592 r7621  
    11# include "ppImage.h"
    22
    3 bool ppImageMosaicChip (pmChip *chip, pmConfig *config, const pmFPAview *view) {
     3bool ppImageMosaicChip (pmConfig *config, const pmFPAview *view, char *outFile, char *inFile) {
    44
    55    bool status;
    66
    7     pmFPAfile *outByChip = psMetadataLookupPtr (&status, config->files, "PPIMAGE.OUTPUT.CHIP");
     7    pmFPAfile *in = psMetadataLookupPtr (&status, config->files, inFile);
    88    if (!status) {
    99        psErrorStackPrint(stderr, "Can't find required I/O file!\n");
     
    1111    }
    1212
    13     pmFPAAddSourceFromView (outByChip->fpa, view, outByChip->format);
    14     pmChip *outChip = pmFPAviewThisChip (view, outByChip->fpa);
    15     pmChipMosaic (outChip, chip);
     13    pmFPAfile *out = psMetadataLookupPtr (&status, config->files, outFile);
     14    if (!status) {
     15        psErrorStackPrint(stderr, "Can't find required I/O file!\n");
     16        exit(EXIT_FAILURE);
     17    }
     18
     19    pmFPAAddSourceFromView (out->fpa, view, out->format);
     20    pmChip *outChip = pmFPAviewThisChip (view, out->fpa);
     21    pmChip *inChip = pmFPAviewThisChip (view, in->fpa);
     22
     23    pmChipMosaic (outChip, inChip);
    1624
    1725    return true;
    1826}
     27
     28bool ppImageMosaicFPA (pmConfig *config, char *outFile, char *inFile) {
     29
     30    bool status;
     31
     32    pmFPAfile *in = psMetadataLookupPtr (&status, config->files, inFile);
     33    if (!status) {
     34        psErrorStackPrint(stderr, "Can't find required I/O file!\n");
     35        exit(EXIT_FAILURE);
     36    }
     37
     38    pmFPAfile *out = psMetadataLookupPtr (&status, config->files, outFile);
     39    if (!status) {
     40        psErrorStackPrint(stderr, "Can't find required I/O file!\n");
     41        exit(EXIT_FAILURE);
     42    }
     43
     44    pmFPAview *view = pmFPAviewAlloc (0);
     45    pmFPAAddSourceFromView (out->fpa, view, out->format);
     46    pmFPAMosaic (out->fpa, in->fpa);
     47
     48    psFree (view);
     49    return true;
     50}
  • trunk/ppImage/src/ppImageOptions.c

    r7531 r7621  
    2929    options->doFringe   = false;        // Fringe subtraction
    3030    options->doPhotom   = false;        // Source identification and photometry
    31     options->doAstrom   = false;        // Astrometry
     31    options->doAstromChip = false;      // Astrometry
     32    options->doAstromMosaic = false;    // Astrometry
    3233
    33     options->doBin1     = false;        // create binned image (scale 1)
    34     options->doBin2     = false;        // create binned image (scale 2)
    35     options->doBin1JPG  = false;        // create jpg of binned image (scale 1)
    36     options->doBin2JPG  = false;        // create jpg of binned image (scale 2)
     34    options->BaseFITS   = false;        // create binned image (scale 1)
     35    options->ChipFITS   = false;        // create binned image (scale 1)
     36    options->FPA1FITS   = false;        // create binned image (scale 1)
     37    options->FPA2FITS   = false;        // create binned image (scale 1)
     38
     39    options->Bin1FITS   = false;        // create binned image (scale 1)
     40    options->Bin2FITS   = false;        // create binned image (scale 2)
     41    options->Bin1JPEG   = false;        // create jpeg of binned image (scale 1)
     42    options->Bin2JPEG   = false;        // create jpeg of binned image (scale 2)
    3743
    3844    // Overscan defaults
     
    164170    if (!status) options->yBin1 = 16;
    165171
    166     options->doBin1 = psMetadataLookupBool(NULL, recipe, "BIN1.FITS");
    167     options->doBin1JPG = psMetadataLookupBool(NULL, recipe, "BIN1.JPEG");
    168     if (options->doBin1JPG && !options->doBin1) {
    169         psLogMsg(__func__, PS_LOG_ERROR, "Invalid Phase2 Options: cannot make JPG of Bin1 image without Bin1 image");
    170         exit(EXIT_FAILURE);
    171     }
     172    options->BaseFITS = psMetadataLookupBool(NULL, recipe, "BASE.FITS");
     173    options->ChipFITS = psMetadataLookupBool(NULL, recipe, "CHIP.FITS");
     174    options->FPA1FITS = psMetadataLookupBool(NULL, recipe, "FPA1.FITS");
     175    options->FPA2FITS = psMetadataLookupBool(NULL, recipe, "FPA2.FITS");
    172176
    173     options->doBin2 = psMetadataLookupBool(NULL, recipe, "BIN2.FITS");
    174     options->doBin2JPG = psMetadataLookupBool(NULL, recipe, "BIN2.JPEG");
    175     if (options->doBin2JPG && !options->doBin2) {
    176         psLogMsg(__func__, PS_LOG_ERROR, "Invalid Phase2 Options: cannot make JPG of Bin2 image without Bin2 image");
    177         exit(EXIT_FAILURE);
    178     }
     177    options->Bin1FITS = psMetadataLookupBool(NULL, recipe, "BIN1.FITS");
     178    options->Bin1JPEG = psMetadataLookupBool(NULL, recipe, "BIN1.JPEG");
     179    options->Bin2FITS = psMetadataLookupBool(NULL, recipe, "BIN2.FITS");
     180    options->Bin2JPEG = psMetadataLookupBool(NULL, recipe, "BIN2.JPEG");
    179181   
    180182    options->doPhotom = psMetadataLookupBool(NULL, recipe, "PHOTOM");
    181     options->doAstrom = psMetadataLookupBool(NULL, recipe, "ASTROM");
    182     if (options->doAstrom && !options->doPhotom) {
     183    options->doAstromChip = psMetadataLookupBool(NULL, recipe, "ASTROM.CHIP");
     184    options->doAstromMosaic = psMetadataLookupBool(NULL, recipe, "ASTROM.MOSAIC");
     185    if ((options->doAstromChip || options->doAstromMosaic) && !options->doPhotom) {
    183186        psLogMsg(__func__, PS_LOG_ERROR, "Invalid Phase2 Options: cannot do ASTROMetry without PHOTOMetry");
    184187        exit(EXIT_FAILURE);
  • trunk/ppImage/src/ppImageOptions.h

    r7531 r7621  
    1212    bool doFringe;                      // Fringe subtraction
    1313    bool doPhotom;                      // Source identification and photometry
    14     bool doAstrom;                      // Astrometry
     14    bool doAstromChip;                  // per-chip Astrometry
     15    bool doAstromMosaic;                // full-mosaic Astrometry
    1516
    1617    bool doOverscan;                    // Overscan subtraction
     
    2223    void *nonLinearSource;
    2324
    24     bool doBin1;
    25     bool doBin1JPG;
     25    bool BaseFITS;
     26    bool ChipFITS;
     27    bool FPA1FITS;
     28    bool FPA2FITS;
     29
     30    bool Bin1FITS;
     31    bool Bin1JPEG;
    2632    int xBin1, yBin1;
    2733
    28     bool doBin2;
    29     bool doBin2JPG;
     34    bool Bin2FITS;
     35    bool Bin2JPEG;
    3036    int xBin2, yBin2;
    3137
  • trunk/ppImage/src/ppImageParseCamera.c

    r7592 r7621  
    66    bool status = false;
    77
    8     // the input image defines the camera
     8    // the input image defines the camera, and all recipes and options the follow
    99    pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PPIMAGE.INPUT", "INPUT");
    1010    if (!status) {
     
    1414
    1515    // add recipe options supplied on command line
    16     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes,   "PHASE2");
     16    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, "PHASE2");
    1717    psMetadata *arglist = psMetadataLookupPtr (&status, config->arguments, "PPIMAGE.OPTIONS");
    1818    psMetadataCopy (recipe, arglist);
     
    2020    // parse the options from the metadata format to the ppImageOptions structure
    2121    ppImageOptions *options = ppImageOptionsParse (config);
    22 
    23     // the following files are output targets
    24     pmFPAfileDefineOutput (config, input->fpa, "PPIMAGE.OUTPUT");
    25     pmFPAfileDefineNewCamera (config, "PPIMAGE.OUTPUT.CHIP");
    2622
    2723    // the following are defined from the argument list, if given,
     
    5652        if (!status) psAbort ("ppImageParseDetrend", "can't find a flat image source");
    5753    }
    58     if (options->doBin1) {
    59         pmFPAfile *file = pmFPAfileDefineFromFPA (config, input->fpa, options->xBin1, options->yBin1, "PPIMAGE.BIN1");
    60         if (options->doBin1JPG) {
    61             pmFPAfileDefineOutput (config, file->fpa, "PPIMAGE.JPEG1");
     54
     55    // the following files are output targets
     56    pmFPAfile *output = pmFPAfileDefineOutput (config, input->fpa, "PPIMAGE.OUTPUT");
     57    pmFPAfile *byChip = pmFPAfileDefineNewCamera (config, "PPIMAGE.OUTPUT.CHIP");
     58    pmFPAfile *byFPA1 = pmFPAfileDefineNewCamera (config, "PPIMAGE.OUTPUT.FPA1");
     59    pmFPAfile *byFPA2 = pmFPAfileDefineNewCamera (config, "PPIMAGE.OUTPUT.FPA2");
     60
     61    // save any of these files?
     62    output->save = options->BaseFITS;
     63    byChip->save = options->ChipFITS;
     64    byFPA1->save = options->FPA1FITS;
     65    byFPA2->save = options->FPA2FITS;
     66
     67    // output is used as a carrier: input to byChip
     68    output->freeLevel = PM_FPA_LEVEL_CHIP;
     69
     70    // define the binned target files (which may just be carriers for some camera configurations)
     71    pmFPAfile *bin1 = pmFPAfileDefineFromFPA (config, byChip->fpa, options->xBin1, options->yBin1, "PPIMAGE.BIN1");
     72    pmFPAfile *bin2 = pmFPAfileDefineFromFPA (config, byChip->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2");
     73
     74    // set the CELL.XBIN and CELL.YBIN for the output mosaiced FPAs
     75    for (int i = 0; i < byFPA1->fpa->chips->n; i++) {
     76        pmChip *chip = byFPA1->fpa->chips->data[i];
     77        for (int j = 0; j < chip->cells->n; j++) {
     78            pmCell *cell = chip->cells->data[j];
     79            psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.XBIN", PS_META_REPLACE, "", options->xBin1);
     80            psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.YBIN", PS_META_REPLACE, "", options->yBin1);
    6281        }
    6382    }
    64     if (options->doBin2) {
    65         pmFPAfile *file = pmFPAfileDefineFromFPA (config, input->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2");
    66         if (options->doBin2JPG) {
    67             pmFPAfileDefineOutput (config, file->fpa, "PPIMAGE.JPEG2");
     83    for (int i = 0; i < byFPA2->fpa->chips->n; i++) {
     84        pmChip *chip = byFPA2->fpa->chips->data[i];
     85        for (int j = 0; j < chip->cells->n; j++) {
     86            pmCell *cell = chip->cells->data[j];
     87            psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.XBIN", PS_META_REPLACE, "", options->xBin2);
     88            psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.YBIN", PS_META_REPLACE, "", options->yBin2);
    6889        }
    6990    }
    7091
    71     // ppImage is supplied with an output name, which may be used by multiple
    72     // output files to construct the output names.  supply this value to the
    73     // files which are write types.
    74     char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
    75     pmFPAfileAddFileNames (config->files, "OUTPUT", output, PM_FPA_MODE_WRITE);
     92    // bin1 and bin2 are used as carriers: input for byFPA1, byFPA2
     93    bin1->freeLevel = PM_FPA_LEVEL_FPA;
     94    bin2->freeLevel = PM_FPA_LEVEL_FPA;
     95
     96    pmFPAfile *jpg1 = pmFPAfileDefineOutput (config, byFPA1->fpa, "PPIMAGE.JPEG1");
     97    pmFPAfile *jpg2 = pmFPAfileDefineOutput (config, byFPA2->fpa, "PPIMAGE.JPEG2");
     98
     99    // XXX we could potentially not define these pmFPAfiles if no output is requested...
     100    bin1->save = options->Bin1FITS;
     101    bin2->save = options->Bin2FITS;
     102    jpg1->save = options->Bin1JPEG;
     103    jpg2->save = options->Bin2JPEG;
    76104
    77105    // Chip selection: turn on only the chips specified (pass status to suppress missing-key log msg)
  • trunk/ppImage/src/ppImagePhotom.c

    r7592 r7621  
    2424    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
    2525    if (!status) {
    26 
    2726        // psphotReadout requires a pmFPAfile supplied with the name PSPHOT.INPUT
    28         // create a pmFPAfile which points at PPIMAGE.OUTPUT
     27        // create a pmFPAfile which points to PPIMAGE.OUTPUT.CHIP (guaranteed to be mosaiced by chip)
    2928        // mode is 'REFERENCE' to prevent double frees of the fpa
    30         pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PPIMAGE.OUTPUT");
     29        pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PPIMAGE.OUTPUT.CHIP");
    3130        input = pmFPAfileDefineInput (config, output->fpa, "PSPHOT.INPUT");
    3231        input->mode = PM_FPA_MODE_REFERENCE;
    3332
    3433        pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT");
    35 
    36         // supply the output name (from cmd-line) to all output (WRITE) files
    37         // XXX does this cause trouble with existing files?
    38         char *outname = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
    39         pmFPAfileAddFileNames (config->files, "OUTPUT", outname, PM_FPA_MODE_WRITE);
    4034    }
    4135
    42     // XXX add the option output files here
     36    // optionally save the residual image
     37    if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) {
     38        pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.RESID");
     39    }
    4340
    44     // int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
    45     // int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
     41    int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
     42    int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
    4643
    47     // we only was to operate on PSPHOT pmFPAfiles here:
    48     pmFPAfileActivate (config->files, false, NULL);
    49     pmFPAfileActivate (config->files, true, "PSPHOT.INPUT");
    50     pmFPAfileActivate (config->files, true, "PSPHOT.RESID");
    51     pmFPAfileActivate (config->files, true, "PSPHOT.OUTPUT");
     44    // these calls construct a new fpa for the I/O handle
    5245
    53     pmFPAfileActivate (config->files, true, "PSPHOT.BACKSUB");
    54     pmFPAfileActivate (config->files, true, "PSPHOT.BACKGND");
    55     pmFPAfileActivate (config->files, true, "PSPHOT.BACKMDL");
     46    // optionally save the background model (small FITS image)
     47    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
     48        pmFPAfileDefineFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL");
     49    }
     50    // optionally save the full background image
     51    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) {
     52        pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKGND");
     53    }
     54    // optionally save the background-subtracted image
     55    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) {
     56        pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKSUB");
     57    }
     58    // optionally save the PSF Model
     59    if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) {
     60        pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.PSF.SAVE");
     61    }
     62    // optionally load the PSF Model
     63    if (psMetadataLookupBool(NULL, recipe, "LOAD.PSF")) {
     64        pmFPAfileDefineInput (config, input->fpa, "PSPHOT.PSF.LOAD");
     65    }
    5666
     67    // XXX not tested (or defined?)
     68    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE");
    5769
     70    // view->cell = -1;
    5871    // iterate over the cells in the current chip
    59     // view->cell = -1;
    60 
    6172    while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    6273        psLogMsg ("ppImagePhot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    6374        if (! cell->process || ! cell->file_exists) { continue; }
    64         pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    6575
    6676        // process each of the readouts
    6777        while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    68             pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    6978            if (! readout->data_exists) { continue; }
    7079
    7180            // run the actual photometry analysis
    7281            psphotReadout (config, view);
     82        }
     83    }
     84    return true;
     85}
    7386
    74             pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
    75         }
    76         pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
    77     }
     87    // we only want to operate on PSPHOT pmFPAfiles here:
     88    // XXX is this necessary?  why invoke I/O during this function?
     89    // the psphot constructed files, if chosen, will be saved at the chip level
     90    // in the next call outside of this function.
     91    // XXX there could be an issue if those files are set for 'cell' or 'readout'
     92    // pmFPAfileActivate (config->files, false, NULL);
     93    // pmFPAfileActivate (config->files, true, "PSPHOT.INPUT");
     94    // pmFPAfileActivate (config->files, true, "PSPHOT.RESID");
     95    // pmFPAfileActivate (config->files, true, "PSPHOT.OUTPUT");
     96    // pmFPAfileActivate (config->files, true, "PSPHOT.BACKSUB");
     97    // pmFPAfileActivate (config->files, true, "PSPHOT.BACKGND");
     98    // pmFPAfileActivate (config->files, true, "PSPHOT.BACKMDL");
     99
     100
    78101
    79102    // de-activate the PSPHOT image files, activate the PPIMAGE ones
     103    # if 0
    80104    pmFPAfileActivate (config->files, false, NULL);
    81105    pmFPAfileActivate (config->files, true, "PPIMAGE.INPUT");
     
    85109    pmFPAfileActivate (config->files, true, "PPIMAGE.FLAT");
    86110    pmFPAfileActivate (config->files, true, "PPIMAGE.OUTPUT");
    87 
    88111    pmFPAfileActivate (config->files, true, "PPIMAGE.BIN1");
    89112    pmFPAfileActivate (config->files, true, "PPIMAGE.JPEG1");
    90113    pmFPAfileActivate (config->files, true, "PPIMAGE.BIN2");
    91114    pmFPAfileActivate (config->files, true, "PPIMAGE.JPEG2");
     115    # endif
    92116
    93     return true;
    94 }
  • trunk/ppImage/src/ppImageRebinReadout.c

    r6849 r7621  
    11#include "ppImage.h"
    22
    3 bool ppImageRebinReadout (pmConfig *config, pmFPAview *view, char *filename)
     3bool ppImageRebinChip (pmConfig *config, pmFPAview *view, char *outName, char *inName) {
     4
     5    pmCell *cell;
     6    pmReadout *inReadout, *outReadout;
     7
     8    pmFPAfile *inFile = psMetadataLookupPtr (NULL, config->files, inName);
     9    if (inFile == NULL) return NULL;
     10
     11    pmFPAfile *outFile = psMetadataLookupPtr (NULL, config->files, outName);
     12    if (outFile == NULL) return NULL;
     13
     14    // XXX double check that chip != -1?
     15
     16    pmChip *inChip = pmFPAviewThisChip (view, inFile->fpa);
     17    pmChip *outChip = pmFPAviewThisChip (view, outFile->fpa);
     18    pmChipCopyStructure (outChip, inChip, outFile->xBin, outFile->yBin);
     19
     20    while ((cell = pmFPAviewNextCell (view, inFile->fpa, 1)) != NULL) {
     21        psLogMsg ("ppImageRebinChip", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     22        if (! cell->process || ! cell->file_exists) { continue; }
     23
     24        // process each of the readouts
     25        while ((inReadout = pmFPAviewNextReadout (view, inFile->fpa, 1)) != NULL) {
     26            if (! inReadout->data_exists) { continue; }
     27
     28            outReadout = pmFPAviewThisReadout (view, outFile->fpa);
     29
     30            // run the rebin code
     31            ppImageRebinReadout (outReadout, inReadout, outFile);
     32        }
     33    }
     34    return true;
     35}
     36
     37bool ppImageRebinReadout (pmReadout *output, pmReadout *input, pmFPAfile *outFile)
    438{
    5     bool status;
    639    psF32 value;
    740    psS32 nPix;
    8 
    9     // find the currently selected readout
    10     pmReadout *input = pmFPAfileThisReadout (config->files, view, "PPIMAGE.INPUT");
    11 
    12     // set up the readouts for dark and bias
    13     pmReadout  *output = pmFPAfileThisReadout (config->files, view, filename);
    14 
    15     // we need the file for the binning factors as well
    16     pmFPAfile *file = psMetadataLookupPtr (&status, config->files, filename);
    17     if (file == NULL) return NULL;
    1841
    1942    // the binning process must not change the size of the output image...
     
    2245    // psFree (stats);
    2346
    24     int dX = file->xBin;
    25     int dY = file->yBin;
     47    int dX = outFile->xBin;
     48    int dY = outFile->yBin;
    2649
    2750    int nX = input->image->numCols;
Note: See TracChangeset for help on using the changeset viewer.