@staticmethod
def masked4D_arrays_to_stress_period_data(dtype, m4ds):
    ' convert a dictionary of 4-dim masked arrays to\n            a stress_period_data style dict of recarray\n        Parameters\n        ----------\n            dtype : numpy dtype\n\n            m4ds : dict {name:masked numpy 4-dim ndarray}\n        Returns\n        -------\n            dict {kper:recarray}\n        '
    assert isinstance(m4ds, dict)
    for (name, m4d) in m4ds.items():
        assert isinstance(m4d, np.ndarray)
        assert (name in dtype.names)
        assert (m4d.ndim == 4)
    keys = list(m4ds.keys())
    for (i1, key1) in enumerate(keys):
        a1 = np.isnan(m4ds[key1])
        for (i2, key2) in enumerate(keys[i1:]):
            a2 = np.isnan(m4ds[key2])
            if (not np.array_equal(a1, a2)):
                raise Exception(('Transient2d error: masking not equal' + ' for {0} and {1}'.format(key1, key2)))
    sp_data = {}
    for kper in range(m4d.shape[0]):
        vals = {}
        for (name, m4d) in m4ds.items():
            arr = m4d[kper, :, :, :]
            isnan = np.argwhere((~ np.isnan(arr)))
            v = []
            for (k, i, j) in isnan:
                v.append(arr[(k, i, j)])
            vals[name] = v
            kk = isnan[:, 0]
            ii = isnan[:, 1]
            jj = isnan[:, 2]
        spd = np.recarray(shape=isnan.shape[0], dtype=dtype)
        spd['i'] = ii
        spd['k'] = kk
        spd['j'] = jj
        for (n, v) in vals.items():
            spd[n] = v
        sp_data[kper] = spd
    return sp_data
convert a dictionary of 4-dim masked arrays to
    a stress_period_data style dict of recarray
Parameters
----------
    dtype : numpy dtype

    m4ds : dict {name:masked numpy 4-dim ndarray}
Returns
-------
    dict {kper:recarray}
@staticmethod
def masked4D_arrays_to_stress_period_data(dtype, m4ds):
    ' convert a dictionary of 4-dim masked arrays to\n            a stress_period_data style dict of recarray\n        Parameters\n        ----------\n            dtype : numpy dtype\n\n            m4ds : dict {name:masked numpy 4-dim ndarray}\n        Returns\n        -------\n            dict {kper:recarray}\n        '
    assert isinstance(m4ds, dict)
    for (name, m4d) in m4ds.items():
        assert isinstance(m4d, np.ndarray)
        assert (name in dtype.names)
        assert (m4d.ndim == 4)
    keys = list(m4ds.keys())
    for (i1, key1) in enumerate(keys):
        a1 = np.isnan(m4ds[key1])
        for (i2, key2) in enumerate(keys[i1:]):
            a2 = np.isnan(m4ds[key2])
            if (not np.array_equal(a1, a2)):
                raise Exception(('Transient2d error: masking not equal' + ' for {0} and {1}'.format(key1, key2)))
    sp_data = {}
    for kper in range(m4d.shape[0]):
        vals = {}
        for (name, m4d) in m4ds.items():
            arr = m4d[kper, :, :, :]
            isnan = np.argwhere((~ np.isnan(arr)))
            v = []
            for (k, i, j) in isnan:
                v.append(arr[(k, i, j)])
            vals[name] = v
            kk = isnan[:, 0]
            ii = isnan[:, 1]
            jj = isnan[:, 2]
        spd = np.recarray(shape=isnan.shape[0], dtype=dtype)
        spd['i'] = ii
        spd['k'] = kk
        spd['j'] = jj
        for (n, v) in vals.items():
            spd[n] = v
        sp_data[kper] = spd
    return sp_data