def test_complex(): pae_meas = PAEMeasure(300, 200, 2, 20.0) complex_chart = np.load('test/noised.npy') saved_complex_res = np.asscalar(np.load('test/complex_result.npy')) assert pae_meas.pae(complex_chart) == saved_complex_res
def test_linear(): pae_meas = PAEMeasure(300, 200, 2, 20.0) x = np.linspace(0, 2, 300) linear_chart = x * 0.5 - 0.5 saved_lin_res = np.asscalar(np.load('test/linear_result.npy')) assert pae_meas.pae(linear_chart) == saved_lin_res
line_postfix = "-line.png" area_postfix = "-area.png" pixel_postfix = "-pixel.png" start_step = 0 param_file = "kpi.txt" start_time = "2017-05-01 00:00:00" end_time = "2017-07-31 12:34:00" min_value, max_value = 0, 21 param_lines = open(param_file).read().split("\n") n = len(param_lines) // 3 width = 1000 height = 200 base_area_png = param_lines[0] + area_postfix base_line_png = param_lines[0] + line_postfix pae_meas = PAEMeasure(width, height) stat_0 = [] def calcMSSSIM(file1, file2): image_raw_data_1 = tf.io.gfile.GFile(file1, "rb").read() image_raw_data_2 = tf.io.gfile.GFile(file2, "rb").read() img_data_1 = tf.image.decode_png(image_raw_data_1) img_data_2 = tf.image.decode_png(image_raw_data_2) img_resized_1 = tf.image.resize(img_data_1, [width, height]) img_resized_2 = tf.image.resize(img_data_2, [width, height]) # calc MS-SSIM with default weights [0.0448,0.2856,0.3001,0.2363,0.1333] msssim = tf.image.ssim_multiscale(img_resized_1, img_resized_2, 100) return msssim
area_postfix = "-area.png" pixel_postfix = "-pixel.png" start_step = 0 param_file = "bus.txt" start_time = "2011-04-03 00:00:00" end_time = "2011-05-05 00:00:00" min_value = 0 max_value = 12500 param_lines = open(param_file).read().split("\n") n = len(param_lines) // 3 width = 1000 height = 200 base_area_png = param_lines[0] + area_postfix base_line_png = param_lines[0] + line_postfix pae_meas = PAEMeasure(width, height) stat_0 = [] def calcMSSSIM(file1, file2): image_raw_data_1 = tf.io.gfile.GFile(file1, "rb").read() image_raw_data_2 = tf.io.gfile.GFile(file2, "rb").read() img_data_1 = tf.image.decode_png(image_raw_data_1) img_data_2 = tf.image.decode_png(image_raw_data_2) img_resized_1 = tf.image.resize(img_data_1, [width, height]) img_resized_2 = tf.image.resize(img_data_2, [width, height]) # calc MS-SSIM with default weights [0.0448,0.2856,0.3001,0.2363,0.1333] msssim = tf.image.ssim_multiscale(img_resized_1, img_resized_2, 100) return msssim