def test_na_parkeys_ir(self): r = self._get_rmap() # bestrefs time conversions still map comment parkeys to N/A header = dict(DETECTOR="IR", CCDAMP="ABCD", BINAXIS1="1.0", BINAXIS2="2.0", CCDGAIN="1.0", SAMP_SEQ="MIF1200", SUBTYPE="FULLIMAG", DARKCORR="PERFORM") # transform for bestrefs dheader = utils.Struct(r.map_irrelevant_parkeys_to_na(header)) self.assertEqual(dheader.DETECTOR, "IR") self.assertEqual(dheader.CCDAMP, "ABCD") self.assertEqual(dheader.BINAXIS1, "N/A") # comment self.assertEqual(dheader.BINAXIS2, "N/A") # non-comment self.assertEqual(dheader.CCDGAIN, "1.0") self.assertEqual(dheader.SAMP_SEQ, "MIF1200") self.assertEqual(dheader.SUBTYPE, "FULLIMAG") self.assertEqual(dheader.DARKCORR, "PERFORM")
def test_ref_to_dataset_ir(self): # rmap update time conversions don't map comment parkeys to N/A r = self._get_rmap() header = dict(DETECTOR="IR", CCDAMP="ABCD", BINAXIS1="1.0", BINAXIS2="2.0", CCDGAIN="1.0", SAMP_SEQ="MIF1200", SUBTYPE="FULLIMAG", DARKCORR="PERFORM") # transform for rmap updates dheader = utils.Struct(r.reference_to_dataset_header(header)) self.assertEqual(dheader.DETECTOR, "IR") self.assertEqual(dheader.CCDAMP, "ABCD") self.assertEqual(dheader.BINAXIS1, "1.0") # comment self.assertEqual(dheader.BINAXIS2, "N/A") # non-comment self.assertEqual(dheader.CCDGAIN, "1.0") self.assertEqual(dheader.SAMP_SEQ, "MIF1200") self.assertEqual(dheader.SUBTYPE, "FULLIMAG") self.assertEqual(dheader.DARKCORR, "N/A")
def jpoll_pull_messages(key, since_id=None): """Return a list of jpoll json message objects from the channel associated with `key` sent after datetime string `since` or since the last pull if since is not specified. """ messages = [] for msg in S.jpoll_pull_messages(key, since_id): decoded = utils.Struct(msg) decoded.data = python23.unescape(decoded.data) messages.append(decoded) return messages
def __init__(self, header): """Initialize this TypeSpec from dict `header`, enforcing requirments and creating suitable defaults for missing fields. """ header = utils.Struct(header) assert "suffix" in header assert "text_descr" in header or header.filetype == "all" if "tpn" not in header: header.tpn = header.instrument.lower() + "_" + header.suffix + ".tpn" if "ld_tpn" not in header: header.ld_tpn = header.instrument.lower() + "_" + header.suffix + "_ld.tpn" if "file_ext" not in header: header.file_ext = ".fits" if "unique_rowkeys" not in header: header.unique_rowkeys = None if "extra_keys" not in header: header.extra_keys = None super(TypeSpec, self).__init__(header.items())
def create_submission(self): """Create a Submission object based on script / command-line parameters.""" return utils.Struct( uploaded_files={ os.path.basename(filepath): filepath for filepath in self.files } if self.args.files else {}, description=self.args.description, username=self.username, creator_name=self.args.creator, change_level=self.args.change_level, auto_rename=not self.args.dont_auto_rename, compare_old_reference=not self.args.dont_compare_old_reference, submission_kind=self.args.submission_kind, observatory=self.observatory, pmap_mode=self.pmap_mode, pmap_name=self.pmap_name, agent="command-line-script")
def test_ref_to_dataset_uvis(self): r = self._get_rmap() header = dict( DETECTOR="UVIS", CCDAMP="ABCD", BINAXIS1="1.0", BINAXIS2="2.0", CCDGAIN="1.0", SAMP_SEQ="MIF1200", SUBTYPE="FULLIMAG", DARKCORR="PERFORM") # transform for rmap updates dheader = utils.Struct(r.reference_to_dataset_header(header)) self.assertEqual(dheader.DETECTOR, "UVIS") self.assertEqual(dheader.CCDAMP, "ABCD") self.assertEqual(dheader.BINAXIS1, "1.0") # comment self.assertEqual(dheader.BINAXIS2, "2.0") # non-comment self.assertEqual(dheader.CCDGAIN, "N/A") self.assertEqual(dheader.SAMP_SEQ, "N/A") self.assertEqual(dheader.SUBTYPE, "N/A") self.assertEqual(dheader.DARKCORR, "N/A")
def get_system_versions(master_version, context=None): """Return the versions Struct associated with cal s/w master_version as defined by `context` which can be defined as "null", "none", or None to use the default context, or with any other valid date based context specifier. """ return utils.Struct(S.get_system_versions(master_version, str(context)))
def get_submission_info(observatory, username): """Return configuration parameters needed for command line file submission relative to the current server, observatory, and username. """ return utils.Struct(S.get_submission_info(observatory, username))
def get_affected_datasets(observatory, old_context=None, new_context=None): """Return a structure describing the ids affected by the last context change.""" return utils.Struct(S.get_affected_datasets(observatory, old_context, new_context))