22"""Plugins for use in DiaSource summary statistics.
25as defined in the schema of the Apdb both in name and units.
31from astropy.stats
import median_absolute_deviation
34from scipy.optimize
import lsq_linear
40from .diaCalculation
import (
41 DiaObjectCalculationPluginConfig,
42 DiaObjectCalculationPlugin)
43from .pluginRegistry
import register
45__all__ = (
"MeanDiaPositionConfig",
"MeanDiaPosition",
46 "HTMIndexDiaPosition",
"HTMIndexDiaPositionConfig",
47 "NumDiaSourcesDiaPlugin",
"NumDiaSourcesDiaPluginConfig",
48 "SimpleSourceFlagDiaPlugin",
"SimpleSourceFlagDiaPluginConfig",
49 "WeightedMeanDiaPsfFluxConfig",
"WeightedMeanDiaPsfFlux",
50 "PercentileDiaPsfFlux",
"PercentileDiaPsfFluxConfig",
51 "SigmaDiaPsfFlux",
"SigmaDiaPsfFluxConfig",
52 "Chi2DiaPsfFlux",
"Chi2DiaPsfFluxConfig",
53 "MadDiaPsfFlux",
"MadDiaPsfFluxConfig",
54 "SkewDiaPsfFlux",
"SkewDiaPsfFluxConfig",
55 "MinMaxDiaPsfFlux",
"MinMaxDiaPsfFluxConfig",
56 "MaxSlopeDiaPsfFlux",
"MaxSlopeDiaPsfFluxConfig",
57 "ErrMeanDiaPsfFlux",
"ErrMeanDiaPsfFluxConfig",
58 "LinearFitDiaPsfFlux",
"LinearFitDiaPsfFluxConfig",
59 "StetsonJDiaPsfFlux",
"StetsonJDiaPsfFluxConfig",
60 "WeightedMeanDiaTotFlux",
"WeightedMeanDiaTotFluxConfig",
61 "SigmaDiaTotFlux",
"SigmaDiaTotFluxConfig")
65 """Decorator for generically catching numpy warnings.
67 def decoratorCatchWarnings(func):
68 @functools.wraps(func)
69 def wrapperCatchWarnings(*args, **kwargs):
70 with warnings.catch_warnings():
72 warnings.filterwarnings(
"ignore", val)
73 return func(*args, **kwargs)
74 return wrapperCatchWarnings
77 return decoratorCatchWarnings
79 return decoratorCatchWarnings(_func)
86@register(
"ap_meanPosition")
88 """Compute the mean position of a DiaObject given a set of DiaSources.
91 ConfigClass = MeanDiaPositionConfig
95 outputCols = [
"ra",
"dec",
"radecMjdTai"]
103 """Compute the mean ra/dec position of the diaObject given the
108 diaObjects : `pandas.DataFrame`
109 Summary objects to store values in.
110 diaSources : `pandas.DataFrame` or `pandas.DataFrameGroupBy`
111 Catalog of DiaSources summarized by this DiaObject.
113 Any additional keyword arguments that may be passed to the plugin.
116 if outCol
not in diaObjects.columns:
117 diaObjects[outCol] = np.nan
119 def _computeMeanPos(df):
122 for idx, src
in df.iterrows()))
123 ra = aveCoord.getRa().asDegrees()
124 dec = aveCoord.getDec().asDegrees()
125 if np.isnan(ra)
or np.isnan(dec):
128 radecMjdTai = df[
"midpointMjdTai"].
max()
130 return pd.Series({
"ra": aveCoord.getRa().asDegrees(),
131 "dec": aveCoord.getDec().asDegrees(),
132 "radecMjdTai": radecMjdTai})
134 ans = diaSources.apply(_computeMeanPos)
135 diaObjects.loc[:, [
"ra",
"dec",
"radecMjdTai"]] = ans
140 htmLevel = pexConfig.Field(
142 doc=
"Level of the HTM pixelization.",
147@register("ap_HTMIndex")
149 """Compute the mean position of a DiaObject given a set of DiaSources.
153 This plugin was implemented to satisfy requirements of old APDB interface
154 which required ``pixelId`` column in DiaObject with HTM20 index. APDB
155 interface had migrated to not need that information, but we keep this
156 plugin in case it may be useful for something else.
158 ConfigClass = HTMIndexDiaPositionConfig
162 inputCols = [
"ra",
"dec"]
163 outputCols = [
"pixelId"]
167 DiaObjectCalculationPlugin.__init__(self, config, name, metadata)
175 """Compute the mean position of a DiaObject given a set of DiaSources
179 diaObjects : `pandas.dataFrame`
180 Summary objects to store values in and read ra/dec from.
182 Id of the diaObject to update.
184 Any additional keyword arguments that may be passed to the plugin.
187 diaObjects.at[diaObjectId,
"ra"] * geom.degrees,
188 diaObjects.at[diaObjectId,
"dec"] * geom.degrees)
189 diaObjects.at[diaObjectId,
"pixelId"] = self.
pixelator.index(
190 sphPoint.getVector())
197@register(
"ap_nDiaSources")
199 """Compute the total number of DiaSources associated with this DiaObject.
202 ConfigClass = NumDiaSourcesDiaPluginConfig
203 outputCols = [
"nDiaSources"]
212 """Compute the total number of DiaSources associated with this DiaObject.
217 Summary object to store values in and read ra/dec from.
219 Any additional keyword arguments that may be passed to the plugin.
221 dtype = diaObjects[
"nDiaSources"].dtype
222 diaObjects.loc[:,
"nDiaSources"] = diaSources.diaObjectId.count().astype(dtype)
229@register(
"ap_diaObjectFlag")
231 """Find if any DiaSource is flagged.
233 Set the DiaObject flag if any DiaSource is flagged.
236 ConfigClass = NumDiaSourcesDiaPluginConfig
237 outputCols = [
"flags"]
246 """Find if any DiaSource is flagged.
248 Set the DiaObject flag if any DiaSource is flagged.
253 Summary object to store values in and read ra/dec from.
255 Any additional keyword arguments that may be passed to the plugin.
257 dtype = diaObjects[
"flags"].dtype
258 diaObjects.loc[:,
"flags"] = diaSources.flags.any().astype(dtype)
265@register(
"ap_meanFlux")
267 """Compute the weighted mean and mean error on the point source fluxes
268 of the DiaSource measured on the difference image.
270 Additionally store number of usable data points.
273 ConfigClass = WeightedMeanDiaPsfFluxConfig
274 outputCols = [
"psfFluxMean",
"psfFluxMeanErr",
"psfFluxNdata"]
282 @catchWarnings(warns=[
"invalid value encountered",
290 """Compute the weighted mean and mean error of the point source flux.
295 Summary object to store values in.
296 diaSources : `pandas.DataFrame`
297 DataFrame representing all diaSources associated with this
299 filterDiaSources : `pandas.DataFrame`
300 DataFrame representing diaSources associated with this
301 diaObject that are observed in the band pass ``band``.
303 Simple, string name of the filter for the flux being calculated.
305 Any additional keyword arguments that may be passed to the plugin.
307 meanName =
"{}_psfFluxMean".format(band)
308 errName =
"{}_psfFluxMeanErr".format(band)
309 nDataName =
"{}_psfFluxNdata".format(band)
310 if meanName
not in diaObjects.columns:
311 diaObjects[meanName] = np.nan
312 if errName
not in diaObjects.columns:
313 diaObjects[errName] = np.nan
314 if nDataName
not in diaObjects.columns:
315 diaObjects[nDataName] = 0
317 def _weightedMean(df):
318 tmpDf = df[~np.logical_or(np.isnan(df[
"psfFlux"]),
319 np.isnan(df[
"psfFluxErr"]))]
320 tot_weight = np.nansum(1 / tmpDf[
"psfFluxErr"] ** 2)
321 fluxMean = np.nansum(tmpDf[
"psfFlux"]
322 / tmpDf[
"psfFluxErr"] ** 2)
323 fluxMean /= tot_weight
325 fluxMeanErr = np.sqrt(1 / tot_weight)
328 nFluxData = len(tmpDf)
330 return pd.Series({meanName: fluxMean,
331 errName: fluxMeanErr,
332 nDataName: nFluxData},
334 df = filterDiaSources.apply(_weightedMean).astype(diaObjects.dtypes[[meanName, errName, nDataName]])
336 diaObjects.loc[:, [meanName, errName, nDataName]] = df
340 percentiles = pexConfig.ListField(
342 default=[5, 25, 50, 75, 95],
343 doc=
"Percentiles to calculate to compute values for. Should be "
348@register("ap_percentileFlux")
350 """Compute percentiles of diaSource fluxes.
353 ConfigClass = PercentileDiaPsfFluxConfig
359 def __init__(self, config, name, metadata, **kwargs):
360 DiaObjectCalculationPlugin.__init__(self,
366 for percent
in self.
config.percentiles]
372 @catchWarnings(warns=["All-NaN slice encountered"])
379 """Compute the percentile fluxes of the point source flux.
384 Summary object to store values in.
385 diaSources : `pandas.DataFrame`
386 DataFrame representing all diaSources associated with this
388 filterDiaSources : `pandas.DataFrame`
389 DataFrame representing diaSources associated with this
390 diaObject that are observed in the band pass ``band``.
392 Simple, string name of the filter for the flux being calculated.
394 Any additional keyword arguments that may be passed to the plugin.
398 for tilePercent
in self.
config.percentiles:
399 pTileName =
"{}_psfFluxPercentile{:02d}".format(band,
401 pTileNames.append(pTileName)
402 if pTileName
not in diaObjects.columns:
403 diaObjects[pTileName] = np.nan
405 dtype = diaObjects[pTileName].dtype
407 def _fluxPercentiles(df):
408 pTiles = np.nanpercentile(df[
"psfFlux"], self.
config.percentiles)
410 dict((tileName, pTile)
411 for tileName, pTile
in zip(pTileNames, pTiles)))
413 diaObjects.loc[:, pTileNames] = filterDiaSources.apply(_fluxPercentiles)
415 diaObjects.loc[:, pTileNames] = filterDiaSources.apply(_fluxPercentiles).astype(dtype)
422@register(
"ap_sigmaFlux")
424 """Compute scatter of diaSource fluxes.
427 ConfigClass = SigmaDiaPsfFluxConfig
429 outputCols = [
"psfFluxSigma"]
443 """Compute the sigma fluxes of the point source flux.
448 Summary object to store values in.
449 diaSources : `pandas.DataFrame`
450 DataFrame representing all diaSources associated with this
452 filterDiaSources : `pandas.DataFrame`
453 DataFrame representing diaSources associated with this
454 diaObject that are observed in the band pass ``band``.
456 Simple, string name of the filter for the flux being calculated.
458 Any additional keyword arguments that may be passed to the plugin.
462 column =
"{}_psfFluxSigma".format(band)
463 if column
in diaObjects:
464 dtype = diaObjects[column].dtype
465 diaObjects.loc[:, column] = filterDiaSources.psfFlux.std().astype(dtype)
467 diaObjects.loc[:, column] = filterDiaSources.psfFlux.std()
474@register(
"ap_chi2Flux")
476 """Compute chi2 of diaSource fluxes.
479 ConfigClass = Chi2DiaPsfFluxConfig
482 inputCols = [
"psfFluxMean"]
484 outputCols = [
"psfFluxChi2"]
492 @catchWarnings(warns=["All-NaN slice encountered"])
499 """Compute the chi2 of the point source fluxes.
504 Summary object to store values in.
505 diaSources : `pandas.DataFrame`
506 DataFrame representing all diaSources associated with this
508 filterDiaSources : `pandas.DataFrame`
509 DataFrame representing diaSources associated with this
510 diaObject that are observed in the band pass ``band``.
512 Simple, string name of the filter for the flux being calculated.
514 Any additional keyword arguments that may be passed to the plugin.
516 meanName =
"{}_psfFluxMean".format(band)
517 column =
"{}_psfFluxChi2".format(band)
520 delta = (df[
"psfFlux"]
521 - diaObjects.at[df.diaObjectId.iat[0], meanName])
522 return np.nansum((delta / df[
"psfFluxErr"]) ** 2)
524 if column
in diaObjects:
525 dtype = diaObjects[column].dtype
526 diaObjects.loc[:, column] = filterDiaSources.apply(_chi2).astype(dtype)
528 diaObjects.loc[:, column] = filterDiaSources.apply(_chi2)
535@register(
"ap_madFlux")
537 """Compute median absolute deviation of diaSource fluxes.
540 ConfigClass = MadDiaPsfFluxConfig
544 outputCols = [
"psfFluxMAD"]
552 @catchWarnings(warns=["All-NaN slice encountered"])
559 """Compute the median absolute deviation of the point source fluxes.
564 Summary object to store values in.
565 diaSources : `pandas.DataFrame`
566 DataFrame representing all diaSources associated with this
568 filterDiaSources : `pandas.DataFrame`
569 DataFrame representing diaSources associated with this
570 diaObject that are observed in the band pass ``band``.
572 Simple, string name of the filter for the flux being calculated.
574 Any additional keyword arguments that may be passed to the plugin.
576 column =
"{}_psfFluxMAD".format(band)
577 if column
in diaObjects:
578 dtype = diaObjects[column].dtype
579 diaObjects.loc[:, column] = \
580 filterDiaSources.psfFlux.apply(median_absolute_deviation,
581 ignore_nan=
True).astype(dtype)
583 diaObjects.loc[:, column] = \
584 filterDiaSources.psfFlux.apply(median_absolute_deviation,
592@register(
"ap_skewFlux")
594 """Compute the skew of diaSource fluxes.
597 ConfigClass = SkewDiaPsfFluxConfig
601 outputCols = [
"psfFluxSkew"]
615 """Compute the skew of the point source fluxes.
620 Summary object to store values in.
621 diaSources : `pandas.DataFrame`
622 DataFrame representing all diaSources associated with this
624 filterDiaSources : `pandas.DataFrame`
625 DataFrame representing diaSources associated with this
626 diaObject that are observed in the band pass ``band``.
628 Simple, string name of the filter for the flux being calculated.
630 Any additional keyword arguments that may be passed to the plugin.
632 column =
"{}_psfFluxSkew".format(band)
633 if column
in diaObjects:
634 dtype = diaObjects[column].dtype
635 diaObjects.loc[:, column] = filterDiaSources.psfFlux.skew().astype(dtype)
637 diaObjects.loc[:, column] = filterDiaSources.psfFlux.skew()
644@register(
"ap_minMaxFlux")
646 """Compute min/max of diaSource fluxes.
649 ConfigClass = MinMaxDiaPsfFluxConfig
653 outputCols = [
"psfFluxMin",
"psfFluxMax"]
667 """Compute min/max of the point source fluxes.
672 Summary object to store values in.
673 diaSources : `pandas.DataFrame`
674 DataFrame representing all diaSources associated with this
676 filterDiaSources : `pandas.DataFrame`
677 DataFrame representing diaSources associated with this
678 diaObject that are observed in the band pass ``band``.
680 Simple, string name of the filter for the flux being calculated.
682 Any additional keyword arguments that may be passed to the plugin.
684 minName =
"{}_psfFluxMin".format(band)
685 if minName
not in diaObjects.columns:
686 diaObjects[minName] = np.nan
687 maxName =
"{}_psfFluxMax".format(band)
688 if maxName
not in diaObjects.columns:
689 diaObjects[maxName] = np.nan
691 dtype = diaObjects[minName].dtype
692 diaObjects.loc[:, minName] = filterDiaSources.psfFlux.min().astype(dtype)
693 diaObjects.loc[:, maxName] = filterDiaSources.psfFlux.max().astype(dtype)
700@register(
"ap_maxSlopeFlux")
702 """Compute the maximum ratio time ordered deltaFlux / deltaTime.
705 ConfigClass = MinMaxDiaPsfFluxConfig
709 outputCols = [
"psfFluxMaxSlope"]
723 """Compute the maximum ratio time ordered deltaFlux / deltaTime.
728 Summary object to store values in.
729 diaSources : `pandas.DataFrame`
730 DataFrame representing all diaSources associated with this
732 filterDiaSources : `pandas.DataFrame`
733 DataFrame representing diaSources associated with this
734 diaObject that are observed in the band pass ``band``.
736 Simple, string name of the filter for the flux being calculated.
738 Any additional keyword arguments that may be passed to the plugin.
742 tmpDf = df[~np.logical_or(np.isnan(df[
"psfFlux"]),
743 np.isnan(df[
"midpointMjdTai"]))]
746 times = tmpDf[
"midpointMjdTai"].to_numpy()
747 timeArgs = times.argsort()
748 times = times[timeArgs]
749 fluxes = tmpDf[
"psfFlux"].to_numpy()[timeArgs]
750 return (np.diff(fluxes) / np.diff(times)).
max()
752 column =
"{}_psfFluxMaxSlope".format(band)
753 if column
in diaObjects:
754 dtype = diaObjects[column].dtype
755 diaObjects.loc[:, column] = filterDiaSources.apply(_maxSlope).astype(dtype)
757 diaObjects.loc[:, column] = filterDiaSources.apply(_maxSlope)
764@register(
"ap_meanErrFlux")
766 """Compute the mean of the dia source errors.
769 ConfigClass = ErrMeanDiaPsfFluxConfig
773 outputCols = [
"psfFluxErrMean"]
787 """Compute the mean of the dia source errors.
792 Summary object to store values in.
793 diaSources : `pandas.DataFrame`
794 DataFrame representing all diaSources associated with this
796 filterDiaSources : `pandas.DataFrame`
797 DataFrame representing diaSources associated with this
798 diaObject that are observed in the band pass ``band``.
800 Simple, string name of the filter for the flux being calculated.
802 Any additional keyword arguments that may be passed to the plugin.
804 column =
"{}_psfFluxErrMean".format(band)
805 if column
in diaObjects:
806 dtype = diaObjects[column].dtype
807 diaObjects.loc[:, column] = filterDiaSources.psfFluxErr.mean().astype(dtype)
809 diaObjects.loc[:, column] = filterDiaSources.psfFluxErr.mean()
816@register(
"ap_linearFit")
818 """Compute fit a linear model to flux vs time.
821 ConfigClass = LinearFitDiaPsfFluxConfig
825 outputCols = [
"psfFluxLinearSlope",
"psfFluxLinearIntercept"]
839 """Compute fit a linear model to flux vs time.
844 Summary object to store values in.
845 diaSources : `pandas.DataFrame`
846 DataFrame representing all diaSources associated with this
848 filterDiaSources : `pandas.DataFrame`
849 DataFrame representing diaSources associated with this
850 diaObject that are observed in the band pass ``band``.
852 Simple, string name of the filter for the flux being calculated.
854 Any additional keyword arguments that may be passed to the plugin.
857 mName =
"{}_psfFluxLinearSlope".format(band)
858 if mName
not in diaObjects.columns:
859 diaObjects[mName] = np.nan
860 bName =
"{}_psfFluxLinearIntercept".format(band)
861 if bName
not in diaObjects.columns:
862 diaObjects[bName] = np.nan
863 dtype = diaObjects[mName].dtype
866 tmpDf = df[~np.logical_or(
867 np.isnan(df[
"psfFlux"]),
868 np.logical_or(np.isnan(df[
"psfFluxErr"]),
869 np.isnan(df[
"midpointMjdTai"])))]
871 return pd.Series({mName: np.nan, bName: np.nan})
872 fluxes = tmpDf[
"psfFlux"].to_numpy()
873 errors = tmpDf[
"psfFluxErr"].to_numpy()
874 times = tmpDf[
"midpointMjdTai"].to_numpy()
875 A = np.array([times / errors, 1 / errors]).transpose()
876 m, b = lsq_linear(A, fluxes / errors).x
877 return pd.Series({mName: m, bName: b}, dtype=dtype)
879 diaObjects.loc[:, [mName, bName]] = filterDiaSources.apply(_linearFit)
886@register(
"ap_stetsonJ")
888 """Compute the StetsonJ statistic on the DIA point source fluxes.
891 ConfigClass = LinearFitDiaPsfFluxConfig
894 inputCols = [
"psfFluxMean"]
896 outputCols = [
"psfFluxStetsonJ"]
910 """Compute the StetsonJ statistic on the DIA point source fluxes.
915 Summary object to store values in.
916 diaSources : `pandas.DataFrame`
917 DataFrame representing all diaSources associated with this
919 filterDiaSources : `pandas.DataFrame`
920 DataFrame representing diaSources associated with this
921 diaObject that are observed in the band pass ``band``.
923 Simple, string name of the filter for the flux being calculated.
925 Any additional keyword arguments that may be passed to the plugin.
927 meanName =
"{}_psfFluxMean".format(band)
930 tmpDf = df[~np.logical_or(np.isnan(df[
"psfFlux"]),
931 np.isnan(df[
"psfFluxErr"]))]
934 fluxes = tmpDf[
"psfFlux"].to_numpy()
935 errors = tmpDf[
"psfFluxErr"].to_numpy()
940 diaObjects.at[tmpDf.diaObjectId.iat[0], meanName])
942 column =
"{}_psfFluxStetsonJ".format(band)
943 if column
in diaObjects:
944 dtype = diaObjects[column].dtype
945 diaObjects.loc[:, column] = filterDiaSources.apply(_stetsonJ).astype(dtype)
947 diaObjects.loc[:, column] = filterDiaSources.apply(_stetsonJ)
950 """Compute the single band stetsonJ statistic.
954 fluxes : `numpy.ndarray` (N,)
955 Calibrated lightcurve flux values.
956 errors : `numpy.ndarray` (N,)
957 Errors on the calibrated lightcurve fluxes.
959 Starting mean from previous plugin.
964 stetsonJ statistic for the input fluxes and errors.
968 .. [1] Stetson, P. B., "On the Automatic Determination of Light-Curve
969 Parameters for Cepheid Variables", PASP, 108, 851S, 1996
971 n_points = len(fluxes)
974 np.sqrt(n_points / (n_points - 1)) * (fluxes - flux_mean) / errors)
975 p_k = delta_val ** 2 - 1
977 return np.mean(np.sign(p_k) * np.sqrt(np.fabs(p_k)))
987 """Compute the stetson mean of the fluxes which down-weights outliers.
989 Weighted biased on an error weighted difference scaled by a constant
990 (1/``a``) and raised to the power beta. Higher betas more harshly
991 penalize outliers and ``a`` sets the number of sigma where a weighted
992 difference of 1 occurs.
996 values : `numpy.dnarray`, (N,)
997 Input values to compute the mean of.
998 errors : `numpy.ndarray`, (N,)
999 Errors on the input values.
1001 Starting mean value or None.
1003 Scalar down-weighting of the fractional difference. lower->more
1004 clipping. (Default value is 2.)
1006 Power law slope of the used to down-weight outliers. higher->more
1007 clipping. (Default value is 2.)
1009 Number of iterations of clipping.
1011 Fractional and absolute tolerance goal on the change in the mean
1012 before exiting early. (Default value is 1e-6)
1017 Weighted stetson mean result.
1021 .. [1] Stetson, P. B., "On the Automatic Determination of Light-Curve
1022 Parameters for Cepheid Variables", PASP, 108, 851S, 1996
1024 n_points = len(values)
1025 n_factor = np.sqrt(n_points / (n_points - 1))
1026 inv_var = 1 / errors ** 2
1029 mean = np.average(values, weights=inv_var)
1030 for iter_idx
in range(n_iter):
1031 chi = np.fabs(n_factor * (values - mean) / errors)
1032 tmp_mean = np.average(
1034 weights=inv_var / (1 + (chi / alpha) ** beta))
1035 diff = np.fabs(tmp_mean - mean)
1037 if diff / mean < tol
and diff < tol:
1046@register(
"ap_meanTotFlux")
1048 """Compute the weighted mean and mean error on the point source fluxes
1049 forced photometered at the DiaSource location in the calibrated image.
1051 Additionally store number of usable data points.
1054 ConfigClass = WeightedMeanDiaPsfFluxConfig
1055 outputCols = [
"scienceFluxMean",
"scienceFluxMeanErr"]
1063 @catchWarnings(warns=[
"invalid value encountered",
1071 """Compute the weighted mean and mean error of the point source flux.
1076 Summary object to store values in.
1077 diaSources : `pandas.DataFrame`
1078 DataFrame representing all diaSources associated with this
1080 filterDiaSources : `pandas.DataFrame`
1081 DataFrame representing diaSources associated with this
1082 diaObject that are observed in the band pass ``band``.
1084 Simple, string name of the filter for the flux being calculated.
1086 Any additional keyword arguments that may be passed to the plugin.
1088 totMeanName =
"{}_scienceFluxMean".format(band)
1089 if totMeanName
not in diaObjects.columns:
1090 diaObjects[totMeanName] = np.nan
1091 totErrName =
"{}_scienceFluxMeanErr".format(band)
1092 if totErrName
not in diaObjects.columns:
1093 diaObjects[totErrName] = np.nan
1096 tmpDf = df[~np.logical_or(np.isnan(df[
"scienceFlux"]),
1097 np.isnan(df[
"scienceFluxErr"]))]
1098 tot_weight = np.nansum(1 / tmpDf[
"scienceFluxErr"] ** 2)
1099 fluxMean = np.nansum(tmpDf[
"scienceFlux"]
1100 / tmpDf[
"scienceFluxErr"] ** 2)
1101 fluxMean /= tot_weight
1102 fluxMeanErr = np.sqrt(1 / tot_weight)
1104 return pd.Series({totMeanName: fluxMean,
1105 totErrName: fluxMeanErr})
1107 df = filterDiaSources.apply(_meanFlux).astype(diaObjects.dtypes[[totMeanName, totErrName]])
1108 diaObjects.loc[:, [totMeanName, totErrName]] = df
1115@register(
"ap_sigmaTotFlux")
1117 """Compute scatter of diaSource fluxes.
1120 ConfigClass = SigmaDiaPsfFluxConfig
1122 outputCols = [
"scienceFluxSigma"]
1136 """Compute the sigma fluxes of the point source flux measured on the
1142 Summary object to store values in.
1143 diaSources : `pandas.DataFrame`
1144 DataFrame representing all diaSources associated with this
1146 filterDiaSources : `pandas.DataFrame`
1147 DataFrame representing diaSources associated with this
1148 diaObject that are observed in the band pass ``band``.
1150 Simple, string name of the filter for the flux being calculated.
1152 Any additional keyword arguments that may be passed to the plugin.
1156 column =
"{}_scienceFluxSigma".format(band)
1157 if column
in diaObjects:
1158 dtype = diaObjects[column].dtype
1159 diaObjects.loc[:, column] = filterDiaSources.scienceFlux.std().astype(dtype)
1162 diaObjects.loc[:, column] = filterDiaSources.scienceFlux.std()
Point in an unspecified spherical coordinate system.
float FLUX_MOMENTS_CALCULATED
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaObjectId, **kwargs)
__init__(self, config, name, metadata)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, **kwargs)
__init__(self, config, name, metadata, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
_stetson_J(self, fluxes, errors, mean=None)
_stetson_mean(self, values, errors, mean=None, alpha=2., beta=2., n_iter=20, tol=1e-6)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
calculate(self, diaObjects, diaSources, filterDiaSources, band, **kwargs)
float DEFAULT_CATALOGCALCULATION
HtmPixelization provides HTM indexing of points and regions.
SpherePoint averageSpherePoint(std::vector< SpherePoint > const &coords)
Return the average of a list of coordinates.
catchWarnings(_func=None, *warns=[])