filename = r'data/Pre.ht3'
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import phconvert as phc
phc.__version__
author = 'Eitan Lerner'
author_affiliation = 'UCLA'
creator = 'Antonino Ingargiola'
creator_affiliation = 'UCLA'
comment = 'A demostrative smFRET-nsALEX measurement.'
sample_name = 'Doubly-labeled ssDNA partially hybridized to a complementary strand.'
dye_names = ['ATTO488', 'ATTO647N']
buffer_name = 'Tris20 mM Ph 7.8'
d, meta = phc.loader.nsalex_ht3(filename,
donor = 0,
acceptor = 1,
alex_period_donor = (150, 1500),
alex_period_acceptor = (1540, 3050),
excitation_wavelengths = (470e-9, 635e-9),
detection_wavelengths = (525e-9, 690e-9),
time_reversed = False)
fig, ax = plt.subplots(figsize=(13, 4))
phc.plotter.alternation_hist(d, ax=ax)
detectors = d['photon_data']['detectors']
print('Detector numbers: ', np.unique(detectors))
print("Detector Counts")
print("-------- --------")
for det, count in zip(*np.unique(detectors, return_counts=True)):
print("%8d %8d" % (det, count))
d['comment'] = comment
d['sample'] = dict(
sample_name=sample_name,
dye_names=[n.encode() for n in dye_names],
buffer_name=buffer_name,
num_dyes = len(dye_names))
d['identity'] = dict(
author=author,
author_affiliation=author_affiliation,
creator=creator,
creator_affiliation=creator_affiliation)
Before writing to disk, we assure the file structure follows the Photon-HDF5 format:
phc.hdf5.assert_valid_photon_hdf5(d)
phc.hdf5.save_photon_hdf5(d, close=False)
#d['_data_file'].close()
h5file = d['_data_file']
h5file.create_group('/', 'user')
pq_group = h5file.create_group('/user', 'picoquant')
for key in meta:
if np.size(meta[key]) > 0:
h5file.create_table(pq_group, key, obj=meta[key])
#h5file.close()
phc.hdf5.print_children(h5file, '/')
phc.hdf5.print_children(h5file, '/user/picoquant')
metadata = phc.hdf5.dict_from_group(h5file.root.user.picoquant)
h5file.close()
from pprint import pprint
filename = d['_data_file'].filename
h5data = phc.hdf5.load_photon_hdf5(filename)
phc.hdf5.dict_from_group(h5data.identity)
phc.hdf5.dict_from_group(h5data.setup)
pprint(phc.hdf5.dict_from_group(h5data.photon_data))