IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20036 for trunk/psastro


Ignore:
Timestamp:
Oct 9, 2008, 3:07:38 PM (18 years ago)
Author:
Paul Price
Message:

Merging from Chris Beaumont branch (cns_branch_20081009) to get luminosity function plots.

Location:
trunk/psastro/src
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastro.h

    r19512 r20036  
    1717// logN = offset + slope * logS
    1818typedef struct {
    19     double mMin;                        // minimum magnitude bin with data
    20     double mMax;                        // maximum magnitude bin with data
    21     double offset;                      // fitted line offset
    22     double slope;                       // fitted line slope
    23     double mPeak;                       // mag of peak bin
    24     int nPeak;                          // # of stars in peak bin
    25     int sPeak;                          // sum of stars to peak bin
     19    double mMin;                        // minimum magnitude bin with data
     20    double mMax;                        // maximum magnitude bin with data
     21    double offset;                      // fitted line offset
     22    double slope;                       // fitted line slope
     23    double mPeak;                       // mag of peak bin
     24    int nPeak;                          // # of stars in peak bin
     25    int sPeak;                          // sum of stars to peak bin
    2626} pmLumFunc;
    2727
     
    4747bool              psastroChooseRefstars (pmConfig *config, psArray *refs);
    4848bool              psastroRefstarSubset (pmReadout *readout);
    49 pmLumFunc        *psastroLuminosityFunction (psArray *stars);
     49pmLumFunc        *psastroLuminosityFunction (psArray *stars, pmLumFunc *rawFunc);
     50bool              psastroLuminosityFunctionPlot(psVector *lnMag, psVector *Mag, pmLumFunc *lumFunc, pmLumFunc *rawFunc);
    5051psArray          *psastroRemoveClumps (psArray *input, int scale);
    5152
     
    5657
    5758// mosaic fitting functions
    58 bool              psastroMosaicDistortion (pmFPA *fpa, psMetadata *recipe, int pass);
     59bool              psastroMosaicDistortion (pmFPA *fpa, psMetadata *recipe, int pass);
    5960psPlaneTransform *psastroMosaicFitRotAndScale (pmFPA *fpa);
    6061bool              psastroMosaicApplyRotAndScale (pmFPA *fpa, psPlaneTransform *TPtoFP);
    61 bool              psastroMosaicDistortionFromGradients (pmFPA *fpa, psMetadata *recipe);
     62bool              psastroMosaicDistortionFromGradients (pmFPA *fpa, psMetadata *recipe);
    6263bool              psastroMosaicCorrectDistortion (pmFPA *fpa, psPlaneTransform *TPtoFP);
    63 bool              psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe);
    64 bool              psastroMosaicAstrom (pmConfig *config);
    65 bool              psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe, int iteration);
    66 bool              psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration);
    67 bool              psastroMosaicSetAstrom (pmFPA *fpa);
    68 bool              psastroMosaicHeaders (pmConfig *config);
    69 bool              psastroMosaicRescaleChips (pmFPA *fpa);
    70 bool              psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration);
     64bool              psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe);
     65bool              psastroMosaicAstrom (pmConfig *config);
     66bool              psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe, int iteration);
     67bool              psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration);
     68bool              psastroMosaicSetAstrom (pmFPA *fpa);
     69bool              psastroMosaicHeaders (pmConfig *config);
     70bool              psastroMosaicRescaleChips (pmFPA *fpa);
     71bool              psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration);
    7172
    7273// Return version strings.
    73 psString          psastroVersion(void);
    74 psString          psastroVersionLong(void);
     74psString          psastroVersion(void);
     75psString          psastroVersionLong(void);
    7576
    7677// demo plots
    77 bool              psastroPlotRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip, psMetadata *recipe);
    78 bool              psastroPlotRefstars (psArray *refstars, psMetadata *recipe);
    79 bool              psastroPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe);
     78bool              psastroPlotRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip, psMetadata *recipe);
     79bool              psastroPlotRefstars (psArray *refstars, psMetadata *recipe);
     80bool              psastroPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe);
    8081
    81 bool              psastroDumpRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip);
    82 bool              psastroDumpRefstars (psArray *refstars, char *filename);
    83 bool              psastroDumpMatches (pmFPA *fpa, char *filename);
    84 bool              psastroDumpStars (psArray *stars, char *filename);
     82bool              psastroDumpRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip);
     83bool              psastroDumpRefstars (psArray *refstars, char *filename);
     84bool              psastroDumpMatches (pmFPA *fpa, char *filename);
     85bool              psastroDumpStars (psArray *stars, char *filename);
    8586bool              psastroDumpMatchedStars (char *filename, psArray *rawstars, psArray *refstars, psArray *match);
    8687bool              psastroDumpGradients (psArray *gradients, char *filename);
    8788
    88 bool              psastroMosaicSetAstrom_tmp (pmFPA *fpa);
    89 int               psastroSortByMag (const void *a, const void *b);
     89bool              psastroMosaicSetAstrom_tmp (pmFPA *fpa);
     90int               psastroSortByMag (const void *a, const void *b);
    9091
    9192bool              psastroFixChips (pmConfig *config, psMetadata *recipe);
  • trunk/psastro/src/psastroLuminosityFunction.c

    r17677 r20036  
    2727}
    2828
    29 pmLumFunc *psastroLuminosityFunction (psArray *stars) {
     29pmLumFunc *psastroLuminosityFunction (psArray *stars, pmLumFunc *rawFunc) {
    3030
    3131    if (stars->n == 0) return NULL;
     
    3636    double mMax = star->Mag;
    3737    for (int i = 0; i < stars->n; i++) {
    38         star = stars->data[i];
    39         mMin = PS_MIN (star->Mag, mMin);
    40         mMax = PS_MAX (star->Mag, mMax);
     38        star = stars->data[i];
     39        mMin = PS_MIN (star->Mag, mMin);
     40        mMax = PS_MAX (star->Mag, mMax);
    4141    }
    4242
    4343    int nBin = 1 + (mMax - mMin) / dMag;
    4444    if (nBin <= 1) {
    45         psLogMsg ("psastro", 4, "insufficient valid stars for this readout\n");
    46         return NULL;
     45        psLogMsg ("psastro", 4, "insufficient valid stars for this readout\n");
     46        return NULL;
    4747    }
    4848
     
    5454
    5555    for (int i = 0; i < stars->n; i++) {
    56         star = stars->data[i];
    57         if (!isfinite(star->Mag)) continue;
    58         int bin = (star->Mag - mMin) / dMag;
    59         if (bin < 0) psAbort("bin cannot be negative!");
    60         if (bin >= nBin) psAbort("bin cannot be > %d!", nBin);
    61         nMags->data.F32[bin] += 1.0;
     56        star = stars->data[i];
     57        if (!isfinite(star->Mag)) continue;
     58        int bin = (star->Mag - mMin) / dMag;
     59        if (bin < 0) psAbort("bin cannot be negative!");
     60        if (bin >= nBin) psAbort("bin cannot be > %d!", nBin);
     61        nMags->data.F32[bin] += 1.0;
    6262    }
    6363
     
    6767    int sPeak = 0;
    6868    for (int i = 0; i < nMags->n; i++) {
    69         if (nMags->data.F32[i] < nPeak) continue;
    70         iPeak = i;
    71         nPeak = nMags->data.F32[i];
    72         sPeak += nPeak;
     69        if (nMags->data.F32[i] < nPeak) continue;
     70        iPeak = i;
     71        nPeak = nMags->data.F32[i];
     72        sPeak += nPeak;
    7373    }
    7474
     
    8181    int n = 0;
    8282    for (int i = 0; i < nMags->n; i++) {
    83         if (nMags->data.F32[i] < 1) continue;
    84         if ((i > iPeak) && (nMags->data.F32[i] < 0.8*nPeak)) continue;
    85         lnMag->data.F32[n] = log10 (nMags->data.F32[i]);
    86         Mag->data.F32[n] = mMin + (i + 0.5)*dMag;
    87         n++;
     83        if (nMags->data.F32[i] < 1) continue;
     84        if ((i > iPeak) && (nMags->data.F32[i] < 0.8*nPeak)) continue;
     85        lnMag->data.F32[n] = log10 (nMags->data.F32[i]);
     86        Mag->data.F32[n] = mMin + (i + 0.5)*dMag;
     87        n++;
    8888    }
    8989    lnMag->n = n;
     
    100100
    101101    if (!psVectorClipFitPolynomial1D(line, stats, mask, 0xff, lnMag, NULL, Mag)) {
    102         psLogMsg ("psastro", 4, "Failed to fit the luminosity function\n");
    103         return(NULL);
     102        psLogMsg ("psastro", 4, "Failed to fit the luminosity function\n");
     103        return(NULL);
    104104    }
    105105
     
    108108    double mMaxValid = NAN;
    109109    for (int i = 0; i < Mag->n; i++) {
    110         if (mask->data.U8[i]) continue;
    111         if (isnan(mMinValid) || (Mag->data.F32[i] < mMinValid)) {
    112             mMinValid = Mag->data.F32[i];
    113         }
    114         if (isnan(mMaxValid) || (Mag->data.F32[i] > mMaxValid)) {
    115             mMaxValid = Mag->data.F32[i];
    116         }
     110        if (mask->data.U8[i]) continue;
     111        if (isnan(mMinValid) || (Mag->data.F32[i] < mMinValid)) {
     112            mMinValid = Mag->data.F32[i];
     113        }
     114        if (isnan(mMaxValid) || (Mag->data.F32[i] > mMaxValid)) {
     115            mMaxValid = Mag->data.F32[i];
     116        }
    117117    }
    118118
     
    129129    lumFunc->sPeak = sPeak;
    130130
     131    psastroLuminosityFunctionPlot(lnMag, Mag, lumFunc, rawFunc);
     132
    131133    psFree (lnMag);
    132134    psFree (nMags);
Note: See TracChangeset for help on using the changeset viewer.