def change_sensor_time_series_to_rare_series(sensor, loudness_of_the_area, start_index, end_index):
		sensor_time_series = sensor.get_time_series()

		cropped_sensor_time_series = crop_time_series(sensor_time_series, start_index, end_index)
		cropped_rare_event_song = crop_time_series(rare_event_song, start_index, end_index)

		merged_series = tstools.merge_series([cropped_rare_event_song, cropped_sensor_time_series], 
		[loudness_of_the_area, 1])

		new_series = sensor_time_series[:]
		#to append previous valus to the new time series
		for i in range(len(merged_series)):
			new_series[start_index + i] = merged_series[i]

		new_series = tstools.normalize_to_range(new_series, 1.0) #normalize to 1
		sensor.set_time_series(new_series)
Ejemplo n.º 2
0
	def set_time_series_according_to_sensor_weight(self, list_of_time_series):
		"""
		Sets the time series of a sensor depending on the location of the grid.
		It normalizes the data so it falls betweem 0 and 1 for the neural network.
		"""
		lattice_of_sensors = []

		for row in range(self.dimension_of_lattice):
			for col in range(self.dimension_of_lattice):

				weigth_from_b = row / (self.dimension_of_lattice * 1.0) #in vertical increase b 
				weigth_from_a = col / (self.dimension_of_lattice * 1.0) #in horizontal increase a
				weight_from_c = 0
				total_weight = weigth_from_a + weigth_from_b

				if total_weight < 1:
					weight_from_c = 1 - total_weight

				list_of_weights = [weigth_from_a, weigth_from_b, weight_from_c]
				time_series_for_sensor = \
				tstools.merge_series(list_of_time_series, list_of_weights)
				time_series_for_sensor = \
				tstools.normalize_to_range(time_series_for_sensor, 1)
				self.set_sensor_time_series(row, col, time_series_for_sensor)