# autogenerated file, do not modify

from os import PathLike, curdir
from typing import Union

from flopy.mf6.data.mfdatautil import ArrayTemplateGenerator, ListTemplateGenerator
from flopy.mf6.mfpackage import MFChildPackages, MFPackage


class ModflowGwfsto(MFPackage):
    """
    ModflowGwfsto defines a STO package.

    Parameters
    ----------
    model
        Model that this package is a part of. Package is automatically
        added to model when it is initialized.
    loading_package : bool, default False
        Do not set this parameter. It is intended for debugging and internal
        processing purposes only.
    save_flows : keyword
        keyword to indicate that cell-by-cell flow terms will be written to the file
        specified with 'budget save file' in output control.
    storagecoefficient : keyword
        keyword to indicate that the ss array is read as storage coefficient rather
        than specific storage.
    ss_confined_only : keyword
        keyword to indicate that compressible storage is only calculated for a
        convertible cell (iconvert>0) when the cell is under confined conditions (head
        greater than or equal to the top of the cell). this option has no effect on
        cells that are marked as being always confined (iconvert=0).  this option is
        identical to the approach used to calculate storage changes under confined
        conditions in modflow-2005.
    perioddata : record tvs6 filein tvs6_filename
        Contains data for the tvs package. Data can be passed as a dictionary to the
        tvs package with variable names as keys and package data as values. Data for
        the perioddata variable is also acceptable. See tvs package documentation for
        more information.
    export_array_ascii : keyword
        keyword that specifies input grid arrays, which already support the layered
        keyword, should be written to layered ascii output files.
    export_array_netcdf : keyword
        keyword that specifies input griddata arrays should be written to the model
        output netcdf file.
    dev_original_specific_storage : keyword
        flag indicating the original storage specific storage formulation should be
        used
    dev_oldstorageformulation : keyword
        development option flag for old storage formulation
    iconvert : [integer]
        is a flag for each cell that specifies whether or not a cell is convertible for
        the storage calculation. 0 indicates confined storage is used. >0 indicates
        confined storage is used when head is above cell top and a mixed formulation of
        unconfined and confined storage is used when head is below cell top.
    ss : [double precision]
        is specific storage (or the storage coefficient if storagecoefficient is
        specified as an option). specific storage values must be greater than or equal
        to 0. if the csub package is included in the gwf model, specific storage must
        be zero for every cell.
    sy : [double precision]
        is specific yield. specific yield values must be greater than or equal to 0.
        specific yield does not have to be specified if there are no convertible cells
        (iconvert=0 in every cell).
    steady_state : keyword
        keyword to indicate that stress period iper is steady-state. steady-state
        conditions will apply until the transient keyword is specified in a subsequent
        begin period block. if the csub package is included in the gwf model, only the
        first and last stress period can be steady-state.
    transient : keyword
        keyword to indicate that stress period iper is transient. transient conditions
        will apply until the steady-state keyword is specified in a subsequent begin
        period block.

    filename : str or PathLike, optional
        Name or path of file where this package is stored.
    pname : str, optional
        Package name.
    **kwargs
        Extra keywords for :class:`flopy.mf6.mfpackage.MFPackage`.

    """

    tvs_filerecord = ListTemplateGenerator(("gwf6", "sto", "options", "tvs_filerecord"))
    iconvert = ArrayTemplateGenerator(("gwf6", "sto", "griddata", "iconvert"))
    ss = ArrayTemplateGenerator(("gwf6", "sto", "griddata", "ss"))
    sy = ArrayTemplateGenerator(("gwf6", "sto", "griddata", "sy"))
    package_abbr = "gwfsto"
    _package_type = "sto"
    dfn_file_name = "gwf-sto.dfn"
    dfn = [
        ["header"],
        [
            "block options",
            "name save_flows",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal ipakcb",
        ],
        [
            "block options",
            "name storagecoefficient",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal istor_coef",
        ],
        [
            "block options",
            "name ss_confined_only",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name tvs_filerecord",
            "type record tvs6 filein tvs6_filename",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package tvs",
            "construct_data perioddata",
            "parameter_name tvs_perioddata",
        ],
        [
            "block options",
            "name tvs6",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name filein",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name tvs6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "reader urword",
            "optional false",
            "tagged false",
        ],
        [
            "block options",
            "name export_array_ascii",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal export_ascii",
        ],
        [
            "block options",
            "name export_array_netcdf",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal export_nc",
            "extended true",
        ],
        [
            "block options",
            "name dev_original_specific_storage",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal iorig_ss",
        ],
        [
            "block options",
            "name dev_oldstorageformulation",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal iconf_ss",
        ],
        [
            "block griddata",
            "name iconvert",
            "type integer",
            "shape (nodes)",
            "valid",
            "reader readarray",
            "layered true",
            "netcdf true",
            "optional false",
            "default 0",
        ],
        [
            "block griddata",
            "name ss",
            "type double precision",
            "shape (nodes)",
            "valid",
            "reader readarray",
            "layered true",
            "netcdf true",
            "optional false",
            "default 1.e-5",
        ],
        [
            "block griddata",
            "name sy",
            "type double precision",
            "shape (nodes)",
            "valid",
            "reader readarray",
            "layered true",
            "netcdf true",
            "optional false",
            "default 0.15",
        ],
        [
            "block period",
            "name iper",
            "type integer",
            "block_variable true",
            "in_record true",
            "tagged false",
            "shape",
            "valid",
            "reader urword",
            "optional false",
        ],
        [
            "block period",
            "name steady-state",
            "type keyword",
            "shape",
            "valid",
            "reader urword",
            "optional true",
            "mf6internal steady_state",
        ],
        [
            "block period",
            "name transient",
            "type keyword",
            "shape",
            "valid",
            "reader urword",
            "optional true",
        ],
    ]

    def __init__(
        self,
        model,
        loading_package=False,
        save_flows=None,
        storagecoefficient=None,
        ss_confined_only=None,
        perioddata=None,
        export_array_ascii=None,
        export_array_netcdf=None,
        dev_original_specific_storage=None,
        dev_oldstorageformulation=None,
        iconvert=0,
        ss=1e-05,
        sy=0.15,
        steady_state=None,
        transient=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowGwfsto."""
        super().__init__(
            parent=model,
            package_type="sto",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.save_flows = self.build_mfdata("save_flows", save_flows)
        self.storagecoefficient = self.build_mfdata(
            "storagecoefficient", storagecoefficient
        )
        self.ss_confined_only = self.build_mfdata("ss_confined_only", ss_confined_only)
        self._tvs_filerecord = self.build_mfdata("tvs_filerecord", None)
        self._tvs_package = self.build_child_package(
            "tvs", perioddata, "tvs_perioddata", self._tvs_filerecord
        )
        self.export_array_ascii = self.build_mfdata(
            "export_array_ascii", export_array_ascii
        )
        self.export_array_netcdf = self.build_mfdata(
            "export_array_netcdf", export_array_netcdf
        )
        self.dev_original_specific_storage = self.build_mfdata(
            "dev_original_specific_storage", dev_original_specific_storage
        )
        self.dev_oldstorageformulation = self.build_mfdata(
            "dev_oldstorageformulation", dev_oldstorageformulation
        )
        self.iconvert = self.build_mfdata("iconvert", iconvert)
        self.ss = self.build_mfdata("ss", ss)
        self.sy = self.build_mfdata("sy", sy)
        self.steady_state = self.build_mfdata("steady-state", steady_state)
        self.transient = self.build_mfdata("transient", transient)

        self._init_complete = True
