IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12505


Ignore:
Timestamp:
Mar 19, 2007, 3:58:02 PM (19 years ago)
Author:
eugene
Message:

updates to fix mosaic astrometry

Location:
trunk/pswarp/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/Makefile.am

    r11554 r12505  
    1717pswarpDataSave.c           \
    1818pswarpDefine.c             \
     19pswarpDefineSkycell.c      \
    1920pswarpErrorCodes.c         \
    2021pswarpMapGrid.c            \
  • trunk/pswarp/src/pswarp.c

    r10952 r12505  
    1414
    1515    psTimerStart ("complete");
     16
     17    // model inits are needed in pmSourceIO
     18    // models defined in psphot/src/models are not available in psastro
     19    pmModelGroupInit ();
    1620
    1721    pmConfig *config = pswarpArguments (argc, argv);
  • trunk/pswarp/src/pswarp.h

    r10957 r12505  
    1111
    1212# include "pswarpErrorCodes.h"
    13 # define PSWARP_RECIPE "PSWARP" // Name of the recipe to use
     13# define PSWARP_RECIPE  "PSWARP" // Name of the recipe to use
     14# define PSASTRO_RECIPE "PSASTRO" // Name of the recipe to use
    1415
    1516// a single pswarpMap converts coordinates from one image to a second image
     
    4748pswarpMapGrid *pswarpMapGridFromImage (pmReadout *dest, pmReadout *src, int nXpix, int nYpix);
    4849bool pswarpMapGridSetGrid (pswarpMapGrid *grid, int ix, int iy, int *gridX, int *gridY);
    49 bool pswarpMapGridNextGrid (pswarpMapGrid *grid, int gridX, int gridY, int *nextX, int *nextY);
     50bool pswarpMapGridNextGrid_X (pswarpMapGrid *grid, int gridX, int *nextX);
     51bool pswarpMapGridNextGrid_Y (pswarpMapGrid *grid, int gridY, int *nextY);
    5052double pswarpMapGridMaxError (pswarpMapGrid *grid);
    5153bool pswarpMapApply (double *outX, double *outY, pswarpMap *map, double inX, double inY);
    5254bool pswarpMapSetLocalModel (pswarpMap *map, pmReadout *dest, pmReadout *src, int ix, int iy);
     55
     56bool pswarpDefineSkycell (pmFPAfile **outFile, pmConfig **outConfig, pmConfig *config, const char *filename, const char *argname);
  • trunk/pswarp/src/pswarpArguments.c

    r10954 r12505  
    2323    psMetadata *options = pmConfigRecipeOptions (config, PSWARP_RECIPE);
    2424
    25     // astrom : used to supply astrometric parameters
    26     if ((N = psArgumentGet (argc, argv, "-astrom"))) {
    27         psArgumentRemove (N, &argc, argv);
    28         psMetadataAddStr (options, PS_LIST_TAIL, "ASTROM_SOURCE", PS_META_REPLACE, "", argv[N]);
    29         psArgumentRemove (N, &argc, argv);
    30     }
     25    pmConfigFileSetsMD (config->arguments, config, "ASTROM",   "-astrom", "-astromlist");
    3126
    3227    // chip selection is used to limit chips to be processed
    3328    if ((N = psArgumentGet (argc, argv, "-chip"))) {
    3429        psArgumentRemove (N, &argc, argv);
    35         psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", psStringCopy(argv[N]));
     30        psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", argv[N]);
    3631        psArgumentRemove (N, &argc, argv);
    3732    }
     33
    3834
    3935    // drop the local view on the options (saved in config->arguments)
  • trunk/pswarp/src/pswarpCleanup.c

    r11280 r12505  
    77    psTimerStop ();
    88    psMemCheckCorruption(stderr, true);
    9     // XXX not used in pswarp pmModelGroupCleanup ();
     9    pmModelGroupCleanup ();
    1010    psTimeFinalize ();
    1111    pmConceptsDone ();
    1212    pmConfigDone ();
    13     // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "pswarp");
    14     fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "pswarp");
     13    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "pswarp");
     14    // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "pswarp");
    1515
    1616    return;
  • trunk/pswarp/src/pswarpDataLoad.c

    r10958 r12505  
    99bool pswarpDataLoad (pmConfig *config) {
    1010
     11    bool status;
    1112    pmChip *chip;
    1213    pmCell *cell;
    1314    pmReadout *readout;
    1415    pmFPAview *view;
     16
     17    // select the current recipe
     18    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE);
     19    if (!recipe) {
     20        psError(PSWARP_ERR_CONFIG, false, "Can't find PSASTRO recipe needed for pixel scale!\n");
     21        return false;
     22    }
     23
     24    // physical pixel scale in microns per pixel
     25    double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE");
     26    if (!status) {
     27        psError(PS_ERR_IO, false, "Failed to lookup pixel scale");
     28        return false;
     29    }
    1530
    1631    // select the input data sources
     
    2136    }
    2237
     38    // use the external astrometry source if supplied
     39    pmFPAfile *astrom = psMetadataLookupPtr (NULL, config->files, "PSWARP.ASTROM");
     40    if (!astrom) {
     41        fprintf (stderr, "*** using header astrometry\n");
     42        astrom = input;
     43    }
     44 
    2345    // select the output readout
    2446    view = pmFPAviewAlloc (0);
     
    4466    // XXX need to optionally load the astrometry datafile
    4567    bool bilevelAstrometry = false;
    46     pmHDU *phu = pmFPAviewThisPHU (view, input->fpa);
     68    pmHDU *phu = pmFPAviewThisPHU (view, astrom->fpa);
    4769    if (phu) {
    4870      char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
     
    5274    }
    5375    if (bilevelAstrometry) {
    54       pmAstromReadBilevelMosaic (input->fpa, phu->header);
     76      pmAstromReadBilevelMosaic (input->fpa, phu->header, pixelScale);
    5577    }
    5678
     
    6486
    6587        // read WCS data from the corresponding header
    66         pmHDU *hdu = pmFPAviewThisHDU (view, input->fpa);
     88        pmHDU *hdu = pmFPAviewThisHDU (view, astrom->fpa);
    6789        if (bilevelAstrometry) {
    6890          pmAstromReadBilevelChip (chip, hdu->header);
    6991        } else {
    70           // XXX get pixelScale from recipes.  does it matter?
    71           float pixelScale = 13.5;
    7292          pmAstromReadWCS (input->fpa, chip, hdu->header, pixelScale);
    7393        }
  • trunk/pswarp/src/pswarpDefine.c

    r11281 r12505  
    44bool pswarpDefine (pmConfig *config) {
    55
    6     // select the current recipe
    7     psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE);
     6    bool status;
     7    psMetadata *recipe = NULL;
     8
     9    // load the pixel scale from the PSASTRO recipe
     10    recipe  = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE);
     11    if (!recipe) {
     12        psError(PSWARP_ERR_CONFIG, false, "Can't find PSASTRO recipe needed for pixel scale!\n");
     13        return false;
     14    }
     15    // physical pixel scale in microns per pixel
     16    double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE");
     17    if (!status) {
     18        psError(PS_ERR_IO, false, "Failed to lookup pixel scale");
     19        return false;
     20    }
     21
     22    // load the PSWARP recipe
     23    recipe  = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE);
    824    if (!recipe) {
    925        psError(PSWARP_ERR_CONFIG, true, "Can't find PSWARP recipe!\n");
     
    3652    }
    3753    if (bilevelAstrometry) {
    38       pmAstromReadBilevelMosaic (skycell->fpa, phu->header);
     54      pmAstromReadBilevelMosaic (skycell->fpa, phu->header, pixelScale);
    3955      pmAstromReadBilevelChip (chip, hdu->header);
    4056    } else {
    41       // XXX get pixelScale from recipes.  does it matter?
    42       float pixelScale = 13.5;
    4357      pmAstromReadWCS (skycell->fpa, chip, hdu->header, pixelScale);
    4458    }
  • trunk/pswarp/src/pswarpMapGrid.c

    r10958 r12505  
    88    int j, nj;
    99
     10    // XXX I was trying to match the grids too closely
    1011    // split the difference of the remainder
    11     int xMin = 0.5*(src->image->numCols % nXpix);
    12     int yMin = 0.5*(src->image->numRows % nYpix);
    13 
    14     int nXpts = src->image->numCols / nXpix;
    15     if (src->image->numCols % nXpix == 0) nXpts ++;
    16     int nYpts = src->image->numRows / nYpix;
    17     if (src->image->numRows % nYpix == 0) nYpts ++;
     12    // int xMin = 0.5*(src->image->numCols % nXpix);
     13    // int yMin = 0.5*(src->image->numRows % nYpix);
     14    int xMin = 0;
     15    int yMin = 0;
     16
     17    int nXpts = src->image->numCols / nXpix + 1;
     18    if (src->image->numCols % nXpix) nXpts ++;
     19    int nYpts = src->image->numRows / nYpix + 1;
     20    if (src->image->numRows % nYpix) nYpts ++;
    1821
    1922    pswarpMapGrid *grid = pswarpMapGridAlloc (nXpts, nYpts);
     
    3942}
    4043
    41 bool pswarpMapGridNextGrid (pswarpMapGrid *grid, int gridX, int gridY, int *nextX, int *nextY) {
     44bool pswarpMapGridNextGrid_X (pswarpMapGrid *grid, int gridX, int *nextX) {
    4245
    4346    *nextX = gridX*grid->nXpix + grid->xMin + 0.5*grid->nXpix;
     47    return true;
     48}
     49
     50bool pswarpMapGridNextGrid_Y (pswarpMapGrid *grid, int gridY, int *nextY) {
     51
    4452    *nextY = gridY*grid->nYpix + grid->yMin + 0.5*grid->nYpix;
    4553    return true;
  • trunk/pswarp/src/pswarpParseCamera.c

    r10954 r12505  
    44
    55    bool status;
     6    pmFPAfile *skycell = NULL;
     7    pmConfig *skyConfig = NULL;
    68
    79    // the input image(s) are required arguments; they define the camera
     
    1315    }
    1416
     17    // the input image(s) are required arguments; they define the camera
     18    status = false;
     19    pmFPAfileDefineFromArgs (&status, config, "PSWARP.ASTROM", "ASTROM");
     20    if (status) {
     21        fprintf (stderr, "using supplied astrometry\n");
     22    } else {
     23        fprintf (stderr, "using header astrometry\n");
     24    }
     25
     26    // the mask is not required - but must conform to input camera
     27    if (!pmFPAfileBindFromArgs (NULL, input, config, "PSWARP.MASK", "MASK")) {
     28        fprintf (stderr, "no mask supplied\n");
     29    }
     30
     31    if (!pmFPAfileBindFromArgs (NULL, input, config, "PSWARP.WEIGHT", "WEIGHT")) {
     32        fprintf (stderr, "no weight supplied\n");
     33    }
     34
    1535    // the input skycell is a required argument: it defines the output image
    16     status = false;
    17     pmFPAfile *skycell = pmFPAfileDefineFromArgs (&status, config, "PSWARP.SKYCELL", "SKYCELL");
    18     if (!skycell) {
     36    // XXX we may need a different skycell structure here
     37    status = pswarpDefineSkycell (&skycell, &skyConfig, config, "PSWARP.SKYCELL", "SKYCELL");
     38    if (!status) {
    1939        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.SKYCELL");
    2040        return false;
    2141    }
    2242
    23     // the mask is not required; the  skycell is a required argument: it defines the output image
    24     status = false;
    25     pmFPAfileDefineFromArgs (&status, config, "PSWARP.MASK", "MASK");
    26     if (!status) {
    27       // build the basic mask concept here
    28     }
    29 
    30     // the weight is not required; the  skycell is a required argument: it defines the output image
    31     status = false;
    32     pmFPAfileDefineFromArgs (&status, config, "PSWARP.WEIGHT", "WEIGHT");
    33     if (!status) {
    34       // build the basic weight concept here
    35     }
    36 
    3743    // these calls bind the I/O handle to the specified fpa
    38     if (!pmFPAfileDefineOutput (config, skycell->fpa, "PSWARP.OUTPUT")) {
     44    if (!pmFPAfileDefineOutput (skyConfig, skycell->fpa, "PSWARP.OUTPUT")) {
    3945        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT");
    4046        return false;
     
    5561    }
    5662    psFree (chips);
     63    psFree (skyConfig);
    5764
    5865    psTrace("pswarp", 1, "Done with pswarpParseCamera...\n");
  • trunk/pswarp/src/pswarpTransformReadout_Opt.c

    r10958 r12505  
    55
    66    int minX, minY, maxX, maxY;
    7     int gridX, gridY, nextGridX, nextGridY;
     7    int gridXo, gridX, gridY, nextGridX, nextGridY;
    88    pswarpMap *map = NULL;
    99
     
    1919
    2020    // we might want to do the rectangular regions outside of the selection independently
    21     psImageInit (output->image, NAN);
     21    // psImageInit (output->image, NAN);
    2222
    2323    // find the output pixel range
     
    3131
    3232    pswarpMapGridSetGrid (grid, minX, minY, &gridX, &gridY);
    33     pswarpMapGridNextGrid (grid, gridX, gridY, &nextGridX, &nextGridY);
     33    pswarpMapGridNextGrid_Y (grid, gridY, &nextGridY);
    3434    map = grid->maps[gridX][gridY];
    3535
     
    3838        if (y >= nextGridY) {
    3939            gridY ++;
    40             pswarpMapGridNextGrid (grid, gridX, gridY, &nextGridX, &nextGridY);
     40            pswarpMapGridNextGrid_Y (grid, gridY, &nextGridY);
    4141            map = grid->maps[gridX][gridY];
    4242        }
     43
     44        gridXo = gridX;
    4345        for (int x = minX; x < maxX; x++) {
    4446            if (x >= nextGridX) {
    4547                gridX ++;
    46                 pswarpMapGridNextGrid (grid, gridX, gridY, &nextGridX, &nextGridY);
     48                pswarpMapGridNextGrid_X (grid, gridX, &nextGridX);
    4749                map = grid->maps[gridX][gridY];
    4850            }
     
    6062            outData[y][x] = (psF32)psImagePixelInterpolate(inImage, inPix->x, inPix->y, NULL, 1, NAN, PS_INTERPOLATE_BILINEAR);
    6163        }
     64        gridX = gridXo;
     65        pswarpMapGridNextGrid_X (grid, gridX, &nextGridX);
     66        map = grid->maps[gridX][gridY];
    6267    }
    6368
Note: See TracChangeset for help on using the changeset viewer.