IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39685


Ignore:
Timestamp:
Sep 11, 2016, 2:29:33 PM (10 years ago)
Author:
eugene
Message:

add photometry difference weighting for the astrometric fit to the psastro.config recipe; add ZPN projection to the WCS I/O

Location:
branches/czw_branch/20160809/psModules/src/astrom
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20160809/psModules/src/astrom/pmAstrometryObjects.c

    r39653 r39685  
    225225    psArray *ref,
    226226    psArray *match,
    227     psStats *stats)
     227    psStats *stats,
     228    const psMetadata *config)
    228229{
    229230    PS_ASSERT_PTR_NON_NULL(map, NULL);
     
    232233    PS_ASSERT_PTR_NON_NULL(match, NULL);
    233234    PS_ASSERT_PTR_NON_NULL(stats, NULL);
     235    PS_ASSERT_PTR_NON_NULL(config, NULL);
     236
     237    // sigma of gaussian window to down-weight photometric outliers (ignored if NAN or 0.0)
     238    bool status;
     239    double photomWindowSigma  = psMetadataLookupF32 (&status, config, "PSASTRO.PHOTOM.WINDOW.SIGMA");
     240    bool   photomWindowApply  = !(isnan(photomWindowSigma) || (fabs(photomWindowSigma < 0.01)));
     241    double photomWindowFactor = photomWindowApply ? -0.5/PS_SQR(photomWindowSigma) : 0.0;
    234242
    235243    // reassign values for clip fit
     
    252260        y->data.F32[i] = refStar->FP->y;
    253261
    254         wt->data.F32[i] = 1.01 - exp(-10.0*PS_SQR(refStar->magCal - rawStar->magCal)); // sigma = 0.22 mag
     262        // wt is used as an error (sqrt(variance)) in the fit. the 1.01 prevents the weight from going to 0.0 for perfect matches
     263        wt->data.F32[i] = 1.01 - exp(photomWindowFactor*PS_SQR(refStar->magCal - rawStar->magCal));
    255264    }
    256265
     
    776785    double gridOffset = psMetadataLookupF32 (&status, config, "PSASTRO.GRID.OFFSET");
    777786
    778     // sampling scale of the grid
    779     double gridScale  = psMetadataLookupF32 (&status, config, "PSASTRO.GRID.SCALE");
     787     // sampling scale of the grid
     788     double gridScale  = psMetadataLookupF32 (&status, config, "PSASTRO.GRID.SCALE");
     789
     790    // sigma of gaussian window to down-weight photometric outliers (ignored if NAN or 0.0)
     791    double photomWindowSigma  = psMetadataLookupF32 (&status, config, "PSASTRO.PHOTOM.WINDOW.SIGMA");
     792    bool   photomWindowApply  = !(isnan(photomWindowSigma) || (fabs(photomWindowSigma < 0.01)));
     793    double photomWindowFactor = photomWindowApply ? -0.5/PS_SQR(photomWindowSigma) : 0.0;
    780794
    781795    // set the static scaling factors
     
    818832            }
    819833
    820             int Npts = 10 * exp(-10.0*PS_SQR(ob1->magCal - ob2->magCal));  // sigma = 0.22 mag
     834            // XXX should I make the scale factor in front a recipe value?
     835            int Npts = 10 * exp(photomWindowFactor*PS_SQR(ob1->magCal - ob2->magCal));
    821836
    822837            // accumulate bin stats
     
    10571072    double tweakNsigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.TWEAK.NSIGMA");
    10581073
     1074    // sigma of gaussian window to down-weight photometric outliers (ignored if NAN or 0.0)
     1075    double photomWindowSigma  = psMetadataLookupF32 (&status, recipe, "PSASTRO.PHOTOM.WINDOW.SIGMA");
     1076    bool   photomWindowApply  = !(isnan(photomWindowSigma) || (fabs(photomWindowSigma < 0.01)));
     1077    double photomWindowFactor = photomWindowApply ? -0.5/PS_SQR(photomWindowSigma) : 0.0;
     1078
    10591079    nBin = 2*tweakRange / tweakScale;
    10601080    psVector *xHist = psVectorAlloc (nBin, PS_TYPE_F32);
     
    10831103                continue;
    10841104
    1085             int Npts = 10 * exp(-10.0*PS_SQR(ob1->magCal - ob2->magCal));  // sigma = 0.22 mag
     1105            // XXX should I make the scale factor in front a recipe value?
     1106            int Npts = 10 * exp(photomWindowFactor*PS_SQR(ob1->magCal - ob2->magCal));  // sigma = 0.22 mag
    10861107
    10871108            xHist->data.F32[xBin] += Npts;
  • branches/czw_branch/20160809/psModules/src/astrom/pmAstrometryObjects.h

    r39653 r39685  
    348348    psArray *ref,
    349349    psArray *match,
    350     psStats *stats
     350    psStats *stats,
     351    const psMetadata *config
    351352);
    352353
  • branches/czw_branch/20160809/psModules/src/astrom/pmAstrometryWCS.c

    r36492 r39685  
    277277    wcs->crpix2 = psMetadataLookupF64 (&status, header, "CRPIX2");
    278278    wcs->toSky = psProjectionAlloc (wcs->crval1*PM_RAD_DEG, wcs->crval2*PM_RAD_DEG, PM_RAD_DEG, PM_RAD_DEG, type);
     279
     280    // XXX if type == ZPN, look for PV2_%d elements:
     281    if (type == PS_PROJ_ZPN) {
     282      psVector *maxRadial = psVectorAlloc (21, PS_TYPE_F64);
     283      for (int i = 0; i <= 20; i++) {
     284        char name[64];
     285        snprintf (name, 64, "PV2_%d", i);
     286
     287        maxRadial->data.F64[i] = 0.0;
     288        double value = psMetadataLookupF64 (&status, header, name);
     289
     290        if (status) {
     291          maxRadial->data.F64[i] = value;
     292          maxRadial->n = i;
     293        }
     294
     295        // PV2_1 is implicit if not present
     296        if ((i == 1) && !status) {
     297          maxRadial->data.F64[i] = 1.0;
     298          continue;
     299        }
     300      }
     301      maxRadial->n ++;
     302      wcs->toSky->radial = maxRadial;
     303    }
    279304
    280305    // These aren't needed but having them empty is disconcerting
     
    375400    psMetadataAddF64 (header, PS_LIST_TAIL, "CRPIX1", PS_META_REPLACE, "", wcs->crpix1);
    376401    psMetadataAddF64 (header, PS_LIST_TAIL, "CRPIX2", PS_META_REPLACE, "", wcs->crpix2);
     402
     403    if (wcs->toSky->type == PS_PROJ_ZPN) {
     404      psAssert (wcs->toSky->radial, "missing radial vector");
     405      for (int i = 0; i < wcs->toSky->radial->n; i++) {
     406        if (wcs->toSky->radial->data.F64[i] == 0.0) continue;
     407        snprintf (name, 16, "PV2_%d", i);
     408        psMetadataAddF64 (header, PS_LIST_TAIL, name, PS_META_REPLACE, "", wcs->toSky->radial->data.F64[i]);
     409      }
     410    }
    377411
    378412    // XXX make it optional to write out CDi_j terms, or other versions
     
    485519    // projection from TPA (linear microns) to SKY (radians)
    486520    psProjection *toSky = psProjectionAlloc (wcs->toSky->R, wcs->toSky->D, PM_RAD_DEG*pdelt1, PM_RAD_DEG*pdelt2, wcs->toSky->type);
     521    toSky->radial = psMemIncrRefCounter (wcs->toSky->radial);
    487522
    488523    if (fpa->toSky == NULL) {
     
    633668    // cdelt1,2 has units of degrees/micron
    634669    fpa->toSky = psProjectionAlloc (wcs->toSky->R, wcs->toSky->D, wcs->cdelt1*PM_RAD_DEG, wcs->cdelt2*PM_RAD_DEG, wcs->toSky->type);
     670    fpa->toSky->radial = psMemIncrRefCounter (wcs->toSky->radial);
    635671
    636672    // create transformation with 0,0 reference pixel
     
    701737    // convert projection from FPA to SKY into wcs projection (degrees to radians)
    702738    wcs->toSky = psProjectionAlloc (fpa->toSky->R, fpa->toSky->D, PM_RAD_DEG, PM_RAD_DEG, fpa->toSky->type);
     739    wcs->toSky->radial = psMemIncrRefCounter (fpa->toSky->radial);
     740
    703741    wcs->crval1 = fpa->toSky->R*PS_DEG_RAD;
    704742    wcs->crval2 = fpa->toSky->D*PS_DEG_RAD;
Note: See TracChangeset for help on using the changeset viewer.