timewise 1.0.0a2__py3-none-any.whl → 1.0.0a6__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.
@@ -1,6 +1,7 @@
1
1
  from pathlib import Path
2
2
  import logging
3
3
  from typing import Iterable, List, cast
4
+ from importlib.util import find_spec
4
5
 
5
6
  import numpy as np
6
7
  from numpy import typing as npt
@@ -8,12 +9,19 @@ import pandas as pd
8
9
  from pymongo import MongoClient, ASCENDING
9
10
  from pymongo.collection import Collection
10
11
  from pymongo.database import Database
11
- from ampel.cli.JobCommand import JobCommand
12
- from ampel.types import DataPointId, StockId
12
+
13
+ if find_spec("ampel.core"):
14
+ AMPEL_EXISTS = True
15
+ from ampel.cli.JobCommand import JobCommand
16
+ else:
17
+ AMPEL_EXISTS = False
13
18
 
14
19
 
15
20
  logger = logging.getLogger(__name__)
16
21
 
22
+ # copy from ampel.types
23
+ StockId = int | bytes | str
24
+
17
25
 
18
26
  class AmpelInterface:
19
27
  def __init__(
@@ -71,6 +79,10 @@ class AmpelInterface:
71
79
  return self.make_ampel_job_file(cfg_path)
72
80
 
73
81
  def run(self, timewise_cfg_path: Path, ampel_config_path: Path):
82
+ if not AMPEL_EXISTS:
83
+ raise ModuleNotFoundError(
84
+ "You are trying to run ampel but it is not installed!"
85
+ )
74
86
  ampel_job_path = self.prepare(timewise_cfg_path)
75
87
  cmd = JobCommand()
76
88
  parser = cmd.get_parser()
@@ -123,7 +135,7 @@ class AmpelInterface:
123
135
  index.append(ic["id"])
124
136
  return pd.DataFrame(records, index=index)
125
137
 
126
- def extract_selected_datapoint_ids(self, stock_id: StockId) -> List[DataPointId]:
138
+ def extract_selected_datapoint_ids(self, stock_id: StockId) -> List[int]:
127
139
  d = self.t1.find_one({"stock": stock_id})
128
140
  if d is None:
129
141
  return []
timewise/query/base.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import abc
2
- from typing import ClassVar, List
3
- from pydantic import BaseModel
2
+ from typing import ClassVar, List, Self
3
+ from pydantic import BaseModel, model_validator
4
4
  from hashlib import sha256
5
5
 
6
6
  from ..tables import TableType
@@ -22,6 +22,13 @@ class Query(abc.ABC, BaseModel):
22
22
  columns: List[str]
23
23
  table: TableType
24
24
 
25
+ @model_validator(mode="after")
26
+ def check_columns(self) -> Self:
27
+ for column in self.columns:
28
+ if column not in self.table.columns_dtypes:
29
+ raise KeyError(f"{column} not found in table {self.table.name}")
30
+ return self
31
+
25
32
  @property
26
33
  @abc.abstractmethod
27
34
  def input_columns(self) -> dict[str, str]: ...
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: timewise
3
- Version: 1.0.0a2
3
+ Version: 1.0.0a6
4
4
  Summary: Download WISE infrared data for many objects and process them with AMPEL
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -10,12 +10,13 @@ Requires-Python: >=3.11,<3.12
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.11
13
+ Provides-Extra: ampel
13
14
  Provides-Extra: dev
14
15
  Provides-Extra: docs
15
- Requires-Dist: ampel-alerts (==0.10.3a5)
16
- Requires-Dist: ampel-core (>=0.10.4.post0,<0.11.0)
17
- Requires-Dist: ampel-photometry (>=0.10.1,<0.11.0)
18
- Requires-Dist: ampel-plot (>=0.9.1,<0.10.0)
16
+ Requires-Dist: ampel-alerts (==0.10.3a5) ; extra == "ampel"
17
+ Requires-Dist: ampel-core (>=0.10.4.post0,<0.11.0) ; extra == "ampel"
18
+ Requires-Dist: ampel-photometry (>=0.10.1,<0.11.0) ; extra == "ampel"
19
+ Requires-Dist: ampel-plot (>=0.9.1,<0.10.0) ; extra == "ampel"
19
20
  Requires-Dist: astropy (>=5.1,<6.0.0)
20
21
  Requires-Dist: autodoc_pydantic[erdantic] (>=2.2.0,<3.0.0) ; extra == "docs"
21
22
  Requires-Dist: backoff (>=2.1.2,<3.0.0)
@@ -36,7 +37,6 @@ Requires-Dist: ruff (>=0.13.0,<0.14.0) ; extra == "dev"
36
37
  Requires-Dist: scikit-image (>=0.19.3,<0.22.0)
37
38
  Requires-Dist: scikit-learn (>=1.3.0,<2.0.0)
38
39
  Requires-Dist: scipy-stubs (>=1.16.2.0,<2.0.0.0) ; extra == "dev"
39
- Requires-Dist: seaborn (>=0.11.2,<0.14.0)
40
40
  Requires-Dist: sphinx-rtd-theme (>=1.3.0,<2.0.0) ; extra == "docs"
41
41
  Requires-Dist: tqdm (>=4.64.0,<5.0.0)
42
42
  Requires-Dist: typer (>=0.19.2,<0.20.0)
@@ -60,23 +60,33 @@ Description-Content-Type: text/markdown
60
60
  This package downloads WISE data for positions on the sky and stacks single-exposure photometry per visit
61
61
 
62
62
  ## Prerequisites
63
+ Python version 3.11.
63
64
 
64
- `timewise` makes use of [AMPEL](https://ampelproject.github.io/ampelastro/) and needs a running [MongoDB](https://www.mongodb.com/).
65
+ If you want to not only download individual exposure photometry but also stack detections per visit (see below),
66
+ you must have access to a running [MongoDB](https://www.mongodb.com/)*.
67
+
68
+ <sub>* On MacOS have alook at the custom `brew` tap
69
+ [here](https://github.com/mongodb/homebrew-brew)
70
+ to get the MongoDB community edition. </sub>
65
71
 
66
72
  ## Installation
67
- The package can be installed via `pip`:
73
+
74
+ ### If you use timewise only for downloading
75
+ The package can be installed via `pip` (but make sure to install the v1 pre-release):
68
76
  ```bash
69
- pip install timewise
77
+ pip install --pre timewise==1.0.0a6
78
+ ```
79
+ ### If you use timewise also for stacking individual exposures
80
+ You must install with the `ampel` extra:
81
+ ```bash
82
+ pip install --pre 'timewise[ampel]==1.0.0a6'
70
83
  ```
71
-
72
84
  To tell AMPEL which modules, aka units, to use, build the corresponding configuration file:
73
85
  ```bash
74
86
  ampel config build -distributions ampel timewise -stop-on-errors 0 -out <path-to-ampel-config-file>
75
87
  ```
76
88
 
77
- ## Usage
78
-
79
- ### Command line interface
89
+ ## Command line interface
80
90
 
81
91
  ```
82
92
  Usage: timewise [OPTIONS] COMMAND [ARGS]...
@@ -161,40 +171,50 @@ ampel:
161
171
  This configuration file will be the input to all subcommands. Downloading and stacking can be run together or separate.
162
172
 
163
173
 
164
- #### All-in-one:
165
- Run download, stacking, and export:
174
+ ### To only download the data:
166
175
  ```bash
167
- timewise run-chain <path-to-config-file> <path-to-ampel-config-file> <output-directory>
176
+ timewise download <path-to-config-file>
168
177
  ```
178
+ The photometry can be found in FITS files in the working directory specified in the configuration file\
179
+ along with metadata JSON files. These tell `timewise` which quries have already completed (per chunk) so the
180
+ download process can be interrupted and re-started at a later time.
181
+
182
+ ### Stack individual exposure by visits
183
+ As mentioned above, this needs installation with the ampel extra.
184
+
169
185
 
170
- #### Separate download and processing:
171
- To only download the data:
186
+ To **execute the stacking** after the download:
172
187
  ```bash
173
- timewise download <path-to-config-file>
188
+ timewise process <path-to-config-file> <path-to-ampel-config-file>
174
189
  ```
175
190
 
176
- To execute the stacking:
191
+ Make some **diagnostic plots** to check the datapoint selection and binning:
177
192
  ```bash
178
- timewise process <path-to-config-file> <path-to-ampel-config-file>
193
+ timewise plot <path-to-config-file> <indices-to-plot> <output-directory>
179
194
  ```
180
195
 
181
- #### Run AMPEL manually
182
- Prepare an AMPEL job file for stacking the single-exposure data:
196
+ As a shortcut, you can also run **download, stacking, and export in one command**:
183
197
  ```bash
184
- timewise prepare-ampel <path-to-config-file>
198
+ timewise run-chain <path-to-config-file> <path-to-ampel-config-file> <output-directory>
185
199
  ```
186
- The result will contain the path to the prepared AMPEL job file that can be run with
200
+
201
+ For more configuration options of the stacking, you can **run AMPEL manually**.
202
+
203
+ 1. Prepare an AMPEL job file for stacking the single-exposure data:
187
204
  ```bash
188
- ampel job -config <path-to-ampel-config-file> -schema <path-to-ampel-job-file>
205
+ timewise prepare-ampel <path-to-config-file>
189
206
  ```
207
+ The result will contain the path to the prepared AMPEL job file.
190
208
 
191
- #### Make some diagnostic plots
192
- To check the datapoint selection and binning, take a quick look at the data:
209
+ 2. Run the AMPEL job
193
210
  ```bash
194
- timewise plot <path-to-config-file> <indices-to-plot> <output-directory>
211
+ ampel job -config <path-to-ampel-config-file> -schema <path-to-ampel-job-file>
195
212
  ```
196
213
 
197
214
 
215
+
216
+
217
+
198
218
  ## Citation
199
219
  If you use `timewise` please make sure to cite [Necker et al. A&A 695, A228 (2025)](https://www.aanda.org/articles/aa/abs/2025/03/aa51340-24/aa51340-24.html).
200
220
  Additionally, you might want to include a reference to the specific version you are using: [![DOI](https://zenodo.org/badge/449677569.svg)](https://zenodo.org/badge/latestdoi/449677569)
@@ -1,13 +1,25 @@
1
- timewise/__init__.py,sha256=F0DR6kHrrc4PGk6Wna72waqVz5Gv15m9PgTOK00b7Kc,24
1
+ ampel/timewise/alert/TimewiseAlertSupplier.py,sha256=RmAWJVOfObaI1x0gt9agRt45WrVj1nhQchaMQ9QgUIA,4127
2
+ ampel/timewise/alert/load/TimewiseFileLoader.py,sha256=ChjOpQpyGTA-H_fjnvQGwa37IFfvfJanPmnVKORVElo,4271
3
+ ampel/timewise/ingest/TiCompilerOptions.py,sha256=xzGOOWAFoFsazocXLsTqtaHIqt_WUXFaacLUoBVKlbo,758
4
+ ampel/timewise/ingest/TiDataPointShaper.py,sha256=KbAg-J0DkMaJA9K67xMY5Pe0SIP0LNKsBNAMnTYV9zA,3180
5
+ ampel/timewise/ingest/TiMongoMuxer.py,sha256=YDiqaYiJ1TvyHUMAlNWHBHCpw0tH4Nvf8eyHUxMbzS8,6475
6
+ ampel/timewise/ingest/tags.py,sha256=ggn0Y6QUnjIwMzOlgKmPX1JPhmnvc21nUrORFhaR0uI,564
7
+ ampel/timewise/t1/T1HDBSCAN.py,sha256=vi1PWF0HFAedVJA4rVoR2YOXQ4jcEgEoUICtmg3rZjw,9301
8
+ ampel/timewise/t1/TimewiseFilter.py,sha256=ZSaXiSDKXCusknLJRMhe2Awj_YfkM74JVXeRbiZonmA,1564
9
+ ampel/timewise/t2/T2StackVisits.py,sha256=x7YcVLz_5fOPAfzso4fFWy4Pwn5txPfRT_Hx49PdbTo,1847
10
+ ampel/timewise/util/AuxDiagnosticPlotter.py,sha256=MZP4LWpFgBUPWPxlx8EEFeRc8rhI7FDO_LlbhKtkwrw,1641
11
+ ampel/timewise/util/pdutil.py,sha256=CJqeYqL2I6A5WnF5S342bwM4omJY-1XwT1XWY2uk3bc,1524
12
+ conf/timewise/ampel.yml,sha256=8NuVSuKqinHT0G66uDPnnw-P7djScKKVHzeFNsH3XZc,360
13
+ timewise/__init__.py,sha256=OhKzin_f9k_6U1rnhXEMzgMu70gbjQImfaWjmZiKhjA,24
2
14
  timewise/backend/__init__.py,sha256=w79nWfCw8n9g98CkHWJELmb4j9xblWC4DGZOV3_XhH4,134
3
15
  timewise/backend/base.py,sha256=dHxRzu2q3uQ0wdGmDxnn-p68Tp19qChue7HMEu56wNA,1080
4
16
  timewise/backend/filesystem.py,sha256=GQ4Hrb6_7Q7fKOn6QUl8bqAihAmyeZoTRxElNIwPQ1Y,2465
5
17
  timewise/chunking.py,sha256=q7njvTSD84gdcvIk54SC-Ob863MsR79RPec8HS-bm4U,1668
6
- timewise/cli.py,sha256=l6j-M2-x1LeDEAEnuDv9tadTNmVoxxMNgfyOaS-0oAw,3641
18
+ timewise/cli.py,sha256=W8SXlUQo7a5aS4_kW40KTs2UkTLQS12JuhgwkRb23DY,4172
7
19
  timewise/config.py,sha256=ZTSokRZMZDqBqVFV9DxvO-47yE9E9xWF48Rcjb0QG10,1044
8
20
  timewise/io/__init__.py,sha256=S7vb0glKJnw6ztOlrD-0Wma2bQZ2RwpmXDLFJLKBMVo,35
9
21
  timewise/io/config.py,sha256=aizLxt9l4aeWQNsvcemtQdr_fW1vLmpRSofcgA3Bgvk,2239
10
- timewise/io/download.py,sha256=rKjeW7nh7xUtHh8llvsg_qmkx71Wzn2LggQnyHwqJOI,10719
22
+ timewise/io/download.py,sha256=IMNWur1FWPKJ7SNMTjevZgWqPP_eYLzXr4Pjp3XOeXI,10589
11
23
  timewise/io/stable_tap.py,sha256=jukCkBi2d7WACOo_kXTMCppzWUsN-pLVg9EDqHi3qd0,3478
12
24
  timewise/plot/__init__.py,sha256=cc00UenWC_8zAkBH-Ylhs3yCF49tAqZ2Al9MfOoXYDI,120
13
25
  timewise/plot/diagnostic.py,sha256=GRp-OUwz2yzzDu9qdViFg_e3Mxl5t1IvUJXZHuMKB2U,8276
@@ -16,12 +28,12 @@ timewise/plot/panstarrs.py,sha256=X2ZULm7QT91cp4qociG0fVeI0saGLJwyKzL0141Vqis,80
16
28
  timewise/plot/sdss.py,sha256=cc1zU-4XFkqc8xH5yqCyMsDJf9w_54B_6NeRMjr9Pt8,2622
17
29
  timewise/process/__init__.py,sha256=Yk-j1B1MnBuuaM6eFi43TxdWmFKbwFHvDsuQZt4yB_c,70
18
30
  timewise/process/config.py,sha256=d4hCvNb8JyJf2-0BTQgJaeOmHGZK_aHEDMb_xyqJgbU,1060
19
- timewise/process/interface.py,sha256=ZTUreyu_WkFTs8pOBNqFmCqgVs5OXEtPHjwpGVV1X_s,4929
31
+ timewise/process/interface.py,sha256=JOIh1wYuE1s9XdSfBRS7qUXexlr-p5UxdwaSjKlRZxE,5207
20
32
  timewise/process/keys.py,sha256=0TEVn-BwfzHGlScU-N8AtxgkhA2mUO0wBu4_ol_ylH4,197
21
33
  timewise/process/stacking.py,sha256=5qk9SYTfDFNFsnw9KAGYW-RndGtdmENKEiIqD6mrJ6I,12707
22
34
  timewise/process/template.yml,sha256=U_xKmygDl3E-viTgZEI8pQIJwWduB52SdI2X9vy61Yo,1037
23
35
  timewise/query/__init__.py,sha256=1OA_FlLI7O0aIDOXHpBKMOyMvYLCd0kQVkzoqbxouyE,242
24
- timewise/query/base.py,sha256=LzG207uIQOEE_RucEKBI4-sHR_EwyILGSlSk10HlEeU,973
36
+ timewise/query/base.py,sha256=GjAoQZpaxVHcpCgPco1y5bpR0Jtd_sp_bYMI26WpAK0,1262
25
37
  timewise/query/positional.py,sha256=6fLfRdzat1jMqJAY7k7dEdnAZRiWyRKpWkbqpwzDKLo,1255
26
38
  timewise/tables/__init__.py,sha256=5efKk4YEhHLA_QTMYc8CQp0nQWXG-F3EAPE6935ManU,263
27
39
  timewise/tables/allwise_p3as_mep.py,sha256=NfCnTOdj_6DSFUWGmrwDyrrxIWvJFHktHWF40K_w5wQ,632
@@ -32,8 +44,8 @@ timewise/util/backoff.py,sha256=bU5yhsBO4U53XEPJ_32tgql9rq_Rzrv7w32nVQYHr64,272
32
44
  timewise/util/csv_utils.py,sha256=5i3Jd4c58-doPs1N_hyYZ8Uc2nvuk9nGwgPNZoNrlu0,298
33
45
  timewise/util/error_threading.py,sha256=uyV1Ri-wf87lpa17Xlp520B1V8DWHh3v9Mk97QrPmv0,2264
34
46
  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,,
47
+ timewise-1.0.0a6.dist-info/METADATA,sha256=2m1fvHTkYBVmko9pENN3GjqWTHpmU9Dgq1Ut54sqmK8,10146
48
+ timewise-1.0.0a6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
49
+ timewise-1.0.0a6.dist-info/entry_points.txt,sha256=mYh1HsUFbV7KT8kxiGqVtR3Pk0oEk6Bd-2c5FsYVhG4,45
50
+ timewise-1.0.0a6.dist-info/licenses/LICENSE,sha256=sVoNJWiTlH-NarJx0wdsob468Pg3JE6vIIgll4lCa3E,1070
51
+ timewise-1.0.0a6.dist-info/RECORD,,