Skip to content
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

Point interpolation weighted method error #148

Open
MarineMercier opened this issue Nov 28, 2023 · 0 comments
Open

Point interpolation weighted method error #148

MarineMercier opened this issue Nov 28, 2023 · 0 comments

Comments

@MarineMercier
Copy link

Hi,

I'm having trouble using the weighted interpolation method for a Point between different stations, I've tried :

point = Point(lon=lon, lat=lat)
point.method = "weighted"
monthly_data = Monthly(point, start_date, end_date)

This piece of code returns an error : KeyError: 'wdir'
image

The code in _resolve_point(...) looks like this :

if method == "nearest" :
   ...
else : 
   # Join score and elevation of involved weather stations
   data = self._data.join(stations[["score", "elevation"]], on="station")

   if not self.granularity == Granularity.NORMALS:
      excluded = data["wdir"]
      excluded = excluded.groupby(pd.Grouper(level="time", freq=self._freq)).agg("first")

   if self.granularity == Granularity.NORMALS:
      ...

   else : 
      data = data.groupby(pd.Grouper(level="time", freq=self._freq)).apply(weighted_average )
      # Drop RangeIndex
      data.index = data.index.droplevel(1)
      # Merge excluded fields
       data["wdir"] = excluded

with data['wdir'] and excluded referring to each other, while none of them is defined in the file.
Using monthly_data = Monthly(Point(lon=lon, lat=lat), start_date, end_date), monthly_data._data seems to never hold a 'wdir' key.

The stations called in self._resolve_point(loc.method, stations, loc.alt,...) is defined as point.get_stations() in interface/timeseries.py, but calling point.get_stations() returns a DataFrame where 'wdir' is also not defined.

Could you please let me know how to find/define this data['wdir'] please?
Thanks in advance for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant