示例#1
0
    def disaggregate_radiation(self, method='pot_rad'):
        """
        Disaggregate solar radiation.

        Parameters
        ----------
        method : str, optional
            Disaggregation method.

            ``pot_rad``
                Calculates potential clear-sky hourly radiation and scales it according to the
                mean daily radiation. (Default)

            ``pot_rad_via_ssd``
                Calculates potential clear-sky hourly radiation and scales it according to the
                observed daily sunshine duration.

            ``pot_rad_via_bc``
                Calculates potential clear-sky hourly radiation and scales it according to daily
                minimum and maximum temperature.
        """
        if self.sun_times is None:
            self.calc_sun_times()

        self.data_disagg.glob = melodist.disaggregate_radiation(
            self.data_daily,
            self.sun_times,
            melodist.potential_radiation(self.data_disagg.index, self.lon,
                                         self.lat, self.timezone),
            method=method,
            angstr_a=self.statistics.glob.angstroem_a,
            angstr_b=self.statistics.glob.angstroem_b,
            bristcamp_a=self.statistics.glob.bristcamp_a,
            bristcamp_c=self.statistics.glob.bristcamp_c)
示例#2
0
    def disaggregate_radiation(self, method='pot_rad'):
        """
        Disaggregate solar radiation.

        Parameters
        ----------
        method : str, optional
            Disaggregation method.

            ``pot_rad``
                Calculates potential clear-sky hourly radiation and scales it according to the
                mean daily radiation. (Default)

            ``pot_rad_via_ssd``
                Calculates potential clear-sky hourly radiation and scales it according to the
                observed daily sunshine duration.

            ``pot_rad_via_bc``
                Calculates potential clear-sky hourly radiation and scales it according to daily
                minimum and maximum temperature.
        """
        if self.sun_times is None:
            self.calc_sun_times()

        self.data_disagg.glob = melodist.disaggregate_radiation(
            self.data_daily,
            self.sun_times,
            melodist.potential_radiation(self.data_disagg.index, self.lon, self.lat, self.timezone),
            method=method,
            angstr_a=self.statistics.glob.angstroem_a,
            angstr_b=self.statistics.glob.angstroem_b,
            bristcamp_a=self.statistics.glob.bristcamp_a,
            bristcamp_c=self.statistics.glob.bristcamp_c
        )
    def calc_radiation_stats(self, data_daily, day_length=None):
        """
        Calculates statistics in order to derive solar radiation from sunshine duration or
        minimum/maximum temperature.

        Parameters
        ----------
        data_daily : DataFrame
            Daily data from the associated ``Station`` object.

        day_length : Series, optional
            Day lengths as calculated by ``calc_sun_times``.
        """
        if 'ssd' in data_daily and day_length is not None:
            df = pd.DataFrame(
                data=dict(ssd=data_daily.ssd, day_length=day_length)).dropna(
                    how='any')
            pot_rad = melodist.potential_radiation(
                melodist.util.hourly_index(df.index), self._lon, self._lat,
                self._timezone)
            pot_rad_daily = pot_rad.resample('D', how='mean')
            obs_rad_daily = self.data.glob.resample('D', how='mean')
            a, b = melodist.fit_angstroem_params(data_daily.ssd, day_length,
                                                 pot_rad_daily, obs_rad_daily)
            self.glob.angstroem_a = a
            self.glob.angstroem_b = b

        if 'tmin' in data_daily and 'tmax' in data_daily:
            pot_rad = melodist.potential_radiation(
                melodist.util.hourly_index(df.index), self._lon, self._lat,
                self._timezone)
            pot_rad_daily = pot_rad.resample('D', how='mean')
            obs_rad_daily = self.data.glob.resample('D', how='mean')
            df = pd.DataFrame(data=dict(
                tmin=data_daily.tmin,
                tmax=data_daily.tmax,
                pot_rad=pot_rad_daily,
                obs_rad=obs_rad_daily,
            )).dropna(how='any')
            a, c = melodist.fit_bristow_campbell_params(
                df.tmin, df.tmax, df.pot_rad, df.obs_rad)
            self.glob.bristcamp_a = a
            self.glob.bristcamp_c = c
