Skip to content

Commit

Permalink
Adding checking for wcs information to the cutout function
Browse files Browse the repository at this point in the history
  • Loading branch information
Clara Brasseur committed May 9, 2019
1 parent 51d48ba commit fb29ef5
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions astrocut/cube_cut.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self):
"VIGNAPP": [None, "vignetting or collimator correction applied"]}


def _parse_table_info(self, table_header, table_row):
def _parse_table_info(self, table_header, table_data, verbose=False):
"""
Takes the header and one entry from the cube table of image header data,
builds a WCS object that encalpsulates the given WCS information,
Expand All @@ -88,7 +88,21 @@ def _parse_table_info(self, table_header, table_row):
One row from the cube image header data table.
"""

# Turning the table row inot a new header object
data_ind = int(len(table_data)/2)
table_row = None

# Making sure we have a row with wcs info
while table_row is None:
table_row = table_data[data_ind]
ra_col = int([x for x in table_header.cards if x[1] == "CTYPE1"][0][0].replace("TTYPE","")) - 1
if "RA" not in table_row[ra_col]:
table_row is None
data_ind += 1

if verbose:
print("Using WCS from row {} out of {}".format(data_ind, len(table_data)))

# Turning the table row into a new header object
wcs_header = fits.header.Header()

for header_key, header_val in table_header.items():
Expand Down Expand Up @@ -619,8 +633,8 @@ def cube_cut(self, cube_file, coordinates, cutout_size,
cube = fits.open(cube_file)

# Get the info we need from the data table
data_ind = int(len(cube[2].data)/2) # using the middle file for table info
self._parse_table_info(cube[2].header, cube[2].data[data_ind])
#data_ind = int(len(cube[2].data)/2) # using the middle file for table info
self._parse_table_info(cube[2].header, cube[2].data, verbose)#[data_ind])

if isinstance(coordinates, SkyCoord):
self.center_coord = coordinates
Expand Down

0 comments on commit fb29ef5

Please sign in to comment.