Better handle edges of surge lookup matrix #15
Merged
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.
Not sure when it happened, but presumably due to some xarray updates, we now sometimes return missing values when pulling the surge impacts lookup for the no-climate-change scenario b/c we are at the lower bound of LSLR and sometimes due to some floating point issues are slightly below the lower bound. However, we do have real cases where interpolation targets are meaningfully below the lower bound of the matrix, in which case we want to assign 0s (which we are doing incorrectly at the moment). This PR updates the surge lookup creation to bump the lower and upper bounds of lslr by 2*epsilon so that we don't erroneously return 0s at the bounds of lslr lookup. It also improves our ability to catch other cases of unintentional surge lookup table interpolation targets falling outside the bounds of the table.
I also realized that the
dask.distributed.wait
function was not catching errored futures but instead was just releasing when all futures were either finished or errored. Not sure if this was always the case or a change in functionality of recent Dask versions, but now we useclient.gather
for futures that return None (so they are negligible in local memory impact) instead ofwait
get_refA
now also handles the potential edge case where it is run on a single segment, which previously would throw an error