Skip to content

Commit

Permalink
Merge pull request #303 from sot/vv-error
Browse files Browse the repository at this point in the history
Fix V&V processing error with Sqsh
  • Loading branch information
jeanconn authored Oct 24, 2024
2 parents aa0c8aa + 3e2472e commit a66f099
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions mica/vv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,15 @@ def _aiid_info(self, save_cols=save_asol_header):
# this should probably be handled in mica.archive.asp_l1
@staticmethod
def _asp1_lookup(obsid, obi, revision):
apstat = Sqsh(dbi="sybase", server="sqlsao", database="axafapstat")
# take these from the first aspect solution file header
aspect_1 = apstat.fetchall(
"""SELECT * FROM aspect_1
WHERE obsid = {obsid}
AND obi = {obi}
AND revision = {revision}
""".format(obsid=obsid, obi=obi, revision=revision)
)
apstat.conn.close()
with Sqsh(dbi="sybase", server="sqlsao", database="axafapstat") as apstat:
# take these from the first aspect solution file header
aspect_1 = apstat.fetchall(
"""SELECT * FROM aspect_1
WHERE obsid = {obsid}
AND obi = {obi}
AND revision = {revision}
""".format(obsid=obsid, obi=obi, revision=revision)
)
if len(aspect_1) > 1:
raise ValueError("More than one entry found for obsid/obi/rev in aspect_1")
if len(aspect_1) == 0:
Expand Down Expand Up @@ -269,7 +268,7 @@ def _save_info_json(self, file=None):
logger.info("Saved JSON to {}".format(file))

def slots_to_db(self):
if self.info()["aspect_1_id"] is None:
if self.info().get("aspect_1_id") is None:
logger.warning(
"Database save not implemented for obsids without aspect_1_ids"
)
Expand Down Expand Up @@ -301,7 +300,7 @@ def _get_ccd_temp(tstart, tstop):

def slots_to_table(self):
save = self.info()
if save["aspect_1_id"] is None:
if save.get("aspect_1_id") is None:
logger.warning("Table save not implemented for obsids without aspect_1_ids")
return
mean_aacccdpt = self._get_ccd_temp(save["tstart"], save["tstop"])
Expand Down Expand Up @@ -932,13 +931,12 @@ def _get_prop(self, propname, propstring):
def _read_ocat_stars(self):
obsid = int(self.asol_header["OBS_ID"])
obi = int(self.asol_header["OBI_NUM"])
ocat_db = Sqsh(dbi="sybase", server="sqlsao", database="axafocat")
stars = ocat_db.fetchall(
"select * from stars where "
"obsid = {} and obi = {} "
"and type != 0".format(obsid, obi)
)
ocat_db.conn.close()
with Sqsh(dbi="sybase", server="sqlsao", database="axafocat") as ocat_db:
stars = ocat_db.fetchall(
"select * from stars where "
"obsid = {} and obi = {} "
"and type != 0".format(obsid, obi)
)
if len(np.unique(stars["obi"])) > 1:
raise ValueError(
"Multi-obi observation. OCAT stars unhelpful to identify missing slot"
Expand Down

0 comments on commit a66f099

Please sign in to comment.