IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6847


Ignore:
Timestamp:
Apr 12, 2006, 8:18:22 PM (20 years ago)
Author:
magnier
Message:

finishing up conversion to pmFPAfile paradigm

Location:
branches/rel10_ifa/psModules/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.c

    r6841 r6847  
    392392
    393393bool pmFPAAddSourceFromView(pmFPA *fpa,   // The FPA
    394                             pmFPAview *phuView, // The view, corresponding to the PHU
     394                            const pmFPAview *phuView, // The view, corresponding to the PHU
    395395                            psMetadata *format // Format of file
    396396                           )
  • branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.h

    r6834 r6847  
    1111
    1212bool pmFPAAddSourceFromView(pmFPA *fpa,   // The FPA
    13                             pmFPAview *phuView, // The view, corresponding to the PHU
     13                            const pmFPAview *phuView, // The view, corresponding to the PHU
    1414                            psMetadata *format // Format of file
    1515                           );
  • branches/rel10_ifa/psModules/src/astrom/pmFPAfile.c

    r6834 r6847  
    22#include "pslib.h"
    33#include "psAdditionals.h"
     4#include "pmConfig.h"
    45#include "pmHDU.h"
    56#include "pmFPA.h"
     
    2223    psFree (file->names);
    2324
     25    psFree (file->format);
     26    psFree (file->name);
     27
    2428    if (file->fits != NULL) {
    2529        psFitsClose (file->fits);
     
    5458    file->fits = NULL;
    5559    file->names = psMetadataAlloc();
     60
     61    file->format = NULL;
     62    file->name = NULL;
    5663
    5764    file->filerule = NULL;
     
    188195    if (fpa != NULL) {
    189196        file->fpa = psMemIncrRefCounter(fpa);
     197    }
     198
     199    // for WRITE type of data, the output format needs to be determined
     200    // this is only needed if the output file is not identical in structure to the input
     201    char *formatName = psMetadataLookupStr (&status, data, "FILE.FORMAT");
     202    if (formatName && strcasecmp (formatName, "NONE")) {
     203        psMetadata *formats = psMetadataLookupMD(&status, camera, "FORMATS"); // List of formats
     204        char *formatFile = psMetadataLookupStr (&status, formats, formatName);
     205        readConfig (&file->format, formatFile, formatName);
    190206    }
    191207
     
    332348bool pmFPAfileWrite (pmFPAfile *file, const pmFPAview *view)
    333349{
     350    // XXX test return false;
     351
    334352    if (file->mode != PM_FPA_MODE_WRITE)
    335353        return false;
     
    372390bool pmFPAfileCreate (pmFPAfile *file, const pmFPAview *view)
    373391{
     392    // XXX test return false;
    374393    if (file->mode != PM_FPA_MODE_WRITE)
    375394        return false;
     
    389408    case PM_FPA_FILE_IMAGE:
    390409        /* create a PHU for thie file, if it does not exist */
    391         pmFPAfileCopyView (file->src, file->fpa, view);
     410        pmFPAfileCopyStructureView (file->fpa, file->src, file->format, file->xBin, file->yBin, view);
    392411        psTrace ("pmFPAfile", 5, "created fpa data elements for %s (fpa: %p)\n", file->filename, file->fpa);
    393412        break;
     
    698717
    699718        // set the view to the corresponding entry for this phu
    700         pmFPAview *view = pmFPAAddSourceFromHeader(fpa, phu, format);
     719        pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format);
    701720
    702721        // XXX is this the correct psMD to save the filename?
     
    786805
    787806        // set the view to the corresponding entry for this phu
    788         pmFPAview *view = pmFPAAddSourceFromHeader(fpa, phu, format);
     807        pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format);
    789808
    790809        // XXX is this the correct psMD to save the filename?
     
    803822}
    804823# endif
     824
     825// create a new output pmFPAfile based on an existing FPA
     826pmFPAfile *pmFPAfileFromFPA (pmConfig *config, pmFPA *src, int xBin, int yBin, char *filename)
     827{
     828    // XXX pmFPAConstruct has many leaks (6919)
     829    pmFPA *fpa = pmFPAConstruct (config->camera);
     830    pmFPAfile *file = pmFPAfileDefine (config->files, config->camera, fpa, filename);
     831    file->src = src; // inherit output elements from this source pmFPA
     832    file->xBin = xBin;
     833    file->yBin = yBin;
     834
     835    return file;
     836}
    805837
    806838// look for the given name on the argument list.
     
    879911
    880912        // set the view to the corresponding entry for this phu
    881         pmFPAview *view = pmFPAAddSourceFromHeader(file->fpa, phu, format);
     913        pmFPAview *view = pmFPAAddSourceFromHeader (file->fpa, phu, format);
    882914
    883915        // XXX is this the correct psMD to save the filename?
     
    957989bool pmFPAfileCopyView (pmFPA *out, pmFPA *in, const pmFPAview *view)
    958990{
    959     // XXX how to we transmit the required binning factor?
    960991    // pmFPAWrite takes care of all PHUs as needed
    961992    if (view->chip == -1) {
     
    9851016    return false;
    9861017
    987     // XXX disable readout write for now
    988     # if (0)
    989 
    990         if (view->readout >= cell->readouts->n) {
    991             return false;
    992         }
    993     pmReadout *readout = cell->readouts->data[view->readout];
    994 
    995     if (view->nRows == 0) {
    996         pmReadoutWrite (readout, fits, NULL, NULL);
    997     } else {
    998         pmReadoutWriteSegment (readout, fits, view->nRows, view->iRows, NULL, NULL);
    999     }
    1000     return true;
    1001     # endif
    1002 }
    1003 
    1004 // need to distinguish between a "copy structure" and a "copy data"
    1005 // need to allow for binning when performing the "copy structure"
     1018    // XXX add readout / segment equivalents
     1019}
     1020
     1021// given an already-opened fits file, write the components corresponding
     1022// to the specified view
     1023bool pmFPAfileCopyStructureView (pmFPA *out, pmFPA *in, psMetadata *format, int xBin, int yBin, const pmFPAview *view)
     1024{
     1025    // pmFPAWrite takes care of all PHUs as needed
     1026    if (view->chip == -1) {
     1027        pmFPAAddSourceFromView (out, view, format);
     1028        pmFPACopyStructure (out, in, xBin, yBin);
     1029        return true;
     1030    }
     1031    if (view->chip >= in->chips->n) {
     1032        return false;
     1033    }
     1034    pmChip *inChip = in->chips->data[view->chip];
     1035    pmChip *outChip = out->chips->data[view->chip];
     1036
     1037    if (view->cell == -1) {
     1038        pmFPAAddSourceFromView (out, view, format);
     1039        pmChipCopyStructure (outChip, inChip, xBin, yBin);
     1040        return true;
     1041    }
     1042    if (view->cell >= inChip->cells->n) {
     1043        return false;
     1044    }
     1045    pmCell *inCell = inChip->cells->data[view->cell];
     1046    pmCell *outCell = outChip->cells->data[view->cell];
     1047
     1048    if (view->readout == -1) {
     1049        pmFPAAddSourceFromView (out, view, format);
     1050        pmCellCopyStructure (outCell, inCell, xBin, yBin);
     1051        return true;
     1052    }
     1053    return false;
     1054
     1055    // XXX add readout / segment equivalents
     1056}
  • branches/rel10_ifa/psModules/src/astrom/pmFPAfile.h

    r6827 r6847  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.1.2.10 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-04-10 20:22:42 $
     9*  @version $Revision: 1.1.2.11 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-04-13 06:17:28 $
    1111*
    1212*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
     
    8181    int xBin;    // desired binning in x direction
    8282    int yBin;    // desired binning in y direction
     83    psMetadata *format;
    8384}
    8485pmFPAfile;
     
    137138pmFPAfile *pmFPAfileFromConf (bool *found, pmConfig *config, char *filename, pmFPA *input);
    138139
     140// create a new output pmFPAfile based on an existing FPA
     141pmFPAfile *pmFPAfileFromFPA (pmConfig *config, pmFPA *src, int xBin, int yBin, char *filename);
     142
    139143// add the specified filename info (value) to the files of the given mode using the given reference name
    140144bool pmFPAfileAddFileNames (psMetadata *files, char *name, char *value, int mode);
     
    145149bool pmFPAfileCopyView (pmFPA *out, pmFPA *in, const pmFPAview *view);
    146150
     151bool pmFPAfileCopyStructureView (pmFPA *out, pmFPA *in, psMetadata *format, int xBin, int yBin, const pmFPAview *view);
     152
    147153# endif
  • branches/rel10_ifa/psModules/src/config/pmConfig.c

    r6819 r6847  
    33 *  @author PAP, IfA
    44 *
    5  *  @version $Revision: 1.7.4.10 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-04-08 20:13:03 $
     5 *  @version $Revision: 1.7.4.11 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-04-13 06:18:22 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6363 *
    6464 */
    65 static bool readConfig(
     65bool readConfig(
    6666    psMetadata **config,                // Config to output
    6767    const char *name,                   // Name of file
  • branches/rel10_ifa/psModules/src/config/pmConfig.h

    r6819 r6847  
    33 *  @author PAP, IfA
    44 *
    5  *  @version $Revision: 1.3.4.7 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-04-08 20:13:03 $
     5 *  @version $Revision: 1.3.4.8 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-04-13 06:18:22 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252    int *argc,
    5353    char **argv);
     54
     55/** we need this elsewhere; make it public **/
     56bool readConfig(
     57    psMetadata **config,                // Config to output
     58    const char *name,                   // Name of file
     59    const char *description             // Description of file
     60);
    5461
    5562/** pmConfigValidateCamera
Note: See TracChangeset for help on using the changeset viewer.