Exemple #1
0
    def save(self, soaring_spot_info):
        file_name = settings.current_dir + "/debug_logs/flightClassDebug.txt"
        if self.file_name == soaring_spot_info.file_names[0]:
            text_file = open(file_name, "w")  # overwriting if exist
        else:
            text_file = open(file_name, "a")  # appending

        text_file.write("file_name: " + self.file_name + "\n")
        text_file.write("airplane: " + self.airplane + "\n")
        text_file.write("competition_id: " + self.competition_id + "\n\n")

        print_array_debug(text_file, "tsk_t", self.tsk_t)

        tsk_t_temp = [""] * len(self.tsk_t)
        for ii in range(len(self.tsk_t)):
            tsk_t_temp[ii] = ss2hhmmss(self.tsk_t[ii])

        print_array_debug(text_file, "tsk_t", tsk_t_temp)
        print_array_debug(text_file, "tsk_i", self.tsk_i)

        text_file.write("gps_altitude: " + str(self.gps_altitude) + "\n")
        text_file.write("outlanded: " + str(self.outlanded) + "\n")
        if self.outlanded:
            text_file.write("outlanding_leg: " + str(self.outlanding_leg) + "\n")
            text_file.write("outlanding time(UTC): " + ss2hhmmss(det_local_time(self.outlanding_b_record, 0)) + "\n")
            text_file.write("outlanding distance from previous tp: " + str(self.outlanding_distance) + "\n")
        text_file.write("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")

        text_file.close()
Exemple #2
0
    def save(self, soaring_spot_info):
        file_name = settings.current_dir + "/debug_logs/flightClassDebug.txt"
        if self.file_name == soaring_spot_info.file_names[0]:
            text_file = open(file_name, "w")  # overwriting if exist
        else:
            text_file = open(file_name, "a")  # appending

        text_file.write("file_name: " + self.file_name + "\n")
        text_file.write("airplane: " + self.airplane + "\n")
        text_file.write("competition_id: " + self.competition_id + "\n\n")

        print_array_debug(text_file, "tsk_t", self.tsk_t)

        tsk_t_temp = [""] * len(self.tsk_t)
        for ii in range(len(self.tsk_t)):
            tsk_t_temp[ii] = ss2hhmmss(self.tsk_t[ii])

        print_array_debug(text_file, "tsk_t", tsk_t_temp)
        print_array_debug(text_file, "tsk_i", self.tsk_i)

        text_file.write("gps_altitude: " + str(self.gps_altitude) + "\n")
        text_file.write("outlanded: " + str(self.outlanded) + "\n")
        if self.outlanded:
            text_file.write("outlanding_leg: " + str(self.outlanding_leg) +
                            "\n")
            text_file.write(
                "outlanding time(UTC): " +
                ss2hhmmss(det_local_time(self.outlanding_b_record, 0)) + "\n")
            text_file.write("outlanding distance from previous tp: " +
                            str(self.outlanding_distance) + "\n")
        text_file.write(
            "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")

        text_file.close()
