LSST Applications g00d0e8bbd7+edbf708997,g03191d30f7+9ce8016dbd,g1955dfad08+0bd186d245,g199a45376c+5137f08352,g1fd858c14a+a888a50aa2,g262e1987ae+45f9aba685,g29ae962dfc+1c7d47a24f,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3fd5ace14f+eed17d2c67,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+c4107e45b5,g67b6fd64d1+6dc8069a4c,g74acd417e5+f452e9c21a,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+2025e9ce17,g7cc15d900a+2d158402f9,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d4809ba88+c4107e45b5,g8d7436a09f+e96c132b44,g8ea07a8fe4+db21c37724,g98df359435+aae6d409c1,ga2180abaac+edbf708997,gac66b60396+966efe6077,gb632fb1845+88945a90f8,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gca7fc764a6+6dc8069a4c,gd7ef33dd92+6dc8069a4c,gda68eeecaf+7d1e613a8d,gdab6d2f7ff+f452e9c21a,gdbb4c4dda9+c4107e45b5,ge410e46f29+6dc8069a4c,ge41e95a9f2+c4107e45b5,geaed405ab2+e194be0d2b,w.2025.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.meas.base.diaCalculationPlugins Namespace Reference

Classes

class  Chi2DiaPsfFlux
 
class  Chi2DiaPsfFluxConfig
 
class  ErrMeanDiaPsfFlux
 
class  ErrMeanDiaPsfFluxConfig
 
class  HTMIndexDiaPosition
 
class  HTMIndexDiaPositionConfig
 
class  LinearFitDiaPsfFlux
 
class  LinearFitDiaPsfFluxConfig
 
class  LombScarglePeriodogram
 
class  LombScarglePeriodogramConfig
 
class  LombScarglePeriodogramMulti
 
class  LombScarglePeriodogramMultiConfig
 
class  MadDiaPsfFlux
 
class  MadDiaPsfFluxConfig
 
class  MaxSlopeDiaPsfFlux
 
class  MaxSlopeDiaPsfFluxConfig
 
class  MeanDiaPosition
 
class  MeanDiaPositionConfig
 
class  MinMaxDiaPsfFlux
 
class  MinMaxDiaPsfFluxConfig
 
class  NumDiaSourcesDiaPlugin
 
class  NumDiaSourcesDiaPluginConfig
 
class  PercentileDiaPsfFlux
 
class  PercentileDiaPsfFluxConfig
 
class  SigmaDiaPsfFlux
 
class  SigmaDiaPsfFluxConfig
 
class  SigmaDiaTotFlux
 
class  SigmaDiaTotFluxConfig
 
class  SimpleSourceFlagDiaPlugin
 
class  SimpleSourceFlagDiaPluginConfig
 
class  SkewDiaPsfFlux
 
class  SkewDiaPsfFluxConfig
 
class  StetsonJDiaPsfFlux
 
class  StetsonJDiaPsfFluxConfig
 
class  WeightedMeanDiaPsfFlux
 
class  WeightedMeanDiaPsfFluxConfig
 
class  WeightedMeanDiaTotFlux
 
class  WeightedMeanDiaTotFluxConfig
 

Functions

 catchWarnings (_func=None, *, warns=[])
 
 typeSafePandasAssignment (target, source, columns, default_dtype=np.float64, int_fill_value=0, force_int_to_float=False)
 
 compute_optimized_periodogram_grid (x0, oversampling_factor=5, nyquist_factor=100)
 

Detailed Description

Plugins for use in DiaSource summary statistics.

Output columns must be
as defined in the schema of the Apdb both in name and units.

Function Documentation

◆ catchWarnings()

lsst.meas.base.diaCalculationPlugins.catchWarnings ( _func = None,
* ,
warns = [] )
Decorator for generically catching numpy warnings.

Definition at line 71 of file diaCalculationPlugins.py.

71def catchWarnings(_func=None, *, warns=[]):
72 """Decorator for generically catching numpy warnings.
73 """
74 def decoratorCatchWarnings(func):
75 @functools.wraps(func)
76 def wrapperCatchWarnings(*args, **kwargs):
77 with warnings.catch_warnings():
78 for val in warns:
79 warnings.filterwarnings("ignore", val)
80 return func(*args, **kwargs)
81 return wrapperCatchWarnings
82
83 if _func is None:
84 return decoratorCatchWarnings
85 else:
86 return decoratorCatchWarnings(_func)
87
88

