IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14889


Ignore:
Timestamp:
Sep 19, 2007, 11:37:58 AM (19 years ago)
Author:
Paul Price
Message:

Had trouble with defining files for psphot from pswarp --- didn't know what format to use, and so ended up using the default one, which was wrong (because wanted to run psphot on the warped image, not the input image). So added format and format name to the pmFPAfile, and new functions to define a file from one already existing, using its camera and format.

Location:
trunk/psModules/src/camera
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPA.h

    r14647 r14889  
    66 * @author Eugene Magnier, IfA
    77 *
    8  * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-08-23 23:42:41 $
     8 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-09-19 21:37:58 $
    1010 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    1111 */
     
    5555    psMetadata *analysis;               ///< FPA-level analysis metadata
    5656    const psMetadata *camera;           ///< Camera configuration
     57    const char *formatName;             ///< Name of camera format
    5758    psArray *chips;                     ///< The component chips
    5859    pmHDU *hdu;                         ///< FITS header data unit of interest, or NULL
  • trunk/psModules/src/camera/pmFPAfile.c

    r14647 r14889  
    2727    psTrace ("pmFPAfileFree", 5, "freeing %s\n", file->name);
    2828    psFree (file->fpa);
     29    psFree (file->src);
    2930    psFree (file->readout);
    3031    psFree (file->names);
    3132
    3233    psFree (file->camera);
     34    psFree (file->cameraName);
    3335    psFree (file->format);
    3436    psFree (file->formatName);
     
    7375
    7476    file->camera = NULL;
     77    file->cameraName = NULL;
    7578    file->format = NULL;
    7679    file->formatName = NULL;
     
    175178
    176179    if (strstr (newName, "{FPA.NAME}") != NULL) {
    177         char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.NAME");
    178         if (name != NULL) {
    179             psStringSubstitute(&newName, "fpa", "{FPA.NAME}");
    180         }
     180        char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.NAME");
     181        if (name != NULL) {
     182            psStringSubstitute(&newName, "fpa", "{FPA.NAME}");
     183        }
    181184    }
    182185    if (strstr (newName, "{CHIP.NAME}") != NULL) {
  • trunk/psModules/src/camera/pmFPAfile.h

    r14647 r14889  
    44 * @author EAM, IfA
    55 *
    6  * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-08-23 23:42:41 $
     6 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-09-19 21:37:58 $
    88 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
    99 */
     
    6565    psFits *fits;                       // for I/O files of fits type (IMAGE, CMP, CMF), we carry a file handle
    6666
    67     bool wrote_phu;                     // have we written a PHU for this file?
     67    bool wrote_phu;                     // have we written a PHU for this file?
    6868    psMetadata *header;                 // pointer (view) to the current hdu header
    6969
     
    9090
    9191    psMetadata *camera;                 // Camera configuration
     92    psString cameraName;                // Name of the camera
    9293    psMetadata *format;                 // Camera format
    93     char *formatName;                   // name of the camera format
     94    psString formatName;                // name of the camera format
    9495}
    9596pmFPAfile;
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r14647 r14889  
    7979        file->fpa = psMemIncrRefCounter(fpa);
    8080        file->camera = psMemIncrRefCounter((psMetadata *)fpa->camera);
     81        file->cameraName = psMemIncrRefCounter(config->cameraName);
    8182    }
    8283
     
    9798                                          pmFPA *fpa, // Optional FPA to bind
    9899                                          const char *name, // Name of file rule
    99                                           const char *cameraName, // Name of camera configuration to use
    100                                           const char *formatName // Name of camera format to use
     100                                          psString cameraName, // Name of camera configuration to use
     101                                          psString formatName // Name of camera format to use
    101102    )
    102103{
     
    164165        } else {
    165166            camera = config->camera;
     167            cameraName = config->cameraName;
    166168        }
    167169    } else {
     
    184186    }
    185187    file->camera = psMemIncrRefCounter(camera);
     188    file->cameraName = psMemIncrRefCounter(cameraName);
    186189
    187190    // Use the format we were told to, the format specified in the file rule, or default to the default format
    188191    if (!formatName || strlen(formatName) == 0) {
    189         // select the format list from the selected camera
    190         formatName = psMetadataLookupStr(&status, data, "FILE.FORMAT");
    191         if (!formatName || strcmp(formatName, "NONE") == 0) {
    192             // Try to get by with the default
    193             formatName = config->formatName;
     192        if (fpa && fpa->formatName && strlen(fpa->formatName) > 0) {
     193            formatName = (psString)fpa->formatName; // Casting away "const" --- it will be copied, so no prob.
     194        } else {
     195            // select the format list from the selected camera
     196            formatName = psMetadataLookupStr(&status, data, "FILE.FORMAT");
     197            if (!formatName || strcmp(formatName, "NONE") == 0) {
     198                // Try to get by with the default
     199                formatName = config->formatName;
     200            }
    194201        }
    195202    }
     
    263270
    264271    return pmFPAfileDefineOutputForFormat(config, fpa, name, NULL, NULL);
     272}
     273
     274// define a pmFPAfile, bind to the optional file if supplied
     275pmFPAfile *pmFPAfileDefineOutputFromFile(const pmConfig *config, pmFPAfile *file, const char *name)
     276{
     277    PS_ASSERT_PTR_NON_NULL(config, NULL);
     278    PS_ASSERT_PTR_NON_NULL(config->files, NULL);
     279    PS_ASSERT_PTR_NON_NULL(config->camera, NULL);
     280    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
     281
     282    char *cameraName = NULL, *formatName = NULL; // Name of camera and format
     283    pmFPA *fpa = NULL;                  // FPA for file
     284    if (file) {
     285        cameraName = file->cameraName;
     286        formatName = file->formatName;
     287        fpa = file->fpa;
     288    }
     289
     290    return pmFPAfileDefineOutputForFormat(config, fpa, name, cameraName, formatName);
    265291}
    266292
     
    911937    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
    912938
    913     // Need to look up the format
    914     bool mdok;                          // Status of MD lookup
    915     psMetadata *formats = psMetadataLookupMetadata(&mdok, src->camera, "FORMATS"); // The FORMATS
    916     if (!mdok || !formats) {
    917         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find FORMATS in camera configuration %s.\n",
    918                 config->cameraName);
    919         return NULL;
    920     }
    921     psMetadata *format = psMetadataLookupMetadata(&mdok, formats, config->formatName); // The format
    922     if (!mdok || !format) {
    923         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find camera format %s within camera %s.\n",
    924                 config->formatName, config->cameraName);
    925         return NULL;
    926     }
    927 
    928939    pmFPA *fpa = pmFPAConstruct(src->camera);
    929940    pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename);
     
    932943        return NULL;
    933944    }
    934     file->src = src; // inherit output elements from this source pmFPA
     945    file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA
    935946    file->xBin = xBin;
    936947    file->yBin = yBin;
    937948    psFree (fpa);
     949    return file;
     950}
     951
     952pmFPAfile *pmFPAfileDefineFromFile(const pmConfig *config, pmFPAfile *src, int xBin, int yBin,
     953                                   const char *filename)
     954{
     955    PS_ASSERT_PTR_NON_NULL(config, false);
     956    PS_ASSERT_PTR_NON_NULL(src, false);
     957    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
     958
     959    pmFPAfile *file = pmFPAfileDefineOutputForFormat(config, NULL, filename, src->cameraName,
     960                                                     src->formatName);
     961    file->src = psMemIncrRefCounter(src->fpa); // inherit output elements from this source pmFPA
     962    file->xBin = xBin;
     963    file->yBin = yBin;
    938964    return file;
    939965}
     
    10381064    }
    10391065
    1040     file->src = src; // inherit output elements from this source pmFPA
     1066    file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA
    10411067
    10421068    file->mosaicLevel = PM_FPA_LEVEL_CHIP; // don't do any I/O on this at a lower level
     
    10831109    }
    10841110
    1085     file->src = src; // inherit output elements from this source pmFPA
     1111    file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA
    10861112
    10871113    file->mosaicLevel = PM_FPA_LEVEL_FPA; // don't do any I/O on this at a lower level
  • trunk/psModules/src/camera/pmFPAfileDefine.h

    r14647 r14889  
    44 * @author EAM, IfA
    55 *
    6  * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-08-23 23:42:41 $
     6 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-09-19 21:37:58 $
    88 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
    99 */
     
    2828// Define an output pmFPAfile
    2929pmFPAfile *pmFPAfileDefineOutput(const pmConfig *config, // Configuration
    30                                 pmFPA *fpa, // Optional FPA to bind
    31                                  const char *name // Name of camera format to use
     30                                pmFPA *fpa, // Optional FPA to bind
     31                                 const char *name // Name of file rule
    3232    );
    3333
     34/// Same as pmFPAfileDefineOutput, but binds to the fpa in the provided file
     35pmFPAfile *pmFPAfileDefineOutputFromFile(const pmConfig *config, // Configuration
     36                                         pmFPAfile *file, // File to bind FPAs, or NULL
     37                                         const char *name // Name of file rule
     38    );
     39
     40/// Define the FPA file using the provided camera and format names.
    3441pmFPAfile *pmFPAfileDefineOutputForFormat(const pmConfig *config, // Configuration
    35                                           pmFPA *fpa, // Optional FPA to bind
    36                                           const char *name, // Name of file rule
    37                                           const char *cameraName, // Name of camera configuration to use
    38                                           const char *formatName // Name of camera format to use
     42                                          pmFPA *fpa, // Optional FPA to bind
     43                                          const char *name, // Name of file rule
     44                                          psString cameraName, // Name of camera configuration to use
     45                                          psString formatName // Name of camera format to use
    3946    );
    4047
     
    6976// reference count is held by the config->files metadata.
    7077pmFPAfile *pmFPAfileDefineFromFPA (const pmConfig *config, pmFPA *src, int xBin, int yBin, const char *filename);
     78
     79/// Same as pmFPAfileDefineFromFPA, except it uses an FPA file instead of an FPA
     80pmFPAfile *pmFPAfileDefineFromFile(const pmConfig *config, // Configuration
     81                                   pmFPAfile *src, // Source file for this file
     82                                   int xBin, int yBin, // Binning for this file
     83                                   const char *filename // Name of file rule
     84    );
     85
    7186
    7287// create a new output pmFPAfile based on an existing FPA
Note: See TracChangeset for help on using the changeset viewer.