IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 3, 2006, 8:48:10 AM (19 years ago)
Author:
magnier
Message:

defined pmConfigConvertFilename, added to all I/O functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSourceIO.c

    r9560 r10421  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-10-14 00:53:56 $
     5 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-12-03 18:48:10 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6060
    6161// Given a FITS file pointer, write the table of object data
    62 bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file)
     62bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    6363{
    6464
     
    6666
    6767    if (view->chip == -1) {
    68         if (!pmFPAWriteObjects (fpa, view, file)) {
     68        if (!pmFPAWriteObjects (fpa, view, file, config)) {
    6969            psError(PS_ERR_IO, false, "Failed to write objects from fpa");
    7070            return false;
     
    8080
    8181    if (view->cell == -1) {
    82         if (!pmChipWriteObjects (chip, view, file)) {
     82        if (!pmChipWriteObjects (chip, view, file, config)) {
    8383            psError(PS_ERR_IO, false, "Failed to write objects from chip");
    8484            return false;
     
    9595
    9696    if (view->readout == -1) {
    97         if (!pmCellWriteObjects (cell, view, file)) {
     97        if (!pmCellWriteObjects (cell, view, file, config)) {
    9898            psError(PS_ERR_IO, false, "Failed to write objects from cell");
    9999            return false;
     
    110110    pmReadout *readout = cell->readouts->data[view->readout];
    111111
    112     if (!pmReadoutWriteObjects (readout, view, file)) {
     112    if (!pmReadoutWriteObjects (readout, view, file, config)) {
    113113        psError(PS_ERR_IO, false, "Failed to write objects from readout %d", view->readout);
    114114        return false;
     
    119119
    120120// read in all chip-level Objects files for this FPA
    121 bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file)
     121bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    122122{
    123123
     
    125125
    126126        pmChip *chip = fpa->chips->data[i];
    127         if (!pmChipWriteObjects (chip, view, file)) {
     127        if (!pmChipWriteObjects (chip, view, file, config)) {
    128128            psError(PS_ERR_IO, false, "Failed to write %dth chip", i);
    129129            return false;
     
    134134
    135135// read in all cell-level Objects files for this chip
    136 bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file)
     136bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    137137{
    138138
     
    140140
    141141        pmCell *cell = chip->cells->data[i];
    142         if (!pmCellWriteObjects (cell, view, file)) {
     142        if (!pmCellWriteObjects (cell, view, file, config)) {
    143143            psError(PS_ERR_IO, false, "Failed to write %dth cell", i);
    144144            return false;
     
    149149
    150150// read in all readout-level Objects files for this cell
    151 bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file)
     151bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    152152{
    153153
     
    155155
    156156        pmReadout *readout = cell->readouts->data[i];
    157         if (!pmReadoutWriteObjects (readout, view, file)) {
     157        if (!pmReadoutWriteObjects (readout, view, file, config)) {
    158158            psError(PS_ERR_IO, false, "Failed to write %dth readout", i);
    159159            return false;
     
    164164
    165165// read in all readout-level Objects files for this cell
    166 bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file)
     166bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    167167{
    168168
    169169    bool status;
     170    char *realname;
    170171    char *filename;
    171172    char *dataname;
     
    183184    case PM_FPA_FILE_RAW:
    184185        filename = pmFPAfileNameFromRule (file->filerule, file, view);
    185         pmSourcesWriteRAW (sources, filename);
     186        realname = pmConfigConvertFilename (filename, config);
     187        pmSourcesWriteRAW (sources, realname);
     188        psFree (realname);
    186189        psFree (filename);
    187190        break;
     
    189192    case PM_FPA_FILE_OBJ:
    190193        filename = pmFPAfileNameFromRule (file->filerule, file, view);
    191         pmSourcesWriteOBJ (sources, filename);
     194        realname = pmConfigConvertFilename (filename, config);
     195        pmSourcesWriteOBJ (sources, realname);
     196        psFree (realname);
    192197        psFree (filename);
    193198        break;
     
    195200    case PM_FPA_FILE_SX:
    196201        filename = pmFPAfileNameFromRule (file->filerule, file, view);
    197         pmSourcesWriteSX (sources, filename);
     202        realname = pmConfigConvertFilename (filename, config);
     203        pmSourcesWriteSX (sources, realname);
     204        psFree (realname);
    198205        psFree (filename);
    199206        break;
     
    203210        hdu = pmFPAviewThisHDU (view, file->fpa);
    204211        filename = pmFPAfileNameFromRule (file->filerule, file, view);
     212        realname = pmConfigConvertFilename (filename, config);
    205213
    206214        // copy the header to an output header, add the output header data
     
    219227        }
    220228
    221         bool status = pmSourcesWriteCMP (sources, filename, outhead);
     229        bool status = pmSourcesWriteCMP (sources, realname, outhead);
    222230        psFree (outhead);
     231        psFree (realname);
    223232        psFree (filename);
    224233
     
    310319
    311320// Given a FITS file pointer, read the table of object data
    312 bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file)
     321bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    313322{
    314323    pmFPA *fpa = file->fpa;
    315324
    316325    if (view->chip == -1) {
    317         pmFPAReadObjects (fpa, view, file);
     326        pmFPAReadObjects (fpa, view, file, config);
    318327        return true;
    319328    }
     
    325334
    326335    if (view->cell == -1) {
    327         pmChipReadObjects (chip, view, file);
     336        pmChipReadObjects (chip, view, file, config);
    328337        return true;
    329338    }
     
    335344
    336345    if (view->readout == -1) {
    337         pmCellReadObjects (cell, view, file);
     346        pmCellReadObjects (cell, view, file, config);
    338347        return true;
    339348    }
     
    344353    pmReadout *readout = cell->readouts->data[view->readout];
    345354
    346     pmReadoutReadObjects (readout, view, file);
     355    pmReadoutReadObjects (readout, view, file, config);
    347356    return true;
    348357}
    349358
    350359// read in all chip-level Objects files for this FPA
    351 bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file)
     360bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    352361{
    353362    for (int i = 0; i < fpa->chips->n; i++) {
    354363        pmChip *chip = fpa->chips->data[i];
    355         pmChipReadObjects (chip, view, file);
     364        pmChipReadObjects (chip, view, file, config);
    356365    }
    357366    return true;
     
    359368
    360369// read in all cell-level Objects files for this chip
    361 bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file)
     370bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    362371{
    363372    for (int i = 0; i < chip->cells->n; i++) {
    364373        pmCell *cell = chip->cells->data[i];
    365         pmCellReadObjects (cell, view, file);
     374        pmCellReadObjects (cell, view, file, config);
    366375    }
    367376    return true;
     
    369378
    370379// read in all readout-level Objects files for this cell
    371 bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file)
     380bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    372381{
    373382    // determine the number of readouts:
     
    384393    for (int i = 0; i < cell->readouts->n; i++) {
    385394        pmReadout *readout = cell->readouts->data[i];
    386         pmReadoutReadObjects (readout, view, file);
     395        pmReadoutReadObjects (readout, view, file, config);
    387396        cell->data_exists = true;
    388397    }
     
    391400
    392401// read in all readout-level Objects files for this cell
    393 bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file)
     402bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    394403{
    395404
     
    427436            psMemIncrRefCounter (file->filename);
    428437        }
    429         file->fits = psFitsOpen (file->filename, "r");
     438
     439        psString realname = pmConfigConvertFilename (file->filename, config);
     440
     441        file->fits = psFitsOpen (realname, "r");
    430442        if (hdu->header != NULL) {
    431443            psFree (hdu->header);
     
    435447        file->fits = NULL;
    436448
    437         sources = pmSourcesReadCMP (file->filename, hdu->header);
     449        sources = pmSourcesReadCMP (realname, hdu->header);
     450        psFree (realname);
    438451        break;
    439452
Note: See TracChangeset for help on using the changeset viewer.