-
-
Save jhunkeler/f08783ca2da7bfd1f8e9ee1d207da5ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
elements = \ | |
re.compile(r"[a-z]+" | |
"(?P<program_id>\d{5})" | |
"(?P<observation>\d{3})" | |
"(?P<visit>\d{3})" | |
"_(?P<visit_group>\d{2})" | |
"(?P<parallel_seq_id>\d{1})" | |
"(?P<activity>\d{2})" | |
"_(?P<exposure_id>\d+)" | |
"_(?P<detector>\w+)" | |
"_(?P<suffix>\w+).*") | |
filename = "jw94015001001_02102_00001_nrcb1_uncal.fits" | |
jwst_file = elements.match(filename) | |
if jwst_file is not None: | |
filename_dict = jwst_file.groupdict() | |
for key, value in filename_dict.items(): | |
print('{:<15s} = {:s}'.format(key, value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: