def test_deprecated_07():
    with pytest.warns(pvlibDeprecationWarning):
        irradiance.extraradiation(300)
    with pytest.warns(pvlibDeprecationWarning):
        irradiance.grounddiffuse(40, 900)
    with pytest.warns(pvlibDeprecationWarning):
        irradiance.total_irrad(32, 180, 10, 180, 0, 0, 0, 1400, 1)
    with pytest.warns(pvlibDeprecationWarning):
        irradiance.globalinplane(0, 1000, 100, 10)
예제 #2
0
def test_deprecated_07():
    with pytest.warns(pvlibDeprecationWarning):
        irradiance.extraradiation(300)
    with pytest.warns(pvlibDeprecationWarning):
        irradiance.grounddiffuse(40, 900)
    with pytest.warns(pvlibDeprecationWarning):
        irradiance.total_irrad(32, 180, 10, 180, 0, 0, 0, 1400, 1)
    with pytest.warns(pvlibDeprecationWarning):
        irradiance.globalinplane(0, 1000, 100, 10)
예제 #3
0
    def get_poa(self,
                dates,
                ghi,
                dhi,
                dni,
                sun_zenith,
                sun_azimuth,
                dni_extra=None,
                airmass=None,
                model="haydavies"):

        if self.method == "pvlib":

            sun_zenith = deg(sun_zenith)
            sun_azimuth = deg(sun_azimuth)

            if dni_extra is None:
                dni_extra = irradiance.extraradiation(DatetimeIndex(dates))
            if airmass is None:
                airmass = atmosphere.relativeairmass(sun_zenith)

            poa = irradiance.total_irrad(self.tilt,
                                         self.azimuth,
                                         sun_zenith,
                                         sun_azimuth,
                                         dni,
                                         ghi,
                                         dhi,
                                         dni_extra=dni_extra,
                                         airmass=airmass,
                                         model=model,
                                         albedo=self.albedo)

            self.poa = poa['poa_global']
예제 #4
0
def test_total_irrad():
    models = ['isotropic', 'klutcher', 'haydavies', 'reindl', 'king', 'perez']
    AM = atmosphere.relativeairmass(ephem_data['apparent_zenith'])

    for model in models:
        total = irradiance.total_irrad(
            32, 180, 
            ephem_data['apparent_zenith'], ephem_data['azimuth'],
            dni=irrad_data['dni'], ghi=irrad_data['ghi'], dhi=irrad_data['dhi'],
            dni_extra=dni_et, airmass=AM,
            model=model,
            surface_type='urban')
예제 #5
0
def get_perfect_voltage_for_a_day(start, freq):
    """This method is used to build a pandas serie with voltage values.
    This serie has DateTime index and contains a value for every "freq"
    seconds during 24 hours starting from "start" date.
    There are several assumptions:
    1. Location is Munich
    2. A battery is pointing to the south, amount of blocks is 20
    3. Sandia Module database is used
    4. pvlib library is heavily used

    :param start: datetime. First timestamp in result series
    :param freq: str. How often voltage should be sampled
    :return: voltage : Series
    """
    surface_tilt = _munich_location.latitude
    surface_azimuth = 180  # pointing south
    date_range = pd.date_range(start=start,
                               end=start + dt.timedelta(
                                   hours=23, minutes=59, seconds=59),
                               freq=freq, tz=_munich_location.tz)

    clearsky_estimations = _munich_location.get_clearsky(date_range)
    dni_extra = irradiance.extraradiation(date_range)
    solar_position = solarposition.get_solarposition(
        date_range, _munich_location.latitude, _munich_location.longitude)
    airmass = atmosphere.relativeairmass(solar_position['apparent_zenith'])
    pressure = atmosphere.alt2pres(_munich_location.altitude)
    am_abs = atmosphere.absoluteairmass(airmass, pressure)

    total_irrad = irradiance.total_irrad(surface_tilt,
                                         surface_azimuth,
                                         solar_position['apparent_zenith'],
                                         solar_position['azimuth'],
                                         clearsky_estimations['dni'],
                                         clearsky_estimations['ghi'],
                                         clearsky_estimations['dhi'],
                                         dni_extra=dni_extra,
                                         model='haydavies')

    temps = pvsystem.sapm_celltemp(total_irrad['poa_global'], 0, 15)
    aoi = irradiance.aoi(surface_tilt, surface_azimuth,
                         solar_position['apparent_zenith'],
                         solar_position['azimuth'])
    # add 0.0001 to avoid np.log(0) and warnings about that
    effective_irradiance = pvsystem.sapm_effective_irradiance(
        total_irrad['poa_direct'], total_irrad['poa_diffuse'], am_abs,
        aoi, _sandia_module) + 0.0001
    sapm = pvsystem.sapm(effective_irradiance, temps['temp_cell'],
                         _sandia_module)

    return sapm['p_mp'] * _module_count
예제 #6
0
def test_total_irrad_scalars(model):
    total = irradiance.total_irrad(
        32, 180,
        10, 180,
        dni=1000, ghi=1100,
        dhi=100,
        dni_extra=1400, airmass=1,
        model=model,
        surface_type='urban')

    assert list(total.keys()) == ['poa_global', 'poa_direct',
                                  'poa_diffuse', 'poa_sky_diffuse',
                                  'poa_ground_diffuse']
    # test that none of the values are nan
    assert np.isnan(np.array(list(total.values()))).sum() == 0
예제 #7
0
def test_total_irrad_scalars(model):
    total = irradiance.total_irrad(
        32, 180,
        10, 180,
        dni=1000, ghi=1100,
        dhi=100,
        dni_extra=1400, airmass=1,
        model=model,
        surface_type='urban')

    assert list(total.keys()) == ['poa_global', 'poa_direct',
                                  'poa_diffuse', 'poa_sky_diffuse',
                                  'poa_ground_diffuse']
    # test that none of the values are nan
    assert np.isnan(np.array(list(total.values()))).sum() == 0
예제 #8
0
def test_total_irrad():
    models = ['isotropic', 'klutcher', 'haydavies', 'reindl', 'king', 'perez']
    AM = atmosphere.relativeairmass(ephem_data['apparent_zenith'])

    for model in models:
        total = irradiance.total_irrad(32,
                                       180,
                                       ephem_data['apparent_zenith'],
                                       ephem_data['azimuth'],
                                       dni=irrad_data['dni'],
                                       ghi=irrad_data['ghi'],
                                       dhi=irrad_data['dhi'],
                                       dni_extra=dni_et,
                                       airmass=AM,
                                       model=model,
                                       surface_type='urban')
예제 #9
0
def test_total_irrad():
    models = ['isotropic', 'klutcher', 'klucher',
              'haydavies', 'reindl', 'king', 'perez']
    AM = atmosphere.relativeairmass(ephem_data['apparent_zenith'])

    for model in models:
        total = irradiance.total_irrad(
            32, 180,
            ephem_data['apparent_zenith'], ephem_data['azimuth'],
            dni=irrad_data['dni'], ghi=irrad_data['ghi'],
            dhi=irrad_data['dhi'],
            dni_extra=dni_et, airmass=AM,
            model=model,
            surface_type='urban')

        assert total.columns.tolist() == ['poa_global', 'poa_direct',
                                          'poa_diffuse', 'poa_sky_diffuse',
                                          'poa_ground_diffuse']
예제 #10
0
def test_total_irrad():
    models = ['isotropic', 'klutcher', 'klucher',
              'haydavies', 'reindl', 'king', 'perez']
    AM = atmosphere.relativeairmass(ephem_data['apparent_zenith'])

    for model in models:
        total = irradiance.total_irrad(
            32, 180,
            ephem_data['apparent_zenith'], ephem_data['azimuth'],
            dni=irrad_data['dni'], ghi=irrad_data['ghi'],
            dhi=irrad_data['dhi'],
            dni_extra=dni_et, airmass=AM,
            model=model,
            surface_type='urban')

        assert total.columns.tolist() == ['poa_global', 'poa_direct',
                                          'poa_diffuse', 'poa_sky_diffuse',
                                          'poa_ground_diffuse']
예제 #11
0
    def tilt_irr(self,
                 surface_tilt=None,
                 surface_azimuth=180,
                 include_solar_pos=False) -> pd.DataFrame:
        """
        Calculate the irradiances(DNI) and angle of incidence (aoi) on a tilted surface

        :param surface_tilt: The surface tilt angle (in degree).
        :param surface_azimuth: The azimuth angle of the surface. Default is 180 degrees.
        :param include_solar_pos: whether to include solar position in the output dataframe.
        :return: a dataframe with calculated solar incidence.
        """

        if surface_tilt is None:
            surface_tilt = self.latitude

        ngo = Location(latitude=self.latitude,
                       longitude=self.longitude,
                       altitude=0,
                       tz='Japan')
        solar_pos = ngo.get_solarposition(
            pd.DatetimeIndex(self.hour_df['avg_time']))

        dni_arr = self.get_DNI()

        irrad_df = total_irrad(surface_tilt=surface_tilt,
                               surface_azimuth=surface_azimuth,
                               apparent_zenith=solar_pos['apparent_zenith'],
                               azimuth=solar_pos['azimuth'],
                               dni=dni_arr,
                               ghi=self.hour_df['GHI'],
                               dhi=self.hour_df['dHI'])

        irrad_df['aoi'] = aoi(surface_tilt, surface_azimuth,
                              solar_pos['zenith'], solar_pos['azimuth'])

        irrad_df['DNI'] = dni_arr

        n_df = pd.concat([self.hour_df, irrad_df], axis=1)

        if include_solar_pos:
            n_df = pd.concat([n_df, solar_pos], axis=1)

        return n_df
