def file_to_instrument(filename): """Given reference or dataset `filename`, return the associated instrument. A key aspect of this function versus get_file_properties() is that observatory is not known. """ basename = os.path.basename(filename).lower() for (_obs, instr) in observatory_instrument_tuples(): if ("_" + instr + "_" in basename) or basename.startswith(instr + "_"): return instr.upper() from crds import data_file header = data_file.get_unconditioned_header(filename, needed_keys=tuple(INSTRUMENT_KEYWORDS)) return header_to_instrument(header)
def file_to_instrument(filename): """Given reference or dataset `filename`, return the associated instrument. A key aspect of this function versus get_file_properties() is that observatory is not known. """ basename = os.path.basename(filename).lower() for (_obs, instr) in observatory_instrument_tuples(): if ("_" + instr + "_" in basename) or basename.startswith(instr + "_"): return instr.upper() from crds import data_file header = data_file.get_unconditioned_header(filename, needed_keys=INSTRUMENT_KEYWORDS) return header_to_instrument(header)
def _cat_header(self, path): """Dump out the header associated with a reference file.""" old = config.ALLOW_SCHEMA_VIOLATIONS.set(True) header = data_file.get_unconditioned_header(path) if self.args.keywords: header2 = {} for keyword in header: for substr in self.args.keywords: if substr in keyword: header2[keyword] = header[keyword] else: header2 = header self._print_lines(path, _pp_lines(header2)) config.ALLOW_SCHEMA_VIOLATIONS.set(old)