IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36359


Ignore:
Timestamp:
Dec 6, 2013, 2:58:40 PM (13 years ago)
Author:
watersc1
Message:

Merge of ppSkycell changes from trunk.

Location:
tags/ipp-20130712/ppSkycell/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20130712/ppSkycell/src

  • tags/ipp-20130712/ppSkycell/src/ppSkycell.h

    r35855 r36359  
    1010typedef struct {
    1111    psString imagesName;                // Filename with images
    12     psString masksName;                 // Filename with masks
    1312    psString wcsrefName;                // Filename with WCS references
    1413    psString outRoot;                   // Output root name
     
    1716    int bin1, bin2;                     // Binning factors
    1817    pmConfig *config;                   // Configuration
    19   bool doFits;                          // hold whether to do fits as well.
     18    bool doFits;                        // hold whether to do fits as well.
     19    int  exptimeOrder;                  // Order of exptime scaling.
    2020} ppSkycellData;
    2121
  • tags/ipp-20130712/ppSkycell/src/ppSkycellArguments.c

    r35855 r36359  
    2929{
    3030    fprintf(stderr, "\nPan-STARRS skycell JPEGifier\n\n");
    31     fprintf(stderr, "Usage: %s -images INPUT.list [-masks MASK.list] OUTPUT_ROOT\n\n",
     31    fprintf(stderr, "Usage: %s -images INPUT.list OUTPUT_ROOT\n\n",
    3232            program);
    3333    fprintf(stderr, "\n");
     
    5050    psMetadata *arguments = psMetadataAlloc(); // Command-line arguments
    5151    psMetadataAddStr(arguments, PS_LIST_TAIL, "-images", 0, "Filename with input images", NULL);
    52     psMetadataAddStr(arguments, PS_LIST_TAIL, "-masks", 0, "Filename with input masks", NULL);
    5352    psMetadataAddStr(arguments, PS_LIST_TAIL, "-wcsref", 0, "Filename with WCS references", NULL);
     53    psMetadataAddS16(arguments, PS_LIST_TAIL, "-exptimeOrder", 0, "Order of exptime scaling", 0);
    5454    if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) {
    5555        usage(argv[0], arguments, data);
     
    5757
    5858    data->imagesName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-images"));
    59     data->masksName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-masks"));
    6059    data->wcsrefName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-wcsref"));
     60    data->exptimeOrder = psMetadataLookupS16(NULL,arguments,"-exptimeOrder");
    6161   
    6262    data->outRoot = psStringCopy(argv[1]);
  • tags/ipp-20130712/ppSkycell/src/ppSkycellCamera.c

    r35855 r36359  
    5656    data->numInputs = images->n;
    5757
    58     psArray *masks = NULL;              // Mask names
    59     if (data->masksName) {
    60         masks = fileList(data->masksName);
    61         if (!masks) {
    62             psError(psErrorCodeLast(), false, "No masks provided.");
    63             psFree(images);
    64             return false;
    65         }
    66         if (masks->n != data->numInputs) {
    67             psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Number of images (%ld) and masks (%ld) do not match",
    68                     images->n, masks->n);
    69             psFree(images);
    70             psFree(masks);
    71             return false;
    72         }
    73     }
    74 
    7558    psArray *wcsref = NULL;             // Names of WCS reference images
    7659    if (data->wcsrefName) {
     
    7962        psError(psErrorCodeLast(), false, "No WCSrefs provided.");
    8063        psFree(images);
    81         psFree(masks);
    8264        return(false);
    8365      }
     
    8668                images->n, wcsref->n);
    8769        psFree(images);
    88         psFree(masks);
    8970        psFree(wcsref);
    9071        return(false);
     
    10485        }
    10586
    106         if (data->masksName) {
    107             fileArguments("MASK", masks->data[i], "Name of the mask", data->config);
    108             if (!pmFPAfileBindFromArgs(&status, image, data->config, "PPSKYCELL.MASK", "MASK") || !status) {
    109                 psError(PS_ERR_IO, false, "Failed to build file from PPSKYCELL.MASK");
    110                 // XXX Cleanup
    111                 return false;
    112             }
    113         }
    114 
    11587        if (data->wcsrefName) {
    11688          fileArguments("WCSREF", wcsref->data[i], "Name of the WCS reference", data->config);
     
    12092            return(false);
    12193          }
    122 /*        if (!pmFPAfileBindFromArgs(&status, image, data->config, "PPSKYCELL.WCSREF", "WCSREF") || !status) { */
    123 /*          psError(PS_ERR_IO, false, "Failed to build file from PPSKYCELL.WCSREF"); */
    124 /*          return false; */
    125 /*        } */
    12694        }
    127        
    12895    }
    12996
     
    145112        psError(psErrorCodeLast(), false, "Unable to define output.");
    146113        return false;
    147     }
    148     if (data->masksName) {
    149       pmFPAfile *mask1 = pmFPAfileDefineOutput(data->config, bin1->fpa , "PPSKYCELL.BIN1.MASK");
    150       if (!mask1) {
    151         psError(psErrorCodeLast(), false, "Unable to define output.");
    152         return false;
    153       }
    154       mask1->save = true;
    155       pmFPAfile *mask2 = pmFPAfileDefineOutput(data->config, bin2->fpa , "PPSKYCELL.BIN2.MASK");
    156       if (!mask2) {
    157         psError(psErrorCodeLast(), false, "Unable to define output.");
    158         return false;
    159       }
    160       mask2->save = true;
    161114    }
    162115
  • tags/ipp-20130712/ppSkycell/src/ppSkycellData.c

    r35855 r36359  
    1414{
    1515    psFree(data->imagesName);
    16     psFree(data->masksName);
    1716    psFree(data->wcsrefName);
    1817    psFree(data->outRoot);
     
    2827
    2928    data->imagesName = NULL;
    30     data->masksName = NULL;
    3129    data->wcsrefName = NULL;
    3230    data->outRoot = NULL;
     
    3634    data->bin2 = 0;
    3735    data->config = NULL;
    38 
     36    data->exptimeOrder = 0;
    3937    return data;
    4038}
  • tags/ipp-20130712/ppSkycell/src/ppSkycellLoop.c

    r35855 r36359  
    1111#define BUFFER 16                       // Size of buffer for projections
    1212
    13 #if (0)
    14 // This is all junk that is basically useless, because it calculates things we already know.
    15 
    16 static void regionMinMax(psRegion *base,// Base region; modified
    17                          const psRegion *compare // Comparison region
    18                          )
    19 {
    20     base->x0 = PS_MAX(base->x0, compare->x0);
    21     base->x1 = PS_MIN(base->x1, compare->x1);
    22     base->y0 = PS_MIN(base->y0, compare->y0);
    23     base->y1 = PS_MAX(base->y1, compare->y1);
    24     return;
    25 }
    26 
    27 
    28 static psRegion *skycellRegion(pmAstromWCS *wcs, // World Coordinate System
    29                                int numCols, int numRows // Size of image
    30     )
    31 {
    32     psPlane *fromCoords = psPlaneAlloc(), *toCoords = psPlaneAlloc(); // Coordinates for transforms
    33     psRegion *region = psRegionAlloc(-INFINITY, INFINITY, INFINITY, -INFINITY); // Region for skycell
    34 
    35 // Limit the region using the nominated point (X,Y)
    36 #define REGION_RANGE(X,Y) \
    37     fromCoords->x = (X); \
    38     fromCoords->y = (Y); \
    39     psPlaneTransformApply(toCoords, wcs->trans, fromCoords); \
    40     printf("%f %f %f %f\n",toCoords->x,toCoords->y,fromCoords->x,fromCoords->y); \
    41     toCoords->x /= wcs->cdelt1; \
    42     toCoords->y /= wcs->cdelt2; \
    43     toCoords->x -= wcs->crpix1;         \
    44     toCoords->y += wcs->crpix2;         \
    45     region->x0 = PS_MAX(region->x0, toCoords->x); \
    46     region->x1 = PS_MIN(region->x1, toCoords->x); \
    47     region->y0 = PS_MIN(region->y0, toCoords->y); \
    48     region->y1 = PS_MAX(region->y1, toCoords->y);
    49     //
    50     REGION_RANGE(0, 0);                 // Lower left
    51     psTrace("ppSkycell", 9, "Start: %.0f %.0f", toCoords->x, toCoords->y);
    52     REGION_RANGE(0, numRows);           // Upper left
    53     REGION_RANGE(numCols, 0);           // Lower right
    54     REGION_RANGE(numCols, numRows);     // Upper right
    55     psTrace("ppSkycell", 9, "Stop: %.0f %.0f\n", toCoords->x, toCoords->y);
    56     psTrace("ppSkycell", 7, "%g %g %g %g\n",wcs->cdelt1,wcs->cdelt2,wcs->crpix1,wcs->crpix2);
    57     return region;
    58 }
    59 #endif
    6013
    6114// Activate/deactivate a single element for a list
     
    13992    psArray *imageRegions = psArrayAlloc(data->numInputs); // Region for image
    14093    psArray *regionHDUs = psArrayAlloc(data->numInputs);
     94
     95    psVector *exptimes = psVectorAlloc(data->numInputs, PS_TYPE_F64);
     96   
    14197    // Determine which projection cells we have to deal with.
    14298    for (int i = 0; i < data->numInputs; i++) {
    14399        pmFPAfile *file = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.IMAGE", i); // File to examine
    144100        // Header in the FPA should have been read as a part of defining the file...
    145 #if 0
    146         bool pmFPAReadHeaderSet(pmFPA *fpa,     // FPA to read into
    147                                 psFits *fits,   // FITS file from which to read
    148                                 pmConfig *config // Configuration
    149             );
    150 #endif
    151101        pmHDU *hdu = file->fpa->hdu;    // Header of interest
    152102
     
    187137            }
    188138        }
    189 
    190         if (!found) {
     139       
     140        if (!found) { // Add new projection cell if we didn't find one.
    191141            psVectorAppend(crval1, wcs->crval1);
    192142            psVectorAppend(crval2, wcs->crval2);
    193143            psVectorAppend(cdelt1, wcs->cdelt1);
    194144            psVectorAppend(cdelt2, wcs->cdelt2);
     145
    195146            psRegion *projRegion = psRegionAlloc(region->x0, region->x1, region->y0, region->y1);
    196147            psArrayAdd(projRegions, projRegions->n, projRegion);
     
    200151            psArrayAdd(regionHDUs,1,hdu);
    201152            numProj++;
     153
    202154        }
    203     }
    204 
     155
     156        // Save exptime
     157        exptimes->data.F64[i] = psMetadataLookupF64(NULL, hdu->header, "EXPTIME");
     158    }
     159
     160    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN);
     161    psVectorStats(stats,exptimes,NULL, NULL, 0);
     162   
    205163    pmFPAfileActivate(data->config->files, false, NULL);
    206164    // Loop over projections
    207165    for (int i = 0; i < numProj; i++) {
    208166        psRegion *projRegion = projRegions->data[i]; // Region for skycell projection
    209         //      projRegion->x0 += 5760;
    210         //projRegion->x1 += 5760;
    211         //      projRegion->x0 +=
    212         //      projRegion->x1 +=
    213167        psTrace("ppSkycell", 2, "Projection %d: [%.0f:%.0f,%.0f:%.0f]\n",
    214168                i, projRegion->x0, projRegion->x1, projRegion->y0, projRegion->y1);
    215         int xSize = projRegion->x1 - projRegion->x0 + 1; // Size of unbinned image
    216         int ySize = projRegion->y1 - projRegion->y0 + 1; // Size of unbinned image
    217         // Size of binned image 1
     169
     170        // Size of unbinned image
     171        int xSize = projRegion->x1 - projRegion->x0 + 1;
     172        int ySize = projRegion->y1 - projRegion->y0 + 1;
     173
     174        // Size of binned images
    218175        int numCols1 = xSize / (float)data->bin1 + 1.5, numRows1 = ySize / (float)data->bin1 + 1.5;
    219         // Size of binned image 2
    220176        int numCols2 = numCols1 / (float)data->bin2 + 1.5, numRows2 = numRows1 / (float)data->bin2 + 1.5;
    221177
    222         psImage *image1 = psImageAlloc(numCols1, numRows1, PS_TYPE_F32); // Binned image
    223         psImage *image2 = psImageAlloc(numCols2, numRows2, PS_TYPE_F32); // Binned image
     178        // Binned image containers
     179        psImage *image1 = psImageAlloc(numCols1, numRows1, PS_TYPE_F32);
     180        psImage *image2 = psImageAlloc(numCols2, numRows2, PS_TYPE_F32);
    224181        psImageInit(image1,NAN);
    225182        psImageInit(image2,NAN);
     183
     184        // Binned image radius values.  Used to determine primacy.
     185        psImage *radius1 = psImageAlloc(numCols1, numRows1, PS_TYPE_F32);
     186        psImage *radius2 = psImageAlloc(numCols2, numRows2, PS_TYPE_F32);
     187        psImageInit(radius1,pow(numCols1 + numRows1,2)); // These values can be anything, just need to be larger than a binned radius.
     188        psImageInit(radius2,pow(numCols1 + numRows1,2));
    226189       
    227         psImage *mask1 = NULL, *mask2 = NULL; // Binned masks
    228         if (data->masksName) {
    229             mask1 = psImageAlloc(numCols1, numRows1, PS_TYPE_IMAGE_MASK);
    230             mask2 = psImageAlloc(numCols2, numRows2, PS_TYPE_IMAGE_MASK);
    231             psImageInit(mask1, 0xFF);
    232             psImageInit(mask2, 0xFF);
    233         }
    234190        // HDU containing the WCS we plan on using
    235191        pmHDU *projhdu = NULL;
     
    249205            }
    250206            pmFPAfileActivateSingle(data->config->files, true, "PPSKYCELL.IMAGE", j);
    251             if (data->masksName) {
    252                 pmFPAfileActivateSingle(data->config->files, true, "PPSKYCELL.MASK", j);
    253             }
    254207
    255208            pmFPAview *view = filesIterateDown(data->config); // View to readout
     
    304257            }
    305258
    306 #if (0)
    307             psRegion *imageRegion = imageRegions->data[j]; // Region for image
    308             fprintf(stderr,"%d IM %f %f %f %f PR %f %f %f %f\n",
    309                     j,
    310                     imageRegion->x0,imageRegion->x1,
    311                     imageRegion->y0,imageRegion->y1,
    312                     projRegion->x0,projRegion->x1,
    313                     projRegion->y0,projRegion->y1);
    314 #endif
     259            // Scale by exposure time
     260            double exptime_factor = pow(exptimes->data.F64[j]/stats->robustMedian,data->exptimeOrder);
     261            if ((isfinite(exptime_factor))&&(exptime_factor != 0.0)) {
     262              psBinaryOp(bin1RO->image,bin1RO->image,"/",
     263                         psScalarAlloc(exptime_factor,  PS_TYPE_F32));
     264              psBinaryOp(bin2RO->image,bin2RO->image,"/",
     265                         psScalarAlloc(exptime_factor,  PS_TYPE_F32));
     266            }
     267            // End scaling
     268
    315269            // Offsets for image on this projection cell are just differences in CRPIX positions.
    316270            int xOffset1 = (-1 * wcs->crpix1 - projRegion->x0) / (float)(data->bin1);
    317271            int yOffset1 = (-1 * wcs->crpix2 - projRegion->y0) / (float)(data->bin1);
    318272           
    319             int xOffset2 = xOffset1 / (float)data->bin2, yOffset2 = yOffset1 / (float)data->bin2;
     273            int xOffset2 = xOffset1 / (float)data->bin2;
     274            int yOffset2 = yOffset1 / (float)data->bin2;
    320275            psTrace("ppSkycell",5,"Offsets: %d %d : %d %d",
    321276                    xOffset1,yOffset1,xOffset2,yOffset2);
    322277
     278            // Check each pixel for primacy.  A pixel is primary
     279            // if it is closer to the central pixel of its skycell
     280            // than any other pixel is to theirs.
     281
     282            // Let's just do the overlay here, instead of doing math, then handing it
     283            // off to another function.  That seems silly.
     284
     285            int u,v,x,y;
     286
     287            double u0 = xOffset1 + (bin1RO->image->numCols) / 2.0;
     288            double v0 = yOffset1 + (bin1RO->image->numRows) / 2.0;
     289            for (x = 0; x < bin1RO->image->numCols; x++) {
     290              for (y = 0; y < bin1RO->image->numRows; y++) {
     291                if (!isfinite(bin1RO->image->data.F32[y][x])) {
     292                  continue;
     293                }
     294                u = x + xOffset1;
     295                v = y + yOffset1;
     296                double R2 = pow(u - u0,2) + pow(v - v0,2);
     297               
     298                if (R2 < radius1->data.F32[v][u]) {
     299                  radius1->data.F32[v][u] = R2;
     300                  image1->data.F32[v][u] = bin1RO->image->data.F32[y][x];
     301                }
     302              }
     303            }
     304
     305            u0 = xOffset2 + (bin2RO->image->numCols) / 2.0;
     306            v0 = yOffset2 + (bin2RO->image->numRows) / 2.0;
     307            for (x = 0; x < bin2RO->image->numCols; x++) {
     308              for (y = 0; y < bin2RO->image->numRows; y++) {
     309                if (!isfinite(bin2RO->image->data.F32[y][x])) {
     310                  continue;
     311                }
     312                u = x + xOffset2;
     313                v = y + yOffset2;
     314                double R2 = pow(u - u0,2) + pow(v - v0,2);
     315                if (R2 < radius2->data.F32[v][u]) {
     316                  radius2->data.F32[v][u] = R2;
     317                  image2->data.F32[v][u] = bin2RO->image->data.F32[y][x];
     318                }
     319              }
     320            }
     321           
     322               
     323               
     324           
    323325            // Overlay the data onto the appropriate pixels in the final outputs
    324326            // XXX Completely neglecting rotations
    325327            // The skycells are divided up neatly with them all having the same orientation
    326             psImageOverlaySection(image1, bin1RO->image, xOffset1, yOffset1, "E");
    327             psImageOverlaySection(image2, bin2RO->image, xOffset2, yOffset2, "E");
    328             if (data->masksName) {
    329                 psImageOverlaySection(mask1, bin1RO->mask, xOffset1, yOffset1, "M");
    330                 psImageOverlaySection(mask2, bin2RO->mask, xOffset2, yOffset2, "M");
    331             }
     328                //          psImageOverlaySection(image1, bin1RO->image, xOffset1, yOffset1, "E");
     329            //      psImageOverlaySection(image2, bin2RO->image, xOffset2, yOffset2, "E");
    332330
    333331            // Cleanup on input loop.
     
    337335            psFree(file->fpa);
    338336            file->fpa = NULL;
    339             if (data->masksName) {
    340                 pmFPAfile *file = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.MASK", j);
    341                 psFree(file->fpa);
    342                 file->fpa = NULL;
    343             }
    344337            pmFPAfileActivate(data->config->files, false, NULL);
    345338        }
     
    350343          pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN1");
    351344          pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN2");
    352           if (data->masksName) {
    353             pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN1.MASK");
    354             pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN2.MASK");
    355           }
    356345        }
    357346       
     
    366355        ro1->image = image1;
    367356        ro2->image = image2;
    368         ro1->mask = mask1;
    369         ro2->mask = mask2;
    370357
    371358        ro1->data_exists = cell1->data_exists = cell1->parent->data_exists = true;
     
    386373          fits1->fpa->hdu->header = psMetadataAlloc();
    387374          psMetadataCopy(fits1->fpa->hdu->header,projhdu->header);
    388 
     375         
    389376          // Change wcs here
    390 #define WCS_DEBUG 0
    391377          if (modify_wcs1) {
    392378            pmAstromWCS *WCS = pmAstromWCSfromHeader(fits1->fpa->hdu->header);
    393379            double cd1f = 1.0 * data->bin1;
    394380            double cd2f = 1.0 * data->bin1;
    395 #if WCS_DEBUG
    396             fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g)\n",data->bin1,data->bin2,
    397                     cd1f,cd2f,WCS->cdelt1,WCS->cdelt2,
    398                     WCS->crpix1,WCS->crpix2
    399                     );
    400 #endif
     381
    401382            WCS->cdelt1 *= cd1f;
    402383            WCS->cdelt2 *= cd2f;
     
    414395              WCS->crpix2 = WCS->crpix2 / cd2f;
    415396            }
    416 #if WCS_DEBUG
    417             fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g) %d %d %d %d\n",data->bin1,data->bin2,
    418                     cd1f,cd2f,WCS->cdelt1,WCS->cdelt2,
    419                     WCS->crpix1,WCS->crpix2,
    420                     WCS->trans->x->nX,              WCS->trans->x->nY,
    421                     WCS->trans->y->nX,              WCS->trans->y->nY
    422                     );
    423 #endif
     397
    424398            for (int q = 0; q <= WCS->trans->x->nX; q++) {
    425399              for (int r = 0; r <= WCS->trans->x->nY; r++) {
    426400                WCS->trans->x->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r);
    427 #if WCS_DEBUG
    428                 fprintf(stderr,"PC: %d %d %g %g\n",
    429                         q,r,pow(cd1f,q) * pow(cd2f,r),
    430                         WCS->trans->x->coeff[q][r]);
    431 #endif
    432401              }
    433402            }
     
    435404              for (int r = 0; r <= WCS->trans->y->nY; r++) {
    436405                WCS->trans->y->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r);
    437 #if WCS_DEBUG
    438                 fprintf(stderr,"PC: %d %d %g %g\n",
    439                          q,r,pow(cd1f,q) * pow(cd2f,r),
    440                          WCS->trans->y->coeff[q][r]);
    441 #endif
    442406              }
    443407            }
    444408            pmAstromWCStoHeader (fits1->fpa->hdu->header,WCS);
    445 #if WCS_DEBUG
    446             WCS = pmAstromWCSfromHeader(fits1->fpa->hdu->header);
    447             fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g)\n",data->bin1,data->bin2,
    448                     cd1f,cd2f,WCS->cdelt1,WCS->cdelt2,
    449                     WCS->crpix1,WCS->crpix2
    450                     );
    451 #endif
    452409            modify_wcs1 = 0;
    453410          }
     
    459416
    460417          pmCell *Fcell1 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN1"); // Rebinned cell 1
    461 /*        // This is a hack to get a functioning header created so the fits images can be written out. */
     418          // This is a hack to get a functioning header created so the fits images can be written out.
    462419          psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.XPARITY", PS_META_REPLACE,"",1);
    463420          psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1);
    464421          psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1);
    465422
     423          // I am baffled that this is the way to get the exposure time updated correctly.
     424          psMetadataItem *item1;
     425          item1 = psMetadataLookup(Fcell1->concepts,"CELL.EXPOSURE");
     426          item1->data.F32 = stats->robustMedian;
     427
    466428          pmReadout *Fro1 = pmReadoutAlloc(Fcell1);
    467429          Fro1->image = image1;
    468           Fro1->mask = mask1;
    469430          Fro1->data_exists = Fcell1->data_exists = Fcell1->parent->data_exists = true;
    470431         
     
    472433          fits1->fileIndex = i;
    473434
    474           // Do the mask if we need to
    475           if (data->masksName) {
    476 /*          pmFPAfile *Mask1 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN1.MASK", 0); */
    477 /*          //      Mask1->fpa->hdu = pmHDUAlloc(NULL); */
    478 /*          //      Mask1->fpa->hdu->header = psMetadataAlloc(); */
    479 /*          //      psMetadataCopy(Mask1->fpa->hdu->header,fits1->fpa->hdu->header); */
    480 /*          pmChip *Mchip1 = pmFPAfileThisChip(data->config->files, view, "PPSKYCELL.BIN1.MASK"); */
    481 /*          psMetadataAddS32(Mchip1->concepts,PS_LIST_TAIL,"CHIP.XPARITY", PS_META_REPLACE,"",1); */
    482 /*          psMetadataAddS32(Mchip1->concepts,PS_LIST_TAIL,"CHIP.YPARITY", PS_META_REPLACE,"",1); */
    483            
    484 /*          pmCell *Mcell1 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN1.MASK"); // Rebinned cell 1 */
    485 /*          /\*           // This is a hack to get a functioning header created so the fits images can be written out. *\/ */
    486 /*          psMetadataAddS32(Mcell1->concepts,PS_LIST_TAIL,"CELL.XPARITY", PS_META_REPLACE,"",1); */
    487 /*          psMetadataAddS32(Mcell1->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1); */
    488 /*          psMetadataAddS32(Mcell1->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1); */
    489            
    490 /*          pmReadout *Mro1 = pmReadoutAlloc(Mcell1); */
    491 /*          Mro1->image = image1; */
    492 /*          Mro1->mask = mask1; */
    493 /*          Mro1->data_exists = Mcell1->data_exists = Mcell1->parent->data_exists = true; */
    494            
    495 /*          Mask1->save = true; */
    496 /*          Mask1->fileIndex = i; */
    497           }
    498            
    499            
    500          
    501435          // Repeat with second binned image
    502436          pmFPAfile *fits2 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN2", 0);
     
    504438          fits2->fpa->hdu->header = psMetadataAlloc();
    505439          psMetadataCopy(fits2->fpa->hdu->header,projhdu->header);
    506 
     440         
    507441          if (modify_wcs2) {
    508442            pmAstromWCS *WCS = pmAstromWCSfromHeader(fits2->fpa->hdu->header);
     
    538472          psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1);
    539473          psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1);
     474
     475          psMetadataItem *item2 = psMetadataLookup(Fcell2->concepts,"CELL.EXPOSURE");
     476          item2->data.F32 = stats->robustMedian;
    540477         
    541478          pmReadout *Fro2 = pmReadoutAlloc(Fcell2);
    542479          Fro2->image = image2;
    543           Fro2->mask = mask2;
    544480          Fro2->data_exists = Fcell2->data_exists = Fcell2->parent->data_exists = true;
    545481
     
    551487
    552488        psFree(view);
    553 #if 0
    554         {
    555             psString filename = NULL;   // Filename for image
    556             psStringAppend(&filename, "skycell_%d_1.fits", i);
    557             psFits *fits = psFitsOpen(filename, "w");
    558             psFree(filename);
    559             psFitsWriteImage(fits, NULL, image1, 0, NULL);
    560             psFitsClose(fits);
    561         }
    562 
    563         {
    564             psString filename = NULL;   // Filename for image
    565             psStringAppend(&filename, "skycell_%d_2.fits", i);
    566             psFits *fits = psFitsOpen(filename, "w");
    567             psFree(filename);
    568             psFitsWriteImage(fits, NULL, image2, 0, NULL);
    569             psFitsClose(fits);
    570         }
    571 #endif
    572489
    573490        filesIterateUp(data->config);
Note: See TracChangeset for help on using the changeset viewer.