timewise 1.0.0a1__py3-none-any.whl → 1.0.0a2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- timewise/__init__.py +1 -1
- timewise/plot/diagnostic.py +1 -1
- timewise/process/config.py +9 -5
- timewise/process/stacking.py +21 -9
- timewise/util/visits.py +9 -9
- {timewise-1.0.0a1.dist-info → timewise-1.0.0a2.dist-info}/METADATA +1 -1
- {timewise-1.0.0a1.dist-info → timewise-1.0.0a2.dist-info}/RECORD +10 -10
- {timewise-1.0.0a1.dist-info → timewise-1.0.0a2.dist-info}/WHEEL +0 -0
- {timewise-1.0.0a1.dist-info → timewise-1.0.0a2.dist-info}/entry_points.txt +0 -0
- {timewise-1.0.0a1.dist-info → timewise-1.0.0a2.dist-info}/licenses/LICENSE +0 -0
timewise/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.0.
|
|
1
|
+
__version__ = "1.0.0a2"
|
timewise/plot/diagnostic.py
CHANGED
|
@@ -106,7 +106,7 @@ class DiagnosticPlotter(BaseModel):
|
|
|
106
106
|
dec = (raw_lightcurve.dec - source_dec) * 3600
|
|
107
107
|
|
|
108
108
|
# get visit map
|
|
109
|
-
visit_map = get_visit_map(raw_lightcurve)
|
|
109
|
+
visit_map = get_visit_map(raw_lightcurve.mjd)
|
|
110
110
|
|
|
111
111
|
# for each visit plot the datapoints on the cutout
|
|
112
112
|
# for each visit plot the datapoints on the cutout
|
timewise/process/config.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
import logging
|
|
3
3
|
|
|
4
|
-
from pydantic import BaseModel
|
|
4
|
+
from pydantic import BaseModel, model_validator
|
|
5
5
|
|
|
6
6
|
from .interface import AmpelInterface
|
|
7
7
|
|
|
@@ -14,10 +14,14 @@ class AmpelConfig(BaseModel):
|
|
|
14
14
|
mongo_db_name: str
|
|
15
15
|
template_path: Path = DEFAULT_TEMPLATE_PATH
|
|
16
16
|
uri: str = "localhost:27017"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
# will default to <mongo_db_name>_input
|
|
18
|
+
input_mongo_db_name: str = ""
|
|
19
|
+
|
|
20
|
+
@model_validator(mode="after") # type: ignore
|
|
21
|
+
def default_input_db_name(self) -> "AmpelConfig":
|
|
22
|
+
if not self.input_mongo_db_name:
|
|
23
|
+
self.input_mongo_db_name = self.mongo_db_name + "_input"
|
|
24
|
+
return self
|
|
21
25
|
|
|
22
26
|
def build_interface(self, original_id_key: str, input_csv: Path) -> AmpelInterface:
|
|
23
27
|
return AmpelInterface(
|
timewise/process/stacking.py
CHANGED
|
@@ -26,6 +26,8 @@ def calculate_epochs(
|
|
|
26
26
|
visit_mask: npt.NDArray[np.int64],
|
|
27
27
|
counts: npt.NDArray[np.int64],
|
|
28
28
|
remove_outliers: bool,
|
|
29
|
+
outlier_threshold: float,
|
|
30
|
+
outlier_quantile: float,
|
|
29
31
|
outlier_mask: npt.NDArray[np.bool_] | None = None,
|
|
30
32
|
) -> tuple[
|
|
31
33
|
npt.NDArray[np.float64],
|
|
@@ -70,7 +72,7 @@ def calculate_epochs(
|
|
|
70
72
|
# --------------------- remove outliers in the bins ---------------------- #
|
|
71
73
|
|
|
72
74
|
# if we do not want to clean outliers just set the threshold to infinity
|
|
73
|
-
|
|
75
|
+
_outlier_threshold = np.inf if not remove_outliers else outlier_threshold
|
|
74
76
|
|
|
75
77
|
# set up empty masks
|
|
76
78
|
outlier_mask = cast(
|
|
@@ -156,15 +158,16 @@ def calculate_epochs(
|
|
|
156
158
|
# take the maximum value of the measured single exposure errors and the standard deviation
|
|
157
159
|
u = np.maximum(std, e_meas)
|
|
158
160
|
|
|
159
|
-
#
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
# Estimate the spread of the flux.
|
|
162
|
+
# To be robust against outliers, do that with quantiles instead of std
|
|
163
|
+
qs = np.zeros_like(counts, dtype=float)
|
|
164
|
+
qs[one_points_mask] = 1e-10
|
|
162
165
|
visits_at_least_two_point = np.unique(visit_mask[~one_points_mask[visit_mask]])
|
|
163
|
-
|
|
166
|
+
qs[visits_at_least_two_point] = np.array(
|
|
164
167
|
[
|
|
165
168
|
np.quantile(
|
|
166
169
|
abs(f[(visit_mask == i) & use_mask] - median[i]),
|
|
167
|
-
|
|
170
|
+
outlier_quantile,
|
|
168
171
|
method="interpolated_inverted_cdf",
|
|
169
172
|
)
|
|
170
173
|
for i in visits_at_least_two_point
|
|
@@ -173,7 +176,7 @@ def calculate_epochs(
|
|
|
173
176
|
|
|
174
177
|
# --------------------- remove outliers in the bins ---------------------- #
|
|
175
178
|
remaining_outliers = (
|
|
176
|
-
abs(median[visit_mask] - f) >
|
|
179
|
+
abs(median[visit_mask] - f) > _outlier_threshold * qs[visit_mask]
|
|
177
180
|
) & ~outlier_mask
|
|
178
181
|
outlier_mask |= remaining_outliers
|
|
179
182
|
n_remaining_outlier = sum(remaining_outliers) if remove_outliers else 0
|
|
@@ -187,7 +190,12 @@ def calculate_epochs(
|
|
|
187
190
|
return median, u, bin_ulim_bool, outlier_mask, use_mask, n_points
|
|
188
191
|
|
|
189
192
|
|
|
190
|
-
def stack_visits(
|
|
193
|
+
def stack_visits(
|
|
194
|
+
lightcurve: pd.DataFrame,
|
|
195
|
+
outlier_threshold: float,
|
|
196
|
+
outlier_quantile: float,
|
|
197
|
+
clean_outliers: bool = True,
|
|
198
|
+
):
|
|
191
199
|
"""
|
|
192
200
|
Combine the data by visits of the satellite of one region in the sky.
|
|
193
201
|
The visits typically consist of some tens of observations. The individual visits are separated by about
|
|
@@ -204,7 +212,7 @@ def stack_visits(lightcurve: pd.DataFrame, clean_outliers: bool = True):
|
|
|
204
212
|
"""
|
|
205
213
|
|
|
206
214
|
# ------------------------- create visit mask -------------------------- #
|
|
207
|
-
visit_map = get_visit_map(lightcurve)
|
|
215
|
+
visit_map = get_visit_map(lightcurve.mjd)
|
|
208
216
|
counts = np.bincount(visit_map)
|
|
209
217
|
|
|
210
218
|
stacked_data: Dict[str, Any] = dict()
|
|
@@ -235,6 +243,8 @@ def stack_visits(lightcurve: pd.DataFrame, clean_outliers: bool = True):
|
|
|
235
243
|
counts,
|
|
236
244
|
remove_outliers=remove_outliers,
|
|
237
245
|
outlier_mask=outlier_mask,
|
|
246
|
+
outlier_quantile=outlier_quantile,
|
|
247
|
+
outlier_threshold=outlier_threshold,
|
|
238
248
|
)
|
|
239
249
|
n_outliers = np.sum(outlier_mask)
|
|
240
250
|
|
|
@@ -300,6 +310,8 @@ def stack_visits(lightcurve: pd.DataFrame, clean_outliers: bool = True):
|
|
|
300
310
|
counts,
|
|
301
311
|
remove_outliers=False,
|
|
302
312
|
outlier_mask=outlier_masks[keys.FLUX_EXT],
|
|
313
|
+
outlier_threshold=outlier_threshold,
|
|
314
|
+
outlier_quantile=outlier_quantile,
|
|
303
315
|
)
|
|
304
316
|
)
|
|
305
317
|
stacked_data[f"{b}{keys.MEAN}{keys.FLUX_DENSITY_EXT}"] = mean_fd
|
timewise/util/visits.py
CHANGED
|
@@ -3,31 +3,31 @@ import pandas as pd
|
|
|
3
3
|
import numpy.typing as npt
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def get_visit_map(
|
|
6
|
+
def get_visit_map(
|
|
7
|
+
mjd: npt.NDArray[np.float64] | pd.Series,
|
|
8
|
+
) -> npt.NDArray[np.int64]:
|
|
7
9
|
"""
|
|
8
10
|
Create a map datapoint to visit
|
|
9
11
|
|
|
10
|
-
:param
|
|
11
|
-
:type
|
|
12
|
+
:param mjd: the MJDs of the observations
|
|
13
|
+
:type mjd: npt.NDArray[float]
|
|
12
14
|
:returns: visit map
|
|
13
15
|
:rtype: npt.ArrayLike
|
|
14
16
|
"""
|
|
15
17
|
# ------------------------- find epoch intervals -------------------------- #
|
|
16
|
-
sorted_mjds = np.sort(
|
|
18
|
+
sorted_mjds = np.sort(mjd)
|
|
17
19
|
epoch_bounds_mask = (sorted_mjds[1:] - sorted_mjds[:-1]) > 100
|
|
18
20
|
epoch_bins = np.array(
|
|
19
|
-
[
|
|
20
|
-
lightcurve.mjd.min() * 0.99
|
|
21
|
-
] # this makes sure that the first datapoint gets selected
|
|
21
|
+
[mjd.min() * 0.99] # this makes sure that the first datapoint gets selected
|
|
22
22
|
+ list(
|
|
23
23
|
((sorted_mjds[1:] + sorted_mjds[:-1]) / 2)[epoch_bounds_mask]
|
|
24
24
|
) # finding the middle between
|
|
25
25
|
+
|
|
26
26
|
# two visits
|
|
27
27
|
[
|
|
28
|
-
|
|
28
|
+
mjd.max() * 1.01
|
|
29
29
|
] # this just makes sure that the last datapoint gets selected as well
|
|
30
30
|
)
|
|
31
31
|
|
|
32
|
-
visit_mask = np.digitize(
|
|
32
|
+
visit_mask = np.digitize(mjd, epoch_bins) - 1
|
|
33
33
|
return visit_mask
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
timewise/__init__.py,sha256=
|
|
1
|
+
timewise/__init__.py,sha256=F0DR6kHrrc4PGk6Wna72waqVz5Gv15m9PgTOK00b7Kc,24
|
|
2
2
|
timewise/backend/__init__.py,sha256=w79nWfCw8n9g98CkHWJELmb4j9xblWC4DGZOV3_XhH4,134
|
|
3
3
|
timewise/backend/base.py,sha256=dHxRzu2q3uQ0wdGmDxnn-p68Tp19qChue7HMEu56wNA,1080
|
|
4
4
|
timewise/backend/filesystem.py,sha256=GQ4Hrb6_7Q7fKOn6QUl8bqAihAmyeZoTRxElNIwPQ1Y,2465
|
|
@@ -10,15 +10,15 @@ timewise/io/config.py,sha256=aizLxt9l4aeWQNsvcemtQdr_fW1vLmpRSofcgA3Bgvk,2239
|
|
|
10
10
|
timewise/io/download.py,sha256=rKjeW7nh7xUtHh8llvsg_qmkx71Wzn2LggQnyHwqJOI,10719
|
|
11
11
|
timewise/io/stable_tap.py,sha256=jukCkBi2d7WACOo_kXTMCppzWUsN-pLVg9EDqHi3qd0,3478
|
|
12
12
|
timewise/plot/__init__.py,sha256=cc00UenWC_8zAkBH-Ylhs3yCF49tAqZ2Al9MfOoXYDI,120
|
|
13
|
-
timewise/plot/diagnostic.py,sha256=
|
|
13
|
+
timewise/plot/diagnostic.py,sha256=GRp-OUwz2yzzDu9qdViFg_e3Mxl5t1IvUJXZHuMKB2U,8276
|
|
14
14
|
timewise/plot/lightcurve.py,sha256=oK0y6RFzv7QSrO1Qqyc1wNghsTILC9QAfIjuoA8i92I,3757
|
|
15
15
|
timewise/plot/panstarrs.py,sha256=X2ZULm7QT91cp4qociG0fVeI0saGLJwyKzL0141Vqis,8014
|
|
16
16
|
timewise/plot/sdss.py,sha256=cc1zU-4XFkqc8xH5yqCyMsDJf9w_54B_6NeRMjr9Pt8,2622
|
|
17
17
|
timewise/process/__init__.py,sha256=Yk-j1B1MnBuuaM6eFi43TxdWmFKbwFHvDsuQZt4yB_c,70
|
|
18
|
-
timewise/process/config.py,sha256=
|
|
18
|
+
timewise/process/config.py,sha256=d4hCvNb8JyJf2-0BTQgJaeOmHGZK_aHEDMb_xyqJgbU,1060
|
|
19
19
|
timewise/process/interface.py,sha256=ZTUreyu_WkFTs8pOBNqFmCqgVs5OXEtPHjwpGVV1X_s,4929
|
|
20
20
|
timewise/process/keys.py,sha256=0TEVn-BwfzHGlScU-N8AtxgkhA2mUO0wBu4_ol_ylH4,197
|
|
21
|
-
timewise/process/stacking.py,sha256=
|
|
21
|
+
timewise/process/stacking.py,sha256=5qk9SYTfDFNFsnw9KAGYW-RndGtdmENKEiIqD6mrJ6I,12707
|
|
22
22
|
timewise/process/template.yml,sha256=U_xKmygDl3E-viTgZEI8pQIJwWduB52SdI2X9vy61Yo,1037
|
|
23
23
|
timewise/query/__init__.py,sha256=1OA_FlLI7O0aIDOXHpBKMOyMvYLCd0kQVkzoqbxouyE,242
|
|
24
24
|
timewise/query/base.py,sha256=LzG207uIQOEE_RucEKBI4-sHR_EwyILGSlSk10HlEeU,973
|
|
@@ -31,9 +31,9 @@ timewise/types.py,sha256=MB-aqpyos1aCS58QWBas34WcwFHiHOkrDj_d9_ZxuVc,667
|
|
|
31
31
|
timewise/util/backoff.py,sha256=bU5yhsBO4U53XEPJ_32tgql9rq_Rzrv7w32nVQYHr64,272
|
|
32
32
|
timewise/util/csv_utils.py,sha256=5i3Jd4c58-doPs1N_hyYZ8Uc2nvuk9nGwgPNZoNrlu0,298
|
|
33
33
|
timewise/util/error_threading.py,sha256=uyV1Ri-wf87lpa17Xlp520B1V8DWHh3v9Mk97QrPmv0,2264
|
|
34
|
-
timewise/util/visits.py,sha256=
|
|
35
|
-
timewise-1.0.
|
|
36
|
-
timewise-1.0.
|
|
37
|
-
timewise-1.0.
|
|
38
|
-
timewise-1.0.
|
|
39
|
-
timewise-1.0.
|
|
34
|
+
timewise/util/visits.py,sha256=4ZXwH7OXmp98tUPZplvuOtykB048kZoYXyuRTwQxT7w,998
|
|
35
|
+
timewise-1.0.0a2.dist-info/METADATA,sha256=d-JYTCE3StZwt-HcUDKzhLA-ahfP9TYbLpGcqRx3O6w,9172
|
|
36
|
+
timewise-1.0.0a2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
37
|
+
timewise-1.0.0a2.dist-info/entry_points.txt,sha256=mYh1HsUFbV7KT8kxiGqVtR3Pk0oEk6Bd-2c5FsYVhG4,45
|
|
38
|
+
timewise-1.0.0a2.dist-info/licenses/LICENSE,sha256=sVoNJWiTlH-NarJx0wdsob468Pg3JE6vIIgll4lCa3E,1070
|
|
39
|
+
timewise-1.0.0a2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|