filename = r'Pre.ht3'
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
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 = 'something'
dye_names = ['ATTO550', 'ATTO647N']
buffer_name = 'TE50'
d, meta = phc.loader.nsalex_ht3(filename,
donor = 0,
acceptor = 1,
alex_period_donor = (150, 1500),
alex_period_acceptor = (1540, 3050),
excitation_wavelengths = (523e-9, 628e-9),
detection_wavelengths = (580e-9, 680e-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))
pd.Series(detectors).value_counts()
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)
#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))