Ejemplo n.º 1
0
    def set_active_time_interval(self, *intervals, **kwargs):
        """
        Set the time interval to be used during the analysis.
        For now, only one interval can be selected. This may be
        updated in the future to allow for self consistent time
        resolved analysis.
        Specified as 'tmin-tmax'. Intervals are in seconds. Example:

        set_active_time_interval("0.0-10.0")

        which will set the energy range 0-10. seconds.
        :param options:
        :param intervals:
        :return:
        """

        self._time_series.set_active_time_intervals(*intervals)

        # extract a spectrum

        if self._response is None:

            self._observed_spectrum = BinnedSpectrum.from_time_series(
                self._time_series, use_poly=False)

        else:

            if self._rsp_is_weighted:
                self._response = self._weighted_rsp.weight_by_counts(
                    *self._time_series.time_intervals.to_string().split(','))

            self._observed_spectrum = BinnedSpectrumWithDispersion.from_time_series(
                self._time_series, self._response, use_poly=False)

        self._active_interval = intervals

        if self._time_series.poly_fit_exists:

            if self._response is None:

                self._background_spectrum = BinnedSpectrum.from_time_series(
                    self._time_series, use_poly=True)

            else:

                self._background_spectrum = BinnedSpectrumWithDispersion.from_time_series(
                    self._time_series, self._response, use_poly=True)

        self._tstart = self._time_series.time_intervals.absolute_start_time
        self._tstop = self._time_series.time_intervals.absolute_stop_time
Ejemplo n.º 2
0
    def set_background_interval(self, *intervals, **options):
        """
        Set the time interval to fit the background.
        Multiple intervals can be input as separate arguments
        Specified as 'tmin-tmax'. Intervals are in seconds. Example:

        setBackgroundInterval("-10.0-0.0","10.-15.")


        :param *intervals:
        :param **options:

        :return: none

        """
        if 'unbinned' in options:

            unbinned = options.pop('unbinned')
        else:

            unbinned = self._default_unbinned

        self._time_series.set_polynomial_fit_interval(*intervals,
                                                      unbinned=unbinned)

        # In theory this will automatically get the poly counts if a
        # time interval already exists

        if self._active_interval is not None:

            if self._response is None:

                self._background_spectrum = BinnedSpectrum.from_time_series(
                    self._time_series, use_poly=True)

            else:

                # we do not need to worry about the interval of the response if it is a set. only the ebounds are extracted here

                self._background_spectrum = BinnedSpectrumWithDispersion.from_time_series(
                    self._time_series, self._response, use_poly=True)