Exemple #1
0
    def determine_point_statistics(self, flight, competition_day):

        self.pointwise_all = self.get_difference_bib()
        for leg in range(competition_day.no_legs):
            self.pointwise_leg.append(self.get_difference_bib())

        phase_number = 0
        leg = 0
        phase = self.all[phase_number]['phase']

        for i in range(flight.b_records.__len__()):
            if flight.tsk_i[0] <= i < flight.tsk_i[-1]:

                if self.all[phase_number]['i_end'] == i:
                    phase_number += 1
                    phase = self.all[phase_number]['phase']

                if i == flight.tsk_i[leg]:
                    leg += 1

                height_difference = det_height(flight.b_records[i+1], flight.gps_altitude) -\
                                    det_height(flight.b_records[i], flight.gps_altitude)
                height = det_height(flight.b_records[i], flight.gps_altitude)
                distance = determine_distance(flight.b_records[i], flight.b_records[i+1], 'pnt', 'pnt')
                time_difference = det_local_time(flight.b_records[i+1], competition_day.utc_to_local) -\
                                  det_local_time(flight.b_records[i], competition_day.utc_to_local)
                time_secs = det_local_time(flight.b_records[i], competition_day.utc_to_local)
                date_obj = datetime.datetime(2014, 6, 21) + datetime.timedelta(seconds=time_secs)
                distance_task = determine_flown_task_distance(leg, flight.b_records[i], competition_day)

                difference_indicators = {'height_difference': height_difference,
                                         'height': height,
                                         'distance': distance,
                                         'distance_task': distance_task,
                                         'time_difference': time_difference,
                                         'time': date_obj,
                                         'phase': phase}

                self.append_differences(difference_indicators, leg)
Exemple #2
0
    def determine_tsk_times(self, competition_day):

        leg = -1  # leg before startline is crossed
        possible_enl = 0  # excluding motor test

        for i in range(len(self.b_records)):

            if self.gps_altitude and det_height(self.b_records[i], False) != 0:
                self.gps_altitude = False

            t = det_local_time(self.b_records[i], competition_day.utc_to_local)

            if leg == -1 and t > competition_day.start_opening and i > 0:
                start = competition_day.task[0]
                if start.taskpoint_completed(self.b_records[i - 1], self.b_records[i]):
                    self.tsk_t.append(t)
                    self.tsk_i.append(i)
                    self.first_start_i = i
                    leg = 0
                    possible_enl = 0
            elif leg == 0:
                if used_engine(self, i):
                    possible_enl = determine_engine_start_i(self, i)
                start = competition_day.task[0]
                tp1 = competition_day.task[1]
                if start.taskpoint_completed(self.b_records[i - 1], self.b_records[i]):
                    if self.file_name == "PR.igc":
                        print "PR restart at t=%s" % ss2hhmmss(t)
                    self.tsk_t[0] = t
                    self.tsk_i[0] = i
                    possible_enl = 0
                if tp1.taskpoint_completed(self.b_records[i - 1], self.b_records[i]):
                    self.tsk_t.append(t)
                    self.tsk_i.append(i)
                    leg += 1
            elif 0 < leg < competition_day.no_tps:
                if used_engine(self, i):
                    possible_enl = determine_engine_start_i(self, i)
                    break
                next_tp = competition_day.task[leg+1]
                if next_tp.taskpoint_completed(self.b_records[i - 1], self.b_records[i]):
                    self.tsk_t.append(t)
                    self.tsk_i.append(i)
                    leg += 1
            elif leg == competition_day.no_legs - 1:
                if used_engine(self, i):
                    possible_enl = determine_engine_start_i(self, i)
                    break
                finish = competition_day.task[-1]
                if finish.taskpoint_completed(self.b_records[i - 1], self.b_records[i]):
                    self.tsk_t.append(t)
                    self.tsk_i.append(i)
                    leg += 1

        b_record1 = self.b_records[self.tsk_i[0]-1]
        b_record2 = self.b_records[self.tsk_i[0]]
        self.tsk_t[0] -= self.start_refinement(competition_day, b_record1, b_record2)
        self.tsk_t[0] -= 1  # Soaring spot takes point before start line!

        if not possible_enl == 0:
            self.outlanding_b_record = self.b_records[possible_enl]

        if not possible_enl == 0 or len(self.tsk_t) != competition_day.no_legs + 1:
            self.outlanded = True
            self.outlanding_leg = len(self.tsk_t)-1
            self.determine_outlanding_location(competition_day)
