コード例 #1
0
    def test_normalization_with_pvw(self):
        ''' Test PVWatts normalization. '''

        pvw_kws = {
            'poa_global': self.poa_global,
            'P_ref': self.power,
            'T_cell': self.temp,
            'gamma_pdc': self.gamma_pdc,
        }

        corr_energy, insolation = normalize_with_pvwatts(self.energy, pvw_kws)

        # Test output is same frequency and length as energy
        self.assertEqual(corr_energy.index.freq, self.energy.index.freq)
        self.assertEqual(len(corr_energy), 12)

        # Test corrected energy is equal to 1.0
        self.assertTrue((corr_energy == 1.0).all())

        # Test expected behavior when energy has no explicit frequency
        self.energy.index.freq = None
        corr_energy, insolation = normalize_with_pvwatts(self.energy, pvw_kws)
        self.assertTrue(np.isnan(
            corr_energy.iloc[0]))  # first valye should be nan
        self.assertTrue(
            (corr_energy.iloc[1:] == 1.0).all())  # rest should be 1

        # Test for valueError when energy frequency can't be inferred
        with self.assertRaises(ValueError):
            corr_energy, insolation = normalize_with_pvwatts(
                self.irregular_timeseries, pvw_kws)
コード例 #2
0
    def test_normalization_with_pvw(self):
        ''' Test PVWatts normalization. '''

        pvw_kws = {
            'poa_global': self.poa_global,
            'power_dc_rated': self.power,
            'temperature_cell': self.temp,
            'gamma_pdc': self.gamma_pdc,
        }

        with pytest.warns(rdtoolsDeprecationWarning):
            corr_energy, insolation = normalize_with_pvwatts(
                self.energy, pvw_kws)
        corr_energy = corr_energy.reindex(self.energy.index)

        # Test output is same frequency and length as energy
        self.assertEqual(corr_energy.index.freq, self.energy.index.freq)
        self.assertEqual(len(corr_energy), 12)

        # Test corrected energy is equal to 1.0
        # first value should be nan because we have no irradiance
        # data prior to the first energy point
        self.assertTrue(np.isnan(corr_energy.iloc[0]))
        self.assertTrue(
            (corr_energy.iloc[1:] == 1.0).all())  # rest should be 1

        # Test expected behavior when energy has no explicit frequency
        self.energy.index.freq = None
        with pytest.warns(rdtoolsDeprecationWarning):
            corr_energy, insolation = normalize_with_pvwatts(
                self.energy, pvw_kws)
        corr_energy = corr_energy.reindex(self.energy.index)
        self.assertTrue(np.isnan(
            corr_energy.iloc[0]))  # first value should be nan
        self.assertTrue(
            (corr_energy.iloc[1:] == 1.0).all())  # rest should be 1

        # Test for valueError when energy frequency can't be inferred
        with self.assertRaises(ValueError):
            with pytest.warns(rdtoolsDeprecationWarning):
                corr_energy, insolation = normalize_with_pvwatts(
                    self.irregular_timeseries, pvw_kws)
コード例 #3
0
    def _pvwatts_norm(self, poa_global, temperature_cell):
        '''
        Normalize PV energy to that expected from a PVWatts model.

        Parameters
        ---------
        poa_global : numeric
            plane of array irradiance in W/m^2
        temperature_cell : numeric
            cell temperature in Celsius

        Returns
        -------
        pandas.Series
            Normalized pv energy
        pandas.Series
            Associated insolation
        '''

        if self.power_dc_rated is None:
            renorm = True
            power_dc_rated = 1.0
        else:
            renorm = False
            power_dc_rated = self.power_dc_rated

        if self.gamma_pdc is None:
            warnings.warn(
                'Temperature coefficient not passed in to TrendAnalysis'
                '. No temperature correction will be conducted.')
        pvwatts_kws = {
            "poa_global": poa_global,
            "power_dc_rated": power_dc_rated,
            "temperature_cell": temperature_cell,
            "poa_global_ref": 1000,
            "temperature_cell_ref": 25,
            "gamma_pdc": self.gamma_pdc
        }

        energy_normalized, insolation = normalization.normalize_with_pvwatts(
            self.pv_energy, pvwatts_kws)

        if renorm:
            # Normalize to the 95th percentile for convenience, this is renormalized out
            # in the calculations but is relevant to normalized_filter()
            x = energy_normalized[np.isfinite(energy_normalized)]
            energy_normalized = energy_normalized / x.quantile(0.95)

        return energy_normalized, insolation
コード例 #4
0
    def test_normalization_with_pvw(self):
        ''' Test PVWatts normalization. '''

        pvw_kws = {
            'poa_global': self.poa_global,
            'P_ref': self.power,
            'T_cell': self.temp,
            'gamma_pdc': self.gamma_pdc,
        }

        corr_energy = normalize_with_pvwatts(self.energy, pvw_kws)

        # Test output is same frequency and length as energy
        self.assertEqual(corr_energy.index.freq, self.energy.index.freq)
        self.assertEqual(len(corr_energy), 12)

        # Test corrected energy is equal to 1.0
        self.assertTrue((corr_energy == 1.0).all())