modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
517 stars 313 forks source link

Modflow Str issue #249

Closed Neilt100 closed 6 years ago

Neilt100 commented 7 years ago

Small issue with writing segment data for the Mf Stream file (mfstr.py). If the segment data dictionary passed to flopy includes more than 3 tributaries (or a list with more than 4 values, allowing an extra value for iupseg), data beyond the third value is not printed to the stream file, and iupseg is printed as the fourth column in the list. This seems to be hard coded: lines 501 to 509 in mfstr.py:

# dataset 9 if self.ntrib > 0: for line in sdata: for idx in range(3): f_str.write(fmt9.format(line[idx])) f_str.write('\n') # dataset 10 if self.ndiv > 0: for line in sdata: f_str.write('{:10d}\n'.format(line[3]))

I have got round this problem by changing line 503 to for idx in range(10):

and line 509 to: f_str.write('{10d}\n'.format(line[10])

Thanks.

langevin-usgs commented 7 years ago

@aleaf-usgs, what do you think? Are you good with the suggested fix?

aleaf commented 7 years ago

If each line in segment_data has to be ntrib + 1 in length, then it seems like this would be the best fix:

# dataset 9
if self.ntrib > 0:
    for line in sdata:
        for idx in range(self.ntrib):
            f_str.write(fmt9.format(line[idx]))
        f_str.write('\n')
# dataset 10
if self.ndiv > 0:
    for line in sdata:
        f_str.write('{:10d}\n'.format(line[self.ntrib]))

I'm a little confused though reading the docstring: If ntrib=0 is specified, itrib values are not used and can be any value for each stress period. If data are specified for dataset 6 for a given stress period and ntrib>0, then itrib data should be specified for columns 0:ntrib. Does this mean that each line in segment data can be a different length if ntrib=0?

Neilt100 commented 6 years ago

Hi,

An issue that came up when using the str file with the most recent development version of Flopy (3.2.9) is in line 381 (in function 'get empty':

    return (create_empty_recarray(ncells, dtype=dtype, default_value=-1.0E+10),
                 create_empty_recarray(nss, dtype=dtype, default_value=0))

The second 'create_empty_recarray' call references the wrong dtype. The dtype should be dtype2.

Thanks.