Skip to content

Commit 77f6ae6

Browse files
committed
Merge branch 'dev' of github.com:gwmod/nlmod into dev
2 parents f26cb39 + f7e0d8e commit 77f6ae6

File tree

8 files changed

+34
-29
lines changed

8 files changed

+34
-29
lines changed

docs/advanced_stress_packages/01_lake.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"mask = lak_grid.area > 0.5 * ds[\"area\"].sel(icell2d=lak_grid.index)\n",
182182
"lak_grid = lak_grid[mask]\n",
183183
"# set the geometry to the entire cell\n",
184-
"gi = flopy.utils.GridIntersect(nlmod.grid.modelgrid_from_ds(ds), method=\"vertex\")\n",
184+
"gi = flopy.utils.GridIntersect(nlmod.grid.modelgrid_from_ds(ds))\n",
185185
"lak_grid.geometry = gi.geoms[lak_grid.index]\n",
186186
"\n",
187187
"# remove drains that overlap with the lake\n",

docs/getting_started.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ On top of that there are some optional dependecies:
111111
- scikit-image (used in nlmod.read.rws.calculate_sea_coverage)
112112
- py7zr (used in nlmod.read.bofek.download_bofek_gdf)
113113
- joblib (used in nlmod.cache)
114-
- colorama (used in nlmod.util.get_color_logger)
115114
- tqdm (used for showing progress in long-running methods)
116115
- hydropandas (used in nlmod.read.knmi and nlmod.read.bro)
117116
- owslib (used in nlmod.read.ahn.get_latest_ahn_from_wcs)

nlmod/dims/grid.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,12 +1347,12 @@ def polygon_to_area(modelgrid, polygon, da, gridtype="structured"):
13471347
df = ix.intersect(polygon, geo_dataframe=True)
13481348

13491349
if gridtype == "structured":
1350-
area_array = util.get_da_from_da_ds(da, dims=("y", "x"), data=0)
1350+
area_array = util.get_da_from_da_ds(da, dims=("y", "x"), data=0.0)
13511351
for row, col, area in zip(df["row"], df["col"], df["areas"]):
13521352
area_array[row, col] = area
13531353
elif gridtype == "vertex":
1354-
area_array = util.get_da_from_da_ds(da, dims=("icell2d",), data=0)
1355-
area_array[df["cellid"]] = df["areas"]
1354+
area_array = util.get_da_from_da_ds(da, dims=("icell2d",), data=0.0)
1355+
area_array[df["cellid"].values] = df["areas"]
13561356

13571357
return area_array
13581358

@@ -2443,6 +2443,22 @@ def get_extent_polygon(ds, rotated=True):
24432443

24442444

24452445
def get_extent_gdf(ds, rotated=True, crs="EPSG:28992"):
2446+
"""Get the model extent as a GeoDataFrame with a polygon.
2447+
2448+
Parameters
2449+
----------
2450+
ds : xr.Dataset
2451+
model dataset.
2452+
rotated : bool, optional
2453+
if True, the extent is corrected for angrot. The default is True.
2454+
crs : str, optional
2455+
Coordinate reference system. The default is "EPSG:28992".
2456+
2457+
Returns
2458+
-------
2459+
gdf : geopandas.GeoDataFrame
2460+
GeoDataFrame containing the model extent as a polygon geometry.
2461+
"""
24462462
polygon = get_extent_polygon(ds, rotated=rotated)
24472463
return gpd.GeoDataFrame(geometry=[polygon], crs=crs)
24482464

nlmod/dims/time.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def set_ds_time_numeric(
394394

395395

396396
def set_time_variables(ds, start, time, steady, steady_start, time_units, nstp, tsmult):
397-
"""Add data variables: steady, nstp and tsmult, set attributes: start, time_units
397+
"""Add data variables: steady, nstp and tsmult, set attributes: start, time_units.
398398
399399
Parameters
400400
----------

nlmod/prt/prt.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ def prp(ds, prt, packagedata, perioddata, pname="prp", **kwargs):
144144
"""
145145
logger.info("creating mf6 PRP")
146146
prp_track_file = kwargs.pop("prp_track_file", f"{ds.model_name}.prp.trk")
147+
# the default value in flopy for coordinate_check_method of 'eager' gives an error
148+
# in MODFLOW verion 6.6.3
147149
prp = fp.mf6.ModflowPrtprp(
148150
prt,
149151
pname=pname,
@@ -156,6 +158,7 @@ def prp(ds, prt, packagedata, perioddata, pname="prp", **kwargs):
156158
boundnames=kwargs.pop("boundnames", False),
157159
exit_solve_tolerance=kwargs.pop("exit_solve_tolerance", 1e-5),
158160
extend_tracking=kwargs.pop("extend_tracking", True),
161+
coordinate_check_method=kwargs.pop("coordinate_check_method", None),
159162
**kwargs,
160163
)
161164
return prp

nlmod/util.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -878,13 +878,7 @@ def __init__(
878878
def format(self, record) -> str:
879879
"""Format the specified record as text."""
880880
record.color = self.colors.get(record.levelname, "")
881-
try:
882-
from colorama import Style
883-
884-
record.reset = Style.RESET_ALL
885-
886-
except ImportError:
887-
record.reset = ""
881+
record.reset = "\x1b[0m"
888882

889883
return super().format(record)
890884

@@ -907,19 +901,13 @@ def get_color_logger(level="INFO", logger_name=None):
907901
else:
908902
FORMAT = "{color}{levelname}:{name}.{funcName}:{message}{reset}"
909903

910-
try:
911-
from colorama import Back, Fore, Style
912-
913-
colors = {
914-
"DEBUG": Fore.CYAN,
915-
"INFO": Fore.GREEN,
916-
"WARNING": Fore.YELLOW,
917-
"ERROR": Fore.RED,
918-
"CRITICAL": Fore.RED + Back.WHITE + Style.BRIGHT,
919-
}
920-
except ImportError:
921-
logger.warning("colorama package not found, colored logging is disabled.")
922-
colors = {}
904+
colors = {
905+
"DEBUG": "\x1b[36m",
906+
"INFO": "\x1b[32m",
907+
"WARNING": "\x1b[33m",
908+
"ERROR": "\x1b[31m",
909+
"CRITICAL": "\x1b[31m" + "\x1b[47m" + "\x1b[1m",
910+
}
923911

924912
formatter = ColoredFormatter(
925913
FORMAT,

nlmod/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from importlib import metadata
22
from platform import python_version
33

4-
__version__ = "0.11.2dev"
4+
__version__ = "0.11.2"
55

66

77
def show_versions() -> None:

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ maintainers = [
2020
]
2121
requires-python = ">= 3.10"
2222
dependencies = [
23-
"flopy>=3.3.6",
23+
"flopy>=3.10.0",
2424
"xarray>=0.16.1",
2525
"netcdf4>=1.7.2",
2626
"rasterio>=1.1.0",
@@ -63,7 +63,6 @@ full = [
6363
"scikit-image",
6464
"py7zr",
6565
"joblib",
66-
"colorama",
6766
"tqdm",
6867
"hydropandas>=0.9.2",
6968
"owslib>=0.24.1",

0 commit comments

Comments
 (0)