Exemple #3
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 #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)
Exemple #5
0
    def determine_phases(self, settings, competitionday, flight):

        b_record_m1 = flight.b_records[flight.tsk_i[0] - 2]
        time_m1 = det_local_time(b_record_m1, competitionday.utc_to_local)

        b_record = flight.b_records[flight.tsk_i[0] - 1]
        time = det_local_time(b_record, competitionday.utc_to_local)
        bearing = det_bearing(b_record_m1, b_record, 'pnt', 'pnt')

        cruise = True
        possible_cruise_start = 0
        possible_thermal_start = 0
        cruise_distance = 0
        temp_bearing_change = 0
        possible_turn_dir = 'left'
        sharp_thermal_entry_found = False
        bearing_change_tot = 0
        leg = 0

        self.create_entry(flight.tsk_i[0], time_m1, 'cruise', -2)
        self.create_entry(flight.tsk_i[0], time_m1, 'cruise', leg)

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

                time_m2 = time_m1

                time_m1 = time
                bearing_m1 = bearing
                b_record_m1 = b_record

                b_record = flight.b_records[i]
                time = det_local_time(b_record, competitionday.utc_to_local)

                bearing = det_bearing(b_record_m1, b_record, 'pnt', 'pnt')
                bearing_change = det_bearing_change(bearing_m1, bearing)
                bearing_change_rate = bearing_change / (time - 0.5*time_m1 - 0.5*time_m2)

                if i == flight.tsk_i[leg+1]:
                    phase = 'cruise' if cruise else 'thermal'
                    leg += 1
                    self.close_entry(i, time, leg-1)
                    self.create_entry(i, time, phase, leg)

                if cruise:

                    if (possible_turn_dir == 'left' and bearing_change_rate < 1e-2) or\
                            (possible_turn_dir == 'right' and bearing_change_rate > -1e-2):

                        bearing_change_tot += det_bearing_change(bearing_m1, bearing)

                        if possible_thermal_start == 0:
                            possible_thermal_start = i
                        elif (not sharp_thermal_entry_found) and abs(bearing_change_rate) > settings.cruise_threshold_bearingRate:
                            sharp_thermal_entry_found = True
                            possible_thermal_start = i

                    else:  # sign change
                        bearing_change_tot = det_bearing_change(bearing_m1, bearing)

                        if bearing_change_rate < 0:
                            possible_turn_dir = 'left'
                        else:
                            possible_turn_dir = 'right'

                        possible_thermal_start = i

                    if abs(bearing_change_tot) > settings.cruise_threshold_bearingTot:
                        cruise = False
                        thermal_start_time = det_local_time(flight.b_records[possible_thermal_start], competitionday.utc_to_local)
                        self.close_entry(possible_thermal_start, thermal_start_time, -2)
                        self.close_entry(possible_thermal_start, thermal_start_time, leg)
                        self.create_entry(possible_thermal_start, thermal_start_time, 'thermal', -2)
                        self.create_entry(possible_thermal_start, thermal_start_time, 'thermal', leg)
                        possible_thermal_start = 0
                        sharp_thermal_entry_found = False
                        bearing_change_tot = 0

                else:  # thermal
                    if abs(bearing_change_rate) > settings.thermal_threshold_bearingRate:
                        if possible_cruise_start != 0:
                            cruise_distance = 0
                            temp_bearing_change = 0
                    else:  # possible cruise
                        if cruise_distance == 0:
                            possible_cruise_start = i
                            possible_cruise_t = time
                            temp_bearing_change += bearing_change
                            temp_bearing_rate_avg = 0
                        else:
                            temp_bearing_change += bearing_change
                            temp_bearing_rate_avg = temp_bearing_change / (time-possible_cruise_t)

                        cruise_distance = determine_distance(flight.b_records[possible_cruise_start-1], b_record,
                                                             'pnt', 'pnt')

                        if cruise_distance > settings.thermal_threshold_distance and \
                                        abs(temp_bearing_rate_avg) < settings.thermal_threshold_bearingRateAvg:

                            cruise = True
                            self.close_entry(possible_cruise_start, possible_cruise_t, -2)
                            self.close_entry(possible_cruise_start, possible_cruise_t, leg)
                            self.create_entry(possible_cruise_start, possible_cruise_t, 'cruise', -2)
                            self.create_entry(possible_cruise_start, possible_cruise_t, 'cruise', leg)
                            possible_cruise_start = 0
                            cruise_distance = 0
                            temp_bearing_change = 0
                            bearing_change_tot = 0

        time = det_local_time(flight.b_records[flight.tsk_i[-1]], competitionday.utc_to_local)
        self.close_entry(flight.tsk_i[-1], time, -2)
        self.close_entry(flight.tsk_i[-1], time, leg)
Exemple #6
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)