Skip to content
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

Methods and tests for setting stream bed elevations #27

Merged
merged 19 commits into from
Aug 27, 2021
Merged

Conversation

briochh
Copy link
Collaborator

@briochh briochh commented Jul 15, 2021

For sane stream reaches set downstream and within model top layer

briochh and others added 17 commits June 8, 2021 17:37
Minor updates to tests after refactoring
Mods and bugfixes also after refactoring
Quick improvements to plotting feedback for stream elev and model top
stuff
TODO:
* Consider  makeing more use of segment division to allow info at
   segment level to propagate better, this is closer to the prvious approach..
* Add support for user explicitly setting desired elevations of
   reaches/segments, e.g. max elevations etc.
   (And propagate through segment elevation changes to reach definitions.)
* Consider using method the moves upstream (from outflow)
   -- may resolve tendancy for auto incision to increase downstream
   (more physical for incision to decrease downstream (generally?))
* Obvs DOCS! (notebook anyone?)
- Use new functions in tests rather than deprecated ones
- Show DeprecationWarning messages too (perhaps a bit much?)
* proper setting of updated botm using mf6.data.set_data()
* remove comment
* little bug fix in botm adjustment
- Fix docstring for plot_profile
- Add draw_lines parameter for plot_reaches_vs_model
Copy link
Owner

@mwtoews mwtoews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@briochh I've left a few comments to discuss and co-ordinate.

"""
if segbyseg:
raise NotImplementedError
self._segbyseg_elevs(minslope, fix_dis, minthick)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should SwnMf6._segbyseg_elevs (currently at L628) be included? It's not used/tested, and will obviously not work, as this structure does not have segment_data (which is exclusive to SwnModflow). We can remove it for the final merge, but keep the code in this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think conceptually it could still be an option. We still have segments. The reach by reach elevation corrections are necessarily (loosely) "pinned". The idea was that if line segment tops and bottoms were available we would try to use these to constrain the reach elevations. Without this we only use the upstream and downstream elevations off each line path. I'm happy for it to stay in as it might be something that we want to implement and the bones of the code that is there could hep with that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, we'll merge it to main, but raise NotImplementedError

@@ -1182,3 +1193,155 @@ def firstpt(g):
ax=ax, label="diversion", marker="D", color="red")

return ax

# __________________ SOME ELEVATION METHODS_________________________
def add_model_topbot_to_reaches(self, m=None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why m should be a variable here? Preferably there is only one model from the self.model property. I realise this is a renamed function where m was available, but could it be removed in this function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, something of a legacy. If self.model will always exist. Then can be dropped. Same probs goes for

def set_topbot_elevs_at_reaches(self, m=None):
and the call to this function in there...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've removed the parameter, which will raise a TypeError if it's supplied.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probs just had it so that my own codes didn't break but shouldn't be too hard to update!

swn/modflow/_swnmf6.py Show resolved Hide resolved
layerbots[k + 1] = layerbots[k] - laythick
self.model.dis.botm.set_data(layerbots)

def _reachbyreach_elevs(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a considerable amount of code overlap between SwnMf6._reachbyreach_elevs and SwnModflow.fix_reach_elevs. Should some of this logic be moved somewhere to SwnModflowBase, where reaches is common? It might need to go into a private _-prefixed function, as the parameters are different.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, a lot of similarities. However, subtle but critical differences. This method in SwnMf6 is essentially a re-write of SwnModflow.fix_reach_elevs but changed to loop over line path rather than segments. There is overlap for sure but the actual functions differ, there is a danger that the method becomes very fragmented if we try and pull out common elements into an abstract base.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll postpone this task for later.

layerbots[k + 1] = layerbots[k] - laythick
self.model.dis.botm.set_data(layerbots)

def _to_rno_elevs(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is any testing coverage here. Is it possible to add/modify a test to get this method tested?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postpone for now, but I'd be nice to have coverage at some point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wkitlasten may be able to put a test together for this... maybe a renaming would help clarify the method too?

@briochh
Copy link
Collaborator Author

briochh commented Aug 27, 2021

@mwtoews I wonder if we could get the logger messages to print to a designated log file? They can be useful to check that thing aren't going silly.

* Remove "m" (model) parameter from:
 - SwnModflowBase.add_model_topbot_to_reaches
 - SwmModflow.get_top_elevs_at_segs
 - SwmModflow.set_topbot_elevs_at_reaches

* Raise NotImplementedError for:
 - SwnMf6.fix_reach_elevs(segbyseg=True)
 - SwnMf6._segbyseg_elevs

Also, improve a few more docstrings
@mwtoews
Copy link
Owner

mwtoews commented Aug 27, 2021

According to the logger module docs for Logging to a file, it should be a matter of:

import logging
logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG)

this seems to work? There probably is a better way, but the logger module is dense to look at.

Otherwise, this can be toggled:

import swn.logger
swn.logger.module_logger.setLevel("DEBUG")

(these only take effect for new objects)

@mwtoews mwtoews merged commit 96ff3a9 into main Aug 27, 2021
@mwtoews mwtoews added this to the 0.4 milestone Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants