IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 21, 2008, 1:33:36 PM (18 years ago)
Author:
bills
Message:

Added a program to replace streaks and to compare two image files
(comparsion not complete yet)
Split streaksremove.c up so to make it less wieldy and to facilitate
reusing the io functions.

Location:
trunk/magic/remove/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src

    • Property svn:ignore
      •  

        old new  
        11streaksremove
         2streaksreplace
         3streakscompare
  • trunk/magic/remove/src/streaksastrom.c

    r20573 r20816  
    150150}
    151151 
     152static bool
     153readAstrometry(streakFiles *sf)
     154{
     155    pmHDU *phu = pmFPAviewThisPHU(sf->view, sf->inAstrom->fpa);
     156    if (phu) {
     157        bool status;
     158        char *ctype = psMetadataLookupStr(&status, phu->header, "CTYPE1");
     159        if (ctype) {
     160            sf->bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
     161        }
     162    }
     163
     164    if (sf->bilevelAstrometry) {
     165        // Do we get here for GPC1 ? I don't necessarily have an fpa for the input image
     166        if (!pmAstromReadBilevelMosaic(sf->inAstrom->fpa, phu->header)) {
     167            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input FPA.");
     168            return false;
     169        }
     170    } else {
     171        pmHDU *hdu = pmFPAviewThisHDU(sf->view, sf->inAstrom->fpa);
     172        PS_ASSERT_PTR_NON_NULL(hdu, 1)
     173        PS_ASSERT_PTR_NON_NULL(hdu->header, 1)
     174
     175        // we use a default FPA pixel scale of 1.0
     176        if (!pmAstromReadWCS (sf->inAstrom->fpa, sf->chip, hdu->header, 1.0)) {
     177            psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for input FPA.");
     178            return false;
     179        }
     180    }
     181
     182    return true;
     183}
     184
     185void
     186setupAstrometry(streakFiles *sf)
     187{
     188    bool status;
     189    // load astrometry file
     190    if (USE_SUPPLIED_ASTROM(sf->stage)) {
     191        sf->inAstrom = pmFPAfileDefineFromArgs(&status, sf->config, "PSWARP.ASTROM", "ASTROM");
     192    } else {
     193        // otherwise get astrometry from pmfile
     194        if (!sf->inImage->pmfile) {
     195            streaksExit("unexpected null pmFPAfile", PS_EXIT_CONFIG_ERROR);
     196        }
     197        sf->inAstrom = sf->inImage->pmfile;
     198    }
     199    sf->view = pmFPAviewAlloc(0);
     200
     201    if (!pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_BEFORE)) {
     202        psError(PS_ERR_UNKNOWN, false, "Failed to load input.");
     203        streaksExit("", PS_EXIT_DATA_ERROR);
     204    }
     205
     206    while ((sf->chip = pmFPAviewNextChip(sf->view, sf->inAstrom->fpa, 1)))  {
     207        if (sf->inAstrom->fpa->chips->n == 1) {
     208            // There's only one chip in this FPA and we've got it so break
     209            break;
     210        }
     211        bool status;
     212        psString chip_name = psMetadataLookupStr(&status, sf->chip->concepts, "CHIP.NAME");
     213        if (!strcmp(chip_name, sf->class_id)) {
     214            break;
     215        }
     216    }
     217    if (!sf->chip) {
     218        psError(PS_ERR_UNKNOWN, true, "Failed to find chip with data.");
     219        streaksExit("", PS_EXIT_DATA_ERROR);
     220    }
     221    if (!pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_BEFORE)) {
     222        psError(PS_ERR_UNKNOWN, false, "failed to load chip");
     223        streaksExit("", PS_EXIT_DATA_ERROR);
     224    }
     225    if (!readAstrometry(sf)) {
     226        psError(PS_ERR_UNKNOWN, false, "failed to read astrometry");
     227        streaksExit("", PS_EXIT_DATA_ERROR);
     228    }
     229}
Note: See TracChangeset for help on using the changeset viewer.