示例#4
0
    def disaggregate_radiation(self, method='pot_rad', pot_rad=None):
        """
        Disaggregate solar radiation.

        Parameters
        ----------
        method : str, optional
            Disaggregation method.

            ``pot_rad``
                Calculates potential clear-sky hourly radiation and scales it according to the
                mean daily radiation. (Default)

            ``pot_rad_via_ssd``
                Calculates potential clear-sky hourly radiation and scales it according to the
                observed daily sunshine duration.

            ``pot_rad_via_bc``
                Calculates potential clear-sky hourly radiation and scales it according to daily
                minimum and maximum temperature.

            ``mean_course``
                Hourly radiation follows an observed average course (calculated for each month).

        pot_rad : Series, optional
            Hourly values of potential solar radiation. If ``None``, calculated internally.
        """
        if self.sun_times is None:
            self.calc_sun_times()

        if pot_rad is None and method != 'mean_course':
            pot_rad = melodist.potential_radiation(self.data_disagg.index,
                                                   self.lon, self.lat,
                                                   self.timezone)

        self.data_disagg.glob = melodist.disaggregate_radiation(
            self.data_daily,
            sun_times=self.sun_times,
            pot_rad=pot_rad,
            method=method,
            angstr_a=self.statistics.glob.angstroem.a,
            angstr_b=self.statistics.glob.angstroem.b,
            bristcamp_a=self.statistics.glob.bristcamp.a,
            bristcamp_c=self.statistics.glob.bristcamp.c,
            mean_course=self.statistics.glob.mean_course)
示例#5
0
    def disaggregate_radiation(self, method='pot_rad', pot_rad=None):
        """
        Disaggregate solar radiation.

        Parameters
        ----------
        method : str, optional
            Disaggregation method.

            ``pot_rad``
                Calculates potential clear-sky hourly radiation and scales it according to the
                mean daily radiation. (Default)

            ``pot_rad_via_ssd``
                Calculates potential clear-sky hourly radiation and scales it according to the
                observed daily sunshine duration.

            ``pot_rad_via_bc``
                Calculates potential clear-sky hourly radiation and scales it according to daily
                minimum and maximum temperature.

            ``mean_course``
                Hourly radiation follows an observed average course (calculated for each month).

        pot_rad : Series, optional
            Hourly values of potential solar radiation. If ``None``, calculated internally.
        """
        if self.sun_times is None:
            self.calc_sun_times()

        if pot_rad is None and method != 'mean_course':
            pot_rad = melodist.potential_radiation(self.data_disagg.index, self.lon, self.lat, self.timezone)

        self.data_disagg.glob = melodist.disaggregate_radiation(
            self.data_daily,
            sun_times=self.sun_times,
            pot_rad=pot_rad,
            method=method,
            angstr_a=self.statistics.glob.angstroem.a,
            angstr_b=self.statistics.glob.angstroem.b,
            bristcamp_a=self.statistics.glob.bristcamp.a,
            bristcamp_c=self.statistics.glob.bristcamp.c,
            mean_course=self.statistics.glob.mean_course
        )
