Skip to content

Commit

Permalink
docs: use np.genfromtxt instead of recfromcsv
Browse files Browse the repository at this point in the history
Use np.genfromtxt instead of np.recfromcsv,
since the latter is deprecated.
  • Loading branch information
SGeeversAtVortech committed Nov 15, 2024
1 parent 3e17e54 commit 86cf76a
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 24 deletions.
8 changes: 6 additions & 2 deletions doc/examples/pyplots/basic_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

# Import Data
output_data_path = "../../../examples/basic/reference_output/timeseries_export.csv"
results = np.recfromcsv(output_data_path, encoding=None)
results = np.genfromtxt(
output_data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)
input_data_path = "../../../examples/basic/input/timeseries_import.csv"
input_data = np.recfromcsv(input_data_path, encoding=None)
input_data = np.genfromtxt(
input_data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in results["time"]]
Expand Down
4 changes: 3 additions & 1 deletion doc/examples/pyplots/cascading_channels_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

# Import Data
data_path = "../../../examples/cascading_channels/reference_output/timeseries_export.csv"
record = np.recfromcsv(data_path, encoding=None)
record = np.genfromtxt(
data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in record["time"]]
Expand Down
45 changes: 37 additions & 8 deletions doc/examples/pyplots/channel_pulse_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,46 @@
output_dir = Path("../../../examples/channel_pulse/reference_output/").resolve()

# Import Data
rtc_tools_record = np.recfromcsv(output_dir / "timeseries_export_inertial_wave.csv", encoding=None)
rtc_tools_semi_impl_record = np.recfromcsv(
output_dir / "timeseries_export_inertial_wave_semi_implicit.csv", encoding=None
rtc_tools_record = np.genfromtxt(
output_dir / "timeseries_export_inertial_wave.csv",
delimiter=",",
encoding=None,
dtype=None,
names=True,
case_sensitive="lower",
)
rtc_tools_conv_acc_record = np.recfromcsv(
output_dir / "timeseries_export_saint_venant.csv", encoding=None
rtc_tools_semi_impl_record = np.genfromtxt(
output_dir / "timeseries_export_inertial_wave_semi_implicit.csv",
delimiter=",",
encoding=None,
dtype=None,
names=True,
case_sensitive="lower",
)
rtc_tools_conv_acc_upwind_record = np.recfromcsv(
output_dir / "timeseries_export_saint_venant_upwind.csv", encoding=None
rtc_tools_conv_acc_record = np.genfromtxt(
output_dir / "timeseries_export_saint_venant.csv",
delimiter=",",
encoding=None,
dtype=None,
names=True,
case_sensitive="lower",
)
rtc_tools_conv_acc_upwind_record = np.genfromtxt(
output_dir / "timeseries_export_saint_venant_upwind.csv",
delimiter=",",
encoding=None,
dtype=None,
names=True,
case_sensitive="lower",
)
hec_ras_record = np.genfromtxt(
output_dir / "HEC-RAS_export.csv",
delimiter=",",
encoding=None,
dtype=None,
names=True,
case_sensitive="lower",
)
hec_ras_record = np.recfromcsv(output_dir / "HEC-RAS_export.csv", encoding=None)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in rtc_tools_record["time"]]
Expand Down
18 changes: 15 additions & 3 deletions doc/examples/pyplots/channel_wave_damping.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@

# Import Data
output_dir = Path("../../../examples/channel_wave_damping/reference_output/").resolve()
record_local_control = np.recfromcsv(
output_dir / "timeseries_export_local_control.csv", encoding=None
record_local_control = np.genfromtxt(
output_dir / "timeseries_export_local_control.csv",
delimiter=",",
encoding=None,
dtype=None,
names=True,
case_sensitive="lower",
)
record_optimization = np.genfromtxt(
output_dir / "timeseries_export.csv",
delimiter=",",
encoding=None,
dtype=None,
names=True,
case_sensitive="lower",
)
record_optimization = np.recfromcsv(output_dir / "timeseries_export.csv", encoding=None)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in record_optimization["time"]]
Expand Down
4 changes: 3 additions & 1 deletion doc/examples/pyplots/ensemble_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
forcasts = {}
for forecast in forecast_names:
data_path = dir_template.format(forecast)
forcasts[forecast] = np.recfromcsv(data_path, encoding=None)
forcasts[forecast] = np.genfromtxt(
data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in forcasts[forecast_names[0]]["time"]]
Expand Down
4 changes: 3 additions & 1 deletion doc/examples/pyplots/goal_programming_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

# Import Data
data_path = "../../../examples/goal_programming/reference_output/timeseries_export.csv"
results = np.recfromcsv(data_path, encoding=None)
results = np.genfromtxt(
data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in results["time"]]
Expand Down
8 changes: 6 additions & 2 deletions doc/examples/pyplots/integrator_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
output_data_path = (
current_folder / "../../../examples/integrator_delay/output/timeseries_export.csv"
)
results = np.recfromcsv(output_data_path, encoding=None)
results = np.genfromtxt(
output_data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)
input_data_path = current_folder / "../../../examples/integrator_delay/input/timeseries_import.csv"
input_data = np.recfromcsv(input_data_path, encoding=None)
input_data = np.genfromtxt(
input_data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in results["time"]]
Expand Down
4 changes: 3 additions & 1 deletion doc/examples/pyplots/lookup_table_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

# Import Data
data_path = "../../../examples/lookup_table/reference_output/timeseries_export.csv"
results = np.recfromcsv(data_path, encoding=None)
results = np.genfromtxt(
data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in results["time"]]
Expand Down
4 changes: 3 additions & 1 deletion doc/examples/pyplots/mixed_integer_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

# Import Data
data_path = "../../../examples/mixed_integer/reference_output/timeseries_export.csv"
results = np.recfromcsv(data_path, encoding=None)
results = np.genfromtxt(
data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in results["time"]]
Expand Down
8 changes: 6 additions & 2 deletions doc/examples/pyplots/pumped_hydropower_system_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
# Import Data
data_path = "../../../examples/pumped_hydropower_system/reference_output/timeseries_export.csv"
import_data_path = "../../../examples/pumped_hydropower_system/input//timeseries_import.csv"
results = np.recfromcsv(data_path, encoding=None)
inputs = np.recfromcsv(import_data_path, encoding=None)
results = np.genfromtxt(
data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)
inputs = np.genfromtxt(
import_data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in results["time"]]
Expand Down
8 changes: 6 additions & 2 deletions doc/examples/pyplots/simulation_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

# Import Data
output_data_path = "../../../examples/simulation/reference_output/timeseries_export.csv"
results = np.recfromcsv(output_data_path, encoding=None)
results = np.genfromtxt(
output_data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)
input_data_path = "../../../examples/simulation/input/timeseries_import.csv"
input_data = np.recfromcsv(input_data_path, encoding=None)
input_data = np.genfromtxt(
input_data_path, delimiter=",", encoding=None, dtype=None, names=True, case_sensitive="lower"
)

# Get times as datetime objects
times = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in results["time"]]
Expand Down

0 comments on commit 86cf76a

Please sign in to comment.