Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hec-dss-python"
version = "0.1.22"
version = "0.1.23"
description = "Python wrapper for the HEC-DSS file database C library."
authors = ["Hydrologic Engineering Center"]
license = "MIT"
Expand Down
9 changes: 8 additions & 1 deletion src/hecdss/hecdss.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ def _get_paired_data(self, pathname):
pd.ordinates = np.array(doubleOrdinates)

n = numberCurves2[0].value
ordinateCount = len(doubleOrdinates)
if n > 1:
# ---------------------------------------------------------------------------------------- #
# rearrange from consecutive values for each curve to consecutive curves for each ordinate #
# ---------------------------------------------------------------------------------------- #
groups = [doubleValues[i*ordinateCount:(i+1)*ordinateCount] for i in range(n)]
doubleValues = list(map(list, zip(*groups)))
pd.values = np.array(doubleValues).reshape((len(doubleOrdinates), n))
# pd.values = [doubleValues[i:i+n] for i in range(0, len(doubleValues), n)]
pd.labels = labels
Expand Down Expand Up @@ -515,7 +522,7 @@ def _get_location_info(self, pathname: str):
)

if status != 0:
print("Function call failed with result:", status)
# print("Function call failed with result:", status)
return None

location_info = LocationInfo.create(
Expand Down
16 changes: 12 additions & 4 deletions src/hecdss/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,22 @@ def hec_dss_pdStore(
c_char_p, # timeZoneName (const char*) - New argument
]

numberCurves = len(pd.values[0])
if numberCurves > 1:
_values = pd.values.tolist()
if len(_values[0]) > 1:
_values = [[_values[i][j] for i in range(len(_values))] for j in range(len(_values[0]))]
values2 = np.array(_values)
else:
values2 = pd.values
c_pathname = c_char_p(pd.id.encode("utf-8"))
c_Ordinates = (c_double * len(pd.ordinates))(*pd.ordinates)
c_OrdinatesLength = len(pd.ordinates)
flat_list = pd.values.flatten()
flat_list = values2.flatten()
c_Values = (c_double * len(flat_list))(*flat_list)
c_ValuesLength = len(flat_list)
c_numberOrdinates = len(pd.ordinates)
c_numberCurves = len(pd.values[0])
c_numberCurves = numberCurves
c_unitsIndependent = c_char_p(pd.units_independent.encode("utf-8"))
c_typeIndependent = c_char_p(pd.type_independent.encode("utf-8"))
c_unitsDependent = c_char_p(pd.units_dependent.encode("utf-8"))
Expand Down Expand Up @@ -1094,8 +1102,8 @@ def hec_dss_locationRetrieve(self, fullPath: str, x: List[float], y: List[float]
verticalDatum[0] = c_verticalDatum.value
timeZoneName[0] = c_timeZoneName.value.decode("utf-8")
supplemental[0] = c_supplemental.value.decode("utf-8")
else:
print("Unable to read location information, Function call failed with result:", result)
# else:
# print("Unable to read location information, Function call failed with result:", result)

return result

Expand Down