IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 23, 2007, 2:52:55 PM (19 years ago)
Author:
eugene
Message:

finish code re-org, add loading of external psf model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSimCreate.c

    r14531 r14657  
    11# include "ppSim.h"
     2
     3// XXX this function forces us to define the camera (on the command line) and format (via the
     4// PPSIM.OUTPUT entry).  In this case, we need to set config->format,formatName based on these
     5// values.  This will be a problem when we want to load an input image (in order to add fake
     6// stars).  We will need to add some logic in ppSimArguments to distinguish the cases of 1)
     7// input image and 2) specified camera
    28
    39pmFPAfile *ppSimCreate(pmConfig *config)
     
    1218
    1319    pmFPAfile *file = pmFPAfileDefineOutput(config, fpa, OUTPUT_FILE);
    14     psFree(fpa);
    1520    if (!file) {
    1621        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to create output file from %s.  "
     
    2025    if (file->type != PM_FPA_FILE_IMAGE) {
    2126        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "%s type is not IMAGE", OUTPUT_FILE);
     27        psFree(fpa);
    2228        psFree(file);
    2329        return NULL;
     
    2531    file->save = true;
    2632
     33    config->format = psMemIncrRefCounter (file->format);
     34    config->formatName = psStringCopy (file->formatName);
     35
    2736    // have we supplied a psf model?
    2837    if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
    2938        bool status = false;
     39
     40        // tie the psf file to the chipMosaic
    3041        pmFPAfileBindFromArgs(&status, file, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
    3142        if (!status) {
    3243            psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD");
    33             return status;
     44            psFree(fpa);
     45            psFree(file);
     46            return NULL;
    3447        }
    3548    }
     49
     50    // XXX only invoke this code for OBJECT types of images
     51    // PPSIM.SOURCES carries the constructed, fake sources with their true parameters
     52    pmFPAfile *simSources = pmFPAfileDefineOutput (config, file->fpa, "PPSIM.SOURCES");
     53    if (!simSources) {
     54        psError(PS_ERR_UNKNOWN, false, "Cannot find a rule for PPSIM.SOURCES");
     55        return false;
     56    }
     57    simSources->save = true;
    3658
    3759    pmFPALevel phuLevel = pmFPAPHULevel(file->format); // Level at which PHU goes
     
    4466            psFree(fpa);
    4567            psFree(view);
     68            psFree(file);
    4669            return NULL;
    4770        }
     
    5578                psFree(fpa);
    5679                psFree(view);
     80                psFree(file);
    5781                return NULL;
    5882            }
     
    6690                    psFree(fpa);
    6791                    psFree(view);
     92                    psFree(file);
    6893                    return NULL;
    6994                }
     
    7196        }
    7297    }
     98
     99    psFree(fpa);
    73100    psFree(view);
    74101
Note: See TracChangeset for help on using the changeset viewer.