IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18464


Ignore:
Timestamp:
Jul 10, 2008, 5:00:53 PM (18 years ago)
Author:
Paul Price
Message:

Fixing projection. Somehow (not sure how), the scale was off, which
was killing the astrometry.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSimLoadStars.c

    r18011 r18464  
    3535    float y0fpa = 0.5*(bounds->y0 + bounds->y1);
    3636
    37     psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MIN",  PS_DATA_F32 | PS_META_REPLACE, "", ra0 - radius);
    38     psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MAX",  PS_DATA_F32 | PS_META_REPLACE, "", ra0 + radius);
     37    psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MIN",  PS_DATA_F32 | PS_META_REPLACE, "",
     38                  ra0 - radius / cos(dec0));
     39    psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MAX",  PS_DATA_F32 | PS_META_REPLACE, "",
     40                  ra0 + radius / cos(dec0));
    3941    psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MIN", PS_DATA_F32 | PS_META_REPLACE, "", dec0 - radius);
    4042    psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MAX", PS_DATA_F32 | PS_META_REPLACE, "", dec0 + radius);
     
    5052    stars = psArrayRealloc (stars, refStars->n);
    5153
     54    psProjection *proj = psProjectionAlloc(ra0, dec0, scale, scale, PS_PROJ_TAN); // Projection
     55
    5256    // Conversion loop
    5357    for (long i = 0; i < refStars->n; i++) {
     
    6064
    6165        // Convert to x,y position on tangent plane, in pixels
    62         float div = (sin(star->ra) * sin(dec0) + cos(star->dec) * cos(dec0) * cos(star->ra - ra0)) * scale;
    63         float xi = cos(star->dec) * sin(star->ra - ra0) / div;
    64         float eta = (sin(star->dec) * cos(dec0) - cos(star->dec) * sin(dec0) * cos(star->ra - ra0)) / div;
     66        psPlane plane;                  // Plane (detector) coordinates
     67        psSphere sphere;                // Sphere (sky) coordinates
     68        sphere.r = star->ra;
     69        sphere.d = star->dec;
     70        psProject(&plane, &sphere, proj);
    6571
    6672        // Apply rotation, make FPA center of boresite
    67         star->x = cos(pa) * xi - sin(pa) * eta + x0fpa;
    68         star->y = sin(pa) * xi + cos(pa) * eta + y0fpa;
     73        star->x = cos(pa) * plane.x - sin(pa) * plane.y + x0fpa;
     74        star->y = sin(pa) * plane.x + cos(pa) * plane.y + y0fpa;
    6975
    7076        // Convert magnitude to peak flux
     
    7783    }
    7884    stars->n = oldSize + refStars->n;
     85    psFree(proj);
    7986
    8087    pmLumFunc *lumfunc = psastroLuminosityFunction (refStars);
     
    8390    psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "FPA.RA", PS_META_REPLACE, "Right ascension", ra0);
    8491    psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "FPA.DEC", PS_META_REPLACE, "Declination", dec0);
    85    
     92
    8693    if (lumfunc) {
    87         psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.MAG.MIN",   PS_META_REPLACE, "min valid magnitude",             lumfunc->mMin);
    88         psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.MAG.MAX",   PS_META_REPLACE, "max valid magnitude",             lumfunc->mMax);
    89         psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.LF.SLOPE",  PS_META_REPLACE, "log-mag histogram slope",         lumfunc->slope);
    90         psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.LF.OFFSET", PS_META_REPLACE, "log-mag histogram offset",        lumfunc->offset);
    91         psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.MAG.PEAK",  PS_META_REPLACE, "magnitude of peak bin",           lumfunc->mPeak);
    92         psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.NUM.PEAK",  PS_META_REPLACE, "number of stars in peak bin", lumfunc->nPeak);
    93         psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.SUM.PEAK",  PS_META_REPLACE, "sum of stars up to peak bin", lumfunc->sPeak);
    94         psFree (lumfunc);
     94        psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.MAG.MIN",   PS_META_REPLACE, "min valid magnitude",             lumfunc->mMin);
     95        psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.MAG.MAX",   PS_META_REPLACE, "max valid magnitude",             lumfunc->mMax);
     96        psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.LF.SLOPE",  PS_META_REPLACE, "log-mag histogram slope",         lumfunc->slope);
     97        psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.LF.OFFSET", PS_META_REPLACE, "log-mag histogram offset",        lumfunc->offset);
     98        psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.MAG.PEAK",  PS_META_REPLACE, "magnitude of peak bin",           lumfunc->mPeak);
     99        psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.NUM.PEAK",  PS_META_REPLACE, "number of stars in peak bin", lumfunc->nPeak);
     100        psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "STARS.REAL.SUM.PEAK",  PS_META_REPLACE, "sum of stars up to peak bin", lumfunc->sPeak);
     101        psFree (lumfunc);
    95102    }
    96103
Note: See TracChangeset for help on using the changeset viewer.