IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19007


Ignore:
Timestamp:
Aug 11, 2008, 11:55:25 AM (18 years ago)
Author:
Paul Price
Message:

Allow correction for fortran style (unit indexed) numbering. This is
important for the SDSS Mosaic camera configuration.

File:
1 edited

Legend:

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

    r19005 r19007  
    1313#include "pmHDU.h"
    1414#include "pmFPA.h"
     15#include "pmHDUUtils.h"
    1516#include "pmFPALevel.h"
    1617#include "pmFPAview.h"
     
    182183    newName = psStringCopy(rule);
    183184
    184     if (strstr (newName, "{FPA.OBS}") != NULL) {
    185         char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.OBS");
    186         if (name != NULL) {
     185    if (strstr(newName, "{FPA.OBS}")) {
     186        char *name = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS");
     187        if (name) {
    187188            psStringSubstitute(&newName, name, "{FPA.OBS}");
    188189        }
    189190    }
    190     if (strstr (newName, "{FPA.NAME}") != NULL) {
    191         char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.NAME");
    192         if (name != NULL) {
     191    if (strstr(newName, "{FPA.NAME}")) {
     192        char *name = psMetadataLookupStr(NULL, fpa->concepts, "FPA.NAME");
     193        if (name) {
    193194            psStringSubstitute(&newName, name, "{FPA.NAME}");
    194195        }
    195196    }
    196     if (strstr (newName, "{CHIP.NAME}") != NULL) {
    197         pmChip *chip = pmFPAviewThisChip (view, fpa);
    198         if (chip != NULL) {
    199             char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
    200             if (name != NULL) {
     197    if (strstr(newName, "{CHIP.NAME}")) {
     198        pmChip *chip = pmFPAviewThisChip(view, fpa);
     199        if (chip) {
     200            char *name = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
     201            if (name) {
    201202                psStringSubstitute(&newName, name, "{CHIP.NAME}");
    202203            }
    203204        }
    204205    }
    205     if (strstr (newName, "{CHIP.ID}") != NULL) {
    206         pmChip *chip = pmFPAviewThisChip (view, fpa);
    207         if (chip != NULL) {
    208             char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.ID");
    209             if (name != NULL) {
     206    if (strstr(newName, "{CHIP.ID}")) {
     207        pmChip *chip = pmFPAviewThisChip(view, fpa);
     208        if (chip) {
     209            char *name = psMetadataLookupStr(NULL, chip->concepts, "CHIP.ID");
     210            if (name) {
    210211                psStringSubstitute(&newName, name, "{CHIP.ID}");
    211212            }
    212213        }
    213214    }
    214     if (strstr (newName, "{CHIP.N}") != NULL) {
     215    if (strstr(newName, "{CHIP.N}")) {
    215216        char *name = NULL;
    216217        if (view->chip < 0) {
    217             psStringAppend (&name, "XX");
     218            psStringAppend(&name, "XX");
    218219        } else {
    219             psStringAppend (&name, "%02d", view->chip);
     220            psStringAppend(&name, "%02d", view->chip);
    220221        }
    221222        psStringSubstitute(&newName, name, "{CHIP.N}");
    222         psFree (name);
    223     }
    224     if (strstr (newName, "{CHIP.NUM}") != NULL) {
     223        psFree(name);
     224    }
     225    if (strstr(newName, "{CHIP.NUM}")) {
    225226        char *name = NULL;
    226227        if (view->chip < 0) {
    227             psStringAppend (&name, "XX");
     228            psStringAppend(&name, "XX");
    228229        } else {
    229             psStringAppend (&name, "%d", view->chip);
     230            int chipNum = view->chip;   // Number of chip
     231            // Potential correction for fortran (unit-indexed) numbering
     232            pmChip *chip = pmFPAviewThisChip(view, fpa); // Chip of interest
     233            pmHDU *hdu = pmHDUFromChip(chip); // Corresponding HDU
     234            bool mdok;                  // Status of MD lookup
     235            psMetadata *formats = psMetadataLookupMetadata(&mdok, hdu->format, "FORMATS"); // Special formats
     236            if (mdok && formats) {
     237                const char *format = psMetadataLookupStr(&mdok, formats, "CHIP.NUM"); // Format for CHIP.NUM
     238                if (mdok && format && strcmp(format, "FORTRAN") == 0) {
     239                    chipNum++;
     240                }
     241            }
     242            psStringAppend(&name, "%d", chipNum);
    230243        }
    231244        psStringSubstitute(&newName, name, "{CHIP.NUM}");
    232         psFree (name);
    233     }
    234     if (strstr (newName, "{CELL.NAME}") != NULL) {
    235         pmCell *cell = pmFPAviewThisCell (view, fpa);
    236         if (cell != NULL) {
    237             char *name = psMetadataLookupStr (NULL, cell->concepts, "CELL.NAME");
    238             if (name != NULL) {
     245        psFree(name);
     246    }
     247    if (strstr(newName, "{CELL.NAME}")) {
     248        pmCell *cell = pmFPAviewThisCell(view, fpa);
     249        if (cell) {
     250            char *name = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
     251            if (name) {
    239252                psStringSubstitute(&newName, name, "{CELL.NAME}");
    240253            }
    241254        }
    242255    }
    243     if (strstr (newName, "{CELL.N}") != NULL) {
     256    if (strstr(newName, "{CELL.N}")) {
    244257        char *name = NULL;
    245258        if (view->cell < 0) {
    246             psStringAppend (&name, "XX");
     259            psStringAppend(&name, "XX");
    247260        } else {
    248             psStringAppend (&name, "%02d", view->cell);
     261            psStringAppend(&name, "%02d", view->cell);
    249262        }
    250263        psStringSubstitute(&newName, name, "{CELL.N}");
    251264    }
    252     if (strstr (newName, "{CELL.NUM}") != NULL) {
     265    if (strstr(newName, "{CELL.NUM}")) {
    253266        char *name = NULL;
    254267        if (view->cell < 0) {
    255             psStringAppend (&name, "XX");
     268            psStringAppend(&name, "XX");
    256269        } else {
    257             psStringAppend (&name, "%d", view->cell);
     270            int cellNum = view->cell;   // Number of cell
     271            // Potential correction for fortran (unit-indexed) numbering
     272            pmCell *cell = pmFPAviewThisCell(view, fpa); // Cell of interest
     273            pmHDU *hdu = pmHDUFromCell(cell); // Corresponding HDU
     274            bool mdok;                  // Status of MD lookup
     275            psMetadata *formats = psMetadataLookupMetadata(&mdok, hdu->format, "FORMATS"); // Special formats
     276            if (mdok && formats) {
     277                const char *format = psMetadataLookupStr(&mdok, formats, "CELL.NUM"); // Format for CELL.NUM
     278                if (mdok && format && strcmp(format, "FORTRAN") == 0) {
     279                    cellNum++;
     280                }
     281            }
     282            psStringAppend(&name, "%d", cellNum);
    258283        }
    259284        psStringSubstitute(&newName, name, "{CELL.NUM}");
    260285    }
    261     if (strstr (newName, "{EXTNAME}") != NULL) {
    262         pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
     286    if (strstr(newName, "{EXTNAME}")) {
     287        pmHDU *hdu = pmFPAviewThisHDU(view, fpa);
    263288        if (hdu->extname && *hdu->extname) {
    264289            psStringSubstitute(&newName, hdu->extname, "{EXTNAME}");
    265290        }
    266291    }
    267     if (strstr (newName, "{FILTER}") != NULL) {
    268         if (fpa != NULL) {
    269             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTER");
    270             if (name && *name) {
    271                 psStringSubstitute(&newName, name, "{FILTER}");
    272             }
    273         }
    274     }
    275     if (strstr (newName, "{FILTER.ID}") != NULL) {
    276         if (fpa != NULL) {
    277             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTERID");
    278             if (name && *name) {
    279                 psStringSubstitute(&newName, name, "{FILTER.ID}");
    280             }
    281         }
    282     }
    283     if (strstr (newName, "{CAMERA}") != NULL) {
    284         if (fpa != NULL) {
    285             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT");
    286             if (name && *name) {
    287                 psStringSubstitute(&newName, name, "{CAMERA}");
    288             }
    289         }
    290     }
    291     if (strstr (newName, "{INSTRUMENT}") != NULL) {
    292         if (fpa != NULL) {
    293             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT");
    294             if (name && *name) {
    295                 psStringSubstitute(&newName, name, "{INSTRUMENT}");
    296             }
    297         }
    298     }
    299     if (strstr (newName, "{DETECTOR}") != NULL) {
    300         if (fpa != NULL) {
    301             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.DETECTOR");
    302             if (name && *name) {
    303                 psStringSubstitute(&newName, name, "{DETECTOR}");
    304             }
    305         }
    306     }
    307     if (strstr (newName, "{TELESCOPE}") != NULL) {
    308         if (fpa != NULL) {
    309             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.TELESCOPE");
    310             if (name && *name) {
    311                 psStringSubstitute(&newName, name, "{TELESCOPE}");
    312             }
     292    if (strstr(newName, "{FILTER}") && fpa) {
     293        char *name = psMetadataLookupStr(NULL, fpa->concepts, "FPA.FILTER");
     294        if (name && *name) {
     295            psStringSubstitute(&newName, name, "{FILTER}");
     296        }
     297    }
     298    if (strstr(newName, "{FILTER.ID}") && fpa) {
     299        char *name = psMetadataLookupStr(NULL, fpa->concepts, "FPA.FILTERID");
     300        if (name && *name) {
     301            psStringSubstitute(&newName, name, "{FILTER.ID}");
     302        }
     303    }
     304    if (strstr(newName, "{CAMERA}") && fpa) {
     305        char *name = psMetadataLookupStr(NULL, fpa->concepts, "FPA.INSTRUMENT");
     306        if (name && *name) {
     307            psStringSubstitute(&newName, name, "{CAMERA}");
     308        }
     309    }
     310    if (strstr(newName, "{INSTRUMENT}") && fpa) {
     311        char *name = psMetadataLookupStr(NULL, fpa->concepts, "FPA.INSTRUMENT");
     312        if (name && *name) {
     313            psStringSubstitute(&newName, name, "{INSTRUMENT}");
     314        }
     315    }
     316    if (strstr(newName, "{DETECTOR}") && fpa) {
     317        char *name = psMetadataLookupStr(NULL, fpa->concepts, "FPA.DETECTOR");
     318        if (name && *name) {
     319            psStringSubstitute(&newName, name, "{DETECTOR}");
     320        }
     321    }
     322    if (strstr(newName, "{TELESCOPE}") && fpa) {
     323        char *name = psMetadataLookupStr(NULL, fpa->concepts, "FPA.TELESCOPE");
     324        if (name && *name) {
     325            psStringSubstitute(&newName, name, "{TELESCOPE}");
    313326        }
    314327    }
Note: See TracChangeset for help on using the changeset viewer.