IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18163


Ignore:
Timestamp:
Jun 17, 2008, 12:16:38 PM (18 years ago)
Author:
Paul Price
Message:

Changing use of psDB* to pmConfig* so that the database handle only has to be set up when required.

Location:
trunk/psModules/src
Files:
18 edited

Legend:

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

    r18137 r18163  
    1717//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1818
    19 bool pmCellReadHeader(pmCell *cell, psFits *fits, psDB *db)
     19bool pmCellReadHeader(pmCell *cell, psFits *fits, pmConfig *config)
    2020{
    2121    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    2323
    2424    if (!cell->hdu) {
    25         return pmChipReadHeader(cell->parent, fits, db);
     25        return pmChipReadHeader(cell->parent, fits, config);
    2626    }
    2727    if (!pmHDUReadHeader(cell->hdu, fits)) {
     
    3030    }
    3131
    32     return pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, false, db);
     32    return pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, false, config);
    3333}
    3434
    3535
    36 bool pmChipReadHeader(pmChip *chip, psFits *fits, psDB *db)
     36bool pmChipReadHeader(pmChip *chip, psFits *fits, pmConfig *config)
    3737{
    3838    PS_ASSERT_PTR_NON_NULL(chip, false);
     
    4040
    4141    if (!chip->hdu) {
    42         return pmFPAReadHeader(chip->parent, fits, db);
     42        return pmFPAReadHeader(chip->parent, fits, config);
    4343    }
    4444    if (!pmHDUReadHeader(chip->hdu, fits)) {
     
    4747    }
    4848
    49     if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, true, db)) {
     49    if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, true, config)) {
    5050        psError(PS_ERR_UNKNOWN, false, "Unable to read concepts for chip.\n");
    5151        return false;
     
    5656
    5757
    58 bool pmFPAReadHeader(pmFPA *fpa, psFits *fits, psDB *db)
     58bool pmFPAReadHeader(pmFPA *fpa, psFits *fits, pmConfig *config)
    5959{
    6060    PS_ASSERT_PTR_NON_NULL(fpa, false);
     
    6969    }
    7070
    71     if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, db)) {
     71    if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, config)) {
    7272        psError(PS_ERR_UNKNOWN, false, "Unable to read concepts for FPA.\n");
    7373        return false;
  • trunk/psModules/src/camera/pmFPAHeader.h

    r18137 r18163  
    11/*  @file pmFPAHeader.h
    22 *  @brief Functions read FITS headers for FPA components
    3  * 
     3 *
    44 *  @author Paul Price, IfA
    5  * 
    6  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2008-06-14 02:15:05 $
     5 *
     6 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2008-06-17 22:16:38 $
    88 *  Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    2121bool pmFPAReadHeader(pmFPA *fpa,        ///< FPA for which to read header
    2222                     psFits *fits,       ///< FITS file handle
    23                      psDB *db
     23                     pmConfig *config   ///< Configuration
    2424                    );
    2525
     
    3030bool pmChipReadHeader(pmChip *chip,     ///< Chip for which to read header
    3131                      psFits *fits,      ///< FITS file handle
    32                      psDB *db
     32                     pmConfig *config   ///< Configuration
    3333                     );
    3434
     
    3939bool pmCellReadHeader(pmCell *cell,     ///< Cell for which to read header
    4040                      psFits *fits,      ///< FITS file handle
    41                      psDB *db
     41                     pmConfig *config   ///< Configuration
    4242                     );
    4343/// @}
  • trunk/psModules/src/camera/pmFPARead.c

    r18140 r18163  
    8282static bool cellNumReadouts(pmCell *cell,    // Cell of interest
    8383                            psFits *fits,    // FITS file
    84                             psDB *db
     84                            pmConfig *config // Configuration
    8585    )
    8686{
     
    9494        return false;
    9595    }
    96     if (!pmCellReadHeader(cell, fits, db)) {
     96    if (!pmCellReadHeader(cell, fits, config)) {
    9797        psError(PS_ERR_IO, false, "Unable to read header for cell!\n");
    9898        return false;
     
    143143                                  int numScans, // Number of scans to read at a time
    144144                                  fpaReadType type, // Type of image
    145                                   psDB *db // Database handle for concepts
     145                                  pmConfig *config // Configuration
    146146    )
    147147{
     
    153153
    154154    if (!pmConceptsReadCell(readout->parent, PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE,
    155                             true, db)) {
     155                            true, config)) {
    156156        psError(PS_ERR_IO, false, "Failed to read concepts for cell.");
    157157        return false;
     
    209209                        int numScans,   // Number of scans to read at a time
    210210                        fpaReadType type, // Type of image
    211                         psDB *db        // Database handle for concepts
     211                        pmConfig *config// Configuration
    212212    )
    213213{
     
    229229        return false;
    230230    }
    231     int naxis3 = cellNumReadouts(cell, fits, db); // Number of planes
     231    int naxis3 = cellNumReadouts(cell, fits, config); // Number of planes
    232232    if (z >= naxis3) {
    233233        // No more to read
     
    237237    int next;                           // Next position
    238238    int last;                           // Last position
    239     if (!readoutScanProperties(&next, &last, readout, numScans, type, db)) {
     239    if (!readoutScanProperties(&next, &last, readout, numScans, type, config)) {
    240240        psError(PS_ERR_UNKNOWN, false, "Unable to determine readout properties.");
    241241        return false;
     
    395395                             int overlap, // Number of scans (row/col) to overlap between scans
    396396                             fpaReadType type, // Type of image
    397                              psDB *db   // Database handle for concepts
     397                             pmConfig *config   // Configuration
    398398    )
    399399{
     
    416416    }
    417417
    418     int naxis3 = cellNumReadouts(cell, fits, db); // Number of image planes
     418    int naxis3 = cellNumReadouts(cell, fits, config); // Number of image planes
    419419    if (z >= naxis3) {
    420420        psError(PS_ERR_IO, false, "Desired image plane (%d) exceeds available number (%d).",
     
    425425    int next;                           // Next position
    426426    int last;                           // Last position
    427     if (!readoutScanProperties(&next, &last, readout, numScans, type, db)) {
     427    if (!readoutScanProperties(&next, &last, readout, numScans, type, config)) {
    428428        psError(PS_ERR_UNKNOWN, false, "Unable to determine readout properties.");
    429429        return false;
     
    532532static bool cellRead(pmCell *cell,      // Cell into which to read
    533533                     psFits *fits,      // FITS file from which to read
    534                      psDB *db,          // Database handle, for concepts ingest
     534                     pmConfig *config,  // Configuration
    535535                     fpaReadType type   // Type to read
    536536                    )
     
    578578
    579579    // load in the concept information for this cell
    580     if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, db)) {
     580    if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, config)) {
    581581        //psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell");
    582582        //return false;
     
    653653static bool chipRead(pmChip *chip,      // Chip into which to read
    654654                     psFits *fits,      // FITS file from which to read
    655                      psDB *db,          // Database handle, for concepts ingest
     655                     pmConfig *config,  // Configuration
    656656                     fpaReadType type   // Type to read
    657657                    )
     
    664664    for (int i = 0; i < cells->n; i++) {
    665665        pmCell *cell = cells->data[i];  // The cell of interest
    666         success |= cellRead(cell, fits, db, type);
     666        success |= cellRead(cell, fits, config, type);
    667667    }
    668668    if (success) {
     
    684684static bool fpaRead(pmFPA *fpa,         // FPA into which to read
    685685                    psFits *fits,       // FITS file from which to read
    686                     psDB *db,           // Database handle, for concepts ingest
     686                    pmConfig *config,   // Configuration
    687687                    fpaReadType type    // Type to read
    688688                   )
     
    695695    for (int i = 0; i < chips->n; i++) {
    696696        pmChip *chip = chips->data[i];  // The cell of interest
    697         success |= chipRead(chip, fits, db, type);
     697        success |= chipRead(chip, fits, config, type);
    698698    }
    699699    if (success) {
     
    720720// pmReadoutReadNext is maintained here (for now) to maintain backwards compatibility.
    721721// pmReadoutReadNext has been replaced by pmReadoutRead, pmReadoutReadChunk, pmReadoutMore
    722 bool pmReadoutReadNext(bool *status, pmReadout *readout, psFits *fits, int z, int numScans, psDB *db)
     722bool pmReadoutReadNext(bool *status, pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
    723723{
    724724    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    741741    }
    742742
    743     if (!pmCellReadHeader(cell, fits, db)) {
     743    if (!pmCellReadHeader(cell, fits, config)) {
    744744        psError(PS_ERR_IO, false, "Unable to read header for cell!\n");
    745745        return false;
     
    896896
    897897
    898 bool pmReadoutMore(pmReadout *readout, psFits *fits, int z, int numScans, psDB *db)
     898bool pmReadoutMore(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
    899899{
    900900    PS_ASSERT_PTR_NON_NULL(readout, false);
    901901    PS_ASSERT_FITS_NON_NULL(fits, false);
    902902
    903     return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_IMAGE, db);
    904 }
    905 
    906 bool pmReadoutReadChunk(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, psDB *db)
     903    return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_IMAGE, config);
     904}
     905
     906bool pmReadoutReadChunk(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, pmConfig *config)
    907907{
    908908    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    911911    PS_ASSERT_INT_NONNEGATIVE(numScans, false);
    912912
    913     return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_IMAGE, db);
    914 }
    915 
    916 bool pmReadoutRead(pmReadout *readout, psFits *fits, int z, psDB *db)
     913    return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_IMAGE, config);
     914}
     915
     916bool pmReadoutRead(pmReadout *readout, psFits *fits, int z, pmConfig *config)
    917917{
    918918    PS_ASSERT_PTR_NON_NULL(readout, false);
    919919    PS_ASSERT_FITS_NON_NULL(fits, false);
    920920
    921     return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_IMAGE, db);
    922 }
    923 
    924 int pmCellNumReadouts(pmCell *cell, psFits *fits, psDB *db)
     921    return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_IMAGE, config);
     922}
     923
     924int pmCellNumReadouts(pmCell *cell, psFits *fits, pmConfig *config)
    925925{
    926926    PS_ASSERT_PTR_NON_NULL(cell, false);
    927927    PS_ASSERT_FITS_NON_NULL(fits, false);
    928928
    929     return cellNumReadouts(cell, fits, db);
    930 }
    931 
    932 bool pmCellRead(pmCell *cell, psFits *fits, psDB *db)
     929    return cellNumReadouts(cell, fits, config);
     930}
     931
     932bool pmCellRead(pmCell *cell, psFits *fits, pmConfig *config)
    933933{
    934934    PS_ASSERT_PTR_NON_NULL(cell, false);
    935935    PS_ASSERT_FITS_NON_NULL(fits, false);
    936936
    937     return cellRead(cell, fits, db, FPA_READ_TYPE_IMAGE);
    938 }
    939 
    940 bool pmChipRead(pmChip *chip, psFits *fits, psDB *db)
     937    return cellRead(cell, fits, config, FPA_READ_TYPE_IMAGE);
     938}
     939
     940bool pmChipRead(pmChip *chip, psFits *fits, pmConfig *config)
    941941{
    942942    PS_ASSERT_PTR_NON_NULL(chip, false);
    943943    PS_ASSERT_FITS_NON_NULL(fits, false);
    944944
    945     return chipRead(chip, fits, db, FPA_READ_TYPE_IMAGE);
    946 }
    947 
    948 bool pmFPARead(pmFPA *fpa, psFits *fits, psDB *db)
     945    return chipRead(chip, fits, config, FPA_READ_TYPE_IMAGE);
     946}
     947
     948bool pmFPARead(pmFPA *fpa, psFits *fits, pmConfig *config)
    949949{
    950950    PS_ASSERT_PTR_NON_NULL(fpa, false);
    951951    PS_ASSERT_FITS_NON_NULL(fits, false);
    952952
    953     return fpaRead(fpa, fits, db, FPA_READ_TYPE_IMAGE);
     953    return fpaRead(fpa, fits, config, FPA_READ_TYPE_IMAGE);
    954954}
    955955
     
    959959//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    960960
    961 bool pmReadoutMoreMask(pmReadout *readout, psFits *fits, int z, int numScans, psDB *db)
     961bool pmReadoutMoreMask(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
    962962{
    963963    PS_ASSERT_PTR_NON_NULL(readout, false);
    964964    PS_ASSERT_FITS_NON_NULL(fits, false);
    965965
    966     return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_MASK, db);
    967 }
    968 
    969 bool pmReadoutReadChunkMask(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, psDB *db)
     966    return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_MASK, config);
     967}
     968
     969bool pmReadoutReadChunkMask(pmReadout *readout, psFits *fits, int z, int numScans, int overlap,
     970                            pmConfig *config)
    970971{
    971972    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    974975    PS_ASSERT_INT_NONNEGATIVE(numScans, false);
    975976
    976     return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_MASK, db);
    977 }
    978 
    979 bool pmReadoutReadMask(pmReadout *readout, psFits *fits, int z, psDB *db)
     977    return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_MASK, config);
     978}
     979
     980bool pmReadoutReadMask(pmReadout *readout, psFits *fits, int z, pmConfig *config)
    980981{
    981982    PS_ASSERT_PTR_NON_NULL(readout, false);
    982983    PS_ASSERT_FITS_NON_NULL(fits, false);
    983984
    984     return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_MASK, db);
    985 }
    986 
    987 bool pmCellReadMask(pmCell *cell, psFits *fits, psDB *db)
     985    return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_MASK, config);
     986}
     987
     988bool pmCellReadMask(pmCell *cell, psFits *fits, pmConfig *config)
    988989{
    989990    PS_ASSERT_PTR_NON_NULL(cell, false);
    990991    PS_ASSERT_FITS_NON_NULL(fits, false);
    991992
    992     return cellRead(cell, fits, db, FPA_READ_TYPE_MASK);
    993 }
    994 
    995 bool pmChipReadMask(pmChip *chip, psFits *fits, psDB *db)
     993    return cellRead(cell, fits, config, FPA_READ_TYPE_MASK);
     994}
     995
     996bool pmChipReadMask(pmChip *chip, psFits *fits, pmConfig *config)
    996997{
    997998    PS_ASSERT_PTR_NON_NULL(chip, false);
    998999    PS_ASSERT_FITS_NON_NULL(fits, false);
    9991000
    1000     return chipRead(chip, fits, db, FPA_READ_TYPE_MASK);
    1001 }
    1002 
    1003 bool pmFPAReadMask(pmFPA *fpa, psFits *fits, psDB *db)
     1001    return chipRead(chip, fits, config, FPA_READ_TYPE_MASK);
     1002}
     1003
     1004bool pmFPAReadMask(pmFPA *fpa, psFits *fits, pmConfig *config)
    10041005{
    10051006    PS_ASSERT_PTR_NON_NULL(fpa, false);
    10061007    PS_ASSERT_FITS_NON_NULL(fits, false);
    10071008
    1008     return fpaRead(fpa, fits, db, FPA_READ_TYPE_MASK);
     1009    return fpaRead(fpa, fits, config, FPA_READ_TYPE_MASK);
    10091010}
    10101011
     
    10131014//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    10141015
    1015 bool pmReadoutMoreWeight(pmReadout *readout, psFits *fits, int z, int numScans, psDB *db)
     1016bool pmReadoutMoreWeight(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
    10161017{
    10171018    PS_ASSERT_PTR_NON_NULL(readout, false);
    10181019    PS_ASSERT_FITS_NON_NULL(fits, false);
    10191020
    1020     return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_WEIGHT, db);
    1021 }
    1022 
    1023 bool pmReadoutReadChunkWeight(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, psDB *db)
     1021    return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_WEIGHT, config);
     1022}
     1023
     1024bool pmReadoutReadChunkWeight(pmReadout *readout, psFits *fits, int z, int numScans, int overlap,
     1025                              pmConfig *config)
    10241026{
    10251027    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    10281030    PS_ASSERT_INT_NONNEGATIVE(numScans, false);
    10291031
    1030     return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_WEIGHT, db);
    1031 }
    1032 
    1033 bool pmReadoutReadWeight(pmReadout *readout, psFits *fits, int z, psDB *db)
     1032    return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_WEIGHT, config);
     1033}
     1034
     1035bool pmReadoutReadWeight(pmReadout *readout, psFits *fits, int z, pmConfig *config)
    10341036{
    10351037    PS_ASSERT_PTR_NON_NULL(readout, false);
    10361038    PS_ASSERT_FITS_NON_NULL(fits, false);
    10371039
    1038     return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_WEIGHT, db);
    1039 }
    1040 
    1041 bool pmCellReadWeight(pmCell *cell, psFits *fits, psDB *db)
     1040    return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_WEIGHT, config);
     1041}
     1042
     1043bool pmCellReadWeight(pmCell *cell, psFits *fits, pmConfig *config)
    10421044{
    10431045    PS_ASSERT_PTR_NON_NULL(cell, false);
    10441046    PS_ASSERT_FITS_NON_NULL(fits, false);
    10451047
    1046     return cellRead(cell, fits, db, FPA_READ_TYPE_WEIGHT);
    1047 }
    1048 
    1049 bool pmChipReadWeight(pmChip *chip, psFits *fits, psDB *db)
     1048    return cellRead(cell, fits, config, FPA_READ_TYPE_WEIGHT);
     1049}
     1050
     1051bool pmChipReadWeight(pmChip *chip, psFits *fits, pmConfig *config)
    10501052{
    10511053    PS_ASSERT_PTR_NON_NULL(chip, false);
    10521054    PS_ASSERT_FITS_NON_NULL(fits, false);
    10531055
    1054     return chipRead(chip, fits, db, FPA_READ_TYPE_WEIGHT);
    1055 }
    1056 
    1057 bool pmFPAReadWeight(pmFPA *fpa, psFits *fits, psDB *db)
     1056    return chipRead(chip, fits, config, FPA_READ_TYPE_WEIGHT);
     1057}
     1058
     1059bool pmFPAReadWeight(pmFPA *fpa, psFits *fits, pmConfig *config)
    10581060{
    10591061    PS_ASSERT_PTR_NON_NULL(fpa, false);
    10601062    PS_ASSERT_FITS_NON_NULL(fits, false);
    10611063
    1062     return fpaRead(fpa, fits, db, FPA_READ_TYPE_WEIGHT);
     1064    return fpaRead(fpa, fits, config, FPA_READ_TYPE_WEIGHT);
    10631065}
    10641066
     
    10671069//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    10681070
    1069 bool pmCellReadHeaderSet(pmCell *cell, psFits *fits, psDB *db)
     1071bool pmCellReadHeaderSet(pmCell *cell, psFits *fits, pmConfig *config)
    10701072{
    10711073    PS_ASSERT_PTR_NON_NULL(cell, false);
    10721074    PS_ASSERT_FITS_NON_NULL(fits, false);
    10731075
    1074     return cellRead(cell, fits, db, FPA_READ_TYPE_HEADER);
    1075 }
    1076 
    1077 bool pmChipReadHeaderSet(pmChip *chip, psFits *fits, psDB *db)
     1076    return cellRead(cell, fits, config, FPA_READ_TYPE_HEADER);
     1077}
     1078
     1079bool pmChipReadHeaderSet(pmChip *chip, psFits *fits, pmConfig *config)
    10781080{
    10791081    PS_ASSERT_PTR_NON_NULL(chip, false);
    10801082    PS_ASSERT_FITS_NON_NULL(fits, false);
    10811083
    1082     return chipRead(chip, fits, db, FPA_READ_TYPE_HEADER);
    1083 }
    1084 
    1085 bool pmFPAReadHeaderSet(pmFPA *fpa, psFits *fits, psDB *db)
     1084    return chipRead(chip, fits, config, FPA_READ_TYPE_HEADER);
     1085}
     1086
     1087bool pmFPAReadHeaderSet(pmFPA *fpa, psFits *fits, pmConfig *config)
    10861088{
    10871089    PS_ASSERT_PTR_NON_NULL(fpa, false);
    10881090    PS_ASSERT_FITS_NON_NULL(fits, false);
    10891091
    1090     return fpaRead(fpa, fits, db, FPA_READ_TYPE_HEADER);
     1092    return fpaRead(fpa, fits, config, FPA_READ_TYPE_HEADER);
    10911093}
    10921094
  • trunk/psModules/src/camera/pmFPARead.h

    r18137 r18163  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2008-06-14 02:15:05 $
     6 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-06-17 22:16:38 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    1111#ifndef PM_FPA_READ_H
    1212#define PM_FPA_READ_H
     13
     14#include <pmConfig.h>
    1315
    1416/// @addtogroup Camera Camera Layout
     
    2022                   int z,               ///< Readout number/plane; zero-offset indexing
    2123                   int numScans,        ///< Number of scans (rows/cols) to read
    22                    psDB *db             ///< Database handle for concepts
     24                   pmConfig *config     ///< Configuration
    2325    );
    2426
     
    3133                        int numScans,   ///< Number of scans (rows/cols) to read
    3234                        int overlap,    ///< Overlap between consecutive reads
    33                         psDB *db        ///< Database handle for concepts
     35                        pmConfig *config ///< Configuration
    3436    );
    3537
     
    3840                   psFits *fits,        ///< FITS file from which to read
    3941                   int z,               ///< Readout number/plane; zero-offset indexing
    40                    psDB *db             ///< Database handle for concepts
     42                   pmConfig *config     ///< Configuration
    4143    );
    4244
     
    5759                       int z,           // Readout number/plane; zero-offset indexing
    5860                       int numRows,      // The number of rows to read
    59                        psDB *db
     61                       pmConfig *config
    6062                      );
    6163
     
    6365///
    6466/// This function is type-independent (doesn't matter if you are interested in the image/mask/weight).
    65 int pmCellNumReadouts(pmCell *cell, psFits *fits, psDB *db);
     67int pmCellNumReadouts(pmCell *cell, psFits *fits, pmConfig *config);
    6668
    6769/// Read an entire cell
     
    7173bool pmCellRead(pmCell *cell,           // Cell to read into
    7274                psFits *fits,           // FITS file from which to read
    73                 psDB *db                // Database handle, for "concepts" ingest
     75                pmConfig *config        // Configuration
    7476               );
    7577
     
    7981bool pmChipRead(pmChip *chip,           // Chip to read into
    8082                psFits *fits,           // FITS file from which to read
    81                 psDB *db                // Database handle, for "concepts" ingest
     83                pmConfig *config        // Configuration
    8284               );
    8385
     
    8789bool pmFPARead(pmFPA *fpa,              // FPA to read into
    8890               psFits *fits,            // FITS file from which to read
    89                psDB *db                 // Database handle, for "concepts" ingest
     91               pmConfig *config         // Configuration
    9092              );
    9193
     
    9799                       int z,           ///< Readout number/plane; zero-offset indexing
    98100                       int numScans,    ///< Number of scans (rows/cols) to read
    99                        psDB *db         ///< Database handle for concepts
     101                       pmConfig *config ///< Configuration
    100102    );
    101103
     
    108110                            int numScans, ///< Number of scans (rows/cols) to read
    109111                            int overlap, ///< Overlap between consecutive reads
    110                             psDB *db    ///< Database handle for concepts
     112                            pmConfig *config ///< Configuration
    111113    );
    112114
     
    115117                       psFits *fits,    ///< FITS file from which to read
    116118                       int z,           ///< Readout number/plane; zero-offset indexing
    117                        psDB *db         ///< Database handle for concepts
     119                       pmConfig *config ///< Configuration
    118120    );
    119121
     
    123125bool pmCellReadMask(pmCell *cell,       // Cell to read into
    124126                    psFits *fits,       // FITS file from which to read
    125                     psDB *db            // Database handle, for "concepts" ingest
     127                    pmConfig *config    // Configuration
    126128                   );
    127129
     
    131133bool pmChipReadMask(pmChip *chip,       // Chip to read into
    132134                    psFits *fits,       // FITS file from which to read
    133                     psDB *db            // Database handle, for "concepts" ingest
     135                    pmConfig *config    // Configuration
    134136                   );
    135137
     
    139141bool pmFPAReadMask(pmFPA *fpa,          // FPA to read into
    140142                   psFits *fits,        // FITS file from which to read
    141                    psDB *db             // Database handle, for "concepts" ingest
     143                   pmConfig *config     // Configuration
    142144                  );
    143145
     
    149151                         int z,         ///< Readout number/plane; zero-offset indexing
    150152                         int numScans,  ///< Number of scans (rows/cols) to read
    151                          psDB *db       ///< Database handle for concepts
     153                         pmConfig *config ///< Configuration
    152154    );
    153155
     
    160162                              int numScans, ///< Number of scans (rows/cols) to read
    161163                              int overlap, ///< Overlap between consecutive reads
    162                               psDB *db  ///< Database handle for concepts
     164                              pmConfig *config ///< Configuration
    163165    );
    164166
     
    167169                         psFits *fits,  ///< FITS file from which to read
    168170                         int z,         ///< Readout number/plane; zero-offset indexing
    169                          psDB *db       ///< Database handle for concepts
     171                         pmConfig *config ///< Configuration
    170172    );
    171173
     
    173175///
    174176/// Same as pmCellRead, but reads into the weight element of the readouts.
    175 bool pmCellReadWeight(pmCell *cell,           // Cell to read into
    176                       psFits *fits,           // FITS file from which to read
    177                       psDB *db                // Database handle, for "concepts" ingest
     177bool pmCellReadWeight(pmCell *cell,     // Cell to read into
     178                      psFits *fits,     // FITS file from which to read
     179                      pmConfig *config  // Configuration
    178180                     );
    179181
     
    181183///
    182184/// Same as pmChipRead, but reads into the weight element of the readouts.
    183 bool pmChipReadWeight(pmChip *chip,           // Chip to read into
    184                       psFits *fits,           // FITS file from which to read
    185                       psDB *db                // Database handle, for "concepts" ingest
     185bool pmChipReadWeight(pmChip *chip,     // Chip to read into
     186                      psFits *fits,     // FITS file from which to read
     187                      pmConfig *config  // Configuration
    186188                     );
    187189
     
    189191///
    190192/// Same as pmFPARead, but reads into the weight element of the readouts.
    191 bool pmFPAReadWeight(pmFPA *fpa,              // FPA to read into
    192                      psFits *fits,            // FITS file from which to read
    193                      psDB *db                 // Database handle, for "concepts" ingest
     193bool pmFPAReadWeight(pmFPA *fpa,        // FPA to read into
     194                     psFits *fits,      // FITS file from which to read
     195                     pmConfig *config   // Configuration
    194196                    );
    195197
     
    197199///
    198200/// Same as pmCellRead, but reads only the headers of the readouts.
    199 bool pmCellReadHeaderSet(pmCell *cell,           // Cell to read into
    200                          psFits *fits,           // FITS file from which to read
    201                          psDB *db                // Database handle, for "concepts" ingest
     201bool pmCellReadHeaderSet(pmCell *cell,  // Cell to read into
     202                         psFits *fits,  // FITS file from which to read
     203                         pmConfig *config // Configuration
    202204    );
    203205
     
    205207///
    206208/// Same as pmChipRead, but reads only the headers of the readouts.
    207 bool pmChipReadHeaderSet(pmChip *chip,           // Chip to read into
    208                       psFits *fits,           // FITS file from which to read
    209                       psDB *db                // Database handle, for "concepts" ingest
     209bool pmChipReadHeaderSet(pmChip *chip,  // Chip to read into
     210                      psFits *fits,     // FITS file from which to read
     211                      pmConfig *config  // Configuration
    210212                     );
    211213
     
    213215///
    214216/// Same as pmFPARead, but reads only the headers of the readouts.
    215 bool pmFPAReadHeaderSet(pmFPA *fpa,              // FPA to read into
    216                         psFits *fits,            // FITS file from which to read
    217                         psDB *db                 // Database handle, for "concepts" ingest
     217bool pmFPAReadHeaderSet(pmFPA *fpa,     // FPA to read into
     218                        psFits *fits,   // FITS file from which to read
     219                        pmConfig *config // Configuration
    218220    );
    219221
  • trunk/psModules/src/camera/pmFPAWrite.c

    r18027 r18163  
    128128static bool cellWrite(pmCell *cell,     // Cell to write
    129129                      psFits *fits,     // FITS file to which to write
    130                       psDB *db,         // Database handle for "concepts" update
     130                      pmConfig *config, // Configuration
    131131                      bool blank,       // Write a blank PHU?
    132132                      fpaWriteType type // Type to write
     
    178178static bool chipWrite(pmChip *chip,     // Chip to write
    179179                      psFits *fits,     // FITS file to which to write
    180                       psDB *db,         // Database handle for "concepts" update
     180                      pmConfig *config, // Configuration
    181181                      bool blank,       // Write a blank PHU?
    182182                      bool recurse,     // Recurse to lower levels?
     
    228228        for (int i = 0; i < cells->n; i++) {
    229229            pmCell *cell = cells->data[i];  // The cell of interest
    230             if (!cellWrite(cell, fits, db, false, type)) {
     230            if (!cellWrite(cell, fits, config, false, type)) {
    231231                psError(PS_ERR_IO, false, "Unable to write Chip.\n");
    232232                return false;
     
    242242static bool fpaWrite(pmFPA *fpa,        // FPA to write
    243243                     psFits *fits,      // FITS file to which to write
    244                      psDB *db,          // Database handle for "concepts" update
     244                     pmConfig *config,  // Configuration
    245245                     bool blank,        // Write a blank PHU?
    246246                     bool recurse,      // Recurse to lower levels?
     
    291291        for (int i = 0; i < chips->n; i++) {
    292292            pmChip *chip = chips->data[i];  // The chip of interest
    293             if (!chipWrite(chip, fits, db, false, true, type)) {
     293            if (!chipWrite(chip, fits, config, false, true, type)) {
    294294                psError(PS_ERR_IO, false, "Unable to write FPA.\n");
    295295                return false;
     
    372372
    373373
    374 bool pmCellWrite(pmCell *cell, psFits *fits, psDB *db, bool blank)
     374bool pmCellWrite(pmCell *cell, psFits *fits, pmConfig *config, bool blank)
    375375{
    376376    PS_ASSERT_PTR_NON_NULL(cell, false);
    377377    PS_ASSERT_PTR_NON_NULL(fits, false);
    378     return cellWrite(cell, fits, db, blank, FPA_WRITE_TYPE_IMAGE);
    379 }
    380 
    381 bool pmChipWrite(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
     378    return cellWrite(cell, fits, config, blank, FPA_WRITE_TYPE_IMAGE);
     379}
     380
     381bool pmChipWrite(pmChip *chip, psFits *fits, pmConfig *config, bool blank, bool recurse)
    382382{
    383383    PS_ASSERT_PTR_NON_NULL(chip, false);
    384384    PS_ASSERT_PTR_NON_NULL(fits, false);
    385     return chipWrite(chip, fits, db, blank, recurse, FPA_WRITE_TYPE_IMAGE);
    386 }
    387 
    388 bool pmFPAWrite(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
     385    return chipWrite(chip, fits, config, blank, recurse, FPA_WRITE_TYPE_IMAGE);
     386}
     387
     388bool pmFPAWrite(pmFPA *fpa, psFits *fits, pmConfig *config, bool blank, bool recurse)
    389389{
    390390    PS_ASSERT_PTR_NON_NULL(fpa, false);
    391391    PS_ASSERT_PTR_NON_NULL(fits, false);
    392     return fpaWrite(fpa, fits, db, blank, recurse, FPA_WRITE_TYPE_IMAGE);
    393 }
    394 
    395 
    396 bool pmCellWriteMask(pmCell *cell, psFits *fits, psDB *db, bool blank)
     392    return fpaWrite(fpa, fits, config, blank, recurse, FPA_WRITE_TYPE_IMAGE);
     393}
     394
     395
     396bool pmCellWriteMask(pmCell *cell, psFits *fits, pmConfig *config, bool blank)
    397397{
    398398    PS_ASSERT_PTR_NON_NULL(cell, false);
    399399    PS_ASSERT_PTR_NON_NULL(fits, false);
    400     return cellWrite(cell, fits, db, blank, FPA_WRITE_TYPE_MASK);
    401 }
    402 
    403 bool pmChipWriteMask(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
     400    return cellWrite(cell, fits, config, blank, FPA_WRITE_TYPE_MASK);
     401}
     402
     403bool pmChipWriteMask(pmChip *chip, psFits *fits, pmConfig *config, bool blank, bool recurse)
    404404{
    405405    PS_ASSERT_PTR_NON_NULL(chip, false);
    406406    PS_ASSERT_PTR_NON_NULL(fits, false);
    407     return chipWrite(chip, fits, db, blank, recurse, FPA_WRITE_TYPE_MASK);
    408 }
    409 
    410 bool pmFPAWriteMask(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
     407    return chipWrite(chip, fits, config, blank, recurse, FPA_WRITE_TYPE_MASK);
     408}
     409
     410bool pmFPAWriteMask(pmFPA *fpa, psFits *fits, pmConfig *config, bool blank, bool recurse)
    411411{
    412412    PS_ASSERT_PTR_NON_NULL(fpa, false);
    413413    PS_ASSERT_PTR_NON_NULL(fits, false);
    414     return fpaWrite(fpa, fits, db, blank, recurse, FPA_WRITE_TYPE_MASK);
    415 }
    416 
    417 
    418 bool pmCellWriteWeight(pmCell *cell, psFits *fits, psDB *db, bool blank)
     414    return fpaWrite(fpa, fits, config, blank, recurse, FPA_WRITE_TYPE_MASK);
     415}
     416
     417
     418bool pmCellWriteWeight(pmCell *cell, psFits *fits, pmConfig *config, bool blank)
    419419{
    420420    PS_ASSERT_PTR_NON_NULL(cell, false);
    421421    PS_ASSERT_PTR_NON_NULL(fits, false);
    422     return cellWrite(cell, fits, db, blank, FPA_WRITE_TYPE_WEIGHT);
    423 }
    424 
    425 bool pmChipWriteWeight(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
     422    return cellWrite(cell, fits, config, blank, FPA_WRITE_TYPE_WEIGHT);
     423}
     424
     425bool pmChipWriteWeight(pmChip *chip, psFits *fits, pmConfig *config, bool blank, bool recurse)
    426426{
    427427    PS_ASSERT_PTR_NON_NULL(chip, false);
    428428    PS_ASSERT_PTR_NON_NULL(fits, false);
    429     return chipWrite(chip, fits, db, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
    430 }
    431 
    432 bool pmFPAWriteWeight(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
     429    return chipWrite(chip, fits, config, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
     430}
     431
     432bool pmFPAWriteWeight(pmFPA *fpa, psFits *fits, pmConfig *config, bool blank, bool recurse)
    433433{
    434434    PS_ASSERT_PTR_NON_NULL(fpa, false);
    435435    PS_ASSERT_PTR_NON_NULL(fits, false);
    436     return fpaWrite(fpa, fits, db, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
     436    return fpaWrite(fpa, fits, config, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
    437437}
    438438
  • trunk/psModules/src/camera/pmFPAWrite.h

    r12705 r18163  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-03-31 04:17:41 $
     6 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-06-17 22:16:38 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    1111#ifndef PM_FPA_WRITE_H
    1212#define PM_FPA_WRITE_H
     13
     14#include <pmConfig.h>
    1315
    1416/// @addtogroup Camera Camera Layout
     
    3234bool pmCellWrite(pmCell *cell,          ///<  Cell to write
    3335                 psFits *fits,          ///<  FITS file to which to write
    34                  psDB *db,              ///<  Database handle for "concepts" update
     36                 pmConfig *config,      ///<  Configuration
    3537                 bool blank             ///<  Write a blank PHU?
    3638                );
     
    4446bool pmChipWrite(pmChip *chip,          ///<  Chip to write
    4547                 psFits *fits,          ///<  FITS file to which to write
    46                  psDB *db,              ///<  Database handle for "concepts" update
     48                 pmConfig *config,      ///<  Configuration
    4749                 bool blank,            ///<  Write a blank PHU?
    4850                 bool recurse           ///<  Recurse to lower levels?
     
    5759bool pmFPAWrite(pmFPA *fpa,             ///<  FPA to write
    5860                psFits *fits,           ///<  FITS file to which to write
    59                 psDB *db,               ///<  Database handle for "concepts" update
     61                pmConfig *config,       ///<  Configuration
    6062                bool blank,             ///<  Write a blank PHU?
    6163                bool recurse            ///<  Recurse to lower levels?
     
    7072bool pmCellWriteMask(pmCell *cell,      ///<  Cell to write
    7173                     psFits *fits,      ///<  FITS file to which to write
    72                      psDB *db,          ///<  Database handle for "concepts" update
     74                     pmConfig *config,  ///<  Configuration
    7375                     bool blank         ///<  Write a blank PHU?
    7476                    );
     
    8385bool pmChipWriteMask(pmChip *chip,      ///<  Chip to write
    8486                     psFits *fits,      ///<  FITS file to which to write
    85                      psDB *db,          ///<  Database handle for "concepts" update
     87                     pmConfig *config,  ///<  Configuration
    8688                     bool blank,        ///<  Write a blank PHU?
    8789                     bool recurse       ///<  Recurse to lower levels?
     
    9799bool pmFPAWriteMask(pmFPA *fpa,         ///<  FPA to write
    98100                    psFits *fits,       ///<  FITS file to which to write
    99                     psDB *db,           ///<  Database handle for "concepts" update
     101                    pmConfig *config,   ///<  Configuration
    100102                    bool blank,         ///<  Write a blank PHU?
    101103                    bool recurse        ///<  Recurse to lower levels?
     
    110112bool pmCellWriteWeight(pmCell *cell,    ///<  Cell to write
    111113                       psFits *fits,    ///<  FITS file to which to write
    112                        psDB *db,        ///<  Database handle for "concepts" update
     114                       pmConfig *config, ///<  Configuration
    113115                       bool blank       ///<  Write a blank PHU?
    114116                      );
     
    123125bool pmChipWriteWeight(pmChip *chip,    ///<  Chip to write
    124126                       psFits *fits,    ///<  FITS file to which to write
    125                        psDB *db,        ///<  Database handle for "concepts" update
     127                       pmConfig *config, ///<  Configuration
    126128                       bool blank,      ///<  Write a blank PHU?
    127129                       bool recurse     ///<  Recurse to lower levels?
     
    137139bool pmFPAWriteWeight(pmFPA *fpa,       ///<  FPA to write
    138140                      psFits *fits,     ///<  FITS file to which to write
    139                       psDB *db,         ///<  Database handle for "concepts" update
     141                      pmConfig *config, ///<  Configuration
    140142                      bool blank,       ///<  Write a blank PHU?
    141143                      bool recurse      ///<  Recurse to lower levels?
  • trunk/psModules/src/camera/pmFPAfileFitsIO.c

    r18139 r18163  
    166166static bool fpaViewReadFitsImage(const pmFPAview *view, // FPA view, specifying the level of interest
    167167                                 pmFPAfile *file, // FPA file of interest
    168                                  psDB *db,
    169                                  bool (*fpaReadFunc)(pmFPA*, psFits*, psDB*), // Function to read FPA
    170                                  bool (*chipReadFunc)(pmChip*, psFits*, psDB*), // Function to read chip
    171                                  bool (*cellReadFunc)(pmCell*, psFits*, psDB*) // Function to read cell
     168                                 pmConfig *config, // Configuration
     169                                 bool (*fpaReadFunc)(pmFPA*, psFits*, pmConfig*), // Function to read FPA
     170                                 bool (*chipReadFunc)(pmChip*, psFits*, pmConfig*), // Function to read chip
     171                                 bool (*cellReadFunc)(pmCell*, psFits*, pmConfig*) // Function to read cell
    172172                                )
    173173{
     
    179179
    180180    if (view->chip == -1) {
    181         return fpaReadFunc(fpa, fits, db);
     181        return fpaReadFunc(fpa, fits, config);
    182182    }
    183183
     
    189189
    190190    if (view->cell == -1) {
    191         return chipReadFunc(chip, fits, db);
     191        return chipReadFunc(chip, fits, config);
    192192    }
    193193
     
    199199
    200200    if (view->readout == -1) {
    201         return cellReadFunc(cell, fits, db);
     201        return cellReadFunc(cell, fits, config);
    202202    }
    203203    psError(PS_ERR_UNKNOWN, true, "Bad view: %d,%d", view->chip, view->cell);
     
    215215
    216216    if (view->nRows == 0) {
    217         pmReadoutRead (readout, fits, db);
     217        pmReadoutRead (readout, fits, config);
    218218    } else {
    219219        pmReadoutReadSegment (readout, fits, view->nRows, view->iRows, NULL, NULL);
     
    228228    PS_ASSERT_PTR_NON_NULL(view, false);
    229229    PS_ASSERT_PTR_NON_NULL(file, false);
    230     return fpaViewReadFitsImage(view, file, config->database, pmFPARead, pmChipRead, pmCellRead);
     230    return fpaViewReadFitsImage(view, file, config, pmFPARead, pmChipRead, pmCellRead);
    231231}
    232232
     
    235235    PS_ASSERT_PTR_NON_NULL(view, false);
    236236    PS_ASSERT_PTR_NON_NULL(file, false);
    237     return fpaViewReadFitsImage(view, file, config->database, pmFPAReadMask, pmChipReadMask, pmCellReadMask);
     237    return fpaViewReadFitsImage(view, file, config, pmFPAReadMask, pmChipReadMask, pmCellReadMask);
    238238}
    239239
     
    242242    PS_ASSERT_PTR_NON_NULL(view, false);
    243243    PS_ASSERT_PTR_NON_NULL(file, false);
    244     return fpaViewReadFitsImage(view, file, config->database, pmFPAReadWeight, pmChipReadWeight, pmCellReadWeight);
     244    return fpaViewReadFitsImage(view, file, config, pmFPAReadWeight, pmChipReadWeight, pmCellReadWeight);
    245245}
    246246
     
    249249    PS_ASSERT_PTR_NON_NULL(view, false);
    250250    PS_ASSERT_PTR_NON_NULL(file, false);
    251     return fpaViewReadFitsImage(view, file, config->database, pmFPAReadDark, pmChipReadDark, pmCellReadDark);
     251    return fpaViewReadFitsImage(view, file, config, pmFPAReadDark, pmChipReadDark, pmCellReadDark);
    252252}
    253253
     
    256256    PS_ASSERT_PTR_NON_NULL(view, false);
    257257    PS_ASSERT_PTR_NON_NULL(file, false);
    258     return fpaViewReadFitsImage(view, file, config->database, pmFPAReadHeaderSet, pmChipReadHeaderSet, pmCellReadHeaderSet);
     258    return fpaViewReadFitsImage(view, file, config, pmFPAReadHeaderSet, pmChipReadHeaderSet, pmCellReadHeaderSet);
    259259}
    260260
     
    267267static bool fpaViewWriteFitsImage(const pmFPAview *view, // FPA view, specifying the level of interest
    268268                                  pmFPAfile *file, // FPA file of interest
    269                                   const pmConfig *config, // Configuration
    270                                   bool (*fpaWriteFunc)(pmFPA*, psFits*, psDB*, bool, bool), // Func for FPA
    271                                   bool (*chipWriteFunc)(pmChip*, psFits*, psDB*, bool, bool), // Func for chip
    272                                   bool (*cellWriteFunc)(pmCell*, psFits*, psDB*, bool) // Func for cell
     269                                  pmConfig *config, // Configuration
     270                                  bool (*fpaWriteFunc)(pmFPA*, psFits*, pmConfig*, bool, bool), // Func FPA
     271                                  bool (*chipWriteFunc)(pmChip*, psFits*, pmConfig*, bool, bool),// Func chip
     272                                  bool (*cellWriteFunc)(pmCell*, psFits*, pmConfig*, bool) // Func cell
    273273                                 )
    274274{
     
    283283    switch (pmFPAviewLevel(view)) {
    284284    case PM_FPA_LEVEL_FPA: {
    285             bool success = fpaWriteFunc(fpa, fits, NULL, false, true);
     285            bool success = fpaWriteFunc(fpa, fits, config, false, true);
    286286            psFree(fpa);
    287287            return success;
     
    289289    case PM_FPA_LEVEL_CHIP: {
    290290            pmChip *chip = pmFPAviewThisChip(view, fpa); // Chip of interest
    291             bool success = chipWriteFunc(chip, fits, NULL, false, true);
     291            bool success = chipWriteFunc(chip, fits, config, false, true);
    292292            psFree(fpa);
    293293            return success;
     
    295295    case PM_FPA_LEVEL_CELL: {
    296296            pmCell *cell = pmFPAviewThisCell(view, fpa); // Cell of interest
    297             bool success = cellWriteFunc(cell, fits, NULL, false);
     297            bool success = cellWriteFunc(cell, fits, config, false);
    298298            psFree(fpa);
    299299            return success;
     
    327327}
    328328
    329 bool pmFPAviewWriteFitsImage(const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     329bool pmFPAviewWriteFitsImage(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    330330{
    331331    PS_ASSERT_PTR_NON_NULL(view, false);
     
    334334}
    335335
    336 bool pmFPAviewWriteFitsMask(const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     336bool pmFPAviewWriteFitsMask(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    337337{
    338338    PS_ASSERT_PTR_NON_NULL(view, false);
     
    341341}
    342342
    343 bool pmFPAviewWriteFitsWeight(const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     343bool pmFPAviewWriteFitsWeight(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    344344{
    345345    PS_ASSERT_PTR_NON_NULL(view, false);
     
    348348}
    349349
    350 bool pmFPAviewWriteFitsDark(const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
     350bool pmFPAviewWriteFitsDark(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    351351{
    352352    PS_ASSERT_PTR_NON_NULL(view, false);
  • trunk/psModules/src/camera/pmFPAfileFitsIO.h

    r18139 r18163  
    55 * @author PAP, IfA
    66 *
    7  * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-06-14 03:19:31 $
     7 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2008-06-17 22:16:38 $
    99 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
    1010 */
     
    1919bool pmFPAviewReadFitsImage(const pmFPAview *view, ///< View specifying level of interest
    2020                            pmFPAfile *file, ///< FPA file into which to read
    21                             pmConfig *config
     21                            pmConfig *config
    2222                           );
    2323
     
    2525bool pmFPAviewReadFitsMask(const pmFPAview *view, ///< View specifying level of interest
    2626                           pmFPAfile *file, ///< FPA file into which to read
    27                             pmConfig *config
     27                            pmConfig *config
    2828                          );
    2929/// Read a weight map into the current view
    3030bool pmFPAviewReadFitsWeight(const pmFPAview *view,  ///< View specifying level of interest
    3131                             pmFPAfile *file, ///< FPA file into which to read
    32                             pmConfig *config
     32                            pmConfig *config
    3333                            );
    3434
     
    3636bool pmFPAviewReadFitsDark(const pmFPAview *view,  ///< View specifying level of interest
    3737                           pmFPAfile *file, ///< FPA file into which to read
    38                             pmConfig *config
     38                            pmConfig *config
    3939    );
    4040
     
    4242bool pmFPAviewReadFitsHeaderSet(const pmFPAview *view,  ///< View specifying level of interest
    4343                                pmFPAfile *file, ///< FPA file into which to read
    44                             pmConfig *config
     44                            pmConfig *config
    4545    );
    4646
     
    4848bool pmFPAviewWriteFitsImage(const pmFPAview *view, ///< View specifying level of interest
    4949                             pmFPAfile *file, ///< FPA file to write
    50                              const pmConfig *config ///< Configuration
     50                             pmConfig *config ///< Configuration
    5151                            );
    5252
     
    5454bool pmFPAviewWriteFitsMask(const pmFPAview *view, ///< View specifying level of interest
    5555                            pmFPAfile *file, ///< FPA file to write
    56                             const pmConfig *config ///< Configuration
     56                            pmConfig *config ///< Configuration
    5757                           );
    5858
     
    6060bool pmFPAviewWriteFitsWeight(const pmFPAview *view, ///< View specifying level of interest
    6161                              pmFPAfile *file, ///< FPA file to write
    62                               const pmConfig *config ///< Configuration
     62                              pmConfig *config ///< Configuration
    6363                             );
    6464
     
    6666bool pmFPAviewWriteFitsDark(const pmFPAview *view, ///< View specifying level of interest
    6767                            pmFPAfile *file, ///< FPA file to write
    68                             const pmConfig *config ///< Configuration
     68                            pmConfig *config ///< Configuration
    6969    );
    7070
  • trunk/psModules/src/concepts/pmConcepts.c

    r18104 r18163  
    1010#include <string.h>
    1111
     12#include "pmConfig.h"
    1213#include "pmHDU.h"
    1314#include "pmFPA.h"
     
    195196                         unsigned int *read,     // What's already been read
    196197                         pmConceptSource source, // The source of the concepts to read
    197                          psDB *db,      // Database handle
     198                         pmConfig *config, // Configuration
    198199                         psMetadata *target // Place into which to read the concepts
    199200                        )
     
    256257    #ifdef HAVE_PSDB
    257258    if (source & PM_CONCEPT_SOURCE_DATABASE && !(*read & PM_CONCEPT_SOURCE_DATABASE)) {
    258         if (p_pmConceptsReadFromDatabase(target, *specs, fpa, chip, cell, db)) {
     259        if (p_pmConceptsReadFromDatabase(target, *specs, fpa, chip, cell, config)) {
    259260            *read |= PM_CONCEPT_SOURCE_DATABASE;
    260261        } else {
     
    276277                          const pmCell *cell, // The cell
    277278                          pmConceptSource source, // The source of the concepts to write
    278                           psDB *db,      // Database handle
     279                          pmConfig *config, // Configuration
    279280                          const psMetadata *concepts // The concepts to write out
    280281                         )
     
    299300    }
    300301    if (source & PM_CONCEPT_SOURCE_DATABASE) {
    301         p_pmConceptsWriteToDatabase(*specs, fpa, chip, cell, db, concepts);
     302        p_pmConceptsWriteToDatabase(*specs, fpa, chip, cell, config, concepts);
    302303    }
    303304
     
    306307
    307308
    308 bool pmConceptsRead(pmFPA *fpa, pmChip *chip, pmCell *cell, pmConceptSource source, psDB *db)
     309bool pmConceptsRead(pmFPA *fpa, pmChip *chip, pmCell *cell, pmConceptSource source, pmConfig *config)
    309310{
    310311    PS_ASSERT_PTR_NON_NULL(fpa, false);
    311     bool success = conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db, fpa->concepts);
     312    bool success = conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source,
     313                                config, fpa->concepts);
    312314    if (chip) {
    313         success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db, chip->concepts);
     315        success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source,
     316                                config, chip->concepts);
    314317    }
    315318    if (cell) {
    316         success &= conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, db, cell->concepts);
     319        success &= conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source,
     320                                config, cell->concepts);
    317321    }
    318322
     
    329333
    330334
    331 bool pmConceptsReadFPA(pmFPA *fpa, pmConceptSource source, bool propagateDown, psDB *db)
     335bool pmConceptsReadFPA(pmFPA *fpa, pmConceptSource source, bool propagateDown, pmConfig *config)
    332336{
    333337    PS_ASSERT_PTR_NON_NULL(fpa, false);
    334338    psTrace("psModules.concepts", 5, "Reading FPA concepts: %p %p\n", conceptsFPA, fpa->concepts);
    335     bool success = conceptsRead(&conceptsFPA, fpa, NULL, NULL, &fpa->conceptsRead, source, db, fpa->concepts);
     339    bool success = conceptsRead(&conceptsFPA, fpa, NULL, NULL, &fpa->conceptsRead, source,
     340                                config, fpa->concepts);
    336341    if (propagateDown) {
    337342        psArray *chips = fpa->chips;    // Array of chips
     
    339344            pmChip *chip = chips->data[i]; // Chip of interest
    340345            if (chip) {
    341                 success &= pmConceptsReadChip(chip, source, false, true, db);
     346                success &= pmConceptsReadChip(chip, source, false, true, config);
    342347            }
    343348        }
     
    347352}
    348353
    349 bool pmConceptsWriteFPA(const pmFPA *fpa, pmConceptSource source, bool propagateDown, psDB *db)
     354bool pmConceptsWriteFPA(const pmFPA *fpa, pmConceptSource source, bool propagateDown, pmConfig *config)
    350355{
    351356    PS_ASSERT_PTR_NON_NULL(fpa, false);
    352357    psTrace("psModules.concepts", 5, "Writing FPA concepts: %p %p\n", conceptsFPA, fpa->concepts);
    353     bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
     358    bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source, config, fpa->concepts);
    354359    if (propagateDown) {
    355360        psArray *chips = fpa->chips;        // Array of chips
     
    357362            pmChip *chip = chips->data[i];  // Chip of interest
    358363            if (chip && !chip->hdu) {
    359                 success &= pmConceptsWriteChip(chip, source, false, true, db);
     364                success &= pmConceptsWriteChip(chip, source, false, true, config);
    360365            }
    361366        }
     
    372377
    373378bool pmConceptsReadChip(pmChip *chip, pmConceptSource source, bool propagateUp,
    374                         bool propagateDown, psDB *db)
     379                        bool propagateDown, pmConfig *config)
    375380{
    376381    PS_ASSERT_PTR_NON_NULL(chip, false);
    377382    psTrace("psModules.concepts", 5, "Reading chip concepts: %p %p\n", conceptsChip, chip->concepts);
    378383    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    379     bool success = conceptsRead(&conceptsChip, fpa, chip, NULL, &chip->conceptsRead, source, db,
     384    bool success = conceptsRead(&conceptsChip, fpa, chip, NULL, &chip->conceptsRead, source, config,
    380385                                chip->concepts);
    381386    if (propagateUp) {
    382         success &= conceptsRead(&conceptsFPA, fpa, chip, NULL, &fpa->conceptsRead, source, db, fpa->concepts);
     387        success &= conceptsRead(&conceptsFPA, fpa, chip, NULL, &fpa->conceptsRead, source,
     388                                config, fpa->concepts);
    383389    }
    384390    if (propagateDown) {
     
    387393            pmCell *cell = cells->data[i];  // Cell of interest
    388394            if (cell) {
    389                 success &= pmConceptsReadCell(cell, source, false, db);
     395                success &= pmConceptsReadCell(cell, source, false, config);
    390396            }
    391397        }
     
    395401
    396402bool pmConceptsWriteChip(const pmChip *chip, pmConceptSource source, bool propagateUp,
    397                          bool propagateDown, psDB *db)
     403                         bool propagateDown, pmConfig *config)
    398404{
    399405    PS_ASSERT_PTR_NON_NULL(chip, false);
    400406    psTrace("psModules.concepts", 5, "Writing chip concepts: %p %p\n", conceptsChip, chip->concepts);
    401407    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    402     bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
     408    bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, source, config, chip->concepts);
    403409    if (propagateUp && !fpa->hdu) {
    404         success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, source, db, fpa->concepts);
     410        success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, source, config, fpa->concepts);
    405411    }
    406412    if (propagateDown) {
     
    409415            pmCell *cell = cells->data[i];  // Cell of interest
    410416            if (cell && !cell->hdu) {
    411                 success &= pmConceptsWriteCell(cell, source, false, db);
     417                success &= pmConceptsWriteCell(cell, source, false, config);
    412418            }
    413419        }
     
    423429}
    424430
    425 bool pmConceptsReadCell(pmCell *cell, pmConceptSource source, bool propagateUp, psDB *db)
     431bool pmConceptsReadCell(pmCell *cell, pmConceptSource source, bool propagateUp, pmConfig *config)
    426432{
    427433    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    430436    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    431437
    432     bool success = conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, db,
     438    bool success = conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, config,
    433439                                cell->concepts);
    434440    if (propagateUp) {
    435         success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db,
     441        success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, config,
    436442                                chip->concepts);
    437         success &= conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db,
     443        success &= conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, config,
    438444                                fpa->concepts);
    439445    }
     
    442448}
    443449
    444 bool pmConceptsWriteCell(const pmCell *cell, pmConceptSource source, bool propagateUp, psDB *db)
     450bool pmConceptsWriteCell(const pmCell *cell, pmConceptSource source, bool propagateUp, pmConfig *config)
    445451{
    446452    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    449455    pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
    450456
    451     bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, source, db, cell->concepts);
     457    bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, source, config, cell->concepts);
    452458    if (propagateUp) {
    453459        if (!chip->hdu) {
    454             success &= conceptsWrite(&conceptsChip, fpa, chip, cell, source, db, chip->concepts);
     460            success &= conceptsWrite(&conceptsChip, fpa, chip, cell, source, config, chip->concepts);
    455461            if (!fpa->hdu) {
    456                 success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, source, db, fpa->concepts);
     462                success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, source, config, fpa->concepts);
    457463            }
    458464        }
  • trunk/psModules/src/concepts/pmConcepts.h

    r17911 r18163  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2008-06-05 01:31:33 $
     6 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-06-17 22:16:38 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    1111#ifndef PM_CONCEPTS_H
    1212#define PM_CONCEPTS_H
     13
     14#include <pmConfig.h>
    1315
    1416/// @addtogroup Concepts Data Abstraction Concepts
     
    105107                    pmCell *cell,       ///< Cell for which to read concepts, or NULL
    106108                    pmConceptSource source, ///< The source of the concepts to read
    107                     psDB *db            ///< Database handle
     109                    pmConfig *config    ///< Configuration
    108110                   );
    109111
     
    120122                       pmConceptSource source, ///< Source for concepts
    121123                       bool propagateDown, ///< Propagate to lower levels?
    122                        psDB *db         ///< Database handle
     124                       pmConfig *config         ///< Configuration
    123125                      );
    124126
     
    130132                        pmConceptSource source, ///< Source for concepts
    131133                        bool propagateDown, ///< Propagate to lower levels?
    132                         psDB *db        ///< Database handle
     134                        pmConfig *config        ///< Configuration
    133135                       );
    134136
     
    146148                        bool propagateUp, ///< Propagate to higher levels?
    147149                        bool propagateDown, ///< Propagate to lower levels?
    148                         psDB *db        ///< Database handle
     150                        pmConfig *config        ///< Configuration
    149151                       );
    150152
     
    157159                         bool propagateUp,///< Propagate to higher levels?
    158160                         bool propagateDown, ///< Propagate to lower levels?
    159                          psDB *db       ///< Database handle
     161                         pmConfig *config       ///< Configuration
    160162                        );
    161163
     
    172174                        pmConceptSource source, ///< Source for concepts
    173175                        bool propagateUp, ///< Propagate to higher levels?
    174                         psDB *db        ///< Database handle
     176                        pmConfig *config        ///< Configuration
    175177                       );
    176178
     
    183185                         pmConceptSource source, ///< Source for concepts
    184186                         bool propagateUp, ///< Propagate to higher levels?
    185                          psDB *db       ///< Database handle
     187                         pmConfig *config ///< Configuration
    186188                        );
    187189
  • trunk/psModules/src/concepts/pmConceptsRead.c

    r17911 r18163  
    99#include <pslib.h>
    1010
     11#include "pmConfig.h"
    1112#include "pmHDU.h"
    1213#include "pmFPA.h"
     
    363364}
    364365
    365 psMetadataItem *p_pmConceptsReadSingleFromDatabase(const char *name, const psMetadata *database, psDB *db,
    366                                                    const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
     366psMetadataItem *p_pmConceptsReadSingleFromDatabase(const char *name, const psMetadata *database,
     367                                                   pmConfig *config, const pmFPA *fpa, const pmChip *chip,
     368                                                   const pmCell *cell)
    367369{
    368370    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
    369     PS_ASSERT_METADATA_NON_NULL(database, NULL);
     371    PS_ASSERT_PTR_NON_NULL(config, NULL);
     372
     373    psDB *db = pmConfigDB(config);      // Database handle
     374    if (!db) {
     375        psErrorClear();
     376        psWarning("Unable to initialise database to write concepts.");
     377        return NULL;
     378    }
    370379
    371380    psMetadataItem *item = psMetadataLookup(database, name); // Item to return
     
    384393
    385394    psString sql = pmConceptsInterpolate(item->data.str, fpa, chip, cell);
    386     if (!p_psDBRunQuery(db, sql)) {
     395    if (!p_psDBRunQuery(config->database, sql)) {
    387396        psWarning("Unable to query database for concept %s --- ignored.", name);
    388397        psFree(sql);
     
    391400    psFree(sql);
    392401
    393     psArray *rows = p_psDBFetchResult(db); // Rows returned from the query
     402    psArray *rows = p_psDBFetchResult(config->database); // Rows returned from the query
    394403    if (rows->n == 0) {
    395404        psWarning("No rows returned from database query for concept %s --- ignored.", name);
     
    408417
    409418bool p_pmConceptsReadFromDatabase(psMetadata *target, const psMetadata *specs,
    410                                   const pmFPA *fpa, const pmChip *chip, const pmCell *cell, psDB *db)
     419                                  const pmFPA *fpa, const pmChip *chip, const pmCell *cell, pmConfig *config)
    411420{
    412421    PS_ASSERT_PTR_NON_NULL(specs, false);
    413422    PS_ASSERT_PTR_NON_NULL(target, false);
     423    PS_ASSERT_PTR_NON_NULL(config, false);
    414424
    415425#ifndef HAVE_PSDB
     
    434444        pmConceptSpec *spec = specItem->data.V; // The specification
    435445        psString name = specItem->name; // The concept name
    436         psMetadataItem *conceptItem = p_pmConceptsReadSingleFromDatabase(name, dbSpec, db, fpa, chip, cell);
     446        psMetadataItem *conceptItem = p_pmConceptsReadSingleFromDatabase(name, dbSpec, config,
     447                                                                         fpa, chip, cell);
    437448        if (conceptItem && !conceptParse(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE,
    438449                                         cameraFormat, target, fpa, chip, cell)) {
  • trunk/psModules/src/concepts/pmConceptsRead.h

    r17911 r18163  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2008-06-05 01:31:33 $
     6 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-06-17 22:16:38 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    6262    const char *name,                   ///< Name of concept
    6363    const psMetadata *database,         ///< DATABASE specification
    64     psDB *db,                           ///< Database handle
     64    pmConfig *config,                   ///< Configuration
    6565    const pmFPA *fpa,                   ///< The FPA
    6666    const pmChip *chip,                 ///< The chip, or NULL
     
    7272/// Examines the DATABASE metadata in the camera format file
    7373/// for concepts in the specs, and imports them into the target.
    74 /// WARNING: This function has not been tested; use at your own risk!
    7574bool p_pmConceptsReadFromDatabase(psMetadata *target, // Place into which to read the concepts
    7675                                  const psMetadata *specs, // The concept specifications
     
    7877                                  const pmChip *chip, // The chip
    7978                                  const pmCell *cell,  // The cell
    80                                   psDB *db // The database handle
     79                                  pmConfig *config // Configuration
    8180                                 );
    8281/// @}
  • trunk/psModules/src/concepts/pmConceptsWrite.c

    r17911 r18163  
    99#include <pslib.h>
    1010
     11#include "pmConfig.h"
    1112#include "pmHDU.h"
    1213#include "pmFPA.h"
     
    427428// XXX Warning: This code has not been tested at all
    428429bool p_pmConceptsWriteToDatabase(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip,
    429                                  const pmCell *cell, psDB *db, const psMetadata *concepts)
     430                                 const pmCell *cell, pmConfig *config, const psMetadata *concepts)
    430431{
    431432    PS_ASSERT_PTR_NON_NULL(specs, false);
    432433    PS_ASSERT_PTR_NON_NULL(concepts, false);
    433 
    434     if (!db) {
    435         return false;
    436     }
     434    PS_ASSERT_PTR_NON_NULL(config, false);
    437435
    438436    #ifndef HAVE_PSDB
     
    456454        psString name = specItem->name; // The concept name
    457455
    458         psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(name, database, db, fpa, chip, cell);
     456        psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(name, database, config, fpa, chip, cell);
    459457        if (!dbItem) {
    460458            continue;
  • trunk/psModules/src/concepts/pmConceptsWrite.h

    r12696 r18163  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-03-30 21:12:56 $
     6 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-06-17 22:16:38 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    5555                                 const pmChip *chip, ///< The chip
    5656                                 const pmCell *cell, ///< The cell
    57                                  psDB *db,///< The database handle
     57                                 pmConfig *config,///< Configuration
    5858                                 const psMetadata *concepts ///< The concepts
    5959                                );
  • trunk/psModules/src/config/pmConfig.c

    r18073 r18163  
    12971297    #else
    12981298
     1299    if (config->database) {
     1300        return config->database;
     1301    }
     1302
    12991303    psBool mdStatus01 = false;
    13001304    psBool mdStatus02 = false;
     
    13221326    }
    13231327
    1324     return psDBInit(dbServer, dbUsername, dbPassword, dbName, dbPort);
     1328    config->database = psDBInit(dbServer, dbUsername, dbPassword, dbName, dbPort);
     1329    return config->database;
    13251330    #endif
    13261331}
  • trunk/psModules/src/detrend/pmDark.c

    r18132 r18163  
    2525// Look up the value of an ordinate in a readout
    2626static bool ordinateLookup(float *value, // Value of ordinate, to return
    27                            bool *inRange, // is value within min : max range?
     27                           bool *inRange, // is value within min : max range?
    2828                           const char *name, // Name of ordinate (concept name)
    2929                           bool scale,  // Scale the value?
     
    7070        if (*value < min || *value > max) {
    7171            psWarning("Value of concept %s (%f) outside range (%f:%f)", name, *value, min, max);
    72             *inRange = false;
     72            *inRange = false;
    7373        }
    7474        *value = 2.0 * (*value - min) / (max - min) - 1.0;
     
    175175                continue;
    176176            }
    177             if (!inRange) {
     177            if (!inRange) {
    178178                roMask->data.U8[j] = 0xff;
    179179                val->data.F32[i] = NAN;
     
    282282                    mask->data.PS_TYPE_MASK_DATA[r] = readout->mask->data.PS_TYPE_MASK_DATA[yIn][xIn];
    283283                }
    284            
    285             }
    286 
    287             // XXX test
    288             if (0 && (i == 377) && (j == 80)) {
    289                 FILE *f = fopen ("test.dat", "w");     
    290                 for (int r = 0; r < inputs->n; r++) {
    291                     fprintf (f, "%d %d  %d  ", i, j, mask->data.U8[r]);
    292                     psVector *value = values->data[r];
    293                     for (int tmpj = 0; tmpj < value->n; tmpj++) {
    294                         fprintf (f, "%f ", value->data.F32[tmpj]);
    295                     }
    296                     fprintf (f, "%f\n", pixels->data.F32[r]);
    297                 }
    298                 fclose (f);
    299             }
     284
     285            }
     286
     287            // XXX test
     288            if (0 && (i == 377) && (j == 80)) {
     289                FILE *f = fopen ("test.dat", "w");
     290                for (int r = 0; r < inputs->n; r++) {
     291                    fprintf (f, "%d %d  %d  ", i, j, mask->data.U8[r]);
     292                    psVector *value = values->data[r];
     293                    for (int tmpj = 0; tmpj < value->n; tmpj++) {
     294                        fprintf (f, "%f ", value->data.F32[tmpj]);
     295                    }
     296                    fprintf (f, "%f\n", pixels->data.F32[r]);
     297                }
     298                fclose (f);
     299            }
    300300
    301301            if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, maskVal, values, iter, rej)) {
     
    426426}
    427427
    428 bool pmFPAWriteDark(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
     428bool pmFPAWriteDark(pmFPA *fpa, psFits *fits, pmConfig *config, bool blank, bool recurse)
    429429{
    430430    PS_ASSERT_PTR_NON_NULL(fpa, false);
    431431    PS_ASSERT_FITS_NON_NULL(fits, false);
    432432
    433     if (!pmFPAWrite(fpa, fits, db, blank, recurse)) {
     433    if (!pmFPAWrite(fpa, fits, config, blank, recurse)) {
    434434        psError(PS_ERR_IO, false, "Unable to write FPA dark images");
    435435        return false;
     
    481481}
    482482
    483 bool pmChipWriteDark(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
     483bool pmChipWriteDark(pmChip *chip, psFits *fits, pmConfig *config, bool blank, bool recurse)
    484484{
    485485    PS_ASSERT_PTR_NON_NULL(chip, false);
    486486    PS_ASSERT_FITS_NON_NULL(fits, false);
    487487
    488     if (!pmChipWrite(chip, fits, db, blank, recurse)) {
     488    if (!pmChipWrite(chip, fits, config, blank, recurse)) {
    489489        psError(PS_ERR_IO, false, "Unable to write chip dark images");
    490490        return false;
     
    532532}
    533533
    534 bool pmCellWriteDark(pmCell *cell, psFits *fits, psDB *db, bool blank)
     534bool pmCellWriteDark(pmCell *cell, psFits *fits, pmConfig *config, bool blank)
    535535{
    536536    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    538538
    539539    // Allow the usual pmFPAWrite functions to handle the heavy lifting for the images
    540     if (!pmCellWrite(cell, fits, db, blank)) {
     540    if (!pmCellWrite(cell, fits, config, blank)) {
    541541        psError(PS_ERR_UNKNOWN, false, "Unable to write dark cell.");
    542542        return false;
     
    623623
    624624
    625 bool pmFPAReadDark(pmFPA *fpa, psFits *fits, psDB *db)
     625bool pmFPAReadDark(pmFPA *fpa, psFits *fits, pmConfig *config)
    626626{
    627627    PS_ASSERT_PTR_NON_NULL(fpa, false);
    628628    PS_ASSERT_FITS_NON_NULL(fits, false);
    629629
    630     if (!pmFPARead(fpa, fits, db)) {
     630    if (!pmFPARead(fpa, fits, config)) {
    631631        psError(PS_ERR_UNKNOWN, false, "Unable to read dark FPA.");
    632632        return false;
     
    658658}
    659659
    660 bool pmChipReadDark(pmChip *chip, psFits *fits, psDB *db)
     660bool pmChipReadDark(pmChip *chip, psFits *fits, pmConfig *config)
    661661{
    662662    PS_ASSERT_PTR_NON_NULL(chip, false);
    663663    PS_ASSERT_FITS_NON_NULL(fits, false);
    664664
    665     if (!pmChipRead(chip, fits, db)) {
     665    if (!pmChipRead(chip, fits, config)) {
    666666        psError(PS_ERR_UNKNOWN, false, "Unable to read dark chip.");
    667667        return false;
     
    690690
    691691
    692 bool pmCellReadDark(pmCell *cell, psFits *fits, psDB *db)
     692bool pmCellReadDark(pmCell *cell, psFits *fits, pmConfig *config)
    693693{
    694694    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    696696
    697697    // Allow the usual pmFPARead functions to handle the heavy lifting for the images
    698     if (!pmCellRead(cell, fits, db)) {
     698    if (!pmCellRead(cell, fits, config)) {
    699699        psError(PS_ERR_UNKNOWN, false, "Unable to read dark cell.");
    700700        return false;
  • trunk/psModules/src/detrend/pmDark.h

    r16949 r18163  
    55#include <pmHDU.h>
    66#include <pmFPA.h>
     7#include <pmConfig.h>
    78
    89#define PM_DARK_ANALYSIS_ORDINATES "DARK.ORDINATES" // Name for dark ordinates in the cell analysis metadata
     
    4546bool pmFPAWriteDark(pmFPA *fpa,         // FPA to write
    4647                    psFits *fits,       // FITS file to which to write
    47                     psDB *db,           // Database, for concepts
     48                    pmConfig *config,   // Configuration
    4849                    bool blank,         // Write a blank only?
    4950                    bool recurse        // Recurse to lower levels?
     
    5354bool pmChipWriteDark(pmChip *chip,      // Chip to write
    5455                     psFits *fits,      // FITS file to which to write
    55                      psDB *db,          // Database, for concepts
     56                     pmConfig *config,  // Configuration
    5657                     bool blank,        // Write a blank only?
    5758                     bool recurse       // Recurse to lower levels?
     
    6162bool pmCellWriteDark(pmCell *cell,      // Cell containing dark information
    6263                     psFits *fits,      // FITS file to which to write
    63                      psDB *db,          // Database, for concepts
     64                     pmConfig *config,  // Configuration
    6465                     bool blank         // Write a blank only?
    6566    );
     
    6869bool pmFPAReadDark(pmFPA *fpa,          // FPA for which to read
    6970                   psFits *fits,        // FITS file to read
    70                    psDB *db             // Database, for concepts
     71                   pmConfig *config     // Configuration
    7172    );
    7273
     
    7475bool pmChipReadDark(pmChip *chip,       // Chip for which to read
    7576                    psFits *fits,       // FITS file to read
    76                     psDB *db            // Database, for concepts
     77                    pmConfig *config    // Configuration
    7778    );
    7879
     
    8081bool pmCellReadDark(pmCell *cell,       // Cell for which to read
    8182                    psFits *fits,       // FITS file to read
    82                     psDB *db            // Database, for concepts
     83                    pmConfig *config    // Configuration
    8384    );
    8485
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r18043 r18163  
    44 *  @author GLG, MHPCC
    55 *
    6  *  @version $Revision: 1.93 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2008-06-10 02:43:01 $
     6 *  @version $Revision: 1.94 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2008-06-17 22:16:38 $
    88 *
    99 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    627627}
    628628
     629
     630float pmSubtractionVarianceFactor(const pmSubtractionKernels *kernels, float x, float y, bool wantDual)
     631{
     632    PM_ASSERT_SUBTRACTION_KERNELS_NON_NULL(kernels, NAN);
     633    PM_ASSERT_SUBTRACTION_KERNELS_SOLUTION(kernels, NAN);
     634    PS_ASSERT_FLOAT_WITHIN_RANGE(x, -1.0, 1.0, NAN);
     635    PS_ASSERT_FLOAT_WITHIN_RANGE(y, -1.0, 1.0, NAN);
     636
     637    // Precalulate polynomial values
     638    psImage *polyValues = p_pmSubtractionPolynomial(NULL, kernels->spatialOrder, x, y);
     639
     640    psKernel *kernel = solvedKernel(NULL, kernels, polyValues, wantDual); // The appropriate kernel
     641    psFree(polyValues);
     642
     643    double sumKernel2 = 0.0;            // Sum of the kernel squared
     644    for (int y = kernel->yMin; y <= kernel->yMax; y++) {
     645        for (int x = kernel->xMin; x <= kernel->xMax; x++) {
     646            sumKernel2 += PS_SQR(kernel->kernel[y][x]);
     647        }
     648    }
     649
     650    psFree(kernel);
     651
     652    return sumKernel2;
     653}
     654
    629655#if 0
    630656psArray *pmSubtractionKernelSolutions(const pmSubtractionKernels *kernels, float x, float y, bool wantDual)
Note: See TracChangeset for help on using the changeset viewer.