Skip to content

Commit

Permalink
HLA-1150: MVM failure due to HAPProduct constructor mismatch (#1693) (#…
Browse files Browse the repository at this point in the history
…1695)

Co-authored-by: Steve Goldman <32876747+s-goldman@users.noreply.github.com>
  • Loading branch information
mdlpstsci and s-goldman committed Nov 5, 2023
1 parent 2d65e32 commit 0bc0126
Show file tree
Hide file tree
Showing 5 changed files with 515 additions and 269 deletions.
2 changes: 1 addition & 1 deletion drizzlepac/haputils/align_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(self, input_list, clobber=False, dqname='DQ', process_type='',
# Apply filter to input observations to insure that they meet minimum criteria for being able to be aligned
log.info(
"{} AlignmentTable: Filter STEP {}".format("-" * 20, "-" * 63))
self.filtered_table = analyze.analyze_data(input_list, type=process_type)
self.filtered_table, _ = analyze.analyze_data(input_list, type=process_type)
log.debug("Input sorted as: \n{}".format(self.filtered_table))

if self.filtered_table['doProcess'].sum() == 0:
Expand Down
27 changes: 20 additions & 7 deletions drizzlepac/haputils/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def mvm_analyze_wrapper(input_filename, log_level=logutil.logging.DEBUG):
log.setLevel(log_level)

# Invoke the low-level analyze_data routine with type = "MVM"
filtered_table = analyze_data([input_filename], type = "MVM")
filtered_table, _ = analyze_data([input_filename], type = "MVM")

# There is only one row in this output table
use_for_mvm = False
Expand Down Expand Up @@ -175,6 +175,9 @@ def analyze_wrapper(input_file_list, log_level=logutil.logging.DEBUG, use_sbchrc
=======
viable_images_list : list
List of images which can be used in the drizzle process.
good_index : list
indices of the viable images in the input_file_list
return_code : int
Numeric code indicative of the status of the analysis of the input data.
Expand All @@ -187,7 +190,7 @@ def analyze_wrapper(input_file_list, log_level=logutil.logging.DEBUG, use_sbchrc
log.setLevel(log_level)

# Analyze the input file list and get the full table assessment
filtered_table = analyze_data(input_file_list, type=type)
filtered_table, analyze_data_good_index = analyze_data(input_file_list, type=type)

# Reduce table to only the data which should be processed (doProcess == 1)
mask = filtered_table["doProcess"] > 0
Expand All @@ -201,6 +204,7 @@ def analyze_wrapper(input_file_list, log_level=logutil.logging.DEBUG, use_sbchrc

good_table = None
good_rows = []
good_index = []
process_list = []
return_value = Ret_code.OK.value

Expand All @@ -210,6 +214,7 @@ def analyze_wrapper(input_file_list, log_level=logutil.logging.DEBUG, use_sbchrc
if filtered_table:
for i, old_row in enumerate(filtered_table):
if old_row["detector"].upper() != "SBC" and old_row["detector"].upper() != "HRC":
good_index.append(i)
good_rows.append(old_row)

# The entire filtered_table contains only SBC or HRC data
Expand All @@ -234,11 +239,11 @@ def analyze_wrapper(input_file_list, log_level=logutil.logging.DEBUG, use_sbchrc
if filtered_table:
# Get the list of all "good" files to use for the alignment
process_list = filtered_table['imageName'].tolist()
good_index = analyze_data_good_index
else:
log.warning("No viable images in single/multi-visit table - no processing done.\n")
return_value = Ret_code.NO_VIABLE_DATA.value

return process_list, return_value
return process_list, good_index, return_value


def analyze_data(input_file_list, log_level=logutil.logging.DEBUG, type=""):
Expand Down Expand Up @@ -268,6 +273,9 @@ def analyze_data(input_file_list, log_level=logutil.logging.DEBUG, type=""):
Astropy Table object containing data pertaining to the associated dataset, including
the do_process bool. It is intended this table is updated by subsequent functions for
bookkeeping purposes.
analyze_data_good_index : list
indices of the viable images in the input_file_list
Notes
=====
Expand Down Expand Up @@ -295,6 +303,8 @@ def analyze_data(input_file_list, log_level=logutil.logging.DEBUG, type=""):
# Set logging level to user-specified level
log.setLevel(log_level)

analyze_data_good_index = []

acs_filt_name_list = [DEFAULT_KEYS['FILKEY1'], DEFAULT_KEYS['FILKEY2']]

# Interpret input filenames and adjust size of column accordingly
Expand Down Expand Up @@ -351,7 +361,7 @@ def analyze_data(input_file_list, log_level=logutil.logging.DEBUG, type=""):
# available for the output table regardless of which keyword is used to
# to determine the data is not viable for alignment.

for input_file in input_file_list:
for i, input_file in enumerate(input_file_list):
header_hdu = 0
header_data = getheader(input_file, header_hdu)

Expand Down Expand Up @@ -521,6 +531,9 @@ def analyze_data(input_file_list, log_level=logutil.logging.DEBUG, type=""):
# processing should be allowed, but there may be some issue with the result (e.g.,
# GYROS mode so some drift)
generate_msg(input_file, msg_type, no_proc_key, no_proc_value)

else:
analyze_data_good_index.append(i)

# Populate a row of the table
output_table.add_row([input_file, instrume, detector, sfilter, aperture, obstype, subarray,
Expand All @@ -530,8 +543,8 @@ def analyze_data(input_file_list, log_level=logutil.logging.DEBUG, type=""):
total_rms, dataset_key, status, fit_qual, headerlet_file,
compromised])
process_msg = ""

return output_table
return output_table, analyze_data_good_index


def generate_msg(filename, msg, key, value):
Expand Down
Loading

0 comments on commit 0bc0126

Please sign in to comment.