Skip to content

Commit 861616e

Browse files
committed
the order is salinity then temperature in the tim file
1 parent a074a44 commit 861616e

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

hydrolib/tools/ext_old_to_new/converters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ def parse_tim_model(
292292
The order of the quantities in the tim file should be as follows:
293293
- time
294294
- discharge
295-
- temperaturedelta (optional)
296295
- salinitydelta (optional)
296+
- temperaturedelta (optional)
297297
- initialtracer-anyname (optional)
298298
- any other quantities from the external forcings file.
299299
@@ -340,8 +340,8 @@ def parse_tim_model(
340340
>>> print(time_series)
341341
{
342342
"discharge": [1.0, 1.0, 1.0, 1.0, 1.0],
343-
"temperaturedelta": [2.0, 2.0, 2.0, 2.0, 2.0],
344-
"salinitydelta": [3.0, 3.0, 3.0, 3.0, 3.0],
343+
"salinitydelta": [2.0, 2.0, 2.0, 2.0, 2.0],
344+
"temperaturedelta": [3.0, 3.0, 3.0, 3.0, 3.0],
345345
"initialtracer-anyname": [4.0, 4.0, 4.0, 4.0, 4.0],
346346
}
347347

hydrolib/tools/ext_old_to_new/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ def find_temperature_salinity_in_quantities(strings: List[str]) -> Dict[str, int
241241
strings (List[str]): A list of strings to search.
242242
243243
Returns:
244-
Dict[str, int]: A dictionary with keys as "temperature" or "salinity"
244+
Dict[str, int]: A dictionary with keys as "salinity" or "temperature"
245245
and values 3 and 4 respectively.
246246
247247
Examples:
248248
>>> find_temperature_salinity_in_quantities(["temperature", "Salinity"])
249-
OrderedDict({"temperaturedelta": 3, "salinitydelta": 4})
249+
OrderedDict({"salinitydelta": 3, "temperaturedelta": 4})
250250
251251
>>> find_temperature_salinity_in_quantities(["Temperature"])
252252
OrderedDict({"temperaturedelta": 3})
@@ -262,11 +262,11 @@ def find_temperature_salinity_in_quantities(strings: List[str]) -> Dict[str, int
262262
"""
263263
result = OrderedDict()
264264

265-
if any("temperature" in string.lower() for string in strings):
266-
result["temperaturedelta"] = 3
267265
if any("salinity" in string.lower() for string in strings):
268-
result["salinitydelta"] = (
269-
result.get("temperaturedelta", 2) + 1
266+
result["salinitydelta"] = 3
267+
if any("temperature" in string.lower() for string in strings):
268+
result["temperaturedelta"] = (
269+
result.get("salinitydelta", 2) + 1
270270
) # Default temperature value is 2
271271

272272
return result

tests/tools/test_converters_source_sink.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def test_default(self):
2525

2626
time_series_data = converter.parse_tim_model(tim_file, ext_file_quantity_list)
2727
assert time_series_data["discharge"] == [1.0, 1.0, 1.0, 1.0, 1.0]
28-
assert time_series_data["temperaturedelta"] == [2.0, 2.0, 2.0, 2.0, 2.0]
29-
assert time_series_data["salinitydelta"] == [3.0, 3.0, 3.0, 3.0, 3.0]
28+
assert time_series_data["salinitydelta"] == [2.0, 2.0, 2.0, 2.0, 2.0]
29+
assert time_series_data["temperaturedelta"] == [3.0, 3.0, 3.0, 3.0, 3.0]
3030
assert time_series_data["initialtracer_anyname"] == [4.0, 4.0, 4.0, 4.0, 4.0]
3131

3232
def test_list_of_ext_quantities_tim_column_mismatch(self):
@@ -171,8 +171,8 @@ def test_default(self):
171171
converter.root_dir = "tests/data/input/source-sink"
172172
new_quantity_block = converter.convert(forcing, ext_file_other_quantities)
173173
assert new_quantity_block.initialtracer_anyname == [4.0, 4.0, 4.0, 4.0, 4.0]
174-
assert new_quantity_block.salinitydelta == [3.0, 3.0, 3.0, 3.0, 3.0]
175-
assert new_quantity_block.temperaturedelta == [2.0, 2.0, 2.0, 2.0, 2.0]
174+
assert new_quantity_block.temperaturedelta == [3.0, 3.0, 3.0, 3.0, 3.0]
175+
assert new_quantity_block.salinitydelta == [2.0, 2.0, 2.0, 2.0, 2.0]
176176
assert new_quantity_block.discharge == [1.0, 1.0, 1.0, 1.0, 1.0]
177177
assert new_quantity_block.zsink == [-4.2]
178178
assert new_quantity_block.zsource == [-3]
@@ -230,8 +230,8 @@ def test_4_5_columns_polyline(self):
230230
with patch("pathlib.Path.with_suffix", return_value=tim_file):
231231
new_quantity_block = converter.convert(forcing, ext_file_other_quantities)
232232
assert new_quantity_block.initialtracer_anyname == [4.0, 4.0, 4.0, 4.0, 4.0]
233-
assert new_quantity_block.salinitydelta == [3.0, 3.0, 3.0, 3.0, 3.0]
234-
assert new_quantity_block.temperaturedelta == [2.0, 2.0, 2.0, 2.0, 2.0]
233+
assert new_quantity_block.temperaturedelta == [3.0, 3.0, 3.0, 3.0, 3.0]
234+
assert new_quantity_block.salinitydelta == [2.0, 2.0, 2.0, 2.0, 2.0]
235235
assert new_quantity_block.discharge == [1.0, 1.0, 1.0, 1.0, 1.0]
236236
assert new_quantity_block.zsink == [-4.2, -5.35]
237237
assert new_quantity_block.zsource == [-3, -2.90]

tests/tools/test_tools_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ def test_convert_interpolation_data():
4141
@pytest.mark.parametrize(
4242
"strings, expected",
4343
[
44-
(["temperature", "Salinity"], {"temperaturedelta": 3, "salinitydelta": 4}),
44+
(["temperature", "Salinity"], {"temperaturedelta": 4, "salinitydelta": 3}),
4545
(["Temperature"], {"temperaturedelta": 3}),
4646
(["Salinity"], {"salinitydelta": 3}),
4747
(["tracers"], {}),
48-
(["TEMPERATURE", "salInity"], {"temperaturedelta": 3, "salinitydelta": 4}),
48+
(["TEMPERATURE", "salInity"], {"temperaturedelta": 4, "salinitydelta": 3}),
4949
([], {}),
5050
(["No relevant data here.", "Nothing to match."], {}),
5151
],

0 commit comments

Comments
 (0)