◆ compute_optimized_periodogram_grid()

lsst.meas.base.diaCalculationPlugins.compute_optimized_periodogram_grid ( x0,
oversampling_factor = 5,
nyquist_factor = 100 )
Computes an optimized periodogram frequency grid for a given time series.

Parameters
----------
x0 : `array`
    The input time axis.
oversampling_factor : `int`, optional
    The oversampling factor for frequency grid.
nyquist_factor : `int`, optional
    The Nyquist factor for frequency grid.

Returns
-------
frequencies : `array`
    The computed optimized periodogram frequency grid.

Definition at line 150 of file diaCalculationPlugins.py.

150def compute_optimized_periodogram_grid(x0, oversampling_factor=5, nyquist_factor=100):
151 """
152 Computes an optimized periodogram frequency grid for a given time series.
153
154 Parameters
155 ----------
156 x0 : `array`
157 The input time axis.
158 oversampling_factor : `int`, optional
159 The oversampling factor for frequency grid.
160 nyquist_factor : `int`, optional
161 The Nyquist factor for frequency grid.
162
163 Returns
164 -------
165 frequencies : `array`
166 The computed optimized periodogram frequency grid.
167 """
168
169 num_points = len(x0)
170 baseline = np.max(x0) - np.min(x0)
171
172 # Calculate the frequency resolution based on oversampling factor and baseline
173 frequency_resolution = 1. / baseline / oversampling_factor
174
175 num_frequencies = int(
176 0.5 * oversampling_factor * nyquist_factor * num_points)
177 frequencies = frequency_resolution + \
178 frequency_resolution * np.arange(num_frequencies)
179
180 return frequencies
181
182

◆ typeSafePandasAssignment()

lsst.meas.base.diaCalculationPlugins.typeSafePandasAssignment ( target,
source,
columns,
default_dtype = np.float64,
int_fill_value = 0,
force_int_to_float = False )
Assign from a source dataframe to a target dataframe in a type safe way.

Parameters
----------
target : `pd.DataFrame`
    Target pandas dataframe.
source : `pd.DataFrame` or `pd.Series`
    Grouped source dataframe.
columns : `list` [`str`]
    List of columns to transfer.
default_dtype : `np.dtype`, optional
    Default datatype (if not in target).
int_fill_value : `int`, optional
    Fill value for integer columns to avoid pandas insisting
    that everything should be float-ified as nans.
force_int_to_float : `bool`, optional
    Force integer columns to float columns? Use this option
    for backwards compatibility for old pandas misfeatures which
    are expected by some downstream processes.

Definition at line 89 of file diaCalculationPlugins.py.

97):
98 """
99 Assign from a source dataframe to a target dataframe in a type safe way.
100
101 Parameters
102 ----------
103 target : `pd.DataFrame`
104 Target pandas dataframe.
105 source : `pd.DataFrame` or `pd.Series`
106 Grouped source dataframe.
107 columns : `list` [`str`]
108 List of columns to transfer.
109 default_dtype : `np.dtype`, optional
110 Default datatype (if not in target).
111 int_fill_value : `int`, optional
112 Fill value for integer columns to avoid pandas insisting
113 that everything should be float-ified as nans.
114 force_int_to_float : `bool`, optional
115 Force integer columns to float columns? Use this option
116 for backwards compatibility for old pandas misfeatures which
117 are expected by some downstream processes.
118 """
119 is_series = isinstance(source, pd.Series)
120 for col in columns:
121 if is_series:
122 source_col = source
123 else:
124 source_col = source[col]
125
126 matched_length = False
127 if col in target.columns:
128 target_dtype = target[col].dtype
129 matched_length = len(target) == len(source)
130 else:
131 target_dtype = default_dtype
132
133 if (matched_length or pd.api.types.is_float_dtype(target_dtype)) and not force_int_to_float:
134 # If we have a matched length or float, we can do a
135 # straight assignment here.
136 target.loc[:, col] = source_col.astype(target_dtype)
137 else:
138 # With mis-matched integers, we must do this dance to preserve types.
139 # Note that this may lose precision with very large numbers.
140
141 # Convert to float
142 target[col] = target[col].astype(np.float64)
143 # Set the column, casting to float.
144 target.loc[:, col] = source_col.astype(np.float64)
145 if not force_int_to_float:
146 # Convert back to integer
147 target[col] = target[col].fillna(int_fill_value).astype(target_dtype)
148
149