fluves / pywaterinfo

Python package to download time series data from waterinfo.be
https://fluves.github.io/pywaterinfo/
MIT License
17 stars 9 forks source link

Download all available measurements (entire timeseries), without having to specify start/end date #33

Closed Olivia-WB closed 3 years ago

Olivia-WB commented 3 years ago

Description

I want to download all available measurements (in time) of a specific time series (from the very first measurement, to today), without knowing the start and end date. For example, to download all the available conductivity time series data of Prosperpolder SF/Zeeschelde (ts_id = 51814010), Something like:

hic.get_timeseries_values(ts_id=51814010, period="ALL")

...would be very useful.

What I Did

from pywaterinfo import Waterinfo
hic = Waterinfo("hic")
ts_conductivity=hic.get_timeseries_values(51814010)

I got the exception:

WaterinfoException: Date information should be provided by a combination of 2 parameters out of from / to / period"

A start&end date or a period are mandatory. Would it be possible to include a default for these parameters that results in the entire available timeseries?

stijnvanhoey commented 3 years ago

@Olivia-WB, I'm sorry I was not able to respond earlier to your request. This is indeed not supported. As a workaround, you can actually get the metadata of the time series to get these automatically:

from pywaterinfo import Waterinfo

hic = Waterinfo("hic")
station_metadata = hic.get_timeseries_list(ts_id = 51814010)[["from", "to"]]
start, end = station_metadata.values[0]
ts_conductivity = hic.get_timeseries_values(51814010, start=start, end=end)

Note for this specific time series I got an error when requesting the entire time series (server error for which you should consult HIC directly), but it illustrates the technical solution (and it works when I only use the start/end separately).

I propose to add this to the documentation of the package instead of adding it as additional option (which could lead to large requests making users losing a lot of credits).

stijnvanhoey commented 3 years ago

@Olivia-WB, see https://github.com/fluves/pywaterinfo/pull/36 PR for the example in the docs

Olivia-WB commented 3 years ago

Thanks a lot Stijn for the useful workaround!

stijnvanhoey commented 3 years ago

Closing this PR, see section https://fluves.github.io/pywaterinfo/tutorial.html#download-with-known-ts-identifier for this example to get the start/end of a time series