IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

defined pmConfigConvertFilename, added to all I/O functions

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

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPA_JPEG.c

    r10417 r10421  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-12-02 04:24:48 $
     7 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-12-03 18:48:10 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3131
    3232
    33 bool pmFPAviewWriteJPEG(const pmFPAview *view, pmFPAfile *file)
     33bool pmFPAviewWriteJPEG(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    3434{
    3535    PS_ASSERT_PTR_NON_NULL(view, false);
     
    3939
    4040    if (view->chip == -1) {
    41         pmFPAWriteJPEG (fpa, view, file);
     41        pmFPAWriteJPEG (fpa, view, file, config);
    4242        return true;
    4343    }
     
    4949
    5050    if (view->cell == -1) {
    51         pmChipWriteJPEG (chip, view, file);
     51        pmChipWriteJPEG (chip, view, file, config);
    5252        return true;
    5353    }
     
    5959
    6060    if (view->readout == -1) {
    61         pmCellWriteJPEG (cell, view, file);
     61        pmCellWriteJPEG (cell, view, file, config);
    6262        return true;
    6363    }
     
    6868    pmReadout *readout = cell->readouts->data[view->readout];
    6969
    70     pmReadoutWriteJPEG (readout, view, file);
     70    pmReadoutWriteJPEG (readout, view, file, config);
    7171    return true;
    7272}
    7373
    7474// read in all chip-level JPEG files for this FPA
    75 bool pmFPAWriteJPEG (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file)
     75bool pmFPAWriteJPEG (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    7676{
    7777    PS_ASSERT_PTR_NON_NULL(fpa, false);
     
    8282
    8383        pmChip *chip = fpa->chips->data[i];
    84         pmChipWriteJPEG (chip, view, file);
     84        pmChipWriteJPEG (chip, view, file, config);
    8585    }
    8686    return true;
     
    8888
    8989// read in all cell-level JPEG files for this chip
    90 bool pmChipWriteJPEG (pmChip *chip, const pmFPAview *view, pmFPAfile *file)
     90bool pmChipWriteJPEG (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    9191{
    9292    PS_ASSERT_PTR_NON_NULL(chip, false);
     
    9797
    9898        pmCell *cell = chip->cells->data[i];
    99         pmCellWriteJPEG (cell, view, file);
     99        pmCellWriteJPEG (cell, view, file, config);
    100100    }
    101101    return true;
     
    103103
    104104// read in all readout-level JPEG files for this cell
    105 bool pmCellWriteJPEG (pmCell *cell, const pmFPAview *view, pmFPAfile *file)
     105bool pmCellWriteJPEG (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    106106{
    107107    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    112112
    113113        pmReadout *readout = cell->readouts->data[i];
    114         pmReadoutWriteJPEG (readout, view, file);
     114        pmReadoutWriteJPEG (readout, view, file, config);
    115115    }
    116116    return true;
     
    118118
    119119// read in all readout-level Objects files for this cell
    120 bool pmReadoutWriteJPEG (pmReadout *readout, const pmFPAview *view, pmFPAfile *file)
     120bool pmReadoutWriteJPEG (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    121121{
    122122    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    178178
    179179    psString name = pmFPAfileNameFromRule (file->filerule, file, view);
     180    psString newName = pmConfigConvertFilename (name, config);
    180181    psString mapname = pmFPAfileNameFromRule (file->filextra, file, view);
    181182    psImageJpegColormap *map = psImageJpegColormapSet (NULL, mapname);
     
    185186    }
    186187
    187     psImageJpeg (map, readout->image, name, min, max);
     188    psImageJpeg (map, readout->image, newName, min, max);
     189    psFree(newName);
    188190    psFree(name);
    189191    psFree(map);
  • trunk/psModules/src/camera/pmFPA_JPEG.h

    r7017 r10421  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-05-01 01:55:43 $
     9*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-12-03 18:48:10 $
    1111*
    1212*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
     
    1919/// @{
    2020
    21 bool pmFPAviewWriteJPEG (const pmFPAview *view, pmFPAfile *file);
    22 bool pmFPAWriteJPEG (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file);
    23 bool pmChipWriteJPEG (pmChip *chip, const pmFPAview *view, pmFPAfile *file);
    24 bool pmCellWriteJPEG (pmCell *cell, const pmFPAview *view, pmFPAfile *file);
    25 bool pmReadoutWriteJPEG (pmReadout *readout, const pmFPAview *view, pmFPAfile *file);
     21bool pmFPAviewWriteJPEG (const pmFPAview *view, pmFPAfile *file, pmConfig *config);
     22bool pmFPAWriteJPEG (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config);
     23bool pmChipWriteJPEG (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config);
     24bool pmCellWriteJPEG (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config);
     25bool pmReadoutWriteJPEG (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config);
    2626
    2727# endif
  • trunk/psModules/src/camera/pmFPA_MANAPLOT.c

    r9585 r10421  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-10-17 00:41:05 $
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-12-03 18:48:10 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3131
    3232
    33 bool pmFPAviewWriteMANAPLOT(const pmFPAview *view, pmFPAfile *file)
     33bool pmFPAviewWriteMANAPLOT(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    3434{
    3535    PS_ASSERT_PTR_NON_NULL(view, false);
     
    3939
    4040    if (view->chip == -1) {
    41         pmFPAWriteMANAPLOT (fpa, view, file);
     41        pmFPAWriteMANAPLOT (fpa, view, file, config);
    4242        return true;
    4343    }
     
    4949
    5050    if (view->cell == -1) {
    51         pmChipWriteMANAPLOT (chip, view, file);
     51        pmChipWriteMANAPLOT (chip, view, file, config);
    5252        return true;
    5353    }
     
    5959
    6060    if (view->readout == -1) {
    61         pmCellWriteMANAPLOT (cell, view, file);
     61        pmCellWriteMANAPLOT (cell, view, file, config);
    6262        return true;
    6363    }
     
    6868    pmReadout *readout = cell->readouts->data[view->readout];
    6969
    70     pmReadoutWriteMANAPLOT (readout, view, file);
     70    pmReadoutWriteMANAPLOT (readout, view, file, config);
    7171    return true;
    7272}
    7373
    7474// read in all chip-level MANAPLOT files for this FPA
    75 bool pmFPAWriteMANAPLOT (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file)
     75bool pmFPAWriteMANAPLOT (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    7676{
    7777    PS_ASSERT_PTR_NON_NULL(fpa, false);
     
    8282
    8383        pmChip *chip = fpa->chips->data[i];
    84         pmChipWriteMANAPLOT (chip, view, file);
     84        pmChipWriteMANAPLOT (chip, view, file, config);
    8585    }
    8686    return true;
     
    8888
    8989// read in all cell-level MANAPLOT files for this chip
    90 bool pmChipWriteMANAPLOT (pmChip *chip, const pmFPAview *view, pmFPAfile *file)
     90bool pmChipWriteMANAPLOT (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    9191{
    9292    PS_ASSERT_PTR_NON_NULL(chip, false);
     
    9797
    9898        pmCell *cell = chip->cells->data[i];
    99         pmCellWriteMANAPLOT (cell, view, file);
     99        pmCellWriteMANAPLOT (cell, view, file, config);
    100100    }
    101101    return true;
     
    103103
    104104// read in all readout-level MANAPLOT files for this cell
    105 bool pmCellWriteMANAPLOT (pmCell *cell, const pmFPAview *view, pmFPAfile *file)
     105bool pmCellWriteMANAPLOT (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    106106{
    107107    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    112112
    113113        pmReadout *readout = cell->readouts->data[i];
    114         pmReadoutWriteMANAPLOT (readout, view, file);
     114        pmReadoutWriteMANAPLOT (readout, view, file, config);
    115115    }
    116116    return true;
     
    118118
    119119// read in all readout-level Objects files for this cell
    120 bool pmReadoutWriteMANAPLOT (pmReadout *readout, const pmFPAview *view, pmFPAfile *file)
     120bool pmReadoutWriteMANAPLOT (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    121121{
    122122    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    136136    // output : filerule
    137137
    138     psString input = pmFPAfileNameFromRule (file->filextra, file, view);
    139     psString output = pmFPAfileNameFromRule (file->filerule, file, view);
    140     psString script = pmFPAfileNameFromRule (file->extname, file, view);
     138    psString tmpName;
     139    tmpName = pmFPAfileNameFromRule (file->filextra, file, view);
     140    psString input = pmConfigConvertFilename (tmpName, config);
     141    psFree (tmpName);
     142
     143    tmpName = pmFPAfileNameFromRule (file->filerule, file, view);
     144    psString output = pmConfigConvertFilename (tmpName, config);
     145    psFree (tmpName);
     146
     147    tmpName = pmFPAfileNameFromRule (file->extname, file, view);
     148    psString script = pmConfigConvertFilename (tmpName, config);
     149    psFree (tmpName);
    141150
    142151    psString line = NULL;
  • trunk/psModules/src/camera/pmFPA_MANAPLOT.h

    r9585 r10421  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-10-17 00:41:05 $
     9*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-12-03 18:48:10 $
    1111*
    1212*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
     
    1919/// @{
    2020
    21 bool pmFPAviewWriteMANAPLOT (const pmFPAview *view, pmFPAfile *file);
    22 bool pmFPAWriteMANAPLOT (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file);
    23 bool pmChipWriteMANAPLOT (pmChip *chip, const pmFPAview *view, pmFPAfile *file);
    24 bool pmCellWriteMANAPLOT (pmCell *cell, const pmFPAview *view, pmFPAfile *file);
    25 bool pmReadoutWriteMANAPLOT (pmReadout *readout, const pmFPAview *view, pmFPAfile *file);
     21bool pmFPAviewWriteMANAPLOT (const pmFPAview *view, pmFPAfile *file, pmConfig *config);
     22bool pmFPAWriteMANAPLOT (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config);
     23bool pmChipWriteMANAPLOT (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config);
     24bool pmCellWriteMANAPLOT (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config);
     25bool pmReadoutWriteMANAPLOT (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config);
    2626
    2727# endif
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r9950 r10421  
    277277    }
    278278
     279    psString realName = pmConfigConvertFilename (infiles->data[0], config);
     280    if (!realName) {
     281        psError(PS_ERR_IO, false, "Failed to convert file name %s\n", (char *) infiles->data[0]);
     282        return NULL;
     283    }
     284
    279285    // load the header of the first image
    280     fits = psFitsOpen (infiles->data[0], "r");
     286    fits = psFitsOpen (realName, "r");
     287    if (!fits) {
     288        psError(PS_ERR_IO, false, "Failed to open file %s\n", realName);
     289        psFree (realName);
     290        return NULL;
     291    }
    281292    phu = psFitsReadHeader (NULL, fits);
     293    if (!phu) {
     294        psError(PS_ERR_IO, false, "Failed to read file header %s\n", realName);
     295        psFree (realName);
     296        return NULL;
     297    }
    282298    psFitsClose (fits);
    283299
     
    286302    format = pmConfigCameraFormatFromHeader (config, phu);
    287303    if (!format) {
    288         psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", (char *)infiles->data[0]);
     304        psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", realName);
    289305        psFree(phu);
     306        psFree (realName);
    290307        return NULL;
    291308    }
     
    294311    fpa = pmFPAConstruct (config->camera);
    295312    if (!fpa) {
    296         psError(PS_ERR_IO, false, "Failed to construct FPA from %s", (char *)infiles->data[0]);
    297         return NULL;
    298     }
     313        psError(PS_ERR_IO, false, "Failed to construct FPA from %s", realName);
     314        psFree (realName);
     315        return NULL;
     316    }
     317    psFree (realName);
    299318
    300319    // load the given filerule (from config->camera) and bind it to the fpa
     
    337356    for (int i = 0; i < infiles->n; i++) {
    338357        if (i > 0) {
    339             fits = psFitsOpen (infiles->data[i], "r");
     358            psString realName = pmConfigConvertFilename (infiles->data[i], config);
     359            if (!realName) {
     360                psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *) infiles->data[i]);
     361                return NULL;
     362            }
     363            fits = psFitsOpen (realName, "r");
     364            if (!fits) {
     365                psError(PS_ERR_IO, false, "Failed to open file %s\n", realName);
     366                psFree (realName);
     367                return NULL;
     368            }
    340369            phu = psFitsReadHeader (NULL, fits);
    341             pmConfigValidateCameraFormat (format, phu);
     370            if (!phu) {
     371                psError(PS_ERR_IO, false, "Failed to read file header %s", realName);
     372                psFree (realName);
     373                psFitsClose (fits);
     374                return NULL;
     375            }
     376            if (!pmConfigValidateCameraFormat (format, phu)) {
     377                psError(PS_ERR_IO, false, "file %s is not from the required camera", realName);
     378                psFree (realName);
     379                psFitsClose (fits);
     380                return NULL;
     381            }
    342382            psFitsClose (fits);
    343383        }
     
    545585
    546586    // Prepend the global path to the file rule
    547     if (config->workdir) {
    548         psStringPrepend(&file->filerule, "%s/", config->workdir);
    549     }
     587    psString tmpName = pmConfigConvertFilename (file->filerule, config);
     588    psFree (file->filerule);
     589    file->filerule = tmpName;
    550590
    551591    if (found) {
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r10385 r10421  
    210210        }
    211211
    212         // XXXX this is very ad-hoc
    213         // XXXX prepend the value config[WORKDIR] to the filename...
    214         char *workdir = psMetadataLookupStr (NULL, config->site, "WORKDIR");
    215         if (workdir) {
    216             psStringPrepend (&file->filename, "%s/", workdir);
    217         }
    218 
    219212        psTrace ("pmFPAfile", 6, "got detrend file %s\n", file->filename);
    220213        psFree (extra);
    221214    }
    222     // if () "neb://" -> get from neb...
     215
     216    // apply filename mangling rules (file://, path://, neb://, WORKDIR)
     217    psString tmpName = pmConfigConvertFilename (file->filename, config);
     218    psFree (file->filename);
     219    file->filename = tmpName;
    223220
    224221    switch (file->type) {
     
    353350    case PM_FPA_FILE_CMP:
    354351    case PM_FPA_FILE_CMF:
    355         pmFPAviewReadObjects (view, file);
     352        pmFPAviewReadObjects (view, file, config);
    356353        psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type);
    357354        break;
    358355
    359356    case PM_FPA_FILE_PSF:
    360         pmFPAviewReadPSFmodel (view, file);
     357        pmFPAviewReadPSFmodel (view, file, config);
    361358        psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type);
    362359        break;
     
    508505    case PM_FPA_FILE_CMF:
    509506        psTrace ("pmFPAfile", 5, "writing object %s (fpa: %p)\n", file->filename, file->fpa);
    510         if (!pmFPAviewWriteObjects (view, file)) {
     507        if (!pmFPAviewWriteObjects (view, file, config)) {
    511508            psError(PS_ERR_IO, false, "Failed to write object %s", file->filename);
    512509            return false;
     
    516513
    517514    case PM_FPA_FILE_PSF:
    518         pmFPAviewWritePSFmodel (view, file);
     515        pmFPAviewWritePSFmodel (view, file, config);
    519516        psTrace ("pmFPAfile", 5, "wrote PSF %s (fpa: %p)\n", file->filename, file->fpa);
    520517        break;
    521518
    522519    case PM_FPA_FILE_JPEG:
    523         pmFPAviewWriteJPEG (view, file);
     520        pmFPAviewWriteJPEG (view, file, config);
    524521        psTrace ("pmFPAfile", 5, "wrote JPEG %s (fpa: %p)\n", file->filename, file->fpa);
    525522        break;
    526523
    527524    case PM_FPA_FILE_MANAPLOT:
    528         pmFPAviewWriteMANAPLOT (view, file);
     525        pmFPAviewWriteMANAPLOT (view, file, config);
    529526        psTrace ("pmFPAfile", 5, "wrote MANAPLOT %s (fpa: %p)\n", file->filename, file->fpa);
    530527        break;
Note: See TracChangeset for help on using the changeset viewer.