NCAR / wrf-python

A collection of diagnostic and interpolation routines for use with output from the Weather Research and Forecasting (WRF-ARW) Model.
https://wrf-python.readthedocs.io
Apache License 2.0
410 stars 155 forks source link

inefficient data fetching due to uncached time extraction #115

Open WeatherGod opened 4 years ago

WeatherGod commented 4 years ago

https://github.com/NCAR/wrf-python/blob/bd1107c605f7f51c712d3a1d22cf359bfcbad874/src/wrf/util.py#L1609

https://twitter.com/JaredALee/status/1263311504469889031

A friend using this package to extract data across many wrf files was encountering huge slowdowns and found huge speedups switching to xarray. I dug a bit and I have a suspicion where the inefficiency is. There are two things about the linked line that concerns me. First, It is called before a possible short-circuit path that doesn't use its result, so perhaps this line can get moved to a few lines down? Second, I notice that this function call doesn't use the passed in _key. I don't fully understand the cache mechanism, but I wonder if this would benefit from it?