示例#1
0
def scpdsi(precip_time_series: np.ndarray,
           pet_time_series: np.ndarray,
           awc,
           data_start_year: int,
           calibration_start_year: int,
           calibration_end_year: int):
    """
    This function computes the self-calibrated Palmer Drought Severity Index
    (scPDSI), Palmer Drought Severity Index (PDSI), Palmer Hydrological Drought
    Index (PHDI), Palmer Modified Drought Index (PMDI), and Palmer Z-Index.

    :param precip_time_series: time series of precipitation values, in inches
    :param pet_time_series: time series of PET values, in inches
    :param awc: available water capacity (soil constant), in inches
    :param data_start_year: initial year of the input precipitation and PET datasets,
                            both of which are assumed to start in January of this year
    :param calibration_start_year: initial year of the calibration period
    :param calibration_end_year: final year of the calibration period
    :return: five numpy arrays containing SCPDSI, PDSI, PHDI, PMDI, and Z-Index values respectively
    """

    return palmer.scpdsi(precip_time_series,
                         pet_time_series,
                         awc,
                         data_start_year,
                         calibration_start_year,
                         calibration_end_year)
示例#2
0
    def test_scpdsi(self):
        '''
        Test for the palmer.scpdsi() function
        '''

        scpdsi, pdsi, phdi, pmdi, zindex = palmer.scpdsi(
            self.fixture_precips_mm_monthly, self.fixture_pet_mm,
            self.fixture_awc_inches, self.fixture_data_year_start_monthly,
            self.fixture_calibration_year_start_monthly,
            self.fixture_calibration_year_end_monthly)

        np.testing.assert_allclose(
            scpdsi,
            self.fixture_palmer_scpdsi_monthly,
            atol=0.001,
            equal_nan=True,
            err_msg='PDSI not computed as expected from monthly inputs')

        #         np.testing.assert_allclose(pdsi,
        #                                    self.fixture_palmer_pdsi_monthly,
        #                                    atol=0.001,
        #                                    equal_nan=True,
        #                                    err_msg='PDSI not computed as expected from monthly inputs')

        np.testing.assert_allclose(
            phdi,
            self.fixture_palmer_scphdi_monthly,
            atol=0.001,
            equal_nan=True,
            err_msg='PHDI not computed as expected from monthly inputs')

        np.testing.assert_allclose(
            pmdi,
            self.fixture_palmer_scpmdi_monthly,
            atol=0.001,
            equal_nan=True,
            err_msg='PMDI not computed as expected from monthly inputs')

        np.testing.assert_allclose(
            zindex,
            self.fixture_palmer_sczindex_monthly,
            atol=0.001,
            equal_nan=True,
            err_msg='Z-Index not computed as expected from monthly inputs')
示例#3
0
def test_scpdsi(
    precips_mm_monthly,
    pet_thornthwaite_mm,
    awc_inches,
    data_year_start_monthly,
    calibration_year_start_monthly,
    calibration_year_end_monthly,
    palmer_pdsi_from_scpdsi_monthly,
    palmer_scpdsi_monthly,
    palmer_scphdi_monthly,
    palmer_scpmdi_monthly,
    palmer_sczindex_monthly,
):
    """
    Test for the palmer.scpdsi() function
    """

    scpdsi, pdsi, phdi, pmdi, zindex = palmer.scpdsi(
        precips_mm_monthly,
        pet_thornthwaite_mm,
        awc_inches,
        data_year_start_monthly,
        calibration_year_start_monthly,
        calibration_year_end_monthly,
    )

    np.testing.assert_allclose(
        scpdsi,
        palmer_scpdsi_monthly,
        atol=0.001,
        equal_nan=True,
        err_msg="PDSI not computed as expected from monthly inputs",
    )

    np.testing.assert_allclose(
        pdsi,
        palmer_pdsi_from_scpdsi_monthly,
        atol=0.001,
        equal_nan=True,
        err_msg="PDSI not computed as expected from monthly inputs",
    )

    np.testing.assert_allclose(
        phdi,
        palmer_scphdi_monthly,
        atol=0.001,
        equal_nan=True,
        err_msg="PHDI not computed as expected from monthly inputs",
    )

    np.testing.assert_allclose(
        pmdi,
        palmer_scpmdi_monthly,
        atol=0.001,
        equal_nan=True,
        err_msg="PMDI not computed as expected from monthly inputs",
    )

    np.testing.assert_allclose(
        zindex,
        palmer_sczindex_monthly,
        atol=0.001,
        equal_nan=True,
        err_msg="Z-Index not computed as expected from monthly inputs",
    )