# 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 ModflowGwfrcha(MFPackage):
    """
    ModflowGwfrcha defines a RCHA 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 recharge 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.
    fixed_cell : keyword
        indicates that recharge will not be reassigned to a cell underlying the cell
        specified in the list if the specified cell is inactive.
    auxiliary : [string]
        defines an array of one or more auxiliary variable names.  there is no limit on
        the number of auxiliary variables that can be provided on this line; however,
        lists of information provided in subsequent blocks must have a column of data
        for each auxiliary variable name defined here.   the number of auxiliary
        variables detected on this line determines the value for naux.  comments cannot
        be provided anywhere on this line as they will be interpreted as auxiliary
        variable names.  auxiliary variables may not be used by the package, but they
        will be available for use by other parts of the program.  the program will
        terminate with an error if auxiliary variables are specified on more than one
        line in the options block.
    auxmultname : string
        name of auxiliary variable to be used as multiplier of recharge.
    print_input : keyword
        keyword to indicate that the list of recharge information will be written to
        the listing file immediately after it is read.
    print_flows : keyword
        keyword to indicate that the list of recharge flow rates will be printed to the
        listing file for every stress period time step in which 'budget print' is
        specified in output control.  if there is no output control option and
        'print_flows' is specified, then flow rates are printed for the last time step
        of each stress period.
    save_flows : keyword
        keyword to indicate that recharge flow terms will be written to the file
        specified with 'budget fileout' in output control.
    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.
    observations : record obs6 filein obs6_filename
        Contains data for the obs package. Data can be passed as a dictionary to the
        obs package with variable names as keys and package data as values. Data for
        the observations variable is also acceptable. See obs package documentation for
        more information.
    export_array_netcdf : keyword
        keyword that specifies input griddata arrays should be written to the model
        output netcdf file.
    irch : [integer]
        irch is the layer number that defines the layer in each vertical column where
        recharge is applied. if irch is omitted, recharge by default is applied to
        cells in layer 1.  irch can only be used if readasarrays is specified in the
        options block.  if irch is specified, it must be specified as the first
        variable in the period block or modflow will terminate with an error.
    recharge : [double precision]
        is the recharge flux rate (:math:`lt^{-1}`).  this rate is multiplied inside
        the program by the surface area of the cell to calculate the volumetric
        recharge rate. the recharge array may be defined by a time-array series (see
        the 'using time-array series in a package' section).
    aux : [double precision]
        is an array of values for auxiliary variable aux(iaux), where iaux is a value
        from 1 to naux, and aux(iaux) must be listed as part of the auxiliary
        variables.  a separate array can be specified for each auxiliary variable.  if
        an array is not specified for an auxiliary variable, then a value of zero is
        assigned.  if the value specified here for the auxiliary variable is the same
        as auxmultname, then the recharge array will be multiplied by this array.

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

    """

    auxiliary = ArrayTemplateGenerator(("gwf6", "rcha", "options", "auxiliary"))
    tas_filerecord = ListTemplateGenerator(
        ("gwf6", "rcha", "options", "tas_filerecord")
    )
    obs_filerecord = ListTemplateGenerator(
        ("gwf6", "rcha", "options", "obs_filerecord")
    )
    irch = ArrayTemplateGenerator(("gwf6", "rcha", "period", "irch"))
    recharge = ArrayTemplateGenerator(("gwf6", "rcha", "period", "recharge"))
    aux = ArrayTemplateGenerator(("gwf6", "rcha", "period", "aux"))
    package_abbr = "gwfrcha"
    _package_type = "rcha"
    dfn_file_name = "gwf-rcha.dfn"
    dfn = [
        ["header", "multi-package", "package-type stress-package"],
        [
            "block options",
            "name readasarrays",
            "type keyword",
            "shape",
            "reader urword",
            "optional false",
            "default true",
        ],
        [
            "block options",
            "name fixed_cell",
            "type keyword",
            "shape",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name auxiliary",
            "type string",
            "shape (naux)",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name auxmultname",
            "type string",
            "shape",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name print_input",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal iprpak",
        ],
        [
            "block options",
            "name print_flows",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal iprflow",
        ],
        [
            "block options",
            "name save_flows",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal ipakcb",
        ],
        [
            "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 options",
            "name obs_filerecord",
            "type record obs6 filein obs6_filename",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package obs",
            "construct_data observations",
            "parameter_name continuous",
        ],
        [
            "block options",
            "name obs6",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name obs6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block options",
            "name export_array_netcdf",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal export_nc",
            "extended true",
        ],
        [
            "block period",
            "name iper",
            "type integer",
            "block_variable true",
            "in_record true",
            "tagged false",
            "shape",
            "valid",
            "reader urword",
            "optional false",
        ],
        [
            "block period",
            "name irch",
            "type integer",
            "shape (ncol*nrow; ncpl)",
            "reader readarray",
            "numeric_index true",
            "optional true",
        ],
        [
            "block period",
            "name recharge",
            "type double precision",
            "shape (ncol*nrow; ncpl)",
            "reader readarray",
            "time_series true",
            "default 1.e-3",
        ],
        [
            "block period",
            "name aux",
            "type double precision",
            "shape (ncol*nrow; ncpl)",
            "reader readarray",
            "time_series true",
            "optional true",
            "mf6internal auxvar",
        ],
    ]

    def __init__(
        self,
        model,
        loading_package=False,
        readasarrays=True,
        fixed_cell=None,
        auxiliary=None,
        auxmultname=None,
        print_input=None,
        print_flows=None,
        save_flows=None,
        timearrayseries=None,
        observations=None,
        export_array_netcdf=None,
        irch=None,
        recharge=0.001,
        aux=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowGwfrcha."""
        super().__init__(
            parent=model,
            package_type="rcha",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.readasarrays = self.build_mfdata("readasarrays", readasarrays)
        self.fixed_cell = self.build_mfdata("fixed_cell", fixed_cell)
        self.auxiliary = self.build_mfdata("auxiliary", auxiliary)
        self.auxmultname = self.build_mfdata("auxmultname", auxmultname)
        self.print_input = self.build_mfdata("print_input", print_input)
        self.print_flows = self.build_mfdata("print_flows", print_flows)
        self.save_flows = self.build_mfdata("save_flows", save_flows)
        self._tas_filerecord = self.build_mfdata("tas_filerecord", None)
        self._tas_package = self.build_child_package(
            "tas", timearrayseries, "tas_array", self._tas_filerecord
        )
        self._obs_filerecord = self.build_mfdata("obs_filerecord", None)
        self._obs_package = self.build_child_package(
            "obs", observations, "continuous", self._obs_filerecord
        )
        self.export_array_netcdf = self.build_mfdata(
            "export_array_netcdf", export_array_netcdf
        )
        self.irch = self.build_mfdata("irch", irch)
        self.recharge = self.build_mfdata("recharge", recharge)
        self.aux = self.build_mfdata("aux", aux)

        self._init_complete = True
