31 figure out ifelse logic for process functions #36
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.
Closes #31
So I had a chance to explore options regarding IF/ELSE style process functions. The good news is nothing weird has to be added to the existing Model engine! My assessment of options (and their relative performances) is stored in
examples/dev_sandbox/running_process_funcs.ipynb.Benchmark: Simple functions (see the notebook) applied over the 25x53 xarray tutorial air temperature grid. I used
%%timeitto check speeds.Results:
xr.where()- turns out this is quite fast (6.83ms in my last benchmark) ONLY IF you do not use the@numpy.vectorizedecorator, despite that being recommended in thexarray.apply_ufunc documentation. Oddly, pre-vectorizing causes a nearly 10x slowdown (64.9ms). Also note thatxr.wherecan not be JIT compiled with Numba.Conclusion: Since option 1 and option 2 are relatively the same speed, I may just go with option 1 since the logic is much clearer. For example, in my notebook option 1 took 2 lines, and option 2 took 7 lines.
Other changes: