IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Adding CHIP.NUM and CELL.NUM replacements in pmFPANameFromRule to
print the chip/cell number without the requirement of two digits.

File:
1 edited

Legend:

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

    r17987 r19005  
    2222{
    2323    if (!file) {
    24         return;
     24        return;
    2525    }
    2626
     
    3838
    3939    if (file->fits != NULL) {
    40         psFitsClose (file->fits);
     40        psFitsClose (file->fits);
    4141    }
    4242    psFree(file->compression);
     
    113113    pmFPAfile *file = psMetadataLookupPtr (&status, files, name);
    114114    if (file == NULL) {
    115         return NULL;
     115        return NULL;
    116116    }
    117117
    118118    // internal files have the readout as a separate element:
    119119    if (file->mode == PM_FPA_MODE_INTERNAL) {
    120         return file->readout;
     120        return file->readout;
    121121    }
    122122
     
    137137    pmFPAfile *file = psMetadataLookupPtr (&status, files, name);
    138138    if (file == NULL) {
    139         return NULL;
     139        return NULL;
    140140    }
    141141
    142142    // internal files have the readout as a separate element:
    143143    if (file->mode == PM_FPA_MODE_INTERNAL) {
    144         return NULL;
     144        return NULL;
    145145    }
    146146
     
    161161    pmFPAfile *file = psMetadataLookupPtr (&status, files, name);
    162162    if (file == NULL) {
    163         return NULL;
     163        return NULL;
    164164    }
    165165
    166166    // internal files have the readout as a separate element:
    167167    if (file->mode == PM_FPA_MODE_INTERNAL) {
    168         return NULL;
     168        return NULL;
    169169    }
    170170
     
    183183
    184184    if (strstr (newName, "{FPA.OBS}") != NULL) {
    185         char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.OBS");
    186         if (name != NULL) {
    187             psStringSubstitute(&newName, name, "{FPA.OBS}");
    188         }
     185        char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.OBS");
     186        if (name != NULL) {
     187            psStringSubstitute(&newName, name, "{FPA.OBS}");
     188        }
    189189    }
    190190    if (strstr (newName, "{FPA.NAME}") != NULL) {
    191         char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.NAME");
    192         if (name != NULL) {
    193             psStringSubstitute(&newName, name, "{FPA.NAME}");
    194         }
     191        char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.NAME");
     192        if (name != NULL) {
     193            psStringSubstitute(&newName, name, "{FPA.NAME}");
     194        }
    195195    }
    196196    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) {
    201                 psStringSubstitute(&newName, name, "{CHIP.NAME}");
    202             }
    203         }
     197        pmChip *chip = pmFPAviewThisChip (view, fpa);
     198        if (chip != NULL) {
     199            char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     200            if (name != NULL) {
     201                psStringSubstitute(&newName, name, "{CHIP.NAME}");
     202            }
     203        }
    204204    }
    205205    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) {
    210                 psStringSubstitute(&newName, name, "{CHIP.ID}");
    211             }
    212         }
     206        pmChip *chip = pmFPAviewThisChip (view, fpa);
     207        if (chip != NULL) {
     208            char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.ID");
     209            if (name != NULL) {
     210                psStringSubstitute(&newName, name, "{CHIP.ID}");
     211            }
     212        }
    213213    }
    214214    if (strstr (newName, "{CHIP.N}") != NULL) {
    215         char *name = NULL;
    216         if (view->chip < 0) {
    217             psStringAppend (&name, "XX");
    218         } else {
    219             psStringAppend (&name, "%02d", view->chip);
    220         }
    221         psStringSubstitute(&newName, name, "{CHIP.N}");
    222         psFree (name);
     215        char *name = NULL;
     216        if (view->chip < 0) {
     217            psStringAppend (&name, "XX");
     218        } else {
     219            psStringAppend (&name, "%02d", view->chip);
     220        }
     221        psStringSubstitute(&newName, name, "{CHIP.N}");
     222        psFree (name);
     223    }
     224    if (strstr (newName, "{CHIP.NUM}") != NULL) {
     225        char *name = NULL;
     226        if (view->chip < 0) {
     227            psStringAppend (&name, "XX");
     228        } else {
     229            psStringAppend (&name, "%d", view->chip);
     230        }
     231        psStringSubstitute(&newName, name, "{CHIP.NUM}");
     232        psFree (name);
    223233    }
    224234    if (strstr (newName, "{CELL.NAME}") != NULL) {
    225         pmCell *cell = pmFPAviewThisCell (view, fpa);
    226         if (cell != NULL) {
    227             char *name = psMetadataLookupStr (NULL, cell->concepts, "CELL.NAME");
    228             if (name != NULL) {
    229                 psStringSubstitute(&newName, name, "{CELL.NAME}");
    230             }
    231         }
     235        pmCell *cell = pmFPAviewThisCell (view, fpa);
     236        if (cell != NULL) {
     237            char *name = psMetadataLookupStr (NULL, cell->concepts, "CELL.NAME");
     238            if (name != NULL) {
     239                psStringSubstitute(&newName, name, "{CELL.NAME}");
     240            }
     241        }
    232242    }
    233243    if (strstr (newName, "{CELL.N}") != NULL) {
    234         char *name = NULL;
    235         if (view->cell < 0) {
    236             psStringAppend (&name, "XX");
    237         } else {
    238             psStringAppend (&name, "%02d", view->cell);
    239         }
    240         psStringSubstitute(&newName, name, "{CELL.N}");
     244        char *name = NULL;
     245        if (view->cell < 0) {
     246            psStringAppend (&name, "XX");
     247        } else {
     248            psStringAppend (&name, "%02d", view->cell);
     249        }
     250        psStringSubstitute(&newName, name, "{CELL.N}");
     251    }
     252    if (strstr (newName, "{CELL.NUM}") != NULL) {
     253        char *name = NULL;
     254        if (view->cell < 0) {
     255            psStringAppend (&name, "XX");
     256        } else {
     257            psStringAppend (&name, "%d", view->cell);
     258        }
     259        psStringSubstitute(&newName, name, "{CELL.NUM}");
    241260    }
    242261    if (strstr (newName, "{EXTNAME}") != NULL) {
    243         pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
    244         if (hdu->extname && *hdu->extname) {
    245             psStringSubstitute(&newName, hdu->extname, "{EXTNAME}");
    246         }
     262        pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
     263        if (hdu->extname && *hdu->extname) {
     264            psStringSubstitute(&newName, hdu->extname, "{EXTNAME}");
     265        }
    247266    }
    248267    if (strstr (newName, "{FILTER}") != NULL) {
    249         if (fpa != NULL) {
    250             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTER");
    251             if (name && *name) {
    252                 psStringSubstitute(&newName, name, "{FILTER}");
    253             }
    254         }
     268        if (fpa != NULL) {
     269            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTER");
     270            if (name && *name) {
     271                psStringSubstitute(&newName, name, "{FILTER}");
     272            }
     273        }
    255274    }
    256275    if (strstr (newName, "{FILTER.ID}") != NULL) {
    257         if (fpa != NULL) {
    258             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTERID");
    259             if (name && *name) {
    260                 psStringSubstitute(&newName, name, "{FILTER.ID}");
    261             }
    262         }
     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        }
    263282    }
    264283    if (strstr (newName, "{CAMERA}") != NULL) {
    265         if (fpa != NULL) {
    266             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT");
    267             if (name && *name) {
    268                 psStringSubstitute(&newName, name, "{CAMERA}");
    269             }
    270         }
     284        if (fpa != NULL) {
     285            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT");
     286            if (name && *name) {
     287                psStringSubstitute(&newName, name, "{CAMERA}");
     288            }
     289        }
    271290    }
    272291    if (strstr (newName, "{INSTRUMENT}") != NULL) {
    273         if (fpa != NULL) {
    274             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT");
    275             if (name && *name) {
    276                 psStringSubstitute(&newName, name, "{INSTRUMENT}");
    277             }
    278         }
     292        if (fpa != NULL) {
     293            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT");
     294            if (name && *name) {
     295                psStringSubstitute(&newName, name, "{INSTRUMENT}");
     296            }
     297        }
    279298    }
    280299    if (strstr (newName, "{DETECTOR}") != NULL) {
    281         if (fpa != NULL) {
    282             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.DETECTOR");
    283             if (name && *name) {
    284                 psStringSubstitute(&newName, name, "{DETECTOR}");
    285             }
    286         }
     300        if (fpa != NULL) {
     301            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.DETECTOR");
     302            if (name && *name) {
     303                psStringSubstitute(&newName, name, "{DETECTOR}");
     304            }
     305        }
    287306    }
    288307    if (strstr (newName, "{TELESCOPE}") != NULL) {
    289         if (fpa != NULL) {
    290             char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.TELESCOPE");
    291             if (name && *name) {
    292                 psStringSubstitute(&newName, name, "{TELESCOPE}");
    293             }
    294         }
     308        if (fpa != NULL) {
     309            char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.TELESCOPE");
     310            if (name && *name) {
     311                psStringSubstitute(&newName, name, "{TELESCOPE}");
     312            }
     313        }
    295314    }
    296315    return newName;
     
    309328
    310329    if (strstr(newRule, "{OUTPUT}") != NULL) {
    311         char *name = psMetadataLookupStr(NULL, file->names, "OUTPUT");
    312         if (name) {
    313             psStringSubstitute(&newRule, name, "{OUTPUT}");
    314         }
     330        char *name = psMetadataLookupStr(NULL, file->names, "OUTPUT");
     331        if (name) {
     332            psStringSubstitute(&newRule, name, "{OUTPUT}");
     333        }
    315334    }
    316335
     
    331350    // pmFPAWrite takes care of all PHUs as needed
    332351    if (view->chip == -1) {
    333         pmFPACopy (out, in);
    334         return true;
     352        pmFPACopy (out, in);
     353        return true;
    335354    }
    336355    if (view->chip >= in->chips->n) {
    337         psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n);
    338         return false;
     356        psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n);
     357        return false;
    339358    }
    340359    pmChip *inChip = in->chips->data[view->chip];
     
    342361
    343362    if (view->cell == -1) {
    344         pmChipCopy (outChip, inChip);
    345         return true;
     363        pmChipCopy (outChip, inChip);
     364        return true;
    346365    }
    347366    if (view->cell >= inChip->cells->n) {
    348         psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld",
    349                 view->cell, inChip->cells->n);
    350         return false;
     367        psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld",
     368                view->cell, inChip->cells->n);
     369        return false;
    351370    }
    352371    pmCell *inCell = inChip->cells->data[view->cell];
     
    354373
    355374    if (view->readout == -1) {
    356         pmCellCopy (outCell, inCell);
    357         return true;
     375        pmCellCopy (outCell, inCell);
     376        return true;
    358377    }
    359378    psError(PS_ERR_UNKNOWN, true, "Returning false");
     
    378397    // pmFPAWrite takes care of all PHUs as needed
    379398    if (view->chip == -1) {
    380         status = pmFPACopyStructure (out, in, xBin, yBin);
    381         return status;
     399        status = pmFPACopyStructure (out, in, xBin, yBin);
     400        return status;
    382401    }
    383402    if (view->chip >= in->chips->n) {
    384         psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n);
    385         return false;
     403        psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n);
     404        return false;
    386405    }
    387406    pmChip *inChip = in->chips->data[view->chip];
     
    389408
    390409    if (view->cell == -1) {
    391         status = pmChipCopyStructure (outChip, inChip, xBin, yBin);
    392         return status;
     410        status = pmChipCopyStructure (outChip, inChip, xBin, yBin);
     411        return status;
    393412    }
    394413    if (view->cell >= inChip->cells->n) {
    395         psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld",
    396                 view->cell, inChip->cells->n);
    397         return false;
     414        psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld",
     415                view->cell, inChip->cells->n);
     416        return false;
    398417    }
    399418    pmCell *inCell = inChip->cells->data[view->cell];
     
    409428
    410429    if (!strcasecmp (type, "SX"))     {
    411         return PM_FPA_FILE_SX;
     430        return PM_FPA_FILE_SX;
    412431    }
    413432    if (!strcasecmp (type, "OBJ"))     {
    414         return PM_FPA_FILE_OBJ;
     433        return PM_FPA_FILE_OBJ;
    415434    }
    416435    if (!strcasecmp (type, "CMP"))     {
    417         return PM_FPA_FILE_CMP;
     436        return PM_FPA_FILE_CMP;
    418437    }
    419438    if (!strcasecmp (type, "CMF"))     {
    420         return PM_FPA_FILE_CMF;
     439        return PM_FPA_FILE_CMF;
    421440    }
    422441    if (!strcasecmp (type, "RAW"))     {
    423         return PM_FPA_FILE_RAW;
     442        return PM_FPA_FILE_RAW;
    424443    }
    425444    if (!strcasecmp (type, "IMAGE"))     {
    426         return PM_FPA_FILE_IMAGE;
     445        return PM_FPA_FILE_IMAGE;
    427446    }
    428447    if (!strcasecmp (type, "PSF"))     {
    429         return PM_FPA_FILE_PSF;
     448        return PM_FPA_FILE_PSF;
    430449    }
    431450    if (!strcasecmp (type, "JPEG"))     {
    432         return PM_FPA_FILE_JPEG;
     451        return PM_FPA_FILE_JPEG;
    433452    }
    434453    if (!strcasecmp (type, "KAPA"))     {
    435         return PM_FPA_FILE_KAPA;
     454        return PM_FPA_FILE_KAPA;
    436455    }
    437456    if (!strcasecmp (type, "MASK"))     {
    438         return PM_FPA_FILE_MASK;
     457        return PM_FPA_FILE_MASK;
    439458    }
    440459    if (!strcasecmp (type, "WEIGHT"))     {
    441         return PM_FPA_FILE_WEIGHT;
     460        return PM_FPA_FILE_WEIGHT;
    442461    }
    443462    if (!strcasecmp (type, "FRINGE")) {
    444         return PM_FPA_FILE_FRINGE;
     463        return PM_FPA_FILE_FRINGE;
    445464    }
    446465    if (!strcasecmp (type, "DARK"))     {
    447         return PM_FPA_FILE_DARK;
     466        return PM_FPA_FILE_DARK;
    448467    }
    449468    if (!strcasecmp (type, "HEADER"))     {
    450         return PM_FPA_FILE_HEADER;
     469        return PM_FPA_FILE_HEADER;
    451470    }
    452471    // deprecate this?
    453472    if (!strcasecmp (type, "ASTROM"))     {
    454         return PM_FPA_FILE_ASTROM_MODEL;
     473        return PM_FPA_FILE_ASTROM_MODEL;
    455474    }
    456475    if (!strcasecmp (type, "ASTROM.MODEL"))     {
    457         return PM_FPA_FILE_ASTROM_MODEL;
     476        return PM_FPA_FILE_ASTROM_MODEL;
    458477    }
    459478    if (!strcasecmp (type, "ASTROM.REFSTARS"))     {
    460         return PM_FPA_FILE_ASTROM_REFSTARS;
     479        return PM_FPA_FILE_ASTROM_REFSTARS;
    461480    }
    462481
     
    468487    switch (type) {
    469488      case PM_FPA_FILE_SX:
    470         return ("SX");
     489        return ("SX");
    471490      case PM_FPA_FILE_OBJ:
    472         return ("OBJ");
     491        return ("OBJ");
    473492      case PM_FPA_FILE_CMP:
    474         return ("CMP");
     493        return ("CMP");
    475494      case PM_FPA_FILE_CMF:
    476         return ("CMF");
     495        return ("CMF");
    477496      case PM_FPA_FILE_RAW:
    478         return ("RAW");
     497        return ("RAW");
    479498      case PM_FPA_FILE_IMAGE:
    480         return ("IMAGE");
     499        return ("IMAGE");
    481500      case PM_FPA_FILE_PSF:
    482         return ("PSF");
     501        return ("PSF");
    483502      case PM_FPA_FILE_JPEG:
    484         return ("JPEG");
     503        return ("JPEG");
    485504      case PM_FPA_FILE_KAPA:
    486         return ("KAPA");
     505        return ("KAPA");
    487506      case PM_FPA_FILE_MASK:
    488         return ("MASK");
     507        return ("MASK");
    489508      case PM_FPA_FILE_WEIGHT:
    490         return ("WEIGHT");
     509        return ("WEIGHT");
    491510      case PM_FPA_FILE_FRINGE:
    492         return ("FRINGE");
     511        return ("FRINGE");
    493512      case PM_FPA_FILE_DARK:
    494         return("DARK");
     513        return("DARK");
    495514      case PM_FPA_FILE_HEADER:
    496         return ("HEADER");
     515        return ("HEADER");
    497516      case PM_FPA_FILE_ASTROM_MODEL:
    498         return ("ASTROM.MODEL");
     517        return ("ASTROM.MODEL");
    499518      case PM_FPA_FILE_ASTROM_REFSTARS:
    500         return ("ASTROM.REFSTARS");
     519        return ("ASTROM.REFSTARS");
    501520      default:
    502         return ("NONE");
     521        return ("NONE");
    503522    }
    504523    return ("NONE");
Note: See TracChangeset for help on using the changeset viewer.