Skip to content

Commit

Permalink
32 refactor kwk processpy (#70)
Browse files Browse the repository at this point in the history
* removed logging basicconfig lines, not needed anymore

* removed last prints in modules

* renamed df_amount_pcolormesh to plot_measurements_amount
  • Loading branch information
veenstrajelmer authored Jun 14, 2024
1 parent d6f888a commit 331a9a1
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 14 deletions.
6 changes: 2 additions & 4 deletions examples/KWK_getcheckdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import kenmerkendewaarden as kw

# set logging level to INFO to get log messages
# calling basicConfig is essential to set logging level of single module, format is optional
import logging
logging.basicConfig(format='%(message)s')
logging.getLogger("kenmerkendewaarden").setLevel(level="INFO")


Expand Down Expand Up @@ -78,9 +76,9 @@

file_plot = os.path.join(dir_meas_amount, "data_amount")

fig, ax = kw.df_amount_pcolormesh(df_amount_ts, relative=True)
fig, ax = kw.plot_measurements_amount(df_amount_ts, relative=True)
fig.savefig(file_plot + "_ts_pcolormesh_relative", dpi=200)
fig, ax = kw.df_amount_pcolormesh(df_amount_ext, relative=True)
fig, ax = kw.plot_measurements_amount(df_amount_ext, relative=True)
fig.savefig(file_plot + "_ext_pcolormesh_relative", dpi=200)


Expand Down
4 changes: 1 addition & 3 deletions examples/KWK_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
import kenmerkendewaarden as kw # pip install git+https://github.com/Deltares-research/kenmerkendewaarden

# set logging level to INFO to get log messages
# calling basicConfig is essential to set logging level of single module, format is optional
import logging
logging.basicConfig(format='%(message)s')
logging.getLogger("kenmerkendewaarden").setLevel(level="INFO")
logging.getLogger("kenmerkendewaarden").setLevel(level="DEBUG")

# TODO: HW/LW numbers not always increasing (at havengetallen): ['HANSWT','BROUWHVSGT08','PETTZD','DORDT']

Expand Down
4 changes: 2 additions & 2 deletions kenmerkendewaarden/data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import logging

__all__ = [
"df_amount_pcolormesh",
"plot_measurements_amount",
"plot_measurements",
"plot_stations",
"derive_statistics",
Expand All @@ -22,7 +22,7 @@
logger = logging.getLogger(__name__)


def df_amount_pcolormesh(df, relative=False):
def plot_measurements_amount(df, relative=False):
df = df.copy()
df[df==0] = np.nan

Expand Down
1 change: 0 additions & 1 deletion kenmerkendewaarden/gemiddeldgetij.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def calc_gemiddeldgetij(df_meas: pd.DataFrame, df_ext: pd.DataFrame = None,
dummy,shallowrel,dummy = hatyan.foreman.get_foreman_shallowrelations()
bool_M2S2only = shallowrel[1].isin([1,2]) & shallowrel[3].isin(['M2','S2']) & shallowrel[5].isin(['M2','S2',np.nan]) & shallowrel.index.isin(const_list_year)
shallowdeps_M2S2 = shallowrel.loc[bool_M2S2only,:5]
print(shallowdeps_M2S2)
"""
components_sn = ['A0','SM','3MS2','MU2','M2','S2','2SM2','3MS4','M4','MS4','4MS6','M6','2MS6','M8','3MS8','M10','4MS10','M12','5MS12']

Expand Down
1 change: 0 additions & 1 deletion kenmerkendewaarden/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ def format_timedelta_ticks(x, pos, n_decimals: int) -> str:
def __call__(self, x, pos: int = 0) -> str:
(vmin, vmax) = tuple(self.axis.get_view_interval())
n_decimals = min(int(np.ceil(np.log10(100 * 10**9 / abs(vmax - vmin)))), 9)
# print(x, pos, n_decimals)
return self.format_timedelta_ticks(x, pos, n_decimals)
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pandas as pd
import kenmerkendewaarden as kw
import logging
logging.basicConfig(format='%(message)s')
logging.getLogger("kenmerkendewaarden").setLevel(level="INFO")

dir_tests = os.path.dirname(__file__) #F9 doesnt work, only F5 (F5 also only method to reload external definition scripts)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def test_derive_statistics(dir_meas, extremes):
@pytest.mark.timeout(120) # useful in case of ddl failure
@pytest.mark.unittest
@pytest.mark.parametrize("extremes", [False,True], ids=["timeseries", "extremes"])
def test_df_amount_pcolormesh(dir_meas_amount, extremes):
def test_plot_measurements_amount(dir_meas_amount, extremes):
df_amount = kw.read_measurements_amount(dir_output=dir_meas_amount, extremes=extremes)
kw.df_amount_pcolormesh(df=df_amount, relative=True)
kw.plot_measurements_amount(df=df_amount, relative=True)


@pytest.mark.unittest
Expand Down

0 comments on commit 331a9a1

Please sign in to comment.