# 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 ModflowUtlspca(MFPackage):
    """
    ModflowUtlspca defines a SPCA 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.
    readasarrays : keyword
        indicates that array-based input will be used for the spc package.  this
        keyword must be specified to use array-based input.  when readasarrays is
        specified, values must be provided for every cell within a model layer, even
        those cells that have an idomain value less than one.  values assigned to cells
        with idomain values less than one are not used and have no effect on simulation
        results.
    print_input : keyword
        keyword to indicate that the list of spc information will be written to the
        listing file immediately after it is read.
    timearrayseries : record tas6 filein tas6_filename
        Contains data for the tas package. Data can be passed as a dictionary to the
        tas package with variable names as keys and package data as values. Data for
        the timearrayseries variable is also acceptable. See tas package documentation
        for more information.
    concentration : [double precision]
        is the concentration of the associated recharge or evapotranspiration stress
        package.  the concentration array may be defined by a time-array series (see
        the "using time-array series in a package" section).
    temperature : [double precision]
        is the temperature of the associated recharge or evapotranspiration stress
        package.  the temperature array may be defined by a time-array series (see the
        "using time-array series in a package" section).

    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`.

    """

    tas_filerecord = ListTemplateGenerator(("spca", "options", "tas_filerecord"))
    concentration = ArrayTemplateGenerator(("spca", "period", "concentration"))
    temperature = ArrayTemplateGenerator(("spca", "period", "temperature"))
    package_abbr = "utlspca"
    _package_type = "spca"
    dfn_file_name = "utl-spca.dfn"
    dfn = [
        ["header", "multi-package"],
        [
            "block options",
            "name readasarrays",
            "type keyword",
            "shape",
            "reader urword",
            "optional false",
            "default true",
        ],
        [
            "block options",
            "name print_input",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name tas_filerecord",
            "type record tas6 filein tas6_filename",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package tas",
            "construct_data timearrayseries",
            "parameter_name tas_array",
        ],
        [
            "block options",
            "name tas6",
            "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 tas6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "reader urword",
            "optional false",
            "tagged false",
        ],
        [
            "block period",
            "name iper",
            "type integer",
            "block_variable true",
            "in_record true",
            "tagged false",
            "shape",
            "valid",
            "reader urword",
            "optional false",
        ],
        [
            "block period",
            "name concentration",
            "type double precision",
            "shape (ncol*nrow; ncpl)",
            "reader readarray",
            "optional true",
        ],
        [
            "block period",
            "name temperature",
            "type double precision",
            "shape (ncol*nrow; ncpl)",
            "reader readarray",
            "optional true",
        ],
    ]

    def __init__(
        self,
        model,
        loading_package=False,
        readasarrays=True,
        print_input=None,
        timearrayseries=None,
        concentration=None,
        temperature=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowUtlspca."""
        super().__init__(
            parent=model,
            package_type="spca",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.readasarrays = self.build_mfdata("readasarrays", readasarrays)
        self.print_input = self.build_mfdata("print_input", print_input)
        self._tas_filerecord = self.build_mfdata("tas_filerecord", None)
        self._tas_package = self.build_child_package(
            "tas", timearrayseries, "tas_array", self._tas_filerecord
        )
        self.concentration = self.build_mfdata("concentration", concentration)
        self.temperature = self.build_mfdata("temperature", temperature)

        self._init_complete = True
