lstosa 0.11.5__py3-none-any.whl → 0.11.6__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,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lstosa
3
- Version: 0.11.5
3
+ Version: 0.11.6
4
4
  Summary: Onsite analysis pipeline for the CTA LST-1
5
5
  Author: María Láinez, José Enrique Ruiz, Lab Saha, Andrés Baquero, José Luis Contreras, Maximilian Linhoff
6
6
  Author-email: Daniel Morcuende <dmorcuen@ucm.es>
@@ -1,5 +1,5 @@
1
1
  osa/__init__.py,sha256=crotf1NMTfNdZuCua_5T_jk3kvZrAAwVw4FPrfxv994,193
2
- osa/_version.py,sha256=ZyFxcHP5D9gYt6tCf5RRnkEsC8isbt9wg2nFTag5BOE,706
2
+ osa/_version.py,sha256=_nuaDP9J6XpAZCjMK8MqVIMfgWOB6l17LU-S9ZDw0Lg,706
3
3
  osa/conftest.py,sha256=AdSHdWqjeMTgIeZEF8fdw6eSliySouivMWCPIqUV2os,24667
4
4
  osa/job.py,sha256=CunwW7xA4mWEocS6KkDZ1K6h_LYh_ePZMyGHyCa6CKg,27863
5
5
  osa/osadb.py,sha256=pkCuYbEG-moHG0uQHxwB7giQAv2XTld4HJ5gdn1F1hA,2422
@@ -18,11 +18,11 @@ osa/high_level/selection_cuts.toml,sha256=ReSmcKtOPZY5JsZ9ExnxYdz7OrJEB8gghCbzHm
18
18
  osa/high_level/significance.py,sha256=mMeG_y2wDnt0O2lSosYkSjaGZQl0V4GnuFrqKwSKSbE,9066
19
19
  osa/high_level/tests/test_significance.py,sha256=nTHgwnL2zkQJduJuWXC4J4N8DlAghOidQki7njZmpSI,572
20
20
  osa/nightsummary/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- osa/nightsummary/database.py,sha256=6-1Y0Rw67QQtp0ekoynX9CVpImfECEUO64sA3fw24og,4276
22
- osa/nightsummary/extract.py,sha256=vI_A_GrP6eQH8f2mr8OreUfrs5LwLNcH9KQLx_WikhQ,11498
21
+ osa/nightsummary/database.py,sha256=XI2eozRK49-yDWnmH6irxfFWhi0qh6W0j1RuWXvk-uA,3980
22
+ osa/nightsummary/extract.py,sha256=VJnQISpT-NR_W0rRUrfI1xb8PkQYSwa1qcFTntS5NPk,11390
23
23
  osa/nightsummary/nightsummary.py,sha256=rPEN_J-rJSgsoCR_ONaW4PB9vjJzZvHgw0a7sYOA7wE,2666
24
24
  osa/nightsummary/set_source_coordinates.py,sha256=e2UT_I_Epm8vte22TasIp28A3KRdcl4dgV4NjlIxwak,1579
25
- osa/nightsummary/tests/test_database.py,sha256=w5Fts-H0eTi1KPV6Of0V2ZOD849Ie14KRe4wFhc9Hh0,242
25
+ osa/nightsummary/tests/test_database.py,sha256=jbWOY1ADJhp949qYpeXMDTMDXn7uZQuiLcMXIUT4avY,128
26
26
  osa/nightsummary/tests/test_extract.py,sha256=SJf0ld33UlK1d2jKweCQWNpGY9ZrIU1vFUdX4slnJps,1877
27
27
  osa/nightsummary/tests/test_nightsummary.py,sha256=0bgGJtlXzwclO2ma9I3X315X0X1bDkjqCaYcp3fay1s,987
28
28
  osa/nightsummary/tests/test_source_coordinates.py,sha256=doyF2e93RnFScPbG79aUmtHLCdGg-5oW8D5qqNDzivw,942
@@ -76,9 +76,9 @@ osa/workflow/dl3.py,sha256=ZMXPrdJA0WOxDiHEW9sdM2vmYix8R3eSMTGc6o42yxg,9860
76
76
  osa/workflow/stages.py,sha256=ILg91VyNXcy--si7CpDa1UFRiugqIH6nKl10Ru2zZVc,7422
77
77
  osa/workflow/tests/test_dl3.py,sha256=81Vt4lNxNjdKi_ehzymqfFWFjncw7GuQcix9S0Yigaw,384
78
78
  osa/workflow/tests/test_stages.py,sha256=aslfOIjf-rvf3r9N7NtimaOKkVB6K1M3bidgHOzRkMs,3985
