-
Notifications
You must be signed in to change notification settings - Fork 6
Add missing lookup_winds functionsAdd missing lookup_winds functions from ramtares_main #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Minsoo-Kang-space
wants to merge
1
commit into
main
Choose a base branch
from
environment-atmos-atmosphere_models-DRWP_atmos
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+76
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -655,6 +655,18 @@ LookupAtmosWinds::compute_average_wind( | |
| { | ||
| compute_average_wind( table_index, false, min_alt, max_alt); | ||
| } | ||
|
|
||
| /****************************************************************************/ | ||
| void | ||
| LookupAtmosWinds::compute_average_wind_interp( | ||
| double min_alt, | ||
| double max_alt, | ||
| double step_alt) | ||
| { | ||
| size_t target_index = (active)? current_index : 0; | ||
| compute_average_wind_interp( target_index, min_alt, max_alt, step_alt); | ||
| } | ||
|
|
||
| /****************************************************************************/ | ||
| void | ||
| LookupAtmosWinds::compute_average_wind( | ||
|
|
@@ -727,6 +739,63 @@ LookupAtmosWinds::compute_average_wind( | |
| } | ||
| } | ||
|
|
||
| /****************************************************************************/ | ||
| void | ||
| LookupAtmosWinds::compute_average_wind_interp( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is major new functionality that needs to be tested and documented before being merged. |
||
| size_t table_index, | ||
| double min_alt, | ||
| double max_alt, | ||
| double step_alt) | ||
| { | ||
| if (table_index >= number_of_datasets) { | ||
| CMLMessage::error( __FILE__,__LINE__, | ||
| "Error computing average wind velocity for profile at index ", | ||
| table_index, ".\nThis index has not been populated with data.\n" | ||
| "Aborting computation.\n"); | ||
| return; | ||
| } | ||
|
|
||
| double original_altitude = altitude; | ||
| jeod::Vector3::initialize(average_wind); | ||
| DRWPTableLookup & table_ = TableLookup_array[table_index]; | ||
|
|
||
| // Table logic to maintain bounds of operated on | ||
| // altitude array within available domain | ||
| double table_end1 = table_.independent->data.front(); | ||
| double table_end2 = table_.independent->data.back(); | ||
| double table_min = std::min(table_end1, table_end2); | ||
| double table_max = std::max(table_end1, table_end2); | ||
| double min_alt_ = std::max(table_min, min_alt); | ||
| double max_alt_ = std::min(table_max, max_alt); | ||
|
|
||
| if (min_alt_ > max_alt_) { | ||
| CMLMessage::error( __FILE__,__LINE__, | ||
| "Error computing average wind velocity within specified bounds\n", | ||
| "No altitude data found in between 'min_alt' (", min_alt, | ||
| ")\nand 'max_alt' (", max_alt, ") for given DRWP Binary file."); | ||
| // Leave average at zero-vector | ||
| return; | ||
| } | ||
| size_t num_alts = (max_alt_ - min_alt_) / step_alt + 1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs divide-by-zero protection. |
||
| for (size_t alt = 0; alt < num_alts; ++alt) { | ||
| altitude = min_alt_ + static_cast<double>(alt) * step_alt; | ||
| table_.update(); | ||
| calculate_wind_mag_dir(); | ||
| jeod::Vector3::incr( wind_velocity_tc, | ||
| average_wind); | ||
| } | ||
|
|
||
| jeod::Vector3::scale( (1.0/num_alts), | ||
| average_wind); | ||
| // We just populated the model's output data with values from an altitude | ||
| // that is not the current altitude. If the model is currently active, that | ||
| // might cause some problems with data logging. | ||
| // Reset model outputs to current table and altitude. | ||
| if (active) { | ||
| update(original_altitude); | ||
| } | ||
| } | ||
|
|
||
| /************************************************************************* | ||
| calculate_speed_of_sound | ||
| Purpose: (computes SOS based on pressure and density at a given altitude) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default arguments for this don't make sense. An altitude increment of zero would never be useful and it's the last argument, so we always need to specify values for every argument. It would also result in a divide-by-zero in the function itself since there's no protection against that case.