Skip to content

Commit

Permalink
Merge pull request OpenMDAO#331 from jkirk5/cleanup
Browse files Browse the repository at this point in the history
Engine deck conversion bugfix
  • Loading branch information
jkirk5 authored Jun 18, 2024
2 parents 9c83a46 + ef03f15 commit 9702291
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
11 changes: 4 additions & 7 deletions aviary/utils/engine_deck_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def EngineDeckConverter(input_file, output_file, data_format: EngineDeckType):
formatted_data[key] = data[key].astype(float)

# convert engine_data from dict to list so it can be sorted
sorted_values = np.array([formatted_data[key] for key in formatted_data]).transpose()
sorted_values = np.array(list(formatted_data.values())).transpose()

# Sort by mach, then altitude, then throttle, then hybrid throttle
sorted_values = sorted_values[np.lexsort(
Expand All @@ -300,14 +300,11 @@ def EngineDeckConverter(input_file, output_file, data_format: EngineDeckType):
for idx, key in enumerate(formatted_data):
formatted_data[key] = sorted_values[:, idx]

# rework formatted_data into 2d array
formatted_data = np.array([formatted_data[key]
for key in header.keys()]).transpose().astype(float)

# store formatted data into NamedValues object
write_data = NamedValues()
for idx, key in enumerate(data):
write_data.set_val(header_names[key], data[key], default_units[key])

for key in data:
write_data.set_val(header_names[key], formatted_data[key], default_units[key])

write_data_file(output_file, write_data, comments, include_timestamp=False)

Expand Down
1 change: 1 addition & 0 deletions aviary/utils/test/test_engine_deck_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def compare_files(self, filepath, skip_list=[]):
exc_string = f'Error: {filename}\nFound: {line_no_whitespace}\nExpected: {expected_line}'
raise Exception(exc_string)

# TODO currently untested!!
# def test_TF_conversion(self):
# return

Expand Down

0 comments on commit 9702291

Please sign in to comment.