def analyse_files(filepaths='all'): """Analyses all given files in list. This function can be used by the command [a]. :param filepaths: list of files to analyse with their relative dir path added .. todo:: Change to no override mode. measurement.Measurement.plot(override=False) .. todo:: a + today => only analyse files for today .. todo:: a + override => override=True """ # get the theme from config theme = configuration['EXPORT_THEME'] if filepaths == 'all': filepaths = find_all_files() elif filepaths == 'today': pass # TODO: only analyse the files of today # analyse all files for f in filepaths: try: m = measurement.Measurement(f) export_fit = 'Mathematica' if configuration['EXPORT_FIT_FUNCTIONS'] == True else False m.fit(fit_function_export=export_fit) m.plot(file_extention=configuration['IMAGE_FORMAT']) m.export_meta(make_html=True, theme=theme) except Exception as e: print(f'The following exception occured during runtime:\n\n{e}\n\nContinuing operation.')
def test_false_url(self): url = 'asdfasdfff' meas = measurement.Measurement(0, 0, 0, 0, 0, 0) com = Communication(url) with self.assertRaises(Exception): com.post_measurement(meas)
def test_wrong_url(self): url = 'https://optiair.azurewebsites.net/api/asdf' meas = measurement.Measurement(0, 0, 0, 0, 0, 0) com = Communication(url) with self.assertRaises(requests.HTTPError): com.post_measurement(meas)
def startStream(self): self.running = True ser = serial.Serial(self.serial_port, timeout=1.0) while (self.running): line = ser.readline().decode("utf-8") measure = measurement.Measurement(line) self.measurementCallback(measure)
def add_measurement_points(self, measurement_points, measurement_titles=[]): # Make a list of empty titles if no titles were given if len(measurement_titles) == 0: measurement_titles = [""] * len(measurement_points) # list of tuples self.measurement_points = np.empty(len(measurement_points), dtype=measurement.Measurement) self.interference_times = np.empty(len(measurement_points)) for i, meas in enumerate(measurement_points): # reflecting on the PEC walls # dist : the 4 reflection points of measurement in the PEC dist = np.empty((4, 2)) dist[0, :] = -meas[0], meas[1] dist[1, :] = meas[0], -meas[1] dist[2, :] = 2 * self.x_length - meas[0], meas[1] dist[3, :] = meas[0], 2 * self.y_length - meas[1] dist -= (self.source.pos_x, self.source.pos_y) # euclidian distance dist = np.linalg.norm(dist, axis=-1) # the least distance between the source & the reflection point of # the measurement will be approx the distance the wave has to # travel min_dist = np.min(dist) # set interference self.interference_times[i] = min_dist / c self.measurement_points[i] = measurement.Measurement( meas[0], meas[1], self.interference_times[i], measurement_titles[i]) self.measurement_points[i].wave_time = (np.linalg.norm( (meas[0] - self.source.pos_x, meas[1] - self.source.pos_y)) / c) # return an estimate maximum of time before inteference occurs (foreach meas_point) self.meas_pos_x = ( np.asarray([meas.pos_x for meas in self.measurement_points]) // self.Delta_x) self.meas_pos_y = ( np.asarray([meas.pos_y for meas in self.measurement_points]) // self.Delta_y) return self.interference_times
def exampleMeasurements(application): time.sleep(1.0) ex1 = measurement.Measurement("") ex1.sensor_name = "CO2" ex1.value = "2000" ex1.unit = "ppm" application.addMeasurement(ex1) time.sleep(1.0) ex2 = measurement.Measurement("") ex2.sensor_name = "CO2" ex2.value = "2200" ex2.unit = "ppm" application.addMeasurement(ex2) time.sleep(1.0) ex3 = measurement.Measurement("") ex3.sensor_name = "Temperature" ex3.value = "22.2" ex3.unit = "C" application.addMeasurement(ex3) ex4 = measurement.Measurement("") ex4.sensor_name = "Humidity" ex4.value = "30" ex4.unit = "%" application.addMeasurement(ex4) time.sleep(1.0) application.removeMeasurement(ex1) time.sleep(1.0) application.removeMeasurement("Temperature") time.sleep(1.0) ex5 = measurement.Measurement("") ex5.sensor_name = "Humidity" ex5.value = "34" ex5.unit = "%" application.addMeasurement(ex5) time.sleep(1.0) ex6 = measurement.Measurement("") ex6.sensor_name = "CO2" ex6.value = "2300" ex6.unit = "ppm" application.addMeasurement(ex6)
sys.exit('Error: %s is not recognized as a valid directory' % path) if not path[-1] == '/': path = path + '/' print 'Photoacoustic Data Analysis Software' print 'Author: Mitchell Duffy' print 'License: MIT License' print '' print 'Building Database...' print 'For large directories this may take a few minutes.' print '' ml = measure_list.MeasureList() for i in os.listdir(path): if not i.endswith('.txt'): continue else: m = measurement.Measurement(path + i) m.process() ml.organize(m) # This fuction is used to check the max/min of each graph in a series #graphll.graphme(ml) menu = graphmenu.GraphMenu(ml)