I can read in an existing MODFLOW 6 simulation using flopy.mf6.MFSimulation.load. Now I want to find out how many stress periods it has, as an integer, as defined by nper in the tdis package. What's the easiest way to do this?
So here is the trick, in flopy classes for MODFLOW 6, all of the information is stored as objects, including integers, arrays, floats, etc. This gives us some nice advantages, but it also makes some of the syntax a little difficult, though we are working to improve that.
Here is a very simple model:
import flopy
sim = flopy.mf6.MFSimulation()
tdis = flopy.mf6.ModflowTdis(sim, nper=10)
gwf = flopy.mf6.ModflowGwf(sim)
dis = flopy.mf6.ModflowGwfdis(gwf)
If we try to get at nper like this:
nper = tdis.nper
print(nper)
then we get back the repr, which looks like this:
{internal}
(10)
The way we get the actual data is to append array:
nper = tdis.nper.array
print(nper)
print(type(nper))
In which case we get the desired information:
10
<class 'int'>
For scalars we are considering changing this behavior so that it behaves like you would think (returning the value directly), but we haven't implemented that yet.