def load_speeds_for_year(self, year, directory, recalc_field_lengths=False):
        if self._verbose:
            print "Loading speeds for station ", self.id
        current_day = date(year, 1, 1)
        last_day = date(year, 12, 31)
        one_day = timedelta(days=1)
        n_days = (last_day - current_day).days

        # initialize empty 2D array to hold speeds
        # dimensions: date (n_days), timeslot (288 5-min slots)
        self.speeds = empty((n_days, 288), dtype=object)

        for day in range(n_days):
            if self._verbose:
                print "    Loading speeds for ", current_day

            # If there are no detectors, there are no valid speeds
            if self.detector_list == []:
                day_speeds = [None] * 288
            # Otherwise, load speeds from each detector
            else:
                try:
                    traffic_file = self.traffic_filename_from_date(current_day)
                    tr = TrafficReader(path.join(directory, traffic_file))

                    # average 1min speeds across detectors
                    day_speeds = impute.average_multilist(
                        [detector.load_speeds(tr, recalc_field_lengths)
                         for detector in self.detector_list])
                    # "short duration temporal linear regression" = impute gaps
                    # up to 3 slots long use adjacent values
                    day_speeds = impute.impute_range(day_speeds,
                                                     impute_length=3,
                                                     input_length=3)
                    # average 1min speeds to 5min speeds
                    day_speeds = impute.average_list(day_speeds, 5)
                    # "short duration temporal linear regression" again
                    day_speeds = impute.impute_range(day_speeds,
                                                     impute_length=3,
                                                     input_length=3)
                    # remove any single missing values by averaging adjacent
                    # values
                    day_speeds = impute.impute1(day_speeds)
                except IOError:
                    # If there is no file for the given day, add a list of
                    # invalid speeds
                    day_speeds = [None] * 288

            self.speeds[day,:] = day_speeds
            current_day = current_day + one_day

        return self.speeds
    def load_speeds(self, traffic_reader, recalc_field_lengths=False):
        # if there are no detectors for this station, give it a speed list of all invalid speeds
        if self.detector_list == []:
            self.speeds = [None] * 288
        # otherwise, load the speeds from the detectors
        else:
            for detector in self.detectors():
                detector.load_speeds(traffic_reader, recalc_field_lengths)

            speeds = impute.average_multilist([detector.load_speeds(traffic_reader) for detector in self.detector_list])
            speeds = impute.impute_range(speeds, impute_length=3, input_length=3)
            speeds = impute.average_list(speeds, 5)
            self.speed_list = impute.impute1(speeds)