IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6726


Ignore:
Timestamp:
Mar 29, 2006, 10:55:42 AM (20 years ago)
Author:
magnier
Message:

fixed up output logic for files and views

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

Legend:

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

    r6713 r6726  
    11#include <stdio.h>
    22#include "pslib.h"
     3#include "psAdditionals.h"
    34#include "pmHDU.h"
    45#include "pmFPA.h"
     
    1920    psFree (file->names);
    2021
    21     psFitsClose (file->fits);
     22    if (file->fits != NULL) {
     23        psFitsClose (file->fits);
     24    }
    2225
    2326    psFree (file->filerule);
     
    2629    psFree (file->extxtra);
    2730
    28     // these are just views:
    29     // psFree (file->filename);
    30     // psFree (file->extname);
     31    psFree (file->filename);
     32    psFree (file->extname);
     33
     34    // these are just views ??
    3135    // psFree (file->phu);
    3236    // psFree (file->header);
     
    6367}
    6468
    65 // XXX is a file allowed to be both READ and WRITE?
    6669pmFPAfile *pmFPAfileDefine (psMetadata *files, psMetadata *format, pmFPA *fpa, char *name)
    6770{
     
    195198}
    196199
    197 // open file (if not already opened XXX : better tracking of open state?
    198 bool pmFPAfileOpen (pmFPAfile *file, pmFPAview *view)
     200// open file (if not already opened)
     201bool pmFPAfileOpen (pmFPAfile *file, const pmFPAview *view)
    199202{
    200203
     
    220223
    221224    // determine the file name
    222     // XXX file->filename needs to be a copy, and freed in places like this...
    223225    file->filename = pmFPAfileNameFromRule (file->filerule, file, view);
    224226    if (file->filename == NULL)
     
    227229    // indirect filenames
    228230    if (!strcasecmp (file->filename, "@FPAIO")) {
     231        psFree (file->filename);
    229232        extra = pmFPAfileNameFromRule (file->filextra, file, view);
    230233        file->filename = psMetadataLookupStr (&status, file->names, extra);
     234        psFree (extra);
    231235        if (file->filename == NULL)
    232236            return false;
     237        // psMetadataLookupStr just returns a view, file->filename must be protected
     238        psMemIncrRefCounter (file->filename);
    233239    }
    234240    if (!strcasecmp (file->filename, "@DETDB")) {
     241        psFree (file->filename);
    235242        extra = pmFPAfileNameFromRule (file->filextra, file, view);
    236243        // file->filename = pmDetrendSelect (extra);
     244        psFree (extra);
    237245        if (file->filename == NULL)
    238246            return false;
     247        psMemIncrRefCounter (file->filename);
    239248    }
    240249
     
    263272}
    264273
    265 bool pmFPAfileRead (pmFPAfile *file, pmFPAview *view)
     274bool pmFPAfileRead (pmFPAfile *file, const pmFPAview *view)
    266275{
    267276    if (file->mode != PM_FPA_MODE_READ)
     
    305314}
    306315
    307 bool pmFPAfileWrite (pmFPAfile *file, pmFPAview *view)
     316bool pmFPAfileWrite (pmFPAfile *file, const pmFPAview *view)
    308317{
    309318    if (file->mode != PM_FPA_MODE_WRITE)
     
    324333    switch (file->type) {
    325334    case PM_FPA_FILE_IMAGE:
    326         psLogMsg (__func__, 3, "write image disabled\n");
    327         // XXX disabled for now
    328         // XXX pmFPAviewWriteFitsImage (view, file->fits);
     335        pmFPAviewWriteFitsImage (view, file);
     336        psTrace ("pmFPAfile", 5, "wrote image %s (fpa: %p)\n", file->filename, file->fpa);
    329337        break;
    330338
     
    335343    case PM_FPA_FILE_CMF:
    336344        pmFPAviewWriteObjects (view, file);
    337         psTrace ("pmFPAfile", 5, "wrote %s (type: %d)\n", file->filename, file->type);
     345        psTrace ("pmFPAfile", 5, "wrote object %s (fpa: %p)\n", file->filename, file->fpa);
    338346        break;
    339347
     
    345353}
    346354
    347 bool pmFPAfileClose (pmFPAfile *file, pmFPAview *view)
     355bool pmFPAfileClose (pmFPAfile *file, const pmFPAview *view)
    348356{
    349357    if (file->state == PM_FPA_STATE_CLOSED) {
     
    385393
    386394// attempt open, read, write, or close pmFPAfiles in files
    387 bool pmFPAfileIOChecks (psMetadata *files, pmFPAview *view, pmFPAfilePlace place)
     395bool pmFPAfileIOChecks (psMetadata *files, const pmFPAview *view, pmFPAfilePlace place)
    388396{
    389397    // recipe override values (command-line options):
     
    405413
    406414// select the rule from the camera configuration, perform substitutions as needed
    407 char *pmFPAfileNameFromRule (char *rule, pmFPAfile *file, pmFPAview *view)
     415char *pmFPAfileNameFromRule (char *rule, pmFPAfile *file, const pmFPAview *view)
    408416{
    409417
     
    445453}
    446454
    447 psImage *pmFPAfileReadoutImage (psMetadata *files, pmFPAview *view, char *name, int Nx, int Ny, int type)
     455psImage *pmFPAfileReadoutImage (psMetadata *files, const pmFPAview *view, char *name, int Nx, int Ny, int type)
    448456{
    449457    bool status;
     
    476484// given an already-opened fits file, read the components corresponding
    477485// to the specified view
    478 bool pmFPAviewReadFitsImage (pmFPAview *view, pmFPAfile *file)
     486bool pmFPAviewReadFitsImage (const pmFPAview *view, pmFPAfile *file)
    479487{
    480488    bool status;
     
    506514        return status;
    507515    }
     516    return false;
    508517
    509518    // XXX pmReadoutRead, pmReadoutReadSegement disabled for now
    510     return false;
    511 
    512519    # if (0)
    513520
     
    526533}
    527534
    528 // XXX image writes disabled for now
    529 # if (0)
    530     // given an already-opened fits file, write the components corresponding
    531     // to the specified view
    532     bool pmFPAviewWriteFitsImage (pmFPAview *view, pmFPAfile *file)
     535// given an already-opened fits file, write the components corresponding
     536// to the specified view
     537bool pmFPAviewWriteFitsImage (const pmFPAview *view, pmFPAfile *file)
    533538{
    534539
     
    536541    psFits *fits = file->fits;
    537542
     543    // pmFPAWrite takes care of all PHUs as needed
    538544    if (view->chip == -1) {
    539         pmFPAWrite (fpa, fits, NULL, NULL);
     545        pmFPAWrite (fpa, fits, NULL);
    540546        return true;
    541547    }
     
    546552    pmChip *chip = fpa->chips->data[view->chip];
    547553
     554    // do we need to write out a PHU for this entry?
     555    if (file->phu == NULL) {
     556        pmHDU *hdu = pmFPAviewThisHDU (view, file->fpa);
     557        pmHDU *phu = pmFPAviewThisPHU (view, file->fpa);
     558        // if this hdu is the phu, the write function below will create the phu
     559        if (hdu != phu) {
     560            // we assume that the PHU is just a header
     561            psMetadata *outhead = psMetadataCopy (NULL, phu->header);
     562            psMetadataAdd (outhead, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true);
     563            psFitsWriteHeaderNotImage (file->fits, outhead);
     564            file->phu = phu->header;
     565            psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type);
     566            psFree (outhead);
     567        }
     568    }
     569
    548570    if (view->cell == -1) {
    549         pmChipWrite (chip, fits, NULL, NULL);
     571        pmChipWrite (chip, fits, NULL);
    550572        return true;
    551573    }
     
    557579
    558580    if (view->readout == -1) {
    559         pmCellWrite (cell, fits, NULL, NULL);
     581        pmCellWrite (cell, fits, NULL);
    560582        return true;
    561583    }
    562 
    563     if (view->readout >= cell->readouts->n) {
    564         return false;
    565     }
     584    return false;
     585
     586    // XXX disable readout write for now
     587    # if (0)
     588
     589        if (view->readout >= cell->readouts->n) {
     590            return false;
     591        }
    566592    pmReadout *readout = cell->readouts->data[view->readout];
    567593
     
    572598    }
    573599    return true;
    574 }
    575 # endif
     600    # endif
     601}
  • branches/rel10_ifa/psModules/src/astrom/pmFPAfile.h

    r6713 r6726  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.1.2.7 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-03-28 02:16:26 $
     9*  @version $Revision: 1.1.2.8 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-03-29 20:55:42 $
    1111*
    1212*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
     
    7474pmFPAfile *pmFPAfileAlloc ();
    7575pmFPAfile *pmFPAfileDefine (psMetadata *files, psMetadata *camera, pmFPA *fpa, char *name);
    76 bool pmFPAfileOpen (pmFPAfile *file, pmFPAview *view);
    77 bool pmFPAfileRead (pmFPAfile *file, pmFPAview *view);
    78 bool pmFPAfileWrite (pmFPAfile *file, pmFPAview *view);
    79 bool pmFPAfileClose (pmFPAfile *file, pmFPAview *view);
     76bool pmFPAfileOpen (pmFPAfile *file, const pmFPAview *view);
     77bool pmFPAfileRead (pmFPAfile *file, const pmFPAview *view);
     78bool pmFPAfileWrite (pmFPAfile *file, const pmFPAview *view);
     79bool pmFPAfileClose (pmFPAfile *file, const pmFPAview *view);
    8080
    81 bool pmFPAfileReadChecks (psMetadata *files, pmFPAview *view);
    82 bool pmFPAfileIOChecks (psMetadata *files, pmFPAview *view, pmFPAfilePlace place);
     81bool pmFPAfileReadChecks (psMetadata *files, const pmFPAview *view);
     82bool pmFPAfileIOChecks (psMetadata *files, const pmFPAview *view, pmFPAfilePlace place);
    8383
    84 psImage *pmFPAfileReadoutImage (psMetadata *files, pmFPAview *view, char *name, int Nx, int Ny, int type);
     84psImage *pmFPAfileReadoutImage (psMetadata *files, const pmFPAview *view, char *name, int Nx, int Ny, int type);
    8585
    8686// read an image into the current view
    87 bool pmFPAviewReadFitsImage (pmFPAview *view, pmFPAfile *file);
     87bool pmFPAviewReadFitsImage (const pmFPAview *view, pmFPAfile *file);
    8888
    8989// write the components for the specified view
    90 bool pmFPAviewWriteFitsImage (pmFPAview *view, pmFPAfile *file);
     90bool pmFPAviewWriteFitsImage (const pmFPAview *view, pmFPAfile *file);
    9191
    9292// convert the rule to a name based on the current view
    93 char *pmFPAfileNameFromRule (char *rule, pmFPAfile *file, pmFPAview *view);
     93char *pmFPAfileNameFromRule (char *rule, pmFPAfile *file, const pmFPAview *view);
    9494
    9595pmFPAfile *pmFPAfileConstruct (psMetadata *files, psMetadata *format, psMetadata *camera, char *name);
  • branches/rel10_ifa/psModules/src/astrom/pmFPAview.c

    r6713 r6726  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-03-28 02:16:26 $
     5 *  @version $Revision: 1.1.2.6 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-03-29 20:55:42 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3939}
    4040
    41 pmFPAdepth pmFPAviewDepth (pmFPAview *view)
     41pmFPAdepth pmFPAviewDepth (const pmFPAview *view)
    4242{
    4343
     
    5454}
    5555
    56 pmChip *pmFPAviewThisChip (pmFPAview *view, pmFPA *fpa)
     56pmChip *pmFPAviewThisChip (const pmFPAview *view, pmFPA *fpa)
    5757{
    5858
     
    100100}
    101101
    102 pmCell *pmFPAviewThisCell (pmFPAview *view, pmFPA *fpa)
     102pmCell *pmFPAviewThisCell (const pmFPAview *view, pmFPA *fpa)
    103103{
    104104
     
    156156}
    157157
    158 pmReadout *pmFPAviewThisReadout (pmFPAview *view, pmFPA *fpa)
     158pmReadout *pmFPAviewThisReadout (const pmFPAview *view, pmFPA *fpa)
    159159{
    160160
     
    211211}
    212212
    213 pmHDU *pmFPAviewThisHDU (pmFPAview *view, pmFPA *fpa)
     213pmHDU *pmFPAviewThisHDU (const pmFPAview *view, pmFPA *fpa)
    214214{
    215215    // the HDU is attached to a cell, chip or fpa
     
    229229}
    230230
    231 pmHDU *pmFPAviewThisPHU (pmFPAview *view, pmFPA *fpa)
     231pmHDU *pmFPAviewThisPHU (const pmFPAview *view, pmFPA *fpa)
    232232{
    233233    // select the HDU which corresponds to the PHU containing this view
    234234
    235235    pmHDU *hdu;
    236     pmFPAview *new;
     236    pmFPAview new;
    237237    pmChip *chip;
    238238    pmCell *cell;
    239239
    240     *new = *view;
     240    new = *view;
    241241
    242242    if (view->chip < 0) {
     
    251251        if (hdu->phu)
    252252            return hdu;
    253         new->chip = -1;
    254         hdu = pmFPAviewThisPHU (new, fpa);
     253        new.chip = -1;
     254        hdu = pmFPAviewThisPHU (&new, fpa);
    255255        return hdu;
    256256    }
     
    260260        if (hdu->phu)
    261261            return hdu;
    262         new->cell = -1;
    263         hdu = pmFPAviewThisPHU (new, fpa);
     262        new.cell = -1;
     263        hdu = pmFPAviewThisPHU (&new, fpa);
    264264        return hdu;
    265265    }
  • branches/rel10_ifa/psModules/src/astrom/pmFPAview.h

    r6713 r6726  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.1.2.7 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-03-28 02:16:26 $
     9*  @version $Revision: 1.1.2.8 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-03-29 20:55:42 $
    1111*
    1212*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
     
    4444
    4545// determine the current view depth
    46 pmFPAdepth pmFPAviewDepth (pmFPAview *view);
     46pmFPAdepth pmFPAviewDepth (const pmFPAview *view);
    4747
    4848// return the currently selected chip for this view
    49 pmChip *pmFPAviewThisChip (pmFPAview *view, pmFPA *fpa);
     49pmChip *pmFPAviewThisChip (const pmFPAview *view, pmFPA *fpa);
    5050
    5151// advance view to the next chip
     
    5353
    5454// return the currently selected cell for this view
    55 pmCell *pmFPAviewThisCell (pmFPAview *view, pmFPA *fpa);
     55pmCell *pmFPAviewThisCell (const pmFPAview *view, pmFPA *fpa);
    5656
    5757// advance view to the next cell
     
    5959
    6060// return the currently selected readout for this view
    61 pmReadout *pmFPAviewThisReadout (pmFPAview *view, pmFPA *fpa);
     61pmReadout *pmFPAviewThisReadout (const pmFPAview *view, pmFPA *fpa);
    6262
    6363// advance view to the next readout
     
    6565
    6666// return the HDU corresponding to the current view
    67 pmHDU *pmFPAviewThisHDU (pmFPAview *view, pmFPA *fpa);
    68 pmHDU *pmFPAviewThisPHU (pmFPAview *view, pmFPA *fpa);
     67pmHDU *pmFPAviewThisHDU (const pmFPAview *view, pmFPA *fpa);
     68pmHDU *pmFPAviewThisPHU (const pmFPAview *view, pmFPA *fpa);
    6969
    7070# endif
  • branches/rel10_ifa/psModules/src/astrom/pmHDU.c

    r6722 r6726  
    1313    psFree(hdu->images);
    1414    psFree(hdu->table);
     15    psFree(hdu->weights);
     16    psFree(hdu->masks);
    1517}
    1618
  • branches/rel10_ifa/psModules/src/objects/pmFPAviewObjectsIO.h

    r6556 r6726  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-03-09 03:14:23 $
     5 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-03-29 20:55:42 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1313# define PM_FPA_OBJECTS_IO_H
    1414
    15 bool pmFPAviewReadObjects (pmFPAview *view, pmFPAfile *file);
    16 bool pmFPAReadObjects (pmFPA *fpa, pmFPAview *view, pmFPAfile *file);
    17 bool pmChipReadObjects (pmChip *chip, pmFPAview *view, pmFPAfile *file);
    18 bool pmCellReadObjects (pmCell *cell, pmFPAview *view, pmFPAfile *file);
    19 bool pmReadoutReadObjects (pmReadout *readout, pmFPAview *view, pmFPAfile *file);
     15bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file);
     16bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file);
     17bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file);
     18bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file);
     19bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file);
    2020
    21 bool pmFPAviewWriteObjects (pmFPAview *view, pmFPAfile *file);
    22 bool pmFPAWriteObjects (pmFPA *fpa, pmFPAview *view, pmFPAfile *file);
    23 bool pmChipWriteObjects (pmChip *chip, pmFPAview *view, pmFPAfile *file);
    24 bool pmCellWriteObjects (pmCell *cell, pmFPAview *view, pmFPAfile *file);
    25 bool pmReadoutWriteObjects (pmReadout *readout, pmFPAview *view, pmFPAfile *file);
     21bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file);
     22bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file);
     23bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file);
     24bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file);
     25bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file);
    2626
    2727# endif /* PM_FPA_OBJECTS_IO_H */
  • branches/rel10_ifa/psModules/src/objects/pmFPAviewReadObjects.c

    r6712 r6726  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-03-28 02:14:56 $
     5 *  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-03-29 20:55:42 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828
    2929// Given a FITS file pointer, read the table of object data
    30 bool pmFPAviewReadObjects (pmFPAview *view, pmFPAfile *file)
     30bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file)
    3131{
    3232    pmFPA *fpa = file->fpa;
     
    6767
    6868// read in all chip-level Objects files for this FPA
    69 bool pmFPAReadObjects (pmFPA *fpa, pmFPAview *view, pmFPAfile *file)
     69bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file)
    7070{
    7171
     
    7979
    8080// read in all cell-level Objects files for this chip
    81 bool pmChipReadObjects (pmChip *chip, pmFPAview *view, pmFPAfile *file)
     81bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file)
    8282{
    8383
     
    9191
    9292// read in all readout-level Objects files for this cell
    93 bool pmCellReadObjects (pmCell *cell, pmFPAview *view, pmFPAfile *file)
     93bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file)
    9494{
    9595
     
    103103
    104104// read in all readout-level Objects files for this cell
    105 bool pmReadoutReadObjects (pmReadout *readout, pmFPAview *view, pmFPAfile *file)
     105bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file)
    106106{
    107107
  • branches/rel10_ifa/psModules/src/objects/pmFPAviewWriteObjects.c

    r6712 r6726  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-03-28 02:14:56 $
     5 *  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-03-29 20:55:42 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1414#include <string.h>
    1515#include "pslib.h"
     16#include "psAdditionals.h"
    1617#include "pmHDU.h"
    1718#include "pmFPA.h"
     
    2728#include "pmFPAviewObjectsIO.h"
    2829
    29 bool psFitsWriteHeaderNotImage (psFits *fits, psMetadata *header)
    30 {
    31 
    32     int status = 0;
    33     char fitsErr[1024];
    34 
    35     psMetadataItem *mdi = NULL;
    36     mdi = psMetadataLookup (header, "NAXIS");
    37     if (mdi != NULL) {
    38         mdi->data.S32 = 0;
    39         mdi->type = PS_DATA_S32;
    40     }
    41 
    42     fits_create_img (fits->fd, SHORT_IMG, 0, NULL, &status);
    43 
    44     if (status != 0) {
    45         fits_get_errstatus (status, fitsErr);
    46         psError (PS_ERR_IO, true, PS_ERRORTEXT_psFits_WRITE_FAILED, fitsErr);
    47         exit (2);
    48     }
    49 
    50     psFitsWriteHeader (header, fits);
    51 
    52     return true;
    53 }
    54 
    5530// Given a FITS file pointer, read the table of object data
    56 bool pmFPAviewWriteObjects (pmFPAview *view, pmFPAfile *file)
     31bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file)
    5732{
    5833
     
    9469
    9570// read in all chip-level Objects files for this FPA
    96 bool pmFPAWriteObjects (pmFPA *fpa, pmFPAview *view, pmFPAfile *file)
     71bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file)
    9772{
    9873
     
    10681
    10782// read in all cell-level Objects files for this chip
    108 bool pmChipWriteObjects (pmChip *chip, pmFPAview *view, pmFPAfile *file)
     83bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file)
    10984{
    11085
     
    11893
    11994// read in all readout-level Objects files for this cell
    120 bool pmCellWriteObjects (pmCell *cell, pmFPAview *view, pmFPAfile *file)
     95bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file)
    12196{
    12297
     
    130105
    131106// read in all readout-level Objects files for this cell
    132 bool pmReadoutWriteObjects (pmReadout *readout, pmFPAview *view, pmFPAfile *file)
     107bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file)
    133108{
    134109
     
    139114    pmHDU *hdu;
    140115    pmHDU *phu;
     116    psMetadata *updates;
     117    psMetadata *outhead;
    141118
    142119    psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
    143     return true;
    144120
    145121    switch (file->type) {
     
    166142        hdu = pmFPAviewThisHDU (view, file->fpa);
    167143        filename = pmFPAfileNameFromRule (file->filerule, file, view);
    168         pmSourcesWriteCMP (sources, filename, hdu->header);
     144
     145        // copy the header to an output header, add the output header data
     146        outhead = psMetadataCopy (NULL, hdu->header);
     147
     148        // check/fix first line (must be SIMPLE = F)
     149        psMetadataItem *item = psMetadataGet (outhead, PS_LIST_HEAD);
     150        if (strcmp (item->name, "SIMPLE") && strcmp (item->name, "XTENSION")) {
     151            psErrorStackPrint(stderr, "invalid header: first line is neither SIMPLE nor XTENSION\n");
     152            exit(EXIT_FAILURE);
     153        }
     154        if (!strcmp (item->name, "XTENSION")) {
     155            psMetadataRemoveIndex (outhead, PS_LIST_HEAD);
     156        }
     157        psMetadataAddBool (outhead, PS_LIST_HEAD, "SIMPLE", PS_META_REPLACE, "CMP file, not simple", false);
     158
     159        // copy over the entries saved in the
     160        updates = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER");
     161        psMetadataCopy (outhead, updates);
     162
     163        pmSourcesWriteCMP (sources, filename, outhead);
     164        psFree (outhead);
    169165        psFree (filename);
    170166        break;
     
    184180
    185181            // CMF always has extensions
    186             psMetadataAdd (phu->header, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true);
    187             psFitsWriteHeaderNotImage (file->fits, phu->header);
     182            outhead = psMetadataCopy (NULL, phu->header);
     183            psMetadataAdd (outhead, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true);
     184            psFitsWriteHeaderNotImage (file->fits, outhead);
    188185            file->phu = phu->header;
    189186            psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type);
    190 
    191             file->phu = phu->header;
     187            psFree (outhead);
    192188        }
    193189
     
    196192            // determine name for header extension
    197193            headname = pmFPAfileNameFromRule (file->extxtra, file, view);
    198             psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "extension name", headname);
    199             psFitsWriteHeaderNotImage (file->fits, hdu->header);
     194            outhead = psMetadataCopy (NULL, hdu->header);
     195            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "extension name", headname);
     196            psFitsWriteHeaderNotImage (file->fits, outhead);
    200197            psTrace ("pmFPAfile", 5, "wrote ext head %s (type: %d)\n", file->filename, file->type);
    201198            file->header = hdu->header;
     199            psFree (outhead);
    202200            psFree (headname);
    203201        }
     
    205203        // write this table to disk
    206204        dataname = pmFPAfileNameFromRule (file->extrule, file, view);
    207         pmSourcesWriteCMF (file->fits, sources, hdu->header, dataname);
     205        updates = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER");
     206        pmSourcesWriteCMF (file->fits, sources, updates, dataname);
     207        psTrace ("pmFPAfile", 5, "wrote ext data %s (type: %d)\n", file->filename, file->type);
    208208        psFree (dataname);
    209209        break;
  • branches/rel10_ifa/psModules/src/objects/pmSourceIO_CMF.c

    r6712 r6726  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-03-28 02:14:56 $
     5 *  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-03-29 20:55:42 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3434    psArray *table;
    3535    psMetadata *row;
    36     psMetadata *theader;
    3736    int i, type;
    3837    psF32 *PAR, *dPAR;
     
    8483
    8584    // create the basic table header
    86     theader = psMetadataAlloc ();
    87     psMetadataAdd (theader, PS_LIST_HEAD, "EXTNAME", PS_DATA_STRING, "extension name", extname);
     85    psMetadataAdd (header, PS_LIST_HEAD, "EXTNAME", PS_DATA_STRING | PS_META_REPLACE, "extension name", extname);
    8886
    89     psFitsWriteTable (fits, theader, table);
     87    psFitsWriteTable (fits, header, table);
    9088    psTrace ("pmFPAfile", 5, "wrote ext data %s\n", extname);
    9189
     90    psFree (table);
    9291    return true;
    9392}
  • branches/rel10_ifa/psModules/src/objects/pmSourceIO_CMP.c

    r6565 r6726  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-03-09 04:25:03 $
     5 *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-03-29 20:55:42 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    107107    }
    108108    fclose (f);
     109    psFree (line);
    109110    return true;
    110111}
  • branches/rel10_ifa/psModules/src/objects/pmSourceIO_SX.c

    r6565 r6726  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-03-09 04:25:03 $
     5 *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-03-29 20:55:42 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7676    }
    7777    fclose (f);
     78    psFree (line);
    7879    return true;
    7980}
Note: See TracChangeset for help on using the changeset viewer.