IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38030


Ignore:
Timestamp:
Mar 28, 2015, 5:32:49 AM (11 years ago)
Author:
eugene
Message:

skip non-gpc1 chips when applying KH correction; in galaxy shape error analysis, measure stdev of theta for a domain of theta - pi : theta + pi; add flags for cases where galaxy shape error analysis fails; add header keyword to note errors are in major,minor,theta not PAR[Sxx,Sxy,Syy]

Location:
branches/eam_branches/ipp-20150326/psastro/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150326/psastro/src/psastroConvert.c

    r36868 r38030  
    335335  pmChip *chip = readout->parent->parent;
    336336  char *chipName = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     337
     338  // skip stacks
     339  if (!strcmp(chipName, "SkyChip")) {
     340    psLogMsg ("psastro.correctKH", PS_LOG_DETAIL, "skipping KH correction: not a gpc1 chip\n");
     341    return true;
     342  }
     343
     344  // only try to address gpc1 chips (should probably check the camera)
     345  if (strncmp(chipName, "XY", 2)) {
     346    psLogMsg ("psastro.correctKH", PS_LOG_DETAIL, "skipping KH correction: not a gpc1 chip\n");
     347    return true;
     348  }
    337349
    338350  psAssert (strlen(chipName) == 4, "error in chip name");
  • branches/eam_branches/ipp-20150326/psastro/src/psastroGalaxyShapeErrors.c

    r38025 r38030  
    1212
    1313# include "psastroInternal.h"
     14
     15double psastroNormalizeAngleToMidpoint (double angle, double midpoint);
    1416
    1517bool psastroGalaxyShapeErrors (psMetadata *recipe, pmReadout *readout) {
     
    7173            if (!(isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXY]) && isfinite(PAR[PM_PAR_SYY]))) {
    7274              // set a mask bit
     75              model->flags |= PM_MODEL_STATUS_NAN_SHAPE;
    7376              continue;
    7477            }
    7578            if (!(isfinite(dPAR[PM_PAR_SXX]) && isfinite(dPAR[PM_PAR_SXY]) && isfinite(dPAR[PM_PAR_SYY]))) {
    7679              // set a (different) mask bit
     80              model->flags |= PM_MODEL_STATUS_NAN_SHAPE_ERR;
    7781              continue;
    7882            }
     
    8993            bool useReff = model->class->useReff;
    9094            psEllipseAxes axes;
     95
     96            float SxxRef = PAR[PM_PAR_SXX];
     97            float SxyRef = PAR[PM_PAR_SXY];
     98            float SyyRef = PAR[PM_PAR_SYY];
     99            if (!(isfinite(SxxRef) && isfinite(SxyRef) && isfinite(SyyRef))) {
     100              // skip objects which are already poor ellipses
     101              model->flags |= PM_MODEL_STATUS_NAN_SHAPE;
     102              continue;
     103            }
     104            pmModelParamsToAxes (&axes, SxxRef, SxyRef, SyyRef, useReff);
     105            if (!(isfinite(axes.major) && isfinite(axes.minor) && isfinite(axes.theta))) {
     106              // skip objects which are already poor ellipses
     107              model->flags |= PM_MODEL_STATUS_NAN_SHAPE;
     108              continue;
     109            }
     110            double ThetaRef = axes.theta;
     111
    91112            for (int k = 0; k < nSample; k++) {
    92113
     
    101122                if (!(isfinite(axes.major) && isfinite(axes.minor) && isfinite(axes.theta))) continue;
    102123
     124                // theta should be in range ThetaRef - PI : ThetaRef + PI
     125                double ThetaNorm = psastroNormalizeAngleToMidpoint (axes.theta, ThetaRef);
     126
    103127                psVectorAppend (majorValues, axes.major);
    104128                psVectorAppend (minorValues, axes.minor);
    105                 psVectorAppend (thetaValues, axes.theta);
     129                psVectorAppend (thetaValues, ThetaNorm);
    106130            }
    107131            if (majorValues->n == 0) {
    108132                psWarning ("failed mc error search");
     133                model->flags |= PM_MODEL_STATUS_FAIL_SHAPE_ERR;
     134                continue;
    109135            }
    110136
     
    129155    psFree (thetaValues);
    130156
     157    psMetadata *header = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER");
     158    psMetadataAddStr (header, PS_LIST_TAIL, "GALAXY.SHAPE.ERRORS", PS_META_REPLACE, "error analysis mode", "MONTE CARLO");
     159
    131160    psLogMsg ("psastro.galaxy", PS_LOG_INFO, "monte carlo shape errors for %d of %d objects: %f sec\n", nObjects, (int) sources->n, psTimerMark ("psastro.galaxy.shape.errors"));
    132161    return true;
    133162}
    134163
     164// these angles are in radians
     165double psastroNormalizeAngleToMidpoint (double angle, double midpoint) {
     166
     167    double x = cos(angle);
     168    double y = sin(angle);
     169
     170    double result = atan2 (y, x);
     171    if (result < midpoint - M_PI) result += 2.0*M_PI;
     172    if (result > midpoint + M_PI) result -= 2.0*M_PI;
     173
     174    return result;
     175}
     176
Note: See TracChangeset for help on using the changeset viewer.