def semester_to_date_plot(self):
        """Dial plot displaying the shutter open efficiency for the semester in which `self.date` lies.

        All dates in the semester up to but excluding `self.date` are included when calculating the shutter open
        efficiency.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot of the shutter open efficiency for the semester to date.
        """

        sem = semester(self.date)
        binned_df = bin_by_semester(df=self.df,
                                    cutoff_date=self.date,
                                    date_column='Date',
                                    semester_column='Semester')
        current_semester = binned_df[binned_df.Semester == sem]
        if len(current_semester):
            shutter_open_efficiency = self._shutter_open_efficiency(
                current_semester.ShutterOpenTime[0],
                current_semester.ScienceTime[0])
        else:
            shutter_open_efficiency = 0

        dial_color_func = neutral_color_func

        return DialPlot(
            values=[shutter_open_efficiency],
            label_values=range(0, 101, 10),
            dial_color_func=dial_color_func,
            display_values=['{:.1f}%'.format(shutter_open_efficiency)],
            **self.kwargs)
Esempio n. 2
0
    def week_to_date_plot(self):
        """Dial plot displaying the weather downtime for the seven days leading up to but excluding `self.date`.

        The weather downtime is displayed as a percentage relative to the night length. In addition its absolute value
        is displayed in minutes.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot displaying the weather downtime for the last seven days.
        """

        weather_downtime = value_last_week(df=self.df,
                                           date=self.date,
                                           date_column='Date',
                                           value_column='TimeLostToProblems')
        night_length = value_last_week(df=self.df,
                                       date=self.date,
                                       date_column='Date',
                                       value_column='NightLength')
        weather_downtime_percentage = 100 * weather_downtime / night_length

        dial_color_func = good_mediocre_bad_color_func(good_limit=3,
                                                       bad_limit=6)

        return DialPlot(values=[weather_downtime_percentage],
                        label_values=[0, 3, 6] +
                        [v for v in range(10, 101, 10)],
                        dial_color_func=dial_color_func,
                        display_values=[
                            '{:.1f}%'.format(weather_downtime_percentage),
                            '{:d}m'.format(int(weather_downtime / 60))
                        ],
                        **self.kwargs)
    def week_to_date_plot(self):
        """Dial plot displaying the operation efficiency for the seven days leading up to but excluding `self.date`.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot displaying the operation efficiency for the last seven days.
        """

        obs_time = value_last_week(df=self.df,
                                   date=self.date,
                                   date_column='Date',
                                   value_column='ObsTime')
        science_time = value_last_week(df=self.df,
                                       date=self.date,
                                       date_column='Date',
                                       value_column='ScienceTime')
        operation_efficiency = self._observation_efficiency(
            obs_time, science_time)

        dial_color_func = good_mediocre_bad_color_func(bad_limit=80,
                                                       good_limit=90)

        return DialPlot(
            values=[operation_efficiency],
            label_values=range(0, 151, 10),
            dial_color_func=dial_color_func,
            display_values=['{:.1f}%'.format(operation_efficiency)],
            **self.kwargs)
    def last_night_plot(self):
        """Dial plot displaying the weather downtime for the date preceding `self.date`.

        The weather downtime is displayed as a percentage relative to the night length. In addition its absolute value
        is displayed in minutes.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot displaying the weather downtime for last night.
        """

        weather_downtime = value_last_night(df=self.df,
                                            date=self.date,
                                            date_column='Date',
                                            value_column='TimeLostToWeather')
        night_length = value_last_night(df=self.df,
                                        date=self.date,
                                        date_column='Date',
                                        value_column='NightLength')
        weather_downtime_percentage = 100 * weather_downtime / night_length

        dial_color_func = good_mediocre_bad_color_func(good_limit=40,
                                                       bad_limit=45)

        return DialPlot(values=[weather_downtime_percentage],
                        label_values=[v for v in range(0, 41, 10)] + [45] +
                        [v for v in range(50, 101, 10)],
                        dial_color_func=dial_color_func,
                        display_values=[
                            '{:.1f}%'.format(weather_downtime_percentage),
                            '{:d}m'.format(int(weather_downtime / 60))
                        ],
                        **self.kwargs)
    def last_night_plot(self):
        """Dial plot displaying the operation efficiency for last night, i.e. for the date preceding `self.date`.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot displaying the operation efficiency for last night.
        """

        obs_time = value_last_night(df=self.df,
                                    date=self.date,
                                    date_column='Date',
                                    value_column='ObsTime')
        science_time = value_last_night(df=self.df,
                                        date=self.date,
                                        date_column='Date',
                                        value_column='ScienceTime')
        operation_efficiency = self._observation_efficiency(
            obs_time, science_time)

        dial_color_func = good_mediocre_bad_color_func(bad_limit=80,
                                                       good_limit=90)

        return DialPlot(
            values=[operation_efficiency],
            label_values=range(0, 151, 10),
            dial_color_func=dial_color_func,
            display_values=['{:.1f}%'.format(operation_efficiency)],
            **self.kwargs)
    def week_to_date_plot(self):
        """Dial plot displaying the science time for the seven days leading up to but excluding `self.date`.

        The science time is displayed as a percentage relative to the night length. In addition its absolute value
        is displayed in minutes.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot displaying the science time for the last seven days.
        """

        science_time = value_last_week(df=self.df,
                                       date=self.date,
                                       date_column='Date',
                                       value_column='ScienceTime')
        night_length = value_last_week(df=self.df,
                                       date=self.date,
                                       date_column='Date',
                                       value_column='NightLength')
        science_time_percentage = 100 * science_time / night_length

        dial_color_func = good_mediocre_bad_color_func(good_limit=47,
                                                       bad_limit=37)

        return DialPlot(
            values=[science_time_percentage],
            label_values=[0, 10, 20, 30, 37, 47, 60, 70, 80, 90, 100],
            dial_color_func=dial_color_func,
            display_values=[
                '{:.1f}%'.format(science_time_percentage),
                '{:d}m'.format(int(science_time / 60))
            ],
            **self.kwargs)
    def last_night_plot(self):
        """Dial plot displaying the engineering time for the date preceding `self.date`.

        The engineering time is displayed as a percentage relative to the night length. In addition its absolute value
        is displayed in minutes.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot displaying the engineering time for last night.
        """

        engineering_time = value_last_night(df=self.df,
                                            date=self.date,
                                            date_column='Date',
                                            value_column='EngineeringTime')
        night_length = value_last_night(df=self.df, date=self.date, date_column='Date', value_column='NightLength')
        engineering_time_percentage = 100 * engineering_time / night_length

        dial_color_func = good_mediocre_bad_color_func(good_limit=13, bad_limit=18)

        return DialPlot(values=[engineering_time_percentage],
                        label_values=[0, 5, 13, 18] + [v for v in range(30, 101, 10)],
                        dial_color_func=dial_color_func,
                        display_values=['{:.1f}%'.format(engineering_time_percentage),
                                        '{:d}m'.format(int(engineering_time / 60))],
                        **self.kwargs)
    def semester_to_date_plot(self):
        """Dial plot displaying the weather downtime for the semester in which `self.date` lies.

        All dates in the semester up to but excluding `self.date` are included when calculating the shutter open
        efficiency.

        The weather downtime is displayed as a percentage relative to the night length. A second hand shows the average
        percentage which must be achieved in the remaining time of the semester in order to achieve the target
        percentage.

        In addition its absolute value is displayed in hours.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot of the shutter open efficiency for the semester to date.
        """

        sem = semester(self.date)
        binned_df = bin_by_semester(df=self.df,
                                    cutoff_date=self.date,
                                    date_column='Date',
                                    semester_column='Semester')
        current_semester = binned_df[binned_df.Semester == sem]
        target_percentage = 55
        if len(current_semester):
            weather_downtime_percentage = 100 * current_semester.TimeLostToWeather[
                0] / current_semester.NightLength[0]
            required_percentage = required_for_semester_average(
                self.date, weather_downtime_percentage, target_percentage)
            weather_downtime = current_semester.TimeLostToWeather[0] / 3600
        else:
            weather_downtime_percentage = 0
            required_percentage = target_percentage
            weather_downtime = 0

        dial_color_func = good_mediocre_bad_color_func(good_limit=49,
                                                       bad_limit=40)

        return DialPlot(
            values=[weather_downtime_percentage, required_percentage],
            label_values=[v for v in range(0, 41, 10)] + [45] +
            [v for v in range(50, 101, 10)],
            dial_color_func=dial_color_func,
            display_values=[
                '{:.1f}%'.format(weather_downtime_percentage),
                '{:.1f}h'.format(weather_downtime)
            ],
            **self.kwargs)
    def week_to_date_plot(self):
        """Dial plot displaying the number of block visits in the seven days leading up to but excluding `self.date`.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot displaying the number of block visits for the last seven days.
        """

        block_visits = value_last_week(df=self.df,
                                       date=self.date,
                                       date_column='Date',
                                       value_column='BlockCount')
        return DialPlot(values=[block_visits],
                        label_values=range(0, 71, 10),
                        dial_color_func=lambda d: '#7f7f7f',
                        display_values=[str(block_visits)],
                        **self.kwargs)
    def last_night_plot(self):
        """Dial plot displaying the number of block visits for the date preceding `self.date`.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot for last night's number of block visits.
        """

        block_visits = value_last_night(df=self.df,
                                        date=self.date,
                                        date_column='Date',
                                        value_column='BlockCount')
        return DialPlot(values=[block_visits],
                        label_values=range(0, 13),
                        dial_color_func=lambda d: '#7f7f7f',
                        display_values=[str(block_visits)],
                        **self.kwargs)
    def last_night_plot(self):
        """Dial plot displaying the operation efficiency for last night."""

        shutter_open_time = value_last_night(df=self.df,
                                             date=self.date,
                                             date_column='Date',
                                             value_column='ShutterOpenTime')
        science_time = value_last_night(df=self.df,
                                        date=self.date,
                                        date_column='Date',
                                        value_column='ScienceTime')
        shutter_open_efficiency = self._shutter_open_efficiency(
            shutter_open_time, science_time)

        return DialPlot(
            values=[shutter_open_efficiency],
            label_values=range(0, 151, 10),
            dial_color_func=neutral_color_func,
            display_values=[str(round(shutter_open_efficiency, 1)) + '%'])
    def week_to_date_plot(self):
        """Dial plot displaying the operation efficiency for the seven days leading up to but excluding `self.date`."""

        shutter_open_time = value_last_week(df=self.df,
                                            date=self.date,
                                            date_column='Date',
                                            value_column='ShutterOpenTime')
        science_time = value_last_week(df=self.df,
                                       date=self.date,
                                       date_column='Date',
                                       value_column='ScienceTime')
        shutter_open_efficiency = self._shutter_open_efficiency(
            shutter_open_time, science_time)

        return DialPlot(
            values=[shutter_open_efficiency],
            label_values=range(0, 151, 10),
            dial_color_func=neutral_color_func,
            display_values=[str(round(shutter_open_efficiency, 1)) + '%'],
            **self.kwargs)
    def semester_to_date_plot(self):
        """Dial plot displaying the operation efficiency for the semester in which `self.date` lies.

        All dates in the semester up to but excluding `self.date` are included when calculating the operation
        efficiency.

        Returns:
        --------
        app.plot.plot.DialPlot
            Plot of the operation efficiency for the semester to date.
        """

        sem = semester(self.date)
        binned_df = bin_by_semester(df=self.df,
                                    cutoff_date=self.date,
                                    date_column='Date',
                                    semester_column='Semester')
        current_semester = binned_df[binned_df.Semester == sem]
        if len(current_semester):
            operation_efficiency = self._observation_efficiency(
                current_semester.ObsTime[0], current_semester.ScienceTime[0])
        else:
            operation_efficiency = 0

        dial_color_func = good_mediocre_bad_color_func(good_limit=90,
                                                       bad_limit=80)

        required_operation_efficiency = required_for_semester_average(
            date=self.date, average=operation_efficiency, target_average=90)

        return DialPlot(
            values=[operation_efficiency, required_operation_efficiency],
            label_values=range(0, 101, 10),
            dial_color_func=dial_color_func,
            display_values=['{:.1f}%'.format(operation_efficiency)],
            **self.kwargs)