示例#6
0
    def calc_radiation_stats(self,
                             data_daily=None,
                             day_length=None,
                             how='all'):
        """
        Calculates statistics in order to derive solar radiation from sunshine duration or
        minimum/maximum temperature.

        Parameters
        ----------
        data_daily : DataFrame, optional
            Daily data from the associated ``Station`` object.

        day_length : Series, optional
            Day lengths as calculated by ``calc_sun_times``.
        """
        assert how in ('all', 'seasonal', 'monthly')

        self.glob.mean_course = melodist.util.calculate_mean_daily_course_by_month(
            self.data.glob)

        if data_daily is not None:
            pot_rad = melodist.potential_radiation(
                melodist.util.hourly_index(data_daily.index), self._lon,
                self._lat, self._timezone)
            pot_rad_daily = pot_rad.resample('D').mean()
            obs_rad_daily = self.data.glob.resample('D').mean()

            if how == 'all':
                month_ranges = [np.arange(12) + 1]
            elif how == 'seasonal':
                month_ranges = [[3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 1, 2]]
            elif how == 'monthly':
                month_ranges = zip(np.arange(12) + 1)

            def myisin(s, v):
                return pd.Series(s).isin(v).values

            def extract_months(s, months):
                return s[myisin(s.index.month, months)]

            if 'ssd' in data_daily and day_length is not None:
                for months in month_ranges:
                    a, b = melodist.fit_angstroem_params(
                        extract_months(data_daily.ssd, months),
                        extract_months(day_length, months),
                        extract_months(pot_rad_daily, months),
                        extract_months(obs_rad_daily, months),
                    )

                    for month in months:
                        self.glob.angstroem.loc[month] = a, b

            if 'tmin' in data_daily and 'tmax' in data_daily:
                df = pd.DataFrame(data=dict(
                    tmin=data_daily.tmin,
                    tmax=data_daily.tmax,
                    pot_rad=pot_rad_daily,
                    obs_rad=obs_rad_daily,
                )).dropna(how='any')

                for months in month_ranges:
                    a, c = melodist.fit_bristow_campbell_params(
                        extract_months(df.tmin, months),
                        extract_months(df.tmax, months),
                        extract_months(df.pot_rad, months),
                        extract_months(df.obs_rad, months),
                    )

                    for month in months:
                        self.glob.bristcamp.loc[month] = a, c
    def calc_radiation_stats(self, data_daily=None, day_length=None, how='all'):
        """
        Calculates statistics in order to derive solar radiation from sunshine duration or
        minimum/maximum temperature.

        Parameters
        ----------
        data_daily : DataFrame, optional
            Daily data from the associated ``Station`` object.

        day_length : Series, optional
            Day lengths as calculated by ``calc_sun_times``.
        """
        assert how in ('all', 'seasonal', 'monthly')

        self.glob.mean_course = melodist.util.calculate_mean_daily_course_by_month(self.data.glob)

        if data_daily is not None:
            pot_rad = melodist.potential_radiation(
                melodist.util.hourly_index(data_daily.index),
                self._lon, self._lat, self._timezone)
            pot_rad_daily = pot_rad.resample('D').mean()
            obs_rad_daily = self.data.glob.resample('D').mean()

            if how == 'all':
                month_ranges = [np.arange(12) + 1]
            elif how == 'seasonal':
                month_ranges = [[3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 1, 2]]
            elif how == 'monthly':
                month_ranges = zip(np.arange(12) + 1)

            def myisin(s, v):
                return pd.Series(s).isin(v).values

            def extract_months(s, months):
                return s[myisin(s.index.month, months)]

            if 'ssd' in data_daily and day_length is not None:
                for months in month_ranges:
                    a, b = melodist.fit_angstroem_params(
                        extract_months(data_daily.ssd, months),
                        extract_months(day_length, months),
                        extract_months(pot_rad_daily, months),
                        extract_months(obs_rad_daily, months),
                    )

                    for month in months:
                        self.glob.angstroem.loc[month] = a, b

            if 'tmin' in data_daily and 'tmax' in data_daily:
                df = pd.DataFrame(
                    data=dict(
                        tmin=data_daily.tmin,
                        tmax=data_daily.tmax,
                        pot_rad=pot_rad_daily,
                        obs_rad=obs_rad_daily,
                    )
                ).dropna(how='any')

                for months in month_ranges:
                    a, c = melodist.fit_bristow_campbell_params(
                        extract_months(df.tmin, months),
                        extract_months(df.tmax, months),
                        extract_months(df.pot_rad, months),
                        extract_months(df.obs_rad, months),
                    )

                    for month in months:
                        self.glob.bristcamp.loc[month] = a, c