IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10954


Ignore:
Timestamp:
Jan 7, 2007, 6:48:50 AM (19 years ago)
Author:
eugene
Message:

functioning pswarp, needs opt code

Location:
trunk/pswarp/src
Files:
2 added
7 edited

Legend:

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

    r10946 r10954  
    1919pswarpErrorCodes.c         \
    2020pswarpParseCamera.c        \
     21pswarpTransformReadout.c   \
    2122pswarpVersion.c           
    2223
  • trunk/pswarp/src/pswarp.h

    r10952 r10954  
    1313# define PSWARP_RECIPE "PSWARP" // Name of the recipe to use
    1414
     15typedef struct {
     16  double Xo, Xx, Xy;
     17  double Yo, Yx, Yy;
     18} pswarpMap;
     19
     20typedef struct {
     21  pswarpMap **grid;
     22  int Nx, Ny;
     23  int nXpix, nYpix;
     24} pswarpMapGrid;
     25
    1526pmConfig *pswarpArguments (int argc, char **argv);
    1627bool pswarpParseCamera (pmConfig *config);
     
    1930bool pswarpDataSave (pmConfig *config);
    2031void pswarpCleanup (pmConfig *config);
     32bool pswarpTransformReadout (pmReadout *output, pmReadout *input, pmConfig *config);
     33
  • trunk/pswarp/src/pswarpArguments.c

    r10832 r10954  
    5050    pmConfigFileSetsMD (config->arguments, config, "WEIGHT", "-weight", "-weightlist");
    5151   
    52     if (argc != 2) {
     52    if (argc != 3) {
    5353        psError(PSWARP_ERR_ARGUMENTS, true, "Incorrect arguments supplied");
    5454        return NULL;
    5555    }
    5656   
     57    psArray *array;
     58
    5759    // output position is fixed
    5860    psMetadataAddStr (config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "", argv[1]);
    5961
    6062    // skycell position is fixed
    61     psMetadataAddStr (config->arguments, PS_LIST_TAIL, "SKYCELL", 0, "", argv[2]);
     63    array = psArrayAlloc(1);
     64    array->data[0] = psStringCopy (argv[2]);
     65    status = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "SKYCELL", PS_DATA_ARRAY, "", array);
     66    psFree (array);
    6267
    6368    psTrace("pswarp", 1, "Done with pswarpArguments...\n");
  • trunk/pswarp/src/pswarpDataLoad.c

    r10952 r10954  
    3232
    3333    // de-activate PSWARP.SKYCELL and PSWARP.OUTPUT
    34     //
     34    pmFPAfileActivate (config->files, false, "PSWARP.SKYCELL");
    3535    pmFPAfileActivate (config->files, false, "PSWARP.OUTPUT");
    36     pmFPAfileActivate (config->files, false, "PSWARP.SKYCELL");
    3736
    3837    pmFPAview *view = pmFPAviewAlloc (0);
     38
     39    // find the FPA phu
     40    // XXX wrap the test below into a function
     41    // XXX need to read only the headers for the skycell
     42    // XXX need to optionally load the astrometry datafile
     43    bool bilevelAstrometry = false;
     44    pmHDU *phu = pmFPAviewThisPHU (view, input->fpa);
     45    if (phu) {
     46      char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
     47      if (ctype) {
     48        bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
     49      }
     50    }
     51    if (bilevelAstrometry) {
     52      pmAstromReadBilevelMosaic (input->fpa, phu->header);
     53    }
    3954
    4055    // files associated with the science image
     
    4560        if (!chip->process || !chip->file_exists) { continue; }
    4661        pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     62
     63        // read WCS data from the corresponding header
     64        pmHDU *hdu = pmFPAviewThisHDU (view, input->fpa);
     65        if (bilevelAstrometry) {
     66          pmAstromReadBilevelChip (chip, hdu->header);
     67        } else {
     68          // XXX get pixelScale from recipes.  does it matter?
     69          float pixelScale = 13.5;
     70          pmAstromReadWCS (input->fpa, chip, hdu->header, pixelScale);
     71        }
    4772
    4873        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
     
    5681                if (! readout->data_exists) { continue; }
    5782
    58                 pswarpConvertReadout (output, readout, config);
     83                pswarpTransformReadout (output, readout, config);
    5984
    6085                pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
  • trunk/pswarp/src/pswarpDefine.c

    r10952 r10954  
    2323    pmFPAfileRead (skycell, view, config);
    2424
     25    // XXX this is not a sufficient test
     26    view->chip = 0;
     27    pmChip *chip = pmFPAviewThisChip (view, skycell->fpa);
     28    pmHDU *phu = pmFPAviewThisPHU (view, skycell->fpa);
     29    pmHDU *hdu = pmFPAviewThisHDU (view, skycell->fpa);
     30    bool bilevelAstrometry = false;
     31    if (phu) {
     32      char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
     33      if (ctype) {
     34        bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
     35      }
     36    }
     37    if (bilevelAstrometry) {
     38      pmAstromReadBilevelMosaic (skycell->fpa, phu->header);
     39      pmAstromReadBilevelChip (chip, hdu->header);
     40    } else {
     41      // XXX get pixelScale from recipes.  does it matter?
     42      float pixelScale = 13.5;
     43      pmAstromReadWCS (skycell->fpa, chip, hdu->header, pixelScale);
     44    }
     45
    2546    // construct the output fpa here
    2647    pmFPAfile *output = psMetadataLookupPtr (NULL, config->files, "PSWARP.OUTPUT");
  • trunk/pswarp/src/pswarpParseCamera.c

    r10952 r10954  
    33bool pswarpParseCamera (pmConfig *config) {
    44
    5     bool status = false;
     5    bool status;
    66
    77    // the input image(s) are required arguments; they define the camera
     8    status = false;
    89    pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PSWARP.INPUT", "INPUT");
    9     if (!status) {
     10    if (!input) {
    1011        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.INPUT");
    1112        return false;
     
    1314
    1415    // the input skycell is a required argument: it defines the output image
     16    status = false;
    1517    pmFPAfile *skycell = pmFPAfileDefineFromArgs (&status, config, "PSWARP.SKYCELL", "SKYCELL");
    16     if (!status) {
    17         psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.INPUT");
     18    if (!skycell) {
     19        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.SKYCELL");
    1820        return false;
    1921    }
    2022
    2123    // the mask is not required; the  skycell is a required argument: it defines the output image
     24    status = false;
    2225    pmFPAfileDefineFromArgs (&status, config, "PSWARP.MASK", "MASK");
    2326    if (!status) {
     
    2629
    2730    // the weight is not required; the  skycell is a required argument: it defines the output image
     31    status = false;
    2832    pmFPAfileDefineFromArgs (&status, config, "PSWARP.WEIGHT", "WEIGHT");
    2933    if (!status) {
     
    3236
    3337    // these calls bind the I/O handle to the specified fpa
    34     pmFPAfileDefineOutput (config, skycell->fpa, "PSWARP.OUTPUT");
     38    if (!pmFPAfileDefineOutput (config, skycell->fpa, "PSWARP.OUTPUT")) {
     39        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT");
     40        return false;
     41    }
    3542
    3643    // Chip selection: turn on only the chips specified
  • trunk/pswarp/src/pswarpTransformReadout.c

    r10952 r10954  
    88
    99    // select the current recipe
    10     psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
     10    // psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE);
    1111
    1212    int outNx = output->image->numCols;
     
    2727    pmChip *chipOutput = cell->parent;
    2828    pmFPA *fpaOutput = chipOutput->parent;
     29
     30    psF32 **outData = output->image->data.F32;
     31    psImage *inImage = input->image;
    2932
    3033    // Iterate over the output image pixels
     
    4851
    4952                // XXX get interpolation method from the recipe
    50                 outImage->data.F32[y][x] = (psF32)psImagePixelInterpolate(image, inPix->x, inPix->y, mask, 1, NAN, PS_INTERPOLATE_BILINEAR);
     53                outData[y][x] = (psF32)psImagePixelInterpolate(inImage, inPix->x, inPix->y, NULL, 1, NAN, PS_INTERPOLATE_BILINEAR);
     54                // modify zero and scale?
    5155
     56                // outData[y][x] = (psF32)psImagePixelInterpolate(inImage, inPix->x, inPix->y, mask, 1, NAN, PS_INTERPOLATE_BILINEAR);
     57               
    5258# if (0)
    5359                if (error) {
     
    5864                                                                                            mask, 1, NAN);
    5965                }
    60 # endif
    61 
    62                 outImage->data.F32[y][x] = (outImage->data.F32[y][x] - offset) / scale;
    63 # if (0)
    6466                if (error) {
    6567                    outError->data.F32[y][x] = outError->data.F32[y][x] / SQUARE(scale);
Note: See TracChangeset for help on using the changeset viewer.