IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 12, 2006, 8:59:15 PM (20 years ago)
Author:
eugene
Message:

tests on non-poisson errors, updates to image background, tests of systematic biases, updates to use pmFPAfile paradigm

File:
1 edited

Legend:

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

    r6727 r6851  
    44
    55    bool status;
    6     psFits *fits = NULL;
    7     psMetadata *phu = NULL;
    8     psMetadata *format = NULL;
    96
    10     // psphot is supplied with a list of input images (may be only one image)
    11     psArray *infiles = psMetadataLookupPtr(&status, config->arguments, "INPUT");
    12     if (!status) psAbort (__func__, "missing INPUT entry");
    13     if (infiles->n < 1) psAbort (__func__, "empty input list");
    14 
    15     // if no camera has been specified, use the first image as a template for the rest.
    16     if (config->camera == NULL) {
    17         fits = psFitsOpen (infiles->data[0], "r");
    18         phu = psFitsReadHeader (NULL, fits);
    19         format = pmConfigCameraFormatFromHeader (config, phu);
    20         psFitsClose (fits);
     7    status = false;
     8    pmFPAfile *input = pmFPAfileFromArgs (&status, config, "PSPHOT.INPUT", "INPUT");
     9    if (!status) {
     10        psAbort (__func__, "missing INPUT entry");
    2111    }
    22     // There's no point in continuing if we can't recognize what we've got
    23     if (! config->camera) {
    24         psErrorStackPrint(stderr, "Can't find camera configuration!\n");
    25         exit(EXIT_FAILURE);
    26     }
    27 
    28     // files
    29     config->files = psMetadataAlloc ();
    30 
    31     // build the template fpa, set up the basic view
    32     // XXX : 216 leaks in pmFPAConstruct / psFree (input)
    33     pmFPA *input = pmFPAConstruct (config->camera);
    34 
    35     // assign the I/O files (potentially) needed by psphot
    36     // the output file is just a view to the file on config->files
    37     pmFPAfile *file = pmFPAfileDefine (config->files, format, input, "PSPHOT.INPUT");
    38     if (!file) {
    39         exit(EXIT_FAILURE);
    40     }
    41 
    42     for (int i = 0; i < infiles->n; i++) {
    43         if (phu == NULL) {
    44             fits = psFitsOpen (infiles->data[i], "r");
    45             phu = psFitsReadHeader (NULL, fits);
    46             pmConfigValidateCameraFormat (format, phu);
    47             psFitsClose (fits);
    48         }
    49 
    50         // set the view to the corresponding entry for this phu
    51         pmFPAview *view = pmFPAAddSource (input, phu, format);
    52 
    53         // XXX is this the correct psMD to save the filename?
    54         char *name = pmFPAfileNameFromRule (file->filextra, file, view);
    55         psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]);
    56 
    57         psFree (view);
    58         psFree (name);
    59         psFree (phu);
    60         phu = NULL;
    61     }
    62 
    63     pmFPAfileDefine (config->files, format, input, "PSPHOT.OUTPUT");
    64     pmFPAfileDefine (config->files, format, input, "PSPHOT.RESID");
    65 
    66     // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_INPUT");
    67     // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_OUTPUT");
    68 
    69     // build the template fpa, set up the basic view
    70     // supply the backgnd with a different camera?
    71     // allow alternate format?
    72     // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.BACKSUB");
    73     // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.BACKGND");
    74     // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.BACKMDL");
    75     // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE");
    76 
    77     // psphot is supplied with the output name
    78     // this needs to be better: supply to all output (WRITE) files?
    79     char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
    80 
    81     file = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");
    82     if (!status) psAbort (__func__, "missing OUTPUT entry");
    83     psMetadataAddStr (file->names, PS_LIST_TAIL, "OUTPUT", 0, "", output);
    84 
    85     file = psMetadataLookupPtr (&status, config->files, "PSPHOT.RESID");
    86     if (!status) psAbort (__func__, "missing OUTPUT entry");
    87     psMetadataAddStr (file->names, PS_LIST_TAIL, "OUTPUT", 0, "", output);
    8812
    8913    // recipe override values (command-line options):
     
    9620    }
    9721    psFree (iter);
     22
     23    // these calls bind the I/O handle to the specified fpa
     24    pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.OUTPUT");
     25    pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.RESID");
     26
     27    // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_INPUT");
     28    // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_OUTPUT");
     29
     30    // 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");
     38
     39    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE");
     40
     41    // psphot is supplied with the output name
     42    // this needs to be better: supply to all output (WRITE) files?
     43    char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
     44    pmFPAfileAddFileNames (config->files, "OUTPUT", output, PM_FPA_MODE_WRITE);
    9845
    9946    // set default recipe values here
     
    12976    # endif
    13077
    131     psFree (input);
    132     psFree (format);
    133 
    13478    psTrace(__func__, 1, "Done with psphotParseCamera...\n");
    13579    return true;
Note: See TracChangeset for help on using the changeset viewer.