Exemple #3
0
    def __init__(self, competition_day, flight):

        self.tsk_distance_all = sum(competition_day.task_distances)
        self.tsk_distance_leg = competition_day.task_distances

        self.no_cruises = flight.phases.cruises_all
        self.no_cruises_leg = flight.phases.cruises_leg

        self.no_thermals = flight.phases.thermals_all
        self.no_thermals_leg = flight.phases.thermals_leg

        startheight = det_height(flight.b_records[flight.tsk_i[0]], flight.gps_altitude)
        finish_height = det_height(flight.b_records[flight.tsk_i[-1]], flight.gps_altitude)

        if flight.outlanded:
            s_flown_task_all = 0
            for leg in range(flight.outlanding_leg):
                s_flown_task_all += competition_day.task_distances[leg]
            s_flown_task_all += flight.outlanding_distance
            s_flown_task_all /= 1000
        else:
            s_flown_task_all = sum(competition_day.task_distances) / 1000

        self.all = {"ranking": flight.ranking,
                    "airplane": flight.airplane,
                    "compID": flight.competition_id,
                    "t_start": ss2hhmmss(flight.tsk_t[0]),
                    "t_finish": ss2hhmmss(flight.tsk_t[-1]),
                    "h_start": startheight,
                    "h_finish": finish_height,
                    "s_flown_task": s_flown_task_all}

        self.leg = []

        # in case of outlanding: only performance is stored from completed legs
        for leg in range(competition_day.no_legs):
            if flight.outlanded and leg == flight.outlanding_leg:
                t_start = flight.tsk_t[leg]
                t_finish = 0
                s_flown_task_leg = flight.outlanding_distance / 1000
                startheight = det_height(flight.b_records[flight.tsk_i[leg]], flight.gps_altitude)
                finish_height = 0
            elif flight.outlanded and leg > flight.outlanding_leg:
                t_start = 0
                t_finish = 0
                s_flown_task_leg = 0
                startheight = 0
                finish_height = 0
            else:
                t_start = flight.tsk_t[leg]
                t_finish = flight.tsk_t[leg+1]
                s_flown_task_leg = competition_day.task_distances[leg] / 1000
                startheight = det_height(flight.b_records[flight.tsk_i[leg]], flight.gps_altitude)
                finish_height = det_height(flight.b_records[flight.tsk_i[leg+1]], flight.gps_altitude)

            self.leg.append({"ranking": self.all["ranking"],
                             "airplane": self.all["airplane"],
                             "compID": self.all["compID"],
                             "t_start": ss2hhmmss(t_start),
                             "t_finish": ss2hhmmss(t_finish),
                             "h_start": startheight,
                             "h_finish": finish_height,
                             "s_flown_task": s_flown_task_leg})
Exemple #4
0
    def determine_tsk_times(self, competition_day):

        leg = -1  # leg before startline is crossed
        possible_enl = 0  # excluding motor test

        for i in range(len(self.b_records)):

            if self.gps_altitude and det_height(self.b_records[i], False) != 0:
                self.gps_altitude = False

            t = det_local_time(self.b_records[i], competition_day.utc_to_local)

            if leg == -1 and t > competition_day.start_opening and i > 0:
                start = competition_day.task[0]
                if start.taskpoint_completed(self.b_records[i - 1],
                                             self.b_records[i]):
                    self.tsk_t.append(t)
                    self.tsk_i.append(i)
                    self.first_start_i = i
                    leg = 0
                    possible_enl = 0
            elif leg == 0:
                if used_engine(self, i):
                    possible_enl = determine_engine_start_i(self, i)
                start = competition_day.task[0]
                tp1 = competition_day.task[1]
                if start.taskpoint_completed(self.b_records[i - 1],
                                             self.b_records[i]):
                    if self.file_name == "PR.igc":
                        print "PR restart at t=%s" % ss2hhmmss(t)
                    self.tsk_t[0] = t
                    self.tsk_i[0] = i
                    possible_enl = 0
                if tp1.taskpoint_completed(self.b_records[i - 1],
                                           self.b_records[i]):
                    self.tsk_t.append(t)
                    self.tsk_i.append(i)
                    leg += 1
            elif 0 < leg < competition_day.no_tps:
                if used_engine(self, i):
                    possible_enl = determine_engine_start_i(self, i)
                    break
                next_tp = competition_day.task[leg + 1]
                if next_tp.taskpoint_completed(self.b_records[i - 1],
                                               self.b_records[i]):
                    self.tsk_t.append(t)
                    self.tsk_i.append(i)
                    leg += 1
            elif leg == competition_day.no_legs - 1:
                if used_engine(self, i):
                    possible_enl = determine_engine_start_i(self, i)
                    break
                finish = competition_day.task[-1]
                if finish.taskpoint_completed(self.b_records[i - 1],
                                              self.b_records[i]):
                    self.tsk_t.append(t)
                    self.tsk_i.append(i)
                    leg += 1

        b_record1 = self.b_records[self.tsk_i[0] - 1]
        b_record2 = self.b_records[self.tsk_i[0]]
        self.tsk_t[0] -= self.start_refinement(competition_day, b_record1,
                                               b_record2)
        self.tsk_t[0] -= 1  # Soaring spot takes point before start line!

        if not possible_enl == 0:
            self.outlanding_b_record = self.b_records[possible_enl]

        if not possible_enl == 0 or len(
                self.tsk_t) != competition_day.no_legs + 1:
            self.outlanded = True
            self.outlanding_leg = len(self.tsk_t) - 1
            self.determine_outlanding_location(competition_day)