Skip to content

Commit

Permalink
Handle summit_utils availablity
Browse files Browse the repository at this point in the history
  • Loading branch information
Vebop committed Nov 25, 2024
1 parent c80cb50 commit 4953b6a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions python/lsst/ts/logging_and_reporting/consolidated_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@


import matplotlib.pyplot as plt
from lsst.summit.utils import ConsDbClient
try:
from lsst.summit.utils import ConsDbClient

have_consdb = True
except:
have_consdb = False


class ConsDbConnection:
Expand All @@ -32,7 +37,7 @@ def __init__(self, url, day_obs):
self.url = url
self.day_obs = day_obs
self.day_obs_int = int(day_obs.replace("-", ""))
self.client = ConsDbClient(url)
self.client = ConsDbClient(url) if have_consdb else None

def query_visit(self, instrument: str, type: str = "visit1"):
"""Query visit1 and visit1_quicklook tables and join the data on
Expand All @@ -46,6 +51,7 @@ def query_visit(self, instrument: str, type: str = "visit1"):
quicklook = self.client.query(ccdvisit1_quicklook)
except Exception as erry:
print(f"{erry=}")
return None

# Join both on visit_id so we can access obs_start for a time axis
return visits.join(quicklook, on="visit_id", lsuffix="", rsuffix="_q")
Expand All @@ -59,6 +65,7 @@ def query_exposure(self, instrument: str, type: str = "exposure"):
exposures = self.client.query(exposure_query)
except Exception as erry:
print(f"{erry=}")
return None

return exposures

Expand All @@ -82,7 +89,7 @@ def plot_ra_dec(y, x):
URL = "http://consdb-pq.consdb:8080/consdb"
day_obs = "2024-06-26"
instruments = "latiss, lsstcomcamsim, lsstcomcam"

"""
for instrument in instruments:
db_client = ConsDbConnection(URL, day_obs)
visits = db_client.query_visit(instrument=instrument)
Expand All @@ -101,3 +108,4 @@ def plot_ra_dec(y, x):
ra = exposures["s_ra"]
dec = exposures["s_dec"]
plot_ra_dec(dec, ra)
"""

0 comments on commit 4953b6a

Please sign in to comment.