From f75d6c2f31d95d1173c6b73a8c0faa33fa3e6463 Mon Sep 17 00:00:00 2001 From: Oksana Zaharko Date: Wed, 18 Mar 2020 09:20:07 +0100 Subject: [PATCH] Z changed cami into h5meta --- pyzebra/app.py | 6 +++--- pyzebra/zebra.py | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pyzebra/app.py b/pyzebra/app.py index ec85fc2..b7b2eb3 100644 --- a/pyzebra/app.py +++ b/pyzebra/app.py @@ -50,14 +50,14 @@ filelist.on_change("value", filelist_callback) def fileinput_callback(_attr, _old, new): - cami_list = pyzebra.read_cami(new) - file_list = cami_list["filelist"] + h5meta_list = pyzebra.read_h5meta(new) + file_list = h5meta_list["filelist"] filelist.menu = file_list fileinput = TextInput() fileinput.on_change("value", fileinput_callback) -#fileinput.value = "/home/usov_i/psi-projects/sinq/data/1.cami" +fileinput.value = "/Users/zaharko/1work/ZeBRa/ZebraSoftware/python_for_zebra/hdfdata/1.cami" def index_spinner_callback(_attr, _old, new): diff --git a/pyzebra/zebra.py b/pyzebra/zebra.py index aca6706..63d8c72 100644 --- a/pyzebra/zebra.py +++ b/pyzebra/zebra.py @@ -1,32 +1,32 @@ import h5py -def read_cami(filepath): - """Read and parse content of a cami file. +def read_h5meta(filepath): + """Read and parse content of a h5meta file. Args: - filepath (str): File path of a cami file. + filepath (str): File path of a h5meta file. Returns: dict: A dictionary with section names and their content. """ - cami_content = dict() - with open(filepath, "r") as cami_file: - line = cami_file.readline() + h5meta_content = dict() + with open(filepath, "r") as h5meta_file: + line = h5meta_file.readline() while line: if line.startswith("#begin"): # read section section = line[7:-1] # len("#begin ") = 7 - cami_content[section] = [] - line = cami_file.readline() + h5meta_content[section] = [] + line = h5meta_file.readline() while not line.startswith("#end"): - cami_content[section].append(line[:-1]) - line = cami_file.readline() + h5meta_content[section].append(line[:-1]) + line = h5meta_file.readline() # read next line after section's end - line = cami_file.readline() + line = h5meta_file.readline() - return cami_content + return h5meta_content def read_detector_data(filepath): @@ -48,18 +48,18 @@ def read_detector_data(filepath): return detector_data -def open_cami(filepath): - """Open cami scan (?) +def open_h5meta(filepath): + """Open h5meta file Args: - filepath (str): File path of a cami file. + filepath (str): File path of a h5meta file. Returns: dict: A dictionary with h5 names and their detector data. """ data = dict() - cami_content = read_cami(filepath) - for file in cami_content["filelist"]: + h5meta_content = read_h5meta(filepath) + for file in h5meta_content["filelist"]: data[file] = read_detector_data(file) return data