79
- lstosa-0.11.5.dist-info/LICENSE,sha256=h6iWot11EtMvaDaS_AvCHKLTNByO5wEbMyNj1c90y1c,1519
80
- lstosa-0.11.5.dist-info/METADATA,sha256=w662afh4R8FFG9Ln0iYtMWvvE8pCYXYcVj1rDezy_dA,7302
81
- lstosa-0.11.5.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
82
- lstosa-0.11.5.dist-info/entry_points.txt,sha256=CzDKpLjZZQm8jJBxOVpMR8Czpgg_Yh-k6IPETp30VZE,1048
83
- lstosa-0.11.5.dist-info/top_level.txt,sha256=_Tj8zVHdrOoWZuuWTHbDpNofxW0imUmKdlXhnxsXJek,4
84
- lstosa-0.11.5.dist-info/RECORD,,
79
+ lstosa-0.11.6.dist-info/LICENSE,sha256=h6iWot11EtMvaDaS_AvCHKLTNByO5wEbMyNj1c90y1c,1519
80
+ lstosa-0.11.6.dist-info/METADATA,sha256=vl7USgduk5P1dGlyqfRIEfmZ2w4d4lev6r4yiXn5BEo,7302
81
+ lstosa-0.11.6.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
82
+ lstosa-0.11.6.dist-info/entry_points.txt,sha256=CzDKpLjZZQm8jJBxOVpMR8Czpgg_Yh-k6IPETp30VZE,1048
83
+ lstosa-0.11.6.dist-info/top_level.txt,sha256=_Tj8zVHdrOoWZuuWTHbDpNofxW0imUmKdlXhnxsXJek,4
84
+ lstosa-0.11.6.dist-info/RECORD,,
osa/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.11.5'
32
- __version_tuple__ = version_tuple = (0, 11, 5)
31
+ __version__ = version = '0.11.6'
32
+ __version_tuple__ = version_tuple = (0, 11, 6)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -14,27 +14,21 @@ __all__ = ["query", "db_available", "get_run_info_from_TCU"]
14
14
 
15
15
  log = myLogger(logging.getLogger(__name__))
16
16
 
17
-
18
- CACO_DB = cfg.get("database", "caco_db")
19
17
  TCU_DB = cfg.get("database", "tcu_db")
20
18
 
21
-
22
19
  def db_available():
23
20
  """Check the connection to the TCU database."""
24
- caco_client = MongoClient(CACO_DB, serverSelectionTimeoutMS=3000)
25
21
  tcu_client = MongoClient(TCU_DB, serverSelectionTimeoutMS=3000)
26
22
  try:
27
- caco_client.server_info()
28
23
  tcu_client.server_info()
29
24
  except ConnectionFailure:
30
- log.warning("TCU or CaCo database not available. No source info will be added.")
25
+ log.warning("TCU database not available. No source info will be added.")
31
26
  return False
32
27
  else:
33
- log.debug("TCU and CaCo database are available. Source info will be added.")
28
+ log.debug("TCU database is available. Source info will be added.")
34
29
  return True
35
30
 