예제 #12
0
    def get_irradiance(self,
                       dni,
                       ghi,
                       dhi,
                       dni_extra=None,
                       airmass=None,
                       model='haydavies',
                       **kwargs):
        """
        Uses the :func:`irradiance.total_irrad` function to calculate
        the plane of array irradiance components on a tilted surface
        defined by ``self.surface_tilt``, ``self.surface_azimuth``, and
        ``self.albedo``.

        Parameters
        ----------
        solar_zenith : float or Series.
            Solar zenith angle.
        solar_azimuth : float or Series.
            Solar azimuth angle.
        dni : float or Series
            Direct Normal Irradiance
        ghi : float or Series
            Global horizontal irradiance
        dhi : float or Series
            Diffuse horizontal irradiance
        dni_extra : float or Series
            Extraterrestrial direct normal irradiance
        airmass : float or Series
            Airmass
        model : String
            Irradiance model.

        **kwargs
            Passed to :func:`irradiance.total_irrad`.

        Returns
        -------
        poa_irradiance : DataFrame
            Column names are: ``total, beam, sky, ground``.
        """

        surface_tilt = kwargs.pop('surface_tilt', self.surface_tilt)
        surface_azimuth = kwargs.pop('surface_azimuth', self.surface_azimuth)

        try:
            solar_zenith = kwargs['solar_zenith']
        except KeyError:
            solar_zenith = self.solar_zenith

        try:
            solar_azimuth = kwargs['solar_azimuth']
        except KeyError:
            solar_azimuth = self.solar_azimuth

        # not needed for all models, but this is easier
        if dni_extra is None:
            dni_extra = irradiance.extraradiation(solar_zenith.index)
            dni_extra = pd.Series(dni_extra, index=solar_zenith.index)

        if airmass is None:
            airmass = atmosphere.relativeairmass(solar_zenith)

        return irradiance.total_irrad(surface_tilt,
                                      surface_azimuth,
                                      solar_zenith,
                                      solar_azimuth,
                                      dni,
                                      ghi,
                                      dhi,
                                      dni_extra=dni_extra,
                                      airmass=airmass,
                                      model=model,
                                      albedo=self.albedo,
                                      **kwargs)
예제 #13
0
    def get_irradiance(self,
                       surface_tilt,
                       surface_azimuth,
                       solar_zenith,
                       solar_azimuth,
                       dni,
                       ghi,
                       dhi,
                       dni_extra=None,
                       airmass=None,
                       model='haydavies',
                       **kwargs):
        """
        Uses the :func:`irradiance.total_irrad` function to calculate
        the plane of array irradiance components on a tilted surface
        defined by the input data and ``self.albedo``.

        For a given set of solar zenith and azimuth angles, the
        surface tilt and azimuth parameters are typically determined
        by :py:method:`~SingleAxisTracker.singleaxis`.

        Parameters
        ----------
        surface_tilt : numeric
            Panel tilt from horizontal.
        surface_azimuth : numeric
            Panel azimuth from north
        solar_zenith : numeric
            Solar zenith angle.
        solar_azimuth : numeric
            Solar azimuth angle.
        dni : float or Series
            Direct Normal Irradiance
        ghi : float or Series
            Global horizontal irradiance
        dhi : float or Series
            Diffuse horizontal irradiance
        dni_extra : float or Series, default None
            Extraterrestrial direct normal irradiance
        airmass : float or Series, default None
            Airmass
        model : String, default 'haydavies'
            Irradiance model.

        **kwargs
            Passed to :func:`irradiance.total_irrad`.

        Returns
        -------
        poa_irradiance : DataFrame
            Column names are: ``total, beam, sky, ground``.
        """

        # not needed for all models, but this is easier
        if dni_extra is None:
            dni_extra = irradiance.extraradiation(solar_zenith.index)

        if airmass is None:
            airmass = atmosphere.relativeairmass(solar_zenith)

        return irradiance.total_irrad(surface_tilt,
                                      surface_azimuth,
                                      solar_zenith,
                                      solar_azimuth,
                                      dni,
                                      ghi,
                                      dhi,
                                      dni_extra=dni_extra,
                                      airmass=airmass,
                                      model=model,
                                      albedo=self.albedo,
                                      **kwargs)
