Skip to content

Commit

Permalink
refactor(imports): add function to import optional packages
Browse files Browse the repository at this point in the history
matplotlib is now a FloPy requirement.
  • Loading branch information
jdhughes-usgs committed Oct 12, 2021
1 parent 76927da commit 99e6dac
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For general modeling issues, please consult a modeling forum, such as the [MODFL
Installation
-----------------------------------------------

FloPy requires **Python** 3.7 (or higher) and **NumPy** 1.15 (or higher). Dependencies for optional FloPy methods are summarized [here](docs/flopy_method_dependencies.md).
FloPy requires **Python** 3.7 (or higher), **NumPy** 1.15.0 (or higher), and **matplotlib** 1.4.0 (or higher). Dependencies for optional FloPy methods are summarized [here](docs/flopy_method_dependencies.md).

To install FloPy type:

Expand Down
34 changes: 15 additions & 19 deletions docs/flopy_method_dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@ Additional dependencies to use optional FloPy helper methods are listed below.

| Method | Python Package |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------ |
| `.PlotMapView()` in `flopy.plot` | **matplotlib** >= 1.4 |
| `.PlotCrossSection()` in `flopy.plot` | **matplotlib** >= 1.4 |
| `.plot()` | **matplotlib** >= 1.4 |
| `.plot_shapefile()` | **matplotlib** >= 1.4 and **Pyshp** >= 1.2 |
| `.to_shapefile()` | **Pyshp** >= 1.2 |
| `.export(*.shp)` | **Pyshp** >= 1.2 |
| `.export(*.nc)` | **netcdf4** >= 1.1, and **python-dateutil** >= 2.4 |
| `.plot_shapefile()` | **Pyshp** >= 2.0.0 |
| `.to_shapefile()` | **Pyshp** >= 2.0.0 |
| `.export(*.shp)` | **Pyshp** >= 2.0.0 |
| `.export(*.nc)` | **netcdf4** >= 1.1, and **python-dateutil** >= 2.4.0 |
| `.export(*.tif)` | **rasterio** |
| `.export(*.asc)` in `flopy.utils.reference` `SpatialReference` class | **scipy.ndimage** |
| `.interpolate()` in `flopy.utils.reference` `SpatialReference` class | **scipy.interpolate** |
| `.interpolate()` in `flopy.mf6.utils.reference` `StructuredSpatialReference` class | **scipy.interpolate** |
| `._parse_units_from_proj4()` in `flopy.utils.reference` `SpatialReference` class | **pyproj** |
| `.get_dataframes()` in `flopy.utils.mflistfile` `ListBudget` class | **pandas** >= 0.15 |
| `.get_dataframes()` in `flopy.utils.observationfile` `ObsFiles` class | **pandas** >= 0.15 |
| `.get_dataframes()` in `flopy.utils.sfroutputfile` `ModflowSfr2` class | **pandas** >= 0.15 |
| `.get_dataframes()` in `flopy.utils.util_list` `MfList` class | **pandas** >= 0.15 |
| `.get_dataframes()` in `flopy.utils.zonebud` `ZoneBudget` class | **pandas** >= 0.15 |
| `.pivot_keyarray()` in `flopy.mf6.utils.arrayutils` `AdvancedPackageUtil` class | **pandas** >= 0.15 |
| `._get_vertices()` in `flopy.mf6.utils.binaryfile_utils` `MFOutputRequester` class | **pandas** >= 0.15 |
| `.get_dataframe()` in `flopy.mf6.utils.mfobservation` `Observations` class | **pandas** >= 0.15 |
| `.df()` in `flopy.modflow.mfsfr2` `SfrFile` class | **pandas** >= 0.15 |
| `.time_coverage()` in `flopy.export.metadata` `acc` class - ***used if available*** | **pandas** >= 0.15 |
| `.loadtxt()` in `flopy.utils.flopyio` - ***used if available*** | **pandas** >= 0.15 |
| `.get_dataframes()` in `flopy.utils.mflistfile` `ListBudget` class | **pandas** >= 0.15.0 |
| `.get_dataframes()` in `flopy.utils.observationfile` `ObsFiles` class | **pandas** >= 0.15.0 |
| `.get_dataframes()` in `flopy.utils.sfroutputfile` `ModflowSfr2` class | **pandas** >= 0.15.0 |
| `.get_dataframes()` in `flopy.utils.util_list` `MfList` class | **pandas** >= 0.15.0 |
| `.get_dataframes()` in `flopy.utils.zonebud` `ZoneBudget` class | **pandas** >= 0.15.0 |
| `.pivot_keyarray()` in `flopy.mf6.utils.arrayutils` `AdvancedPackageUtil` class | **pandas** >= 0.15.0 |
| `._get_vertices()` in `flopy.mf6.utils.binaryfile_utils` `MFOutputRequester` class | **pandas** >= 0.15.0 |
| `.get_dataframe()` in `flopy.mf6.utils.mfobservation` `Observations` class | **pandas** >= 0.15.0 |
| `.df()` in `flopy.modflow.mfsfr2` `SfrFile` class | **pandas** >= 0.15.0 |
| `.time_coverage()` in `flopy.export.metadata` `acc` class - ***used if available*** | **pandas** >= 0.15.0 |
| `.loadtxt()` in `flopy.utils.flopyio` - ***used if available*** | **pandas** >= 0.15.0 |
| `.generate_classes()` in `flopy.mf6.utils` | [**pymake**](https://github.com/modflowpy/pymake) |
| `.intersect()` in `flopy.discretization.VertexGrid` | **matplotlib** >= 1.4 |
| `GridIntersect()` in `flopy.utils.gridintersect` | **shapely** |
| `GridIntersect().plot_polygon()` in `flopy.utils.gridintersect` | **shapely** and **descartes** |
| `Raster()` in `flopy.utils.Raster` | **rasterio**, **affine**, and **scipy** |
Expand Down
22 changes: 16 additions & 6 deletions etc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,38 @@ name: flopy
channels:
- conda-forge
dependencies:
# required
- python>=3.7
- numpy>=1.15.0
- matplotlib>=1.4.0

# testing
- pylint
- flake8
- black
- nose
- nose-timer
- coverage

# optional
- appdirs
- requests
- numpy>=1.15
- matplotlib
- bmipy
- python-dateutil>=2.4.0
- affine
- scipy
- pandas
- netcdf4
- pyshp
- pyshp>=2.0.0
- rasterio
- fiona
- descartes
- pyproj
- shapely
- geos
- geojson
- vtk
- vtk

# external dependencies
- requests

# MODFLOW API dependencies
- bmipy
2 changes: 2 additions & 0 deletions flopy/utils/utl_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

VERSIONS = {
"shapefile": "2.0.0",
"dateutil": "2.4.0",
"pandas": "0.15.0",
}

# A mapping from import name to package name (on PyPI) for packages where
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
license="CC0",
platforms="Windows, Mac OS-X, Linux",
install_requires=[
"numpy >=1.15",
"matplotlib",
"numpy>=1.15.0",
"matplotlib>=1.4.0",
],
packages=[
"flopy",
Expand Down

0 comments on commit 99e6dac

Please sign in to comment.