Changeset 20036 for trunk/psastro
- Timestamp:
- Oct 9, 2008, 3:07:38 PM (18 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 1 added
- 2 edited
-
psastro.h (modified) (3 diffs)
-
psastroLuminosityFunction.c (modified) (8 diffs)
-
psastroLuminosityFunctionPlot.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastro.h
r19512 r20036 17 17 // logN = offset + slope * logS 18 18 typedef struct { 19 double mMin; // minimum magnitude bin with data20 double mMax; // maximum magnitude bin with data21 double offset; // fitted line offset22 double slope; // fitted line slope23 double mPeak; // mag of peak bin24 int nPeak; // # of stars in peak bin25 int sPeak; // sum of stars to peak bin19 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 26 26 } pmLumFunc; 27 27 … … 47 47 bool psastroChooseRefstars (pmConfig *config, psArray *refs); 48 48 bool psastroRefstarSubset (pmReadout *readout); 49 pmLumFunc *psastroLuminosityFunction (psArray *stars); 49 pmLumFunc *psastroLuminosityFunction (psArray *stars, pmLumFunc *rawFunc); 50 bool psastroLuminosityFunctionPlot(psVector *lnMag, psVector *Mag, pmLumFunc *lumFunc, pmLumFunc *rawFunc); 50 51 psArray *psastroRemoveClumps (psArray *input, int scale); 51 52 … … 56 57 57 58 // mosaic fitting functions 58 bool psastroMosaicDistortion (pmFPA *fpa, psMetadata *recipe, int pass);59 bool psastroMosaicDistortion (pmFPA *fpa, psMetadata *recipe, int pass); 59 60 psPlaneTransform *psastroMosaicFitRotAndScale (pmFPA *fpa); 60 61 bool psastroMosaicApplyRotAndScale (pmFPA *fpa, psPlaneTransform *TPtoFP); 61 bool psastroMosaicDistortionFromGradients (pmFPA *fpa, psMetadata *recipe);62 bool psastroMosaicDistortionFromGradients (pmFPA *fpa, psMetadata *recipe); 62 63 bool 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);64 bool psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe); 65 bool psastroMosaicAstrom (pmConfig *config); 66 bool psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe, int iteration); 67 bool psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration); 68 bool psastroMosaicSetAstrom (pmFPA *fpa); 69 bool psastroMosaicHeaders (pmConfig *config); 70 bool psastroMosaicRescaleChips (pmFPA *fpa); 71 bool psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration); 71 72 72 73 // Return version strings. 73 psString psastroVersion(void);74 psString psastroVersionLong(void);74 psString psastroVersion(void); 75 psString psastroVersionLong(void); 75 76 76 77 // 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);78 bool psastroPlotRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip, psMetadata *recipe); 79 bool psastroPlotRefstars (psArray *refstars, psMetadata *recipe); 80 bool psastroPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe); 80 81 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);82 bool psastroDumpRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip); 83 bool psastroDumpRefstars (psArray *refstars, char *filename); 84 bool psastroDumpMatches (pmFPA *fpa, char *filename); 85 bool psastroDumpStars (psArray *stars, char *filename); 85 86 bool psastroDumpMatchedStars (char *filename, psArray *rawstars, psArray *refstars, psArray *match); 86 87 bool psastroDumpGradients (psArray *gradients, char *filename); 87 88 88 bool psastroMosaicSetAstrom_tmp (pmFPA *fpa);89 int psastroSortByMag (const void *a, const void *b);89 bool psastroMosaicSetAstrom_tmp (pmFPA *fpa); 90 int psastroSortByMag (const void *a, const void *b); 90 91 91 92 bool psastroFixChips (pmConfig *config, psMetadata *recipe); -
trunk/psastro/src/psastroLuminosityFunction.c
r17677 r20036 27 27 } 28 28 29 pmLumFunc *psastroLuminosityFunction (psArray *stars ) {29 pmLumFunc *psastroLuminosityFunction (psArray *stars, pmLumFunc *rawFunc) { 30 30 31 31 if (stars->n == 0) return NULL; … … 36 36 double mMax = star->Mag; 37 37 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); 41 41 } 42 42 43 43 int nBin = 1 + (mMax - mMin) / dMag; 44 44 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; 47 47 } 48 48 … … 54 54 55 55 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; 62 62 } 63 63 … … 67 67 int sPeak = 0; 68 68 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; 73 73 } 74 74 … … 81 81 int n = 0; 82 82 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++; 88 88 } 89 89 lnMag->n = n; … … 100 100 101 101 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); 104 104 } 105 105 … … 108 108 double mMaxValid = NAN; 109 109 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 } 117 117 } 118 118 … … 129 129 lumFunc->sPeak = sPeak; 130 130 131 psastroLuminosityFunctionPlot(lnMag, Mag, lumFunc, rawFunc); 132 131 133 psFree (lnMag); 132 134 psFree (nMags);
Note:
See TracChangeset
for help on using the changeset viewer.
