Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix V&V processing error with Sqsh #303

Open
wants to merge 2 commits into
base: no-aiprops-report
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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