ArtesiaWater / hydropandas

Module for loading observation data into custom DataFrames
https://hydropandas.readthedocs.io
MIT License
51 stars 10 forks source link

Spline interpolation for any ObsCollection #106

Closed OnnoEbbens closed 1 year ago

OnnoEbbens commented 1 year ago

The function get_knmi_obslist has an option to get a time series at any location by using spline interpolation. In order to clean up the io_knmi module I propose to remove it from there and make a more general function that does the trick for any ObsCollection. I am aware that it would probably give bad results on most ObsCollections but I would like to try it anyway. Furthermore we could add more methods than just the spline interpolation in the future.

Than the function would probably look something like this:

def interpolate_oc(xy, ObsCollection, method='spline'):

     # some magic

     return observation

Curious what your thought are on this @martinvonk

martinvonk commented 1 year ago

This should not be too difficult. The interpolate function is set up in a very general manner. Taking a list of [x,y] coordinates (locations of interest) and a DataFrame with the measurements as columns and observation times as index. The measurements locations are now retrieved from the KNMI list of stations but these are present in the obscollection so should be no problem to change this.

https://github.com/ArtesiaWater/hydropandas/blob/cdb97d9708ad659379d9b4feb61278591e1a15f7/hydropandas/io/io_knmi.py#L2007-L2082