Skip to content

Point interpolation weighted method error  #148

Open
@MarineMercier

Description

@MarineMercier

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions