-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Golnesa variable friction #346
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
08f136a
adding yz_coordinate
b9fdf4b
Added vegetation to loc and def, tests updated
322728f
Linters
f48fe07
Update shape in yz & unit test, fric/veg function
1d4ba2d
Clean up & bergemeer sql update
71caea3
comments
4061d13
test.yml
4a259bb
update no 'single' vegetation
572616b
bergemeer update + corrections
bf063ea
update docstrings + minor corrections + changelog
895ab2b
schema version update
224a37d
schema version update
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,12 @@ class CrossSectionDefinition: | |
shape: CrossSectionShape | ||
height: str # space-separated list of floats | ||
width: str # space-separated list of floats | ||
friction_values: str # space-separated list of floats | ||
vegetation_stem_densities: str # space-separated list of floats | ||
vegetation_stem_diameters: str # space-separated list of floats | ||
vegetation_heights: str # space-separated list of floats | ||
vegetation_drag_coefficients: str # space-separated list of floats | ||
|
||
|
||
|
||
class CrossSectionDefinitions(Array[CrossSectionDefinition]): | ||
|
@@ -43,36 +49,47 @@ def convert(self, ids): | |
content_pk=ids, | ||
code=self.code[idx], | ||
count=0, | ||
count_yz = 0, | ||
) | ||
if len(result) == 0: | ||
return result | ||
|
||
offset = 0 | ||
tables = [] | ||
tables_yz = [] | ||
|
||
|
||
# Numpy array views on width/height based on idx | ||
width_idx = self.width[idx] | ||
height_idx = self.height[idx] | ||
|
||
for i, shape in enumerate(self.shape[idx]): | ||
tabulator = tabulators[shape] | ||
result.shape[i], result.width_1d[i], result.height_1d[i], table = tabulator( | ||
result.shape[i], result.width_1d[i], result.height_1d[i], table, yz = tabulator( | ||
shape, width_idx[i], height_idx[i] | ||
) | ||
if table is not None: | ||
result.count[i] = len(table) | ||
result.offset[i] = offset | ||
daanvaningen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
offset += len(table) | ||
tables.append(table) | ||
if yz is not None: | ||
result.count_yz[i] = len(yz) | ||
tables_yz.append(yz) | ||
GolnesaK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
result.offset[:] = np.roll(np.cumsum(result.count), 1) | ||
result.offset[0] = 0 | ||
result.offset_yz[:] = np.roll(np.cumsum(result.count_yz), 1) | ||
result.offset_yz[0] = 0 | ||
|
||
if len(tables) > 0: | ||
result.tables = np.concatenate(tables, axis=0) | ||
else: | ||
result.tables = np.empty((0, 2)) | ||
|
||
if len(tables_yz) > 0: | ||
result.tables_yz = np.concatenate(tables_yz, axis=0) | ||
else: | ||
result.tables_yz = np.empty((0, 4)) | ||
|
||
return result | ||
|
||
|
||
|
@@ -85,11 +102,14 @@ class CrossSection: | |
height_1d: float | ||
offset: int | ||
count: int | ||
offset_yz: int | ||
count_yz: int | ||
# tables: Tuple[float, float] has different length so is specified on CrossSections | ||
|
||
|
||
class CrossSections(Array[CrossSection]): | ||
tables = None | ||
tables_yz = None | ||
|
||
|
||
def tabulate_builtin(shape, width, height): | ||
|
@@ -112,7 +132,7 @@ def tabulate_builtin(shape, width, height): | |
f"Unable to parse cross section definition width (got: '{width}')." | ||
) | ||
|
||
return shape, width, None, None | ||
return shape, width, None, None, None | ||
GolnesaK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def tabulate_egg(shape, width, height): | ||
|
@@ -151,17 +171,17 @@ def tabulate_egg(shape, width, height): | |
widths = np.sqrt(p / q) * 2 | ||
|
||
table = np.array([heights, widths]).T | ||
return CrossSectionShape.TABULATED_TRAPEZIUM, width, height, table | ||
return CrossSectionShape.TABULATED_TRAPEZIUM, width, height, table, None | ||
|
||
|
||
def tabulate_inverted_egg(shape, width, height): | ||
"""Tabulate the egg shape, upside down. | ||
|
||
See tabulate_egg. | ||
""" | ||
type_, width, height, table = tabulate_egg(shape, width, height) | ||
type_, width, height, table, yz = tabulate_egg(shape, width, height) | ||
GolnesaK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
table[:, 1] = table[::-1, 1] | ||
return type_, width, height, table | ||
return type_, width, height, table, None | ||
|
||
|
||
def tabulate_closed_rectangle(shape, width, height): | ||
|
@@ -185,7 +205,7 @@ def tabulate_closed_rectangle(shape, width, height): | |
f"(got: '{width}', '{height}')." | ||
) | ||
table = np.array([[0.0, width], [height, 0.0]], order="F") | ||
return CrossSectionShape.TABULATED_RECTANGLE, width, height, table | ||
return CrossSectionShape.TABULATED_RECTANGLE, width, height, table, None | ||
|
||
|
||
def _parse_tabulated(width, height): | ||
|
@@ -229,10 +249,10 @@ def tabulate_tabulated(shape, width, height): | |
f"(got: {height})." | ||
) | ||
|
||
return shape, np.max(widths), np.max(heights), np.array([heights, widths]).T | ||
return shape, np.max(widths), np.max(heights), np.array([heights, widths]).T, None | ||
|
||
|
||
def tabulate_yz(shape, width, height): | ||
def tabulate_yz(shape, width, height, friction_values, vegetation_stem_densities, vegetation_stem_diameters, vegetation_heights, vegetation_drag_coefficients): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This call signature doesn't match the other call signatures (at line 68 you did adjust the altered return value, but the new parameters aren't provided) I think it is good to leave the call signature as is and provide the additional vegentation coefs at a different moment. |
||
"""Tabulate an (open or closed) YZ profile | ||
|
||
Args: | ||
|
@@ -275,6 +295,19 @@ def tabulate_yz(shape, width, height): | |
if is_closed: | ||
ys = ys[:-1] | ||
zs = zs[:-1] | ||
yz = None | ||
else: | ||
yz = np.zeros((len(ys), 4), dtype=float) | ||
yz[:, 0] = ys | ||
yz[:, 1] = zs | ||
fric = np.array([float(x) for x in friction_values.split(" ")]) | ||
veg_stemden = np.array([float(x) for x in vegetation_stem_densities.split(" ")]) | ||
veg_stemdia = np.array([float(x) for x in vegetation_stem_diameters.split(" ")]) | ||
veg_hght = np.array([float(x) for x in vegetation_heights.split(" ")]) | ||
veg_drag = np.array([float(x) for x in vegetation_drag_coefficients.split(" ")]) | ||
yz[:-1, 2] = fric | ||
yz[:-1, 3] = veg_stemden * veg_stemdia * veg_hght * veg_drag | ||
|
||
|
||
# Adapt non-unique height coordinates. Why? | ||
# Because if a segment of the profile is exactly horizontal, we need 2 widths | ||
|
@@ -318,7 +351,7 @@ def tabulate_yz(shape, width, height): | |
table = table[1:] | ||
|
||
height_1d, width_1d = table.max(axis=0).tolist() | ||
return CrossSectionShape.TABULATED_TRAPEZIUM, width_1d, height_1d, table | ||
return CrossSectionShape.TABULATED_TRAPEZIUM, width_1d, height_1d, table, yz | ||
|
||
|
||
tabulators = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you run the
black
code formatter? There's apre-commit
configuration in this repo, so after you installed the pre-commit tool (https://pre-commit.com/), you have to dopre-commit install
inside the repository and thenpre-commit run all