reformat code using python-lsp-ruff

This commit is contained in:
2024-07-01 15:21:52 +02:00
parent 271ecbb631
commit 5a62fa4983
13 changed files with 1271 additions and 860 deletions

View File

@@ -1,19 +1,21 @@
#!/usr/bin/python
def main(infiles=None):
"""
Retrieve native spatial resolution from given observation.
"""
from os.path import join as path_join
from warnings import catch_warnings, filterwarnings
from astropy.io.fits import getheader
from astropy.wcs import WCS, FITSFixedWarning
from numpy.linalg import eig
if infiles is None:
print("Usage: \"python get_cdelt.py -f infiles\"")
print('Usage: "python get_cdelt.py -f infiles"')
return 1
prod = [["/".join(filepath.split('/')[:-1]), filepath.split('/')[-1]] for filepath in infiles]
prod = [["/".join(filepath.split("/")[:-1]), filepath.split("/")[-1]] for filepath in infiles]
data_folder = prod[0][0]
infiles = [p[1] for p in prod]
@@ -21,14 +23,14 @@ def main(infiles=None):
size = {}
for currfile in infiles:
with catch_warnings():
filterwarnings('ignore', message="'datfix' made the change", category=FITSFixedWarning)
filterwarnings("ignore", message="'datfix' made the change", category=FITSFixedWarning)
wcs = WCS(getheader(path_join(data_folder, currfile))).celestial
key = currfile[:-5]
size[key] = wcs.array_shape
if wcs.wcs.has_cd():
cdelt[key] = eig(wcs.wcs.cd)[0]*3600.
cdelt[key] = eig(wcs.wcs.cd)[0] * 3600.0
else:
cdelt[key] = wcs.wcs.cdelt*3600.
cdelt[key] = wcs.wcs.cdelt * 3600.0
print("Image name, native resolution in arcsec and shape")
for currfile in infiles:
@@ -41,7 +43,7 @@ def main(infiles=None):
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='Query MAST for target products')
parser.add_argument('-f', '--files', metavar='path', required=False, nargs='*', help='the full or relative path to the data products', default=None)
parser = argparse.ArgumentParser(description="Query MAST for target products")
parser.add_argument("-f", "--files", metavar="path", required=False, nargs="*", help="the full or relative path to the data products", default=None)
args = parser.parse_args()
exitcode = main(infiles=args.files)