IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 1, 2007, 12:10:36 PM (19 years ago)
Author:
eugene
Message:

limit to brightest PSASTRO.MAX.NSTAR for comparison

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroConvert.c

    r10855 r11551  
    11# include "psastro.h"
    2 // XXX leak free 2006.04.27
     2// leak free 2006.04.27
    33
    44bool psastroConvertFPA (pmFPA *fpa, psMetadata *recipe) {
     
    2929}
    3030
    31 // XXX pass/apply the WCS information?
     31// pass/apply the WCS information?
    3232bool psastroConvertReadout (pmReadout *readout, psMetadata *recipe) {
    3333
     34    bool status;
     35
     36    // PSPHOT.SOURCES carries the pmSource objects (from psphot analysis or loaded externally)
    3437    psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
    3538    if (sources == NULL)
    3639        return false;
    3740
    38     psArray *rawstars = pmSourceToAstromObj (sources);
     41    // convert the pmSource objects into pmAstromObj objects (drop !STAR and SATSTAR?)
     42    psArray *inStars = pmSourceToAstromObj (sources);
    3943
    40     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.RAWSTARS", PS_DATA_ARRAY, "astrometry objects", rawstars);
    41     psLogMsg ("psastro", 4, "loaded %ld sources\n", rawstars->n);
     44    // sort in ascending magnitude order
     45    psArraySort (inStars, psastroSortByMag);
    4246
    43     psFree (rawstars);
     47    // we are going to select the brighter Nmax subset for astrometry
     48    int nMax = psMetadataLookupS32 (&status, recipe, "PSASTRO.MAX.NSTAR");
     49    if (!status || (nMax < 10)) nMax = 300; // 10 is really somewhat absurd as a lower limit
     50
     51    // choose the first nMax sources
     52    psArray *rawStars = psArrayAlloc (PS_MIN (nMax, inStars->n));
     53    for (int i = 0; i < rawStars->n; i++) {
     54        rawStars->data[i] = psMemIncrRefCounter (inStars->data[i]);
     55    }
     56
     57    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.RAWSTARS", PS_DATA_ARRAY, "astrometry objects", rawStars);
     58    psLogMsg ("psastro", 4, "loaded %ld sources, using %ld of %ld good sources\n", sources->n, rawStars->n, inStars->n);
     59
     60    psFree (inStars);
     61    psFree (rawStars);
    4462
    4563    return true;
    4664}
    4765
    48 // XXX select a magnitude range?
     66// select a magnitude range?
    4967psArray *pmSourceToAstromObj (psArray *sources) {
    5068
     
    5573
    5674        // only accept the PSF sources?
     75        // XXX drop SATSTAR?
    5776        if (source->type != PM_SOURCE_TYPE_STAR) continue;
    5877
     
    7998    return objects;
    8099}
     100
     101// sort by Mag (ascending)
     102int psastroSortByMag (const void **a, const void **b)
     103{
     104    pmAstromObj *A = *(pmAstromObj **) a;
     105    pmAstromObj *B = *(pmAstromObj **) b;
     106
     107    psF32 mA = (isfinite(A->Mag)) ? A->Mag : FLT_MAX;
     108    psF32 mB = (isfinite(B->Mag)) ? B->Mag : FLT_MAX;
     109
     110    psF32 diff = mA - mB;
     111    if (diff > FLT_EPSILON) return (+1);
     112    if (diff < FLT_EPSILON) return (-1);
     113    return (0);
     114}
     115
Note: See TracChangeset for help on using the changeset viewer.