Skip to content

Commit

Permalink
refactor(namfile): whitespace in NAM file and MFList output files (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews authored and langevin-usgs committed Jul 30, 2019
1 parent 7e0a80d commit 4aa9661
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
11 changes: 5 additions & 6 deletions flopy/discretization/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,11 @@ def __init__(self, grid_type=None, top=None, botm=None, idomain=None,
# access to basic grid properties
###################################
def __repr__(self):
s = "xll:{0:<.10G}; yll:{1:<.10G}; rotation:{2:<G}; ". \
format(self.xoffset, self.yoffset, self.angrot)
s += "proj4_str:{0}; ".format(self.proj4)
s += "units:{0}; ".format(self.units)
s += "lenuni:{0}; ".format(self.lenuni)
return s
return (
"xll:{0:<.10G}; yll:{1:<.10G}; rotation:{2:<G}; proj4_str:{3}; "
"units:{4}; lenuni:{5}"
.format(self.xoffset, self.yoffset, self.angrot, self.proj4,
self.units, self.lenuni))

@property
def grid_type(self):
Expand Down
11 changes: 7 additions & 4 deletions flopy/mbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,14 +915,17 @@ def get_name_file_entries(self):
----------
"""
s = ''
lines = []
for p in self.packagelist:
for i in range(len(p.name)):
if p.unit_number[i] == 0:
continue
s += '{:14s} {:5d} '.format(p.name[i], p.unit_number[i]) + \
'{:s} {:s}\n'.format(p.file_name[i], p.extra[i])
return s
s = '{:14s} {:5d} {}'.format(
p.name[i], p.unit_number[i], p.file_name[i])
if p.extra[i]:
s += ' ' + p.extra[i]
lines.append(s)
return '\n'.join(lines) + '\n'

def has_package(self, name):
"""
Expand Down
2 changes: 1 addition & 1 deletion flopy/modflow/mf.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def write_name_file(self):
f_nam.write('{}\n'.format(self.heading))
if self.structured:
f_nam.write('#' + str(self.modelgrid))
f_nam.write(" ;start_datetime:{0}\n".format(self.start_datetime))
f_nam.write("; start_datetime:{0}\n".format(self.start_datetime))
if self.version == 'mf2k':
if self.glo.unit_number[0] > 0:
f_nam.write('{:14s} {:5d} {}\n'.format(self.glo.name[0],
Expand Down
16 changes: 9 additions & 7 deletions flopy/utils/util_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,15 @@ def write_transient(self, f, single_per=None, forceInternal=False):

if kper_vtype == np.recarray:
name = f.name
f.close()
f = open(name, 'ab+')
# print(f)
self.__tofile(f, kper_data)
f.close()
f = open(name, 'a')
# print(f)
if self.__binary:
f.close()
# switch file append mode to binary
with open(name, 'ab+') as f:
self.__tofile(f, kper_data)
# continue back to non-binary
f = open(name, 'a')
else:
self.__tofile(f, kper_data)
elif kper_vtype == str:
f.write(' open/close ' + kper_data)
if self.__binary:
Expand Down

0 comments on commit 4aa9661

Please sign in to comment.