TLDR: if care about SpatialReference or the way Flopy handles importing, exporting and plotting of geographic information, please comment and provide input! Specifically, input on the purpose and design paradigms of SpatialReference, or any alternative implementations that would better address the issues below if you don't agree with what's proposed.
@langevin-usgs and @jdhughes-usgs have tasked @spaulins-usgs, @jlarsen-usgs and me with refactoring flopy's plotting, export and spatial reference capabilities so that they behave consistently between the MODFLOW-6 and pre-MODFLOW-6 classes, and are also unified/extended to handle unstructured grids. So far, development towards those goals has centered around a generic ModelGrid class, with subclasses for unstructured and structured grids. The ModelGrid family of classes are supposed to provide information about the model grid that is independent of the MODFLOW version or grid input specification (e.g., the cells of any grid can be described by exterior vertices).
One key issue related to both export and plotting is how transformations are handled between model computational coordinates and geographic or "real-world" coordinates. Currently, this functionality is performed for structured grids by the SpatialReference class. The notebook example referenced below provides a brief rundown of the core-functionality and motivation behind SpatialReference. While @jtwhite79 and I (and perhaps others) have found SR to be very useful for pre- and post-processing models, there have also been a number of criticisms including:
- too many attributes
- attribute names are confusing; not clear which ones contain model coordinates vs. geographic coordinates
- no one knows how to use it
- too specific to structured grids
- methods such as
export_array() should be in the export module instead
One proposed approach (that is somewhat implemented on the main branch tip for this effort) is to move much of SR's functionality into the ModelGrid class, and have SR only perform transformations. Some problems with this approach are that it doesn't clear up the attribute name confusion, requires more user input (instantiation of both SR class and ModelGrid classes for stand-alone functionality), and it is not backwards-compatible.
Another approach is demonstrated in this Notebook, which also attempts to articulate the main ideas behind SpatialReference. In this revision, the new ModelGrid class stores coordinate information in the model computational coordinates, and SpatialReference transforms and stores the same key attributes in geographic coordinates. Separating the model and geographic coordinate information into two classes with the same attribute interface will hopefully alleviate some of the attribute name confusion.
Note that in response to criticism of attribute names, I am proposing some name changes (which may or may not be helpful):
| old name |
new name |
what it is |
| xcentergrid |
xcenters |
array of x-coordinates for model cell centers |
| ycentergrid |
ycenters |
array of y-coordinates for model cell centers |
| xgrid |
xedges |
array of x-coordinates for model cell corners |
| ygrid |
yedges |
array of y-coordinates for model cell corners |
| get_gridlines() |
gridlines |
list of tuple sequences that describe cell edges (for plotting) |
If we were to change any names, I think at least a 1 release deprecation warning (similar to other python packages) would be the best way to go.
As shown in the above notebook, I am also proposing that we retain export functionality in SR (such as export_array), and even expand SR to including methods for sampling geographic information to the model grid.
Please comment if you have an opinion.
@mwtoews, @mnfienen.
TLDR: if care about
SpatialReferenceor the wayFlopyhandles importing, exporting and plotting of geographic information, please comment and provide input! Specifically, input on the purpose and design paradigms ofSpatialReference, or any alternative implementations that would better address the issues below if you don't agree with what's proposed.@langevin-usgs and @jdhughes-usgs have tasked @spaulins-usgs, @jlarsen-usgs and me with refactoring flopy's plotting, export and spatial reference capabilities so that they behave consistently between the MODFLOW-6 and pre-MODFLOW-6 classes, and are also unified/extended to handle unstructured grids. So far, development towards those goals has centered around a generic
ModelGridclass, with subclasses for unstructured and structured grids. TheModelGridfamily of classes are supposed to provide information about the model grid that is independent of the MODFLOW version or grid input specification (e.g., the cells of any grid can be described by exterior vertices).One key issue related to both export and plotting is how transformations are handled between model computational coordinates and geographic or "real-world" coordinates. Currently, this functionality is performed for structured grids by the
SpatialReferenceclass. The notebook example referenced below provides a brief rundown of the core-functionality and motivation behindSpatialReference.While @jtwhite79 and I (and perhaps others) have found SR to be very useful for pre- and post-processing models, there have also been a number of criticisms including:export_array()should be in the export module insteadOne proposed approach (that is somewhat implemented on the main branch tip for this effort) is to move much of SR's functionality into the
ModelGridclass, and have SR only perform transformations. Some problems with this approach are that it doesn't clear up the attribute name confusion, requires more user input (instantiation of both SR class andModelGridclasses for stand-alone functionality), and it is not backwards-compatible.Another approach is demonstrated in this Notebook, which also attempts to articulate the main ideas behind
SpatialReference. In this revision, the newModelGridclass stores coordinate information in the model computational coordinates, andSpatialReferencetransforms and stores the same key attributes in geographic coordinates. Separating the model and geographic coordinate information into two classes with the same attribute interface will hopefully alleviate some of the attribute name confusion.Note that in response to criticism of attribute names, I am proposing some name changes (which may or may not be helpful):
If we were to change any names, I think at least a 1 release deprecation warning (similar to other python packages) would be the best way to go.
As shown in the above notebook, I am also proposing that we retain export functionality in SR (such as
export_array), and even expand SR to including methods for sampling geographic information to the model grid.Please comment if you have an opinion.
@mwtoews, @mnfienen.