36
-
37
- def query(obs_id: int, property_name: str):
31
+ def query(obs_id: int):
38
32
  """
39
33
  Query the source name and coordinates from TCU database.
40
34
 
@@ -42,13 +36,11 @@ def query(obs_id: int, property_name: str):
42
36
  ----------
43
37
  obs_id : int
44
38
  Run number
45
- property_name : str
46
- Properties from drive information e.g. `DriveControl_SourceName`,
47
- `DriveControl_RA_Target`, `DriveControl_Dec_Target`
39
+
48
40
 
49
41
  Returns
50
42
  -------
51
- query_result : str or None
43
+ query_result : Dict
52
44
  Query result from database. It can be either the source name or its coordinates.
53
45
 
54
46
  Raises
@@ -60,47 +52,47 @@ def query(obs_id: int, property_name: str):
60
52
  if not isinstance(obs_id, int):
61
53
  obs_id = int(obs_id)
62
54
 
63
- caco_client = MongoClient(CACO_DB)
64
- tcu_client = MongoClient(TCU_DB)
65
-
66
- with caco_client, tcu_client:
67
- run_info = caco_client["CACO"]["RUN_INFORMATION"]
68
- run = run_info.find_one({"run_number": obs_id})
55
+ try:
56
+ tcu_client = MongoClient(TCU_DB, serverSelectionTimeoutMS=3000)
57
+ db = tcu_client["lst1_obs_summary"]
58
+ camera_col = db["camera"]
69
59
 
70
- try:
71
- start = datetime.fromisoformat(run["start_time"].replace("Z", ""))
72
- end = datetime.fromisoformat(run["stop_time"].replace("Z", ""))
73
- except TypeError:
74
- return None
60
+ run_info = camera_col.find_one({"run_number": obs_id})
75
61
 
76
- bridges_monitoring = tcu_client["bridgesmonitoring"]
77
- property_collection = bridges_monitoring["properties"]
78
- chunk_collection = bridges_monitoring["chunks"]
79
- descriptors = property_collection.find(
80
- {"property_name": property_name},
81
- )
62
+ if not run_info:
63
+ log.info(f"Run {obs_id} not found 'lst1_obs_summary.camera'")
64
+ else:
82
65
 
83
- entries = {"name": property_name, "time": [], "value": []}
66
+ tstart = run_info.get("tstart")
67
+ tstop = run_info.get("tstop")
68
+ run_type = run_info.get("kind")
84
69
 
85
- for descriptor in descriptors:
86
- query_property = {"pid": descriptor["_id"]}
70
+ tstart_iso = datetime.fromtimestamp(tstart).isoformat(sep=" ", timespec="seconds")
87
71
 
88
- if start is not None:
89
- query_property["begin"] = {"$gte": start}
72
+ log.info(f"Run {obs_id} ({run_type}) found.")
73
+ log.info(f"Time: {tstart_iso} (Timestamp: {tstart})")
90
74
 
91
- if end is not None:
92
- query_property["end"] = {"$lte": end}
75
+ telescope_col = db["telescope"]
76
+ query = {
77
+ "tstart": {"$lte": tstop},
78
+ "tstop": {"$gte": tstart}
79
+ }
93
80
 
94
- chunks = chunk_collection.find(query_property)
81
+ tel_doc = telescope_col.find_one(query, sort=[("tstart", -1)])
95
82
 
96
- for chunk in chunks:
97
- for value in chunk["values"]:
98
- entries["time"].append(value["t"])
99
- entries["value"].append(value["val"])
83
+ if tel_doc:
100
84
 
101
- source_name = entries["value"][0]
102
- return source_name if source_name != "" else None
85
+ config = tel_doc.get("data", {}).get("structure", [])[0]
86
+ target = config.get("target", {})
87
+ source_name = target.get("name", "Desconocido")
88
+ ra = target.get("source_ra", "N/A")
89
+ dec = target.get("source_dec", "N/A")
90
+ return {"source_name": source_name, "ra": ra, "dec": dec}
91
+ else:
92
+ log.info("\nNo information found for that time range in 'lst1_obs_summary.telescope'.")
103
93
 
94
+ except Exception as e:
95
+ log.info(f"ERROR: {e}")
104
96
 
105
97
  def get_run_info_from_TCU(run_id: int, tcu_server: str) -> Tuple:
106
98
  """
@@ -173,15 +173,16 @@ def extract_runs(summary_table):
173
173
  # Make sure we are looking at actual data runs. Avoid test runs.
174
174
  if run.run > 0 and run.type == "DATA":
175
175
  log.debug(f"Looking info in TCU DB for run {run.run}")
176
- run.source_name = database.query(
177
- obs_id=run.run, property_name="DriveControl_SourceName"
176
+
177
+ tcu_result = database.query(
178
+ obs_id=run.run
178
179
  )
179
- run.source_ra = database.query(
180
- obs_id=run.run, property_name="DriveControl_RA_Target"
181
- )
182
- run.source_dec = database.query(
183
- obs_id=run.run, property_name="DriveControl_Dec_Target"
184
- )
180
+
181
+ if tcu_result is not None:
182
+ run.source_name = tcu_result.get("source_name")
183
+ run.source_ra = tcu_result.get("ra")
184
+ run.source_dec = tcu_result.get("dec")
185
+
185
186
  # Store this source information (run_id, source_name, source_ra, source_dec)
186
187
  # into an astropy Table and save to disk in RunCatalog files. In this way, the
187
188
  # information can be dumped anytime later more easily than accessing the
@@ -1,9 +1,8 @@
1
- import pytest
2
- from pymongo.errors import ConnectionFailure
3
-
1
+ from osa.nightsummary import database
4
2
 
5
3
  def test_query():
6
- from osa.nightsummary import database
4
+ result = database.query(obs_id=20038)
5
+ assert result is None
6
+
7
+
7
8
 
8
- with pytest.raises(ConnectionFailure):
9
- database.query(obs_id=1616, property_name="DriveControl_SourceName")