IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 18, 2006, 8:44:12 AM (20 years ago)
Author:
eugene
Message:

select refstars by magnitude, fix various memory leaks, better error tests, fix luminosity function test

File:
1 edited

Legend:

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

    r9587 r9627  
    55  // select the raw objects for this readout
    66  psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");
    7   if (rawstars == NULL) { continue; }
     7  if (rawstars == NULL)  {
     8    psError(PSASTRO_ERR_DATA, false, "missing rawstars in psastroRefstarSubset\n");
     9    return false;
     10  }
    811
    912  // select the raw objects for this readout
    1013  psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");
    11   if (refstars == NULL) { continue; }
     14  if (refstars == NULL)  {
     15    psError(PSASTRO_ERR_DATA, false, "missing refstars in psastroRefstarSubset\n");
     16    return false;
     17  }
    1218
    1319  // calculate luminosity functions for rawstars and refstars
     
    1521  // is needed...
    1622  pmLumFunc *rawfunc = psastroLuminosityFunction (rawstars);
     23  if (rawfunc == NULL) {
     24    psError(PSASTRO_ERR_DATA, false, "error measuring rawstar luminosity function\n");
     25    return NULL;
     26  }
    1727  pmLumFunc *reffunc = psastroLuminosityFunction (refstars);
     28  if (reffunc == NULL) {
     29    psError(PSASTRO_ERR_DATA, false, "error measuring refstar luminosity function\n");
     30    return NULL;
     31  }
     32 
     33  // XXXX test
     34  // psFree (rawfunc);
     35  // psFree (reffunc);
     36  // return true;
    1837
    1938  // what is the offset between the two lines at the average magnitude?
    20   mRef = 0.5*(reffunc->mMin + reffunc->mMax);
    21   logRho = mRef * reffunc->slope + reffunc->offset;
    22   mRaw = (logRho - rawfunc->offset) / rawfunc->slope;
     39  double mRef = 0.5*(reffunc->mMin + reffunc->mMax);
     40  double logRho = mRef * reffunc->slope + reffunc->offset;
     41  double mRaw = (logRho - rawfunc->offset) / rawfunc->slope;
    2342
    2443  psLogMsg ("psastro", 4, "mRef: %f, logRho: %f, mRaw: %f\n", mRef, logRho, mRaw);
    2544
    26   mRefMax = rawfunc->mMax - mRaw + mRef;
     45  double mRefMax = rawfunc->mMax - mRaw + mRef;
    2746  psLogMsg ("psastro", 4, "clipping stars fainter than %f\n", mRefMax);
    2847
     
    3150    pmAstromObj *ref = refstars->data[i];
    3251    if (ref->Mag > mRefMax) continue;
    33     psArrayAdd (subset, ref);
     52    psArrayAdd (subset, 100, ref);
    3453  }
    3554
    36   psLogMsg ("psastro", 4, "keeping %d of %d reference stars\n", subset->n, refstars->n);
     55  psLogMsg ("psastro", 4, "keeping %ld of %ld reference stars\n", subset->n, refstars->n);
    3756
    3857  psMetadataRemoveKey (readout->analysis, "PSASTRO.REFSTARS");
    3958  psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", subset);
    4059
     60  psFree (rawfunc);
     61  psFree (reffunc);
     62  psFree (subset);
     63
    4164  return true;
    4265}
Note: See TracChangeset for help on using the changeset viewer.