djlampert / PyHSPF

Python extensions to the Hydrological Simulation Program in Fortran (HSPF), including classes for gathering input data, building input files, performing simulations, postprocessing results, calibrating hydrology process parameters, and forecasting climate and land use change effects on water resources
Other
83 stars 51 forks source link

Perlnd and Implnd Class's get_*() methods return unnamed tuples. #11

Open lucashtnguyen opened 5 years ago

lucashtnguyen commented 5 years ago

For example, Perlnd line 276:

    def get_pwat_parm1(self):
        """Returns the PWAT-PARM1 flags as a tuple."""

        return (self.operation,     self.CSNO, self.RTOP, self.UZFG, self.VCS, 
                self.VUZ, self.VNN, self.VIFW, self.VIRC, self.VLE, self.IFFC, 
                self.HWT, self.IRRG)

We could use a namedtuple to return a more useful result like:

    from collections import namedtuple
    ...
    def get_pwat_parm1(self):
        """Returns the PWAT-PARM1 flags as a tuple."""
        pwat_parm1 = namedtuple(
            'pwat_parm1',
            [
                'operation', 'CSNO',
                'RTOP', 'UZFG',
                'VCS', 'VUZ',
                'VNN', 'VIFW',
                'VIRC', 'VLE',
                'IFFC', 'HWT',
                'IRRG'
            ]
        )

        res = pwat_parm1(
            operation = self.operation,
            CSNO = self.CSNO,
            RTOP = self.RTOP,
            UZFG = self.UZFG,
            VCS = self.VCS,
            VUZ = self.VUZ,
            VNN = self.VNN,
            VIFW = self.VIFW,
            VIRC = self.VIRC,
            VLE = self.VLE,
            IFFC = self.IFFC,
            HWT = self.HWT,
            IRRG = self.IRRG
        )
        return res

which would return something like pwat_parm1(operation=1, CSNO=1, RTOP=1, UZFG=1, VCS=1, VUZ=1, VNN=1, VIFW=1, VIRC=1, VLE=1, IFFC=1, HWT=1, IRRG=1)