Minimal example#

 1# -*- coding: utf-8 -*-
 2"""
 3for use with test_cli.py, requires files from online source
 4
 5"""
 6
 7import hatyan
 8hatyan.close('all')
 9import urllib
10
11dir_testdata = "https://raw.githubusercontent.com/Deltares/hatyan/main/tests/data_unitsystemtests/"
12
13current_station = 'VLISSGN'
14
15# retrieve files from online
16file_list = [f'{current_station}_ana.txt',f'{current_station}_ext.txt']
17for fname in file_list:
18    url = dir_testdata+fname
19    with urllib.request.urlopen(url) as response:
20        data = response.read()
21    with open(fname, "w") as f:
22        f.write(data.decode('utf-8'))
23
24file_data_comp1 = f'{current_station}_ana.txt'
25
26times_pred = slice("2019-01-01","2019-02-01", "10min")
27
28comp_fromfile = hatyan.read_components(filename=file_data_comp1)
29
30#prediction and validation
31ts_prediction = hatyan.prediction(comp=comp_fromfile, times=times_pred)
32hatyan.write_dia(ts=ts_prediction, filename='prediction_%s_%s.dia'%(times_pred.step,current_station))
33ts_ext_prediction = hatyan.calc_HWLW(ts=ts_prediction)
34hatyan.write_dia(ts=ts_ext_prediction, filename='prediction_%s_%s_HWLW.dia'%(times_pred.step,current_station))
35fig, (ax1,ax2) = hatyan.plot_timeseries(ts=ts_prediction, ts_ext=ts_ext_prediction)
36fig.savefig('prediction_%s_%s'%(times_pred.step, current_station))