Deltares-research / kenmerkendewaarden

Derive indicators from waterlevel measurements
https://deltares-research.github.io/kenmerkendewaarden/
GNU General Public License v3.0
2 stars 0 forks source link

decide on hat/lat method #73

Open veenstrajelmer opened 3 months ago

veenstrajelmer commented 3 months ago

Several methods possible:

Also the settings can be varied:

Consider the method and settings before deciding on a method, a 2021 memo shows the impact of different choices: 11204107-003-ZKS-0003_v0.5-Comparison of several LAT calculation methods.docx

The two implemented methods can be compared with this code:

import os
import pandas as pd
import hatyan
import kenmerkendewaarden as kw

dir_hatyan_data = r'c:\DATA\hatyan\tests\data_unitsystemtests'
# or online at https://github.com/Deltares/hatyan/blob/main/tests/data_unitsystemtests/HOEKVHLD_ana.txt
dir_kw_data = r'c:\DATA\kenmerkendewaarden\tests\testdata'
# or online at https://github.com/Deltares-research/kenmerkendewaarden/blob/main/tests/testdata/HOEK_KW.dia

current_station = 'HOEKVHLD'
methods = ["components", "measurements"]
hatlat = ["HAT","LAT"]
hat_lat_allstats = pd.DataFrame(index=methods, columns=hatlat)

# based on components
print(f'computing hat/lat from components for {current_station}')
file_comp = os.path.join(dir_hatyan_data, f'{current_station}_ana.txt')
comp = hatyan.read_components(filename=file_comp)
print(f'>> components for period {comp.attrs["tstart"]} to {comp.attrs["tstop"]}, SA/SM from 19y')
hat, lat = kw.calc_hat_lat_fromcomponents(comp=comp)
hat_lat_allstats.loc["components","HAT"] = hat
hat_lat_allstats.loc["components","LAT"] = lat

# based on measurements
print(f'computing hat/lat from measurements for {current_station}')
file_meas = os.path.join(dir_kw_data, 'HOEK_KW.dia')
df_meas = hatyan.read_dia(filename=file_meas)
df_meas_19y = df_meas.loc["2001":"2019"]
print(f">> measurements for period {df_meas_19y.index.min()} to {df_meas_19y.index.max()}")
hat, lat = kw.calc_hat_lat_frommeasurements(df_meas_19y)
hat_lat_allstats.loc["measurements","HAT"] = hat
hat_lat_allstats.loc["measurements","LAT"] = lat

# compute range and print
hat_lat_allstats["range"] = hat_lat_allstats["HAT"] - hat_lat_allstats["LAT"]
print(hat_lat_allstats)

Prints:

computing hat/lat from components for HOEKVHLD
>> period 2009-01-01 00:00:00 to 2012-12-31 23:00:00
computing hat/lat from measurements for HOEKVHLD
>> period 2001-01-01 00:00:00+01:00 to 2019-12-31 23:50:00+01:00
                   HAT       LAT     range
components    1.604644 -0.914127  2.518772
measurements  1.685611 -1.039573  2.725184