-
Notifications
You must be signed in to change notification settings - Fork 6
MAW support for grouping wells #509
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
Changes from 5 commits
2a5f31e
703424f
e4b842b
71e08f5
71f69b4
7aad5da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -132,8 +132,11 @@ def maw_from_df( | |||||||||||||||
| botm="botm", | ||||||||||||||||
| Q="Q", | ||||||||||||||||
| rw="rw", | ||||||||||||||||
| radius_skin=None, | ||||||||||||||||
| hk_skin=None, | ||||||||||||||||
| condeqn="THIEM", | ||||||||||||||||
| strt=None, | ||||||||||||||||
| group=None, | ||||||||||||||||
| aux=None, | ||||||||||||||||
| boundnames=None, | ||||||||||||||||
| ds=None, | ||||||||||||||||
|
|
@@ -164,20 +167,38 @@ def maw_from_df( | |||||||||||||||
| The column in df that contains the volumetric well rate. This column can contain | ||||||||||||||||
| floats, or strings belonging to timeseries added later. A positive value | ||||||||||||||||
| indicates recharge (injection) and a negative value indicates discharge | ||||||||||||||||
| (extraction) The default is "Q". | ||||||||||||||||
| (extraction). If wells are grouped, the values refer to the rates of all the | ||||||||||||||||
| wells in the group combined and thus must be the same for all wells in the | ||||||||||||||||
| group. The default is "Q". | ||||||||||||||||
| rw : str, optional | ||||||||||||||||
| The column in df that contains the radius for the multi-aquifer well. The | ||||||||||||||||
| default is "rw". | ||||||||||||||||
| radius_skin : str, optional | ||||||||||||||||
| The column in df that contains the radius of the skin around the well; the | ||||||||||||||||
| distance between the center of the well and the outside of the filter pack. Is | ||||||||||||||||
| larger than `rw`. Only used if `condeqn` is SKIN, CUMULATIVE, or MEAN. The | ||||||||||||||||
| default is None, which means that the skin is not used. | ||||||||||||||||
| hk_skin : str, optional | ||||||||||||||||
| The column in df that contains the horizontal hydraulic conductivity of the skin | ||||||||||||||||
| around the well. Only used if `condeqn` is SKIN, CUMULATIVE, or MEAN. The default | ||||||||||||||||
| is None, which means that the skin is not used. | ||||||||||||||||
| condeqn : str, optional | ||||||||||||||||
| String that defines the conductance equation that is used to calculate the | ||||||||||||||||
| saturated conductance for the multi-aquifer well. The default is "THIEM". | ||||||||||||||||
| strt : float, optional | ||||||||||||||||
| The starting head for the multi-aquifer well. The default is None, which uses | ||||||||||||||||
| model surface level as the strt value. | ||||||||||||||||
| group : str, optional | ||||||||||||||||
| The column in df that contains the group name for the wells. If this is not | ||||||||||||||||
| None, wells with the same group name are grouped together such that the rate is | ||||||||||||||||
| divided over the wells in the group. Note that empty strings are treated as | ||||||||||||||||
| unique group names, so wells with an empty string in the group column are | ||||||||||||||||
| treated as a separate group. The default is None, which means that each well is | ||||||||||||||||
| treated as a separate well. | ||||||||||||||||
| aux : str of list of str, optional | ||||||||||||||||
| The column(s) in df that contain auxiliary variables. The default is None. | ||||||||||||||||
| boundnames : str, optional | ||||||||||||||||
| THe column in df thet . The default is None. | ||||||||||||||||
| The column in df that contains the boundary names. The default is None. | ||||||||||||||||
| ds : xarray.Dataset | ||||||||||||||||
| Dataset with model data. Needed to determine cellid when grid-rotation is used. | ||||||||||||||||
| The default is None. | ||||||||||||||||
|
|
@@ -199,74 +220,125 @@ def maw_from_df( | |||||||||||||||
| df = _add_cellid(df, ds=ds, gwf=gwf, x=x, y=y, silent=silent) | ||||||||||||||||
| multipliers = _get_layer_multiplier_for_wells(df, top, botm, ds=ds, gwf=gwf) | ||||||||||||||||
|
|
||||||||||||||||
| # configure groups | ||||||||||||||||
| if df.index.has_duplicates: | ||||||||||||||||
| raise ValueError( | ||||||||||||||||
| "The index of the DataFrame must be unique. Indexing `multipliers` would go" | ||||||||||||||||
|
||||||||||||||||
| "The index of the DataFrame must be unique. Indexing `multipliers` would go" | |
| "The index of the DataFrame must be unique. Indexing `multipliers` would go " |
Outdated
Copilot
AI
Aug 11, 2025
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.
The total parameter in tqdm should reflect the number of groups being processed, not the number of wells. When wells are grouped, there will be fewer iterations than len(df). This could cause the progress bar to be inaccurate.
| iw = 0 # grouped well index | |
| for well_group_name, well_group in tqdm( | |
| df.groupby(group_by), total=len(df), desc="Adding MAW wells", disable=silent | |
| n_groups = group_by.nunique() | |
| iw = 0 # grouped well index | |
| for well_group_name, well_group in tqdm( | |
| df.groupby(group_by), total=n_groups, desc="Adding MAW wells", disable=silent |
Outdated
Copilot
AI
Aug 11, 2025
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.
This check uses df.cellid but should use well_group['cellid'] to check the data type for the current group. Using the entire dataframe could give incorrect results when the group contains mixed data types.
| if pd.api.types.is_integer_dtype(df.cellid): | |
| if pd.api.types.is_integer_dtype(well_group["cellid"]): |
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.
There's a trailing space at the end of this line in the docstring.