Skip to content

Commit 27fd011

Browse files
committed
Renamed sanitize_mat function
1 parent b9318b2 commit 27fd011

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

PyStemmusScope/forcing_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def prepare_global_variables(data, input_path, config):
161161
matfiledata['Dur_tot'] = float(total_duration) # Matlab expects a 'double'
162162

163163
hdf5storage.savemat(input_path / "forcing_globals.mat", matfiledata, appendmat=False)
164-
utils.sanitize_mat_file(input_path / "forcing_globals.mat")
164+
utils.remove_dates_from_header(input_path / "forcing_globals.mat")
165165

166166

167167
def prepare_forcing(config):

PyStemmusScope/soil_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,4 @@ def prepare_soil_data(config):
227227
hdf5storage.savemat(
228228
Path(config["InputPath"]) / "soil_parameters.mat", mdict=matfiledata, appendmat=False,
229229
)
230-
utils.sanitize_mat_file(Path(config["InputPath"]) / "soil_parameters.mat")
230+
utils.remove_dates_from_header(Path(config["InputPath"]) / "soil_parameters.mat")

PyStemmusScope/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ def to_absolute_path(
6969
return pathlike.expanduser().resolve(strict=must_exist)
7070

7171

72-
def sanitize_mat_file(filename):
72+
def remove_dates_from_header(filename):
73+
"""Removes the datetime string from the .mat file header.
74+
75+
MATLAB raises an error when some characters are non-UTF-8 (?), e.g. Chinese month
76+
names. This function removes this part of the file header to avoid this problem.
77+
78+
Args:
79+
filename (Path): Valid path to the .mat file
80+
"""
7381
with open(filename, "rb") as f:
7482
data = f.read()
7583

0 commit comments

Comments
 (0)