Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:CIRADA-Tools/RM-Tools into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikOsinga committed Aug 14, 2024
2 parents 73d95f3 + 857b5ae commit 8415fc2
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions RMutils/util_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,39 @@

def update_position_wcsaxes(header):
# Store and delete the WCSAXES keyword
wcsaxes = header['WCSAXES']
del header['WCSAXES']
wcsaxes = header["WCSAXES"]
del header["WCSAXES"]

# Determine the correct insertion point before the first WCS-related keyword
wcs_keywords = ['CRPIX1', 'CRPIX2', 'CRVAL1', 'CRVAL2', 'CTYPE1', 'CTYPE2', 'CUNIT1', 'CUNIT2', 'PC1_1', 'PC2_2', 'CD1_1', 'CD2_2']
wcs_keywords = [
"CRPIX1",
"CRPIX2",
"CRVAL1",
"CRVAL2",
"CTYPE1",
"CTYPE2",
"CUNIT1",
"CUNIT2",
"PC1_1",
"PC2_2",
"CD1_1",
"CD2_2",
]

# Convert the header keys to a list
header_keys = list(header.keys())

# Find the first occurrence of any WCS-related keyword
insert_pos = min(header_keys.index(key) for key in wcs_keywords if key in header_keys)
insert_pos = min(
header_keys.index(key) for key in wcs_keywords if key in header_keys
)

# Insert WCSAXES at the correct position
header.insert(insert_pos, ('WCSAXES', wcsaxes))
header.insert(insert_pos, ("WCSAXES", wcsaxes))

return header


def remove_header_third_fourth_axis(header):
"""Removes extra axes from header to compress down to 2 axes"""
# List of keys related to the 3rd and 4th axes to remove (essentially everything with a '3' or '4')
Expand Down

0 comments on commit 8415fc2

Please sign in to comment.