-
Notifications
You must be signed in to change notification settings - Fork 6
Release 0.11.2 #544
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
Merged
Merged
Release 0.11.2 #544
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0f0062c
Update version.py
rubencalje e36951d
Fix error in nlmod.lake.clip_meteorological_data_from_ds
rubencalje 03d0dcc
Fix tests for pandas 3.0 (#538)
rubencalje 9b7a1d1
Update to flopy version 3.10.0
OnnoEbbens 81c1a1f
update to flopy 3.10.0
OnnoEbbens e828b70
from cellids to cellid
OnnoEbbens c31df50
Revert "from cellids to cellid"
OnnoEbbens 118ccf2
remove cellids
OnnoEbbens 78c3488
Merge branch 'dev' into flopy-3.10.0
OnnoEbbens 56bfbd4
ruff
OnnoEbbens e0c0e1d
Fix broken test by skipping `HTTPError` in `test_gwo()`
rubencalje 978dfd3
Merge pull request #539 from gwmod/flopy-3.10.0
dbrakenhoff 471edf5
better error handling for downloading bofek
OnnoEbbens 89e5f18
Fix minor issue in grid.py after PR #539
rubencalje badaeea
Update flopy version (see issue #542)
rubencalje ce25309
remove colorama dependency (#543)
OnnoEbbens 59a5269
Fix notebook errors
rubencalje f78e82b
set coordinate_check_method to None
rubencalje f7e0d8e
Update version.py
rubencalje f26cb39
make sure to index with integer and not with a Series
OnnoEbbens 77f6ae6
Merge branch 'dev' of github.com:gwmod/nlmod into dev
OnnoEbbens 0ec26fc
Update some docstrings
rubencalje 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # %% | ||
| import os | ||
| import geopandas as gpd | ||
| from shapely.geometry import Polygon, MultiPolygon | ||
| from matplotlib.textpath import TextPath | ||
| from matplotlib.font_manager import FontProperties | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| import nlmod | ||
| import numpy as np | ||
|
|
||
|
|
||
| # %% | ||
| def string_to_gdf(text, font, size=500, x_offset=0, **kwargs): | ||
| tp = TextPath((x_offset, 0), text, size=size, prop=font) | ||
| polygons = [] | ||
|
|
||
| # Matplotlib returns list of polygons (outer + inner contours) | ||
| for poly in tp.to_polygons(): | ||
| if len(poly) >= 3: | ||
| polygons.append(Polygon(poly)) | ||
|
|
||
| # if a polygon has holes, we need to reconstruct it | ||
| final_polygons = [] | ||
| used = [False] * len(polygons) | ||
| for i, outer in enumerate(polygons): | ||
| if used[i]: | ||
| continue | ||
| holes = [] | ||
| for j, inner in enumerate(polygons): | ||
| if i != j and not used[j]: | ||
| if outer.contains(inner): | ||
| holes.append(inner.exterior.coords) | ||
| used[j] = True | ||
| final_polygons.append(Polygon(outer.exterior.coords, holes)) | ||
| used[i] = True | ||
|
|
||
| gdf = gpd.GeoDataFrame(geometry=final_polygons, **kwargs) | ||
| return gdf | ||
|
|
||
|
|
||
| text = "NLMOD" | ||
| # font_path = "C:/Windows/Fonts/consola.ttf" # Adjust for your system | ||
| font_path = "C:/Windows/Fonts/cour.ttf" # Courier font | ||
| font = FontProperties(fname=font_path) | ||
| text_size = 100 # Larger size -> smoother curves | ||
|
|
||
| gdf = string_to_gdf(text, font, size=text_size) | ||
|
|
||
| if False: | ||
| gdf.plot() | ||
| plt.axis("equal") | ||
| plt.show() | ||
|
|
||
| dx = 10 | ||
| extent = gdf.total_bounds[[0, 2, 1, 3]] | ||
|
|
||
| # add a buffer of 10 % of width | ||
| buffer = 0.1 * (extent[1] - extent[0]) | ||
| extent = np.array( | ||
| [ | ||
| extent[0] - buffer, | ||
| extent[1] + buffer, | ||
| extent[2] - buffer, | ||
| extent[3] + buffer, | ||
| ] | ||
| ) | ||
| if False: | ||
| # make sure vertical extent is at least half of the horizontal extent | ||
| height = extent[3] - extent[2] | ||
| width = extent[1] - extent[0] | ||
| center_y = 0.5 * (extent[2] + extent[3]) | ||
| if height < 0.5 * width: | ||
| height = 0.5 * width | ||
| extent = np.array( | ||
| [ | ||
| extent[0], | ||
| extent[1], | ||
| center_y - 0.5 * height, | ||
| center_y + 0.5 * height, | ||
| ] | ||
| ) | ||
|
|
||
| extent = (extent / dx).round() * dx | ||
| ds = nlmod.get_ds(extent, dx) | ||
| ds = nlmod.grid.refine(ds, "logo", [(gdf, 2)]) | ||
|
|
||
| nlmod.plot.modelgrid(ds) | ||
|
|
||
| # %% plot the logo | ||
| # add 1 percent margin | ||
| margin = 0.01 * (extent[1] - extent[0]) | ||
| extent = ( | ||
| extent[0] - margin, | ||
| extent[1] + margin, | ||
| extent[2] - margin, | ||
| extent[3] + margin, | ||
| ) | ||
| figwidth = 5 | ||
| figheight = figwidth * (extent[3] - extent[2]) / (extent[1] - extent[0]) | ||
| f = plt.figure(figsize=(figwidth, figheight)) | ||
| ax = f.add_axes([0, 0, 1, 1]) | ||
| ax.axis("equal") | ||
| ax.axis(extent) | ||
| color = "k" | ||
| nlmod.plot.modelgrid(ds, color=color, ax=ax, linewidth=0.5, clip_on=False, antialiased=False) | ||
|
|
||
| ax.set_xlabel("") | ||
| ax.set_ylabel("") | ||
| ax.set_title("") | ||
| ax.axis("off") | ||
|
|
||
| # %% save logo | ||
| fname = f"logo_text" | ||
| dpi = 300 | ||
| if figwidth != 5: | ||
| fname = f"{fname}_{figwidth}" | ||
| dpi = None | ||
| f.savefig(os.path.join("_static", f"{fname}.png"), dpi=dpi) | ||
| f.savefig(os.path.join("_static", f"{fname}.svg")) | ||
|
|
||
| # %% |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.