Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
369 changes: 243 additions & 126 deletions autotest/t007_test.py

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions examples/data/mt3d_test/mfnwt_mt3dusgs/sft_crnkNic/CrnkNic.nam
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Name file for MODFLOW-NWT, generated by Flopy version 3.2.6.
#xul:0; yul:15; rotation:0; proj4_str:+init=EPSG:4326; units:meters; lenuni:2; length_multiplier:1.0 ;start_datetime:1-1-1970
#xul:0; yul:15; rotation:0; proj4_str:EPSG:4326; units:meters; lenuni:2; length_multiplier:1.0 ;start_datetime:1-1-1970
LIST 2 CrnkNic.list
OC 14 CrnkNic.oc
NWT 32 CrnkNic.nwt
DIS 11 CrnkNic.dis
UPW 31 CrnkNic.upw
BAS6 13 CrnkNic.bas
SFR 17 CrnkNic.sfr
LMT6 30 CrnkNic.lmt6
GAGE 120 CrnkNic.gage
OC 14 CrnkNic.oc
NWT 32 CrnkNic.nwt
DIS 11 CrnkNic.dis
UPW 31 CrnkNic.upw
BAS6 13 CrnkNic.bas
SFR 17 CrnkNic.sfr
LMT6 30 CrnkNic.lmt6
GAGE 120 CrnkNic.gage
DATA(BINARY) 51 CrnkNic.hds REPLACE
DATA(BINARY) 53 CrnkNic.cbc REPLACE
DATA 61 CrnkNic.gag1
Expand Down
18 changes: 9 additions & 9 deletions examples/data/options/sagehen/sagehen.nam
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#Name file for GSFLOW MODFLOW-NWT model, generated by GSFloPy
#xul:0; yul:6570; rotation:0; proj4_str:+init=EPSG:4326; units:meters; lenuni:2; length_multiplier:1.0 ;start_datetime:1/1/1970
LIST 26 sagehen.list
BAS6 8 sagehen.bas
OC 9 sagehen.oc
#xul:0; yul:6570; rotation:0; proj4_str:EPSG:4326; units:meters; lenuni:2; length_multiplier:1.0 ;start_datetime:1/1/1970
LIST 26 sagehen.list
BAS6 8 sagehen.bas
OC 9 sagehen.oc
DIS 11 sagehen.dis
LPF 12 sagehen.lpf
UZF 14 sagehen.uzf
LPF 12 sagehen.lpf
UZF 14 sagehen.uzf
SFR 15 sagehen.sfr
WEL 18 sagehen.wel
DATA 58 head_sagehen.out REPLACE
DATA 66 uz2_sagehen.out
DATA 67 uz3_sagehen.out
DATA 68 uz4_sagehen.out
DATA 66 uz2_sagehen.out
DATA 67 uz3_sagehen.out
DATA 68 uz4_sagehen.out
DATA 65 uz1_sagehen.out
# DATA 90 reduced_wells.out
7 changes: 2 additions & 5 deletions flopy/discretization/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,15 @@ def proj4(self):
proj4 = None
if self._proj4 is not None:
if "epsg" in self._proj4.lower():
if "init" not in self._proj4.lower():
proj4 = "+init=" + self._proj4
else:
proj4 = self._proj4
proj4 = self._proj4
# set the epsg if proj4 specifies it
tmp = [i for i in self._proj4.split() if
'epsg' in i.lower()]
self._epsg = int(tmp[0].split(':')[1])
else:
proj4 = self._proj4
elif self.epsg is not None:
proj4 = '+init=epsg:{}'.format(self.epsg)
proj4 = 'epsg:{}'.format(self.epsg)
return proj4

@proj4.setter
Expand Down
36 changes: 20 additions & 16 deletions flopy/export/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def __init__(self, output_filename, model, time_values=None,

proj4_str = self.model_grid.proj4
if proj4_str is None:
proj4_str = '+init=epsg:4326'
proj4_str = 'epsg:4326'
self.log(
'Warning: model has no coordinate reference system specified. '
'Using default proj4 string: {}'.format(proj4_str))
Expand Down Expand Up @@ -629,17 +629,19 @@ def initialize_geometry(self):
raise Exception("NetCdf error importing pyproj module:\n" + str(e))

proj4_str = self.proj4_str
print('initialize_geometry::proj4_str = {}'.format(proj4_str))

if "epsg" in proj4_str.lower() and "init" not in proj4_str.lower():
proj4_str = "+init=" + proj4_str
self.log("building grid crs using proj4 string: {0}".format(proj4_str))
self.log("building grid crs using proj4 string: {}".format(proj4_str))
try:
self.grid_crs = Proj(proj4_str, preserve_units=True, errcheck=True)

except Exception as e:
self.log("error building grid crs:\n{0}".format(str(e)))
raise Exception("error building grid crs:\n{0}".format(str(e)))
self.log("building grid crs using proj4 string: {0}".format(proj4_str))

print('initialize_geometry::self.grid_crs = {}'.format(self.grid_crs))

self.log("building grid crs using proj4 string: {}".format(proj4_str))

vmin, vmax = self.model_grid.botm.min(), \
self.model_grid.top.max()
Expand All @@ -652,10 +654,12 @@ def initialize_geometry(self):
xs = self.model_grid.xyzcellcenters[0].copy()

# Transform to a known CRS
nc_crs = Proj(init=self.nc_epsg_str)
nc_crs = Proj(self.nc_epsg_str)
print('initialize_geometry::nc_crs = {}'.format(nc_crs))

self.log("projecting grid cell center arrays " + \
"from {0} to {1}".format(str(self.grid_crs.srs),
str(nc_crs.srs)))
"from {} to {}".format(str(self.grid_crs.srs),
str(nc_crs.srs)))
try:
self.xs, self.ys = transform(self.grid_crs, nc_crs, xs, ys)
except Exception as e:
Expand Down Expand Up @@ -701,15 +705,15 @@ def initialize_file(self, time_values=None):
import netCDF4
except Exception as e:
self.logger.warn("error importing netCDF module")
raise Exception(
"NetCdf error importing netCDF4 module:\n" + str(e))
msg = "NetCdf error importing netCDF4 module:\n" + str(e)
raise Exception(msg)

# open the file for writing
try:
self.nc = netCDF4.Dataset(self.output_filename, "w")
except Exception as e:
raise Exception(
"error creating netcdf dataset:\n{0}".format(str(e)))
msg = "error creating netcdf dataset:\n{}".format(str(e))
raise Exception(msg)

# write some attributes
self.log("setting standard attributes")
Expand Down Expand Up @@ -754,8 +758,8 @@ def initialize_file(self, time_values=None):
crs.inverse_flattening = self.nc_inverse_flat
self.log("setting CRS info")

attribs = {"units": "{0} since {1}".format(self.time_units,
self.start_datetime),
attribs = {"units": "{} since {}".format(self.time_units,
self.start_datetime),
"standard_name": "time",
"long_name": NC_LONG_NAMES.get("time", "time"),
"calendar": "gregorian",
Expand Down Expand Up @@ -1050,8 +1054,8 @@ def get_longnames_from_docstrings(self, outfile='longnames.json'):
try:
from numpydoc.docscrape import NumpyDocString
except Exception as e:
raise Exception(
"NetCdf error importing numpydoc module:\n" + str(e))
msg = 'NetCdf error importing numpydoc module:\n' + str(e)
raise Exception(msg)

def startstop(ds):
"""Get just the Parameters section of the docstring."""
Expand Down
2 changes: 1 addition & 1 deletion flopy/export/shapefile_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ def get_spatialreference(epsg, text='esriwkt'):
# epsg code not listed on spatialreference.org
# may still work with pyproj
elif text == 'epsg':
return '+init=epsg:{}'.format(epsg)
return 'epsg:{}'.format(epsg)

@staticmethod
def getproj4(epsg):
Expand Down
9 changes: 3 additions & 6 deletions flopy/utils/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,15 @@ def proj4_str(self):
proj4_str = None
if self._proj4_str is not None:
if "epsg" in self._proj4_str.lower():
if "init" not in self._proj4_str.lower():
proj4_str = "+init=" + self._proj4_str
else:
proj4_str = self._proj4_str
proj4_str = self._proj4_str
# set the epsg if proj4 specifies it
tmp = [i for i in self._proj4_str.split() if
'epsg' in i.lower()]
self._epsg = int(tmp[0].split(':')[1])
else:
proj4_str = self._proj4_str
elif self.epsg is not None:
proj4_str = '+init=epsg:{}'.format(self.epsg)
proj4_str = 'epsg:{}'.format(self.epsg)
return proj4_str

@property
Expand Down Expand Up @@ -2195,7 +2192,7 @@ def get_spatialreference(epsg, text='esriwkt'):
# epsg code not listed on spatialreference.org
# may still work with pyproj
elif text == 'epsg':
return '+init=epsg:{}'.format(epsg)
return 'epsg:{}'.format(epsg)


def getproj4(epsg):
Expand Down
3 changes: 2 additions & 1 deletion requirements.travis.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
appdirs
matplotlib
netcdf4
netcdf4 ; python_version != '3.8'
netcdf4 != 1.5.3 ; python_version == '3.8'
fiona ; python_version < '3.8'
descartes
pyproj
Expand Down