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
15 changes: 11 additions & 4 deletions avaframe/com1DFA/DFAtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,17 @@ def normalize(x, y, z):
z component of the normalized vector
"""
norme = norm(x, y, z)
ind = np.where(norme > 0)
x[ind] = x[ind] / norme[ind]
y[ind] = y[ind] / norme[ind]
z[ind] = z[ind] / norme[ind]
# elementwise division by norme
Comment thread
fso42 marked this conversation as resolved.
factor = np.divide(
1.0,
norme,
out=np.zeros_like(norme, dtype=float),
where=norme > 0,
)

x = x * factor
y = y * factor
z = z * factor

return x, y, z

Expand Down
6 changes: 4 additions & 2 deletions avaframe/in1Data/getInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def getAndCheckInputFiles(inputDir, folder, inputType, fileExt="shp", fileSuffix
inputType : str
type of input (used for the logging messages).
fileExt: str, list
file extension e.g. shp, asc, tif - optional; default is shp
file extension e.g. shp, asc, tif, csv - optional; default is shp
fileSuffix: str
file name part before extension

Expand All @@ -365,10 +365,12 @@ def getAndCheckInputFiles(inputDir, folder, inputType, fileExt="shp", fileSuffix
path to file checked
available: str
Yes or No depending on if there is a file available (if No, OutputFile is None)
fileTypeFormat: str
file type format
"""
available = "No"

supportedFileFormats = [".shp", ".asc", ".tif"]
supportedFileFormats = [".shp", ".asc", ".tif", ".csv"]
Comment thread
fso42 marked this conversation as resolved.

# Define the directory to search and the extensions
if fileExt == "":
Expand Down
20 changes: 17 additions & 3 deletions avaframe/tests/test_com1DFA.py
Original file line number Diff line number Diff line change
Expand Up @@ -3313,10 +3313,24 @@ def test_adaptDEM():
demAdapted, fieldsAdapted = com1DFA.adaptDEM(demInput, fieldsInput, cfg["GENERAL"])

for key in demAdapted.keys():
assert np.all(demAdapted[key] == dem[key])
if isinstance(demAdapted[key], np.ndarray):
assert np.allclose(
demAdapted[key],
dem[key],
equal_nan=True,
)
else:
assert np.all(demAdapted[key] == dem[key])
for key in fieldsAdapted.keys():
assert np.all(fieldsAdapted[key] == fields[key])

if isinstance(fieldsAdapted[key], np.ndarray):
assert np.allclose(
fieldsAdapted[key],
fields[key],
equal_nan=True,
)
else:
assert np.all(fieldsAdapted[key] == fields[key])

fields["FTEnt"] = np.zeros_like(fields["FTDet"])
fields["FTDet"] = np.array(
[
Expand Down
Loading