filename = r'dsdna_d7+d17_50_50_1.spc'
%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 = 'dsdna_d7+d17_50_50'
dye_names = ['ATTO550', 'ATTO647N']
buffer_name = 'TE50'
d, meta = phc.loader.nsalex_bh(filename,
donor = 4,
acceptor = 6,
laser_pulse_rate = 40e6,
tcspc_range = 60e-9,
timestamps_unit = 60e-9,
alex_period_donor = (270, 1500),
alex_period_acceptor = (1800, 3300),
excitation_wavelengths = (532e-9, 635e-9),
detection_wavelengths = (580e-9, 680e-9),
time_reversed = False,
allow_missing_set = 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()
/user/bh_params
¶h5file = d['_data_file']
h5file.create_group('/', 'user')
bh_group = h5file.create_group('/user', 'becker_hickl')
phc.hdf5.dict_to_group(bh_group, meta)
#h5file.close()
phc.hdf5.print_children(h5file, '/user')
phc.hdf5.print_children(h5file, '/user/becker_hickl/identification')
#phc.hdf5.print_children(h5file, '/user/becker_hickl/sys_params')
phc.hdf5.dict_from_group(h5file.root.user.becker_hickl.identification)
#phc.hdf5.dict_from_group(h5file.root.user.becker_hickl.sys_params)
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))