예제 #14
0
    def get_irradiance(self, surface_tilt, surface_azimuth,
                       solar_zenith, solar_azimuth, dni, ghi, dhi,
                       dni_extra=None, airmass=None, model='haydavies',
                       **kwargs):
        """
        Uses the :func:`irradiance.total_irrad` function to calculate
        the plane of array irradiance components on a tilted surface
        defined by the input data and ``self.albedo``.

        For a given set of solar zenith and azimuth angles, the
        surface tilt and azimuth parameters are typically determined
        by :py:method:`~SingleAxisTracker.singleaxis`.

        Parameters
        ----------
        surface_tilt : numeric
            Panel tilt from horizontal.
        surface_azimuth : numeric
            Panel azimuth from north
        solar_zenith : numeric
            Solar zenith angle.
        solar_azimuth : numeric
            Solar azimuth angle.
        dni : float or Series
            Direct Normal Irradiance
        ghi : float or Series
            Global horizontal irradiance
        dhi : float or Series
            Diffuse horizontal irradiance
        dni_extra : float or Series, default None
            Extraterrestrial direct normal irradiance
        airmass : float or Series, default None
            Airmass
        model : String, default 'haydavies'
            Irradiance model.

        **kwargs
            Passed to :func:`irradiance.total_irrad`.

        Returns
        -------
        poa_irradiance : DataFrame
            Column names are: ``total, beam, sky, ground``.
        """

        # not needed for all models, but this is easier
        if dni_extra is None:
            dni_extra = irradiance.extraradiation(solar_zenith.index)

        if airmass is None:
            airmass = atmosphere.relativeairmass(solar_zenith)

        return irradiance.total_irrad(surface_tilt,
                                      surface_azimuth,
                                      solar_zenith,
                                      solar_azimuth,
                                      dni, ghi, dhi,
                                      dni_extra=dni_extra, airmass=airmass,
                                      model=model,
                                      albedo=self.albedo,
                                      **kwargs)
예제 #15
0
    def get_irradiance(self, dni, ghi, dhi,
                       dni_extra=None, airmass=None, model='haydavies',
                       **kwargs):
        """
        Uses the :func:`irradiance.total_irrad` function to calculate
        the plane of array irradiance components on a tilted surface
        defined by 
        ``self.surface_tilt``, ``self.surface_azimuth``, and
        ``self.albedo``.
        
        Parameters
        ----------
        solar_zenith : float or Series.
            Solar zenith angle.
        solar_azimuth : float or Series.
            Solar azimuth angle.
        dni : float or Series
            Direct Normal Irradiance
        ghi : float or Series
            Global horizontal irradiance
        dhi : float or Series
            Diffuse horizontal irradiance
        dni_extra : float or Series
            Extraterrestrial direct normal irradiance
        airmass : float or Series
            Airmass
        model : String
            Irradiance model.
        
        **kwargs
            Passed to :func:`irradiance.total_irrad`.
        
        Returns
        -------
        poa_irradiance : DataFrame
            Column names are: ``total, beam, sky, ground``.
        """

        surface_tilt = kwargs.pop('surface_tilt', self.surface_tilt)
        surface_azimuth = kwargs.pop('surface_azimuth', self.surface_azimuth)
        
        try:
            solar_zenith = kwargs['solar_zenith']
        except KeyError:
            solar_zenith = self.solar_zenith
        
        try:
            solar_azimuth = kwargs['solar_azimuth']
        except KeyError:
            solar_azimuth = self.solar_azimuth

        # not needed for all models, but this is easier
        if dni_extra is None:
            dni_extra = irradiance.extraradiation(solar_zenith.index)
            dni_extra = pd.Series(dni_extra, index=solar_zenith.index)

        if airmass is None:
            airmass = atmosphere.relativeairmass(solar_zenith)

        return irradiance.total_irrad(surface_tilt,
                                      surface_azimuth,
                                      solar_zenith,
                                      solar_azimuth,
                                      dni, ghi, dhi,
                                      dni_extra=dni_extra, airmass=airmass,
                                      model=model,
                                      albedo=self.albedo,
                                      **kwargs)