timewise 1.0.0a1__tar.gz → 1.0.0a2__tar.gz

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.
Files changed (39) hide show
  1. {timewise-1.0.0a1 → timewise-1.0.0a2}/PKG-INFO +1 -1
  2. {timewise-1.0.0a1 → timewise-1.0.0a2}/pyproject.toml +1 -1
  3. timewise-1.0.0a2/timewise/__init__.py +1 -0
  4. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/plot/diagnostic.py +1 -1
  5. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/process/config.py +9 -5
  6. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/process/stacking.py +21 -9
  7. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/util/visits.py +9 -9
  8. timewise-1.0.0a1/timewise/__init__.py +0 -1
  9. {timewise-1.0.0a1 → timewise-1.0.0a2}/LICENSE +0 -0
  10. {timewise-1.0.0a1 → timewise-1.0.0a2}/README.md +0 -0
  11. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/backend/__init__.py +0 -0
  12. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/backend/base.py +0 -0
  13. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/backend/filesystem.py +0 -0
  14. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/chunking.py +0 -0
  15. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/cli.py +0 -0
  16. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/config.py +0 -0
  17. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/io/__init__.py +0 -0
  18. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/io/config.py +0 -0
  19. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/io/download.py +0 -0
  20. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/io/stable_tap.py +0 -0
  21. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/plot/__init__.py +0 -0
  22. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/plot/lightcurve.py +0 -0
  23. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/plot/panstarrs.py +0 -0
  24. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/plot/sdss.py +0 -0
  25. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/process/__init__.py +0 -0
  26. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/process/interface.py +0 -0
  27. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/process/keys.py +0 -0
  28. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/process/template.yml +0 -0
  29. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/query/__init__.py +0 -0
  30. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/query/base.py +0 -0
  31. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/query/positional.py +0 -0
  32. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/tables/__init__.py +0 -0
  33. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/tables/allwise_p3as_mep.py +0 -0
  34. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/tables/base.py +0 -0
  35. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/tables/neowiser_p1bs_psd.py +0 -0
  36. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/types.py +0 -0
  37. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/util/backoff.py +0 -0
  38. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/util/csv_utils.py +0 -0
  39. {timewise-1.0.0a1 → timewise-1.0.0a2}/timewise/util/error_threading.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: timewise
3
- Version: 1.0.0a1
3
+ Version: 1.0.0a2
4
4
  Summary: Download WISE infrared data for many objects and process them with AMPEL
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [project]
6
6
  name = "timewise"
7
- version = "1.0.0a1"
7
+ version = "1.0.0a2"
8
8
  description = "Download WISE infrared data for many objects and process them with AMPEL"
9
9
  authors = [
10
10
  { name = "Jannis Necker", email = "jannis.necker@gmail.com" },
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0a2"
@@ -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
@@ -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
- @property
19
- def input_mongo_db_name(self) -> str:
20
- return self.mongo_db_name + "_input"
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(
@@ -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
- outlier_thresh = np.inf if not remove_outliers else 20
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
- # calculate 90% confidence interval
160
- u70 = np.zeros_like(counts, dtype=float)
161
- u70[one_points_mask] = 1e-10
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
- u70[visits_at_least_two_point] = np.array(
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
- 0.7,
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) > outlier_thresh * u70[visit_mask]
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(lightcurve: pd.DataFrame, clean_outliers: bool = True):
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
@@ -3,31 +3,31 @@ import pandas as pd
3
3
  import numpy.typing as npt
4
4
 
5
5
 
6
- def get_visit_map(lightcurve: pd.DataFrame) -> npt.NDArray[np.int64]:
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 lightcurve: the raw lightcurve
11
- :type lightcurve: pd.DataFrame
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(lightcurve.mjd)
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
- lightcurve.mjd.max() * 1.01
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(lightcurve.mjd, epoch_bins) - 1
32
+ visit_mask = np.digitize(mjd, epoch_bins) - 1
33
33
  return visit_mask
@@ -1 +0,0 @@
1
- __version__ = "1.0.0a1"
File without changes
File without changes
File without changes
File without changes