def reference_uri_to_cache_path(reference_uri, observatory=None): """Convert an abstract CRDS reference file URI into an absolute path for the file as located in the CRDS cache. Parameters ---------- reference_uri : string identifying an abstract CRDS reference file, .e.g. 'crds://jwst_miri_flat_0177.fits' observatory : string naming the telescope/project for CRDS, e.g. 'jwst' `observatory` should be omitted, None, or defined as a literal string value. Omission and the value None are interpreted as 'jwst'. Returns ------- reference_path : absolute file path to reference_uri in the CRDS cache, .e.g. '/grp/crds/cache/references/jwst/jwst_miri_flat_0177.fits' Standard CRDS cache paths are typically defined relative to the CRDS_PATH environment variable. See https://jwst-crds.stsci.edu guide and top level page for more info on configuring CRDS. The default CRDS_PATH value is /grp/crds/cache, currently on the Central Store. """ if not reference_uri.startswith("crds://"): raise exceptions.CrdsError( "CRDS reference URI's should start with 'crds://' but got", repr(reference_uri)) observatory = (observatory or 'jwst').lower() basename = config.pop_crds_uri(reference_uri) return crds.locate_file(basename, observatory)
def reference_uri_to_cache_path(reference_uri): """Convert an abstract CRDS reference file URI into an absolute path for the file as located in the CRDS cache. e.g. 'crds://jwst_miri_flat_0177.fits' --> '/grp/crds/cache/references/jwst/jwst_miri_flat_0177.fits' Standard CRDS cache paths are typically defined relative to the CRDS_PATH environment variable. See https://jwst-crds.stsci.edu guide and top level page for more info on configuring CRDS. The default CRDS_PATH value is /grp/crds/cache, currently on the Central Store. """ if not reference_uri.startswith("crds://"): raise exceptions.CrdsError("CRDS reference URI's should start with 'crds://' but got", repr(reference_uri)) basename = config.pop_crds_uri(reference_uri) return crds.locate_file(basename, "jwst")
def reference_uri_to_cache_path(reference_uri): """Convert an abstract CRDS reference file URI into an absolute path for the file as located in the CRDS cache. e.g. 'crds://jwst_miri_flat_0177.fits' --> '/grp/crds/cache/references/jwst/jwst_miri_flat_0177.fits' Standard CRDS cache paths are typically defined relative to the CRDS_PATH environment variable. See https://jwst-crds.stsci.edu guide and top level page for more info on configuring CRDS. The default CRDS_PATH value is /grp/crds/cache, currently on the Central Store. """ assert reference_uri.startswith( "crds://"), "CRDS file URI's should start with 'crds://'" basename = config.pop_crds_uri(reference_uri) return crds.locate_file(basename, "jwst")
def __init__(self, input_hdu: Union[str, fits.HDUList], reference_name: str, match_keys: Sequence[str], header_request: REQUEST = None, table_request: REQUEST = None, header_defaults: Dict[str, Any] = None): self.reference = input_hdu[0].header[reference_name].split('$')[-1] self.match_keys = match_keys self.match_values = self._get_input_match_values(input_hdu) path = crds.locate_file(self.reference, 'hst') # Check for gzipped files if not os.path.exists(path): path += '.gz' with fits.open(path) as ref: super().__init__(ref, header_request, table_request, header_defaults)