def main(): print(sys.argv) if len(sys.argv) < 3: print('Expected "show/save/html" then type of analysis') return fig_option = sys.argv[1] if fig_option not in ["show", "save", "html"]: print('Expected "show/save/html" as first option') return analyze_option = sys.argv[2] data = read_data() fig = analyze.get_fig(analyze_option, data) if fig_option == "show": fig.show() elif fig_option == "html": fig.write_html("index.html") elif fig_option == "save": if len(sys.argv) < 4: print("Expected filename to save") return name = sys.argv[3] filepath = os.path.join(constants.IMAGE_FOLDER, name) fig.write_image(filepath)
plt.errorbar((data['postsamples']), data['medium'], yerr=data['std_dev'], label=label) plt.xscale('log') plt.legend(loc='best') plt.xlabel(xlabel) plt.ylabel(ylabel) plt.tight_layout(pad=0) meas_path = '/home/milosz/Projects/master/measurements/transport_measurements/' save_path = '/home/milosz/Projects/master/figures/measurements/' file_name = meas_path + 'XMLRPC/XMLRPC_efficiency_ZMQRPC.txt' XML_dat_4_chan = read_data(file_name)[3] file_name = meas_path + 'ZMQ/ZMQ_pickle.txt' ZMQ_pickle_dat_4_chan = read_data(file_name)[3] file_name = meas_path + 'numpy/ZMQ/ZMQ_pickle_numpy.txt' ZMQ_pickle_numpy_dat_4_chan = read_data(file_name)[3] file_name = meas_path + 'ZMQ/ZMQ_json.txt' ZMQ_json_dat_4_chan = read_data(file_name)[3] file_name = meas_path + 'ZMQ/ZMQ_protobuf.txt' ZMQ_protobuf_dat_4_chan = read_data(file_name)[3] file_name = meas_path + 'TCP/TCP_pickle.txt' TCP_pickle_dat_4_chan = read_data(file_name)[3]
from __future__ import print_function from builtins import range from pareto import * import parse names, values = parse.read_data('../data/results_10000_a.out') #names, values = parse.read_data('../data/20161207_results_100k.out') vals = [[v[i] for i in range(len(v)) if names[2][i].endswith('_abserr')] for idx, p, v in values] #timing(pareto_bruteforce)(vals) pareto_vals = timing(pareto)(vals) print(len(vals), len(pareto_vals))
('s', 's0', 's00', 'e', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5'): (10., 2.1), ('sa', 'sa0', 'sa00', 's0a'): (6.2, 1.1), ('sab', 'sabc', 'sabb', 'sabbc', 'sabd', 'sam', 'sb', 'sbab', 'sbb', 'sba', 'sb0', 'sb0a'): (6.5, 0.5), ('sbc', 'sbbc', 'sb0', 'sc'): (4.7, 0.4), ('scd', 'sd', 'cd'): (3.9, 0.6), ('sdm', 'irr'): (1.7, 0.6) } def clean_type(gtype): cleaned = gtype.lower().replace('?', '').replace('(r)', '').replace('(s)', '').replace('(r\')', '').replace('(rs)', '') cleaned = cleaned.replace('edge-on', '').replace('pec', '') cleaned = re.sub('[/^+-]', '', cleaned) return cleaned.strip() def get_mass_estimate(luminosity, gtype): cleaned_type = clean_type(gtype) for typeset in M_LUM_RATIOS: if cleaned_type in typeset: lum_ratio, err = M_LUM_RATIOS[typeset] return SOLAR_MASS * lum_ratio * luminosity, SOLAR_MASS * err * luminosity return SOLAR_MASS * DEFAULT_RATIO[0] * luminosity, SOLAR_MASS * DEFAULT_RATIO[1] * luminosity if __name__=='__main__': data_list = read_data() gtypes = set() for data in data_list: if data[LUM] and data[GTYPE]: gtypes.add(clean_type(data[GTYPE])) for gtype in gtypes: if not any([gtype in k for k in M_LUM_RATIOS]): print gtype
def save_histogram(data, name): mean, var, sigma = calculate_statistics(data) fig, ax = plt.subplots() ax.hist(data, bins=100) props = dict(boxstyle='round', facecolor='wheat', alpha=0.5) text = "Mean: {:<1.2f}\n".format(mean) +\ "Sigma: {:<1.2f}\n".format(sigma) ax.text(0.80, 0.95, text, transform=ax.transAxes, fontsize=10, verticalalignment='top', bbox=props) plt.xlabel('ns') plt.savefig('/home/milosz/Projects/master/figures/measurements/' + name + '.svg', format='svg') meas_path = '/home/milosz/Projects/master/measurements/precision/' save_path = '/home/milosz/Projects/master/figures/measurements/' #for file in os.listdir(meas_path): # if file.endswith('.txt'): # data = read_data(meas_path + file) # save_histogram(data, file.replace('.txt', '')) file = 'WRTD_other_day.txt' data = read_data(meas_path + file) save_histogram(data, file.replace('.txt', ''))
label=label) plt.legend(loc='best') plt.xlabel(xlabel) plt.ylabel(ylabel) plt.subplot(212) plt.errorbar((data['postsamples']), data['medium'], yerr=data['std_dev'], label=label) plt.xscale('log') plt.legend(loc='best') plt.xlabel(xlabel) plt.ylabel(ylabel) plt.tight_layout(pad=0) meas_path = '/home/milosz/Projects/master/measurements/freq_meas/' save_path = '/home/milosz/Projects/master/figures/measurements/' file_name = meas_path + 'loop_adc/frequency_meas.txt' loop_adc = read_data(file_name)[3] file_name = meas_path + 'loop_server/frequency_meas.txt' loop_server = read_data(file_name)[3] add_data_to_fig(loop_adc, 'ADC loop', 'postsamples', 'acquisition frequency[Hz]') add_data_to_fig(loop_server, 'Server loop', 'postsamples', 'acquisition frequency[Hz]') plt.savefig(save_path + 'loop_adc_server_comparison.svg', format='svg')