alliander-opensource / weather-provider-api

This API is intended to help you fetch weather data from different data sources in an efficient and uniform way. By just supplying a list of locations and a time window you can get data for a specific source immediately. This project is licensed under the MPL-2.0 license.
https://alliander-opensource.github.io/weather-provider-api/
Mozilla Public License 2.0
26 stars 6 forks source link

WPLA 2.x \\ BUG - Couldn't select data from ERA5SL repositories. #89

Closed rflinnenbank closed 1 year ago

rflinnenbank commented 1 year ago

The bug itself

One of the previous fixes that also brought with it version increases, while not breaking any tests or causing any errors, appears to have come with a bug:

This bug occurs:

The cause:

The cause was a complicated one...

When constructing the final Xarray Dataset that becomes the source for the output, a field "coord" is build by combining the "lat" and "lon" index fields. This field (in short) allows the NetCDF4 and NetCDF3 output formats to allow for their usage with maps. While the creation of the field itself still works as intended, the creation meant a full rebuild of the existing multi-indexed index.

During this process some form of floating point issue occurred, causing all of the "lon"-values (and somehow only the "lon"-values) to be replaced by values that were slightly off from their 2 decimal counter-parts. This meant that a 3.2 value might suddenly be represented by a relative 3.200001 value, for example when comparing directly to a standard float value of 3.2.

This, of course, caused any comparison to the grid values to be off ever so slightly, resulting in no found data for that value, causing a error indicating "no data found"...

The solution:

As the actual value is still correct, if a different representation of the value, the only issue currently is the comparison of these values to the grid-rounded values of weather data requests. Because of that we'll only address the comparison, and let the actual output formats do the rest of the rounding.

rflinnenbank commented 1 year ago

Fixed as of version 2.35