Skip to content
Snippets Groups Projects
Commit 6c6919b6 authored by Philipp Arras's avatar Philipp Arras
Browse files

Fits2field: Add AIPS compatilibity

parent 6f56b77d
Branches
Tags
1 merge request!37Draft: Observation: introduce __hash__
......@@ -64,6 +64,7 @@ def fits2field(file_name, ignore_units=False, from_wsclean=False):
assert image_data.shape[0] == 1 # Only one Stokes component
image_data = image_data[0]
head = hdu_list[0].header
if len(set(["CUNIT1", "CUNIT2", "CUNIT3"]) & set(head.keys())) >= 1:
assert head["CUNIT1"].strip() == "deg"
assert head["CUNIT2"].strip() == "deg"
assert head["CUNIT3"].strip() == "Hz"
......@@ -87,7 +88,20 @@ def fits2field(file_name, ignore_units=False, from_wsclean=False):
if not ignore_units:
if head["BUNIT"].upper() == "JY/BEAM":
fac = np.pi / 4 / np.log(2)
scale = fac * head["BMAJ"] * head["BMIN"] * (np.pi / 180) ** 2
if "BMIN" in head:
bmin, bmaj = head["BMIN"], head["BMAJ"]
else:
def parse(lst, iden):
# Can parse strings of the form:
# AIPS CLEAN BMAJ= 2.5976E-04 BMIN= 2.2344E-04 BPA= -58.25
res = list(filter(lambda ll: iden in ll, lst))
assert len(res) == 1
res = list(filter(lambda s: s != "", res[0].split(" ")))
return res[res.index(iden) + 1]
bmaj = float(parse(head["HISTORY"], "BMAJ="))
bmin = float(parse(head["HISTORY"], "BMIN="))
scale = fac * bmin * bmaj * (np.pi / 180) ** 2
elif head["BUNIT"].upper() == "JY/PIXEL":
scale = abs(refs[0][2] * refs[1][2])
else:
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment