-
Notifications
You must be signed in to change notification settings - Fork 2
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
consider refactoring the interpolate data section of the prepbufr builder to see if we can appropriately reduce the levels of nesting. #405
Comments
For my own reference - typically, folks recommend keeping nesting to 2-3 levels deep. They deal with deeper nesting via guard clauses and extracting functions. Some resources that could be useful: |
After going through all the data comparison to the legacy data and seeing all the problems with interpolation I no longer think it is possible to reduce the complexity of these steps. The heights must be interpolated with the hypsometric equation for every height. Following the hypsometric interpolation the logarithmic interpolation is necessary to get data at the standard levels. Closing this. |
This issue was less about reducing the complexity of the steps - those are all very necessary. However, I was hoping we could make the function less nested/easier to understand & update by extracting components into subfunctions. Could we reopen this issue? As a more trivial example for this section of code: VxIngest/src/vxingest/prepbufr_to_cb/prepbufr_builder.py Lines 346 to 357 in 930d7d7
We could refactor out into a subfunction and use that. def should_skip_variable(self, report: int, variable: string) -> bool:
"""Contains the rules to determine if a variable should be skipped"""
if report == 120 and "wind" in variable.lower():
# skip this one - it is handled in the 220 report
return True
if (
report == 220
and variable.lower() != "pressure"
and "wind" not in variable.lower()
):
# skip this one - it is handled in the 120 report - except for pressure
return True
return False We'd then use it in the if self.should_skip_variable(report, variable):
continue
... We'd then do this to break out other parts of the function and reduce its nestedness. I've had some fun asking Copilot how to reduce the nesting for the |
This issue is stale because it has been open 90 days with no activity. |
We can consider refactoring the interpolate data section of the prepbufr builder to see if we can appropriately reduce the levels of nesting. The build_document method has to
The nesting on step 3 can be confusing. Perhaps there is a way to make it flatter.
The text was updated successfully, but these errors were encountered: