In [ ]:
import sys
sys.path.append('../..')

import pyotc

pyotc.plt.ion()

Generate HeightCalibration object and get PSD data from files


In [ ]:
hc = pyotc.HeightCalibration()

basename = 'B01_'
directory = '../exampleData/height_calibration_single_psds/'

hc.get_psd_files(basename, directory=directory);

# bounds = {'x': (10, 20e3), 'y': (10, 20e3), 'z': (10, 4e3)}
bounds = (1, 45e3)
# bounds = None

#f_ex = {'x': [12, 88], 'y': [8, 48, 52], 'z': [48]}
f_ex = None

hc.gen_psd_fits(bounds=bounds, f_exclude=f_ex)

Fit the PSDs


In [ ]:
''' If dynamic is set to True, the set height is used to determine if a
    fit is run with a Lorentzian PSD or a hydrodynamically correct PSD. '''

hc.setup_psd_fits(model='lorentzian', lp_filter=True, lp_fixed=True, f3dB=8800, alpha=0.3)

bounds = {'x': (1, 20e3), 'y': (1, 20e3), 'z': (1, 10e3)}
#bounds = (100, 45e3)
#bounds = None

#f_ex = {'x': [12, 88], 'y': [8, 48, 52], 'z': [48]}
f_ex = 8.0  # exclude crosstalk from excitation

# kwargs = {'f_c': 4e3}  # initial guesses
kwargs = {}

hc.fit_psds(bounds=bounds, f_exclude=f_ex,
            fitreport=0, plot_fits=True,
            use_heights=False, plot_kws={'showLegend': False}, **kwargs);

determine focal shift


In [ ]:
hc.determine_focal_shift(idx_slice=slice(22, -4))

set the focal shift


In [ ]:
hc.focal_shift = 0.63

In [ ]:
hc.plot_pc_results()

exclude some data


In [ ]:
hc.exclude_heights_outside(0.2, 10, reset=True)

In [ ]:
hc.fit_rel_drag(method='radius', plot_fit=True, h0=-0.6)

find out which surface height was determined


In [ ]:
hc.rel_drag_fit.params['h0']

fit all data


In [ ]:
hc.fit_height_data(method='radius', fit_dissens_osci=True, plot_fit=True, fit_drag_first=False)

In [ ]:
hc.save_hc_data()

adjust heights


In [ ]:
hc.add_height_offset(0.5809)

In [ ]:
hc.reset_recalc()

In [ ]:
hc.plot_pc_results()

re-fit psds (if necessary)


In [ ]:
hc.setup_psd_fits(model='lorentzian', lp_filter=True, lp_fixed=True, f3dB=8800, alpha=0.3)

# heights = [1.00, ]
heights = None  # fit all available psds

# names = ['x', 'y']  # fit only particular axes
names = None  # fir all available axes

bounds = {'x': (1, 20e3), 'y': (1, 20e3), 'z': (1, 10e3)}
#bounds = (100, 45e3)
#bounds = None

#f_ex = {'x': [12, 88], 'y': [8, 48, 52], 'z': [48]}
f_ex = 8.0

# kwargs = {'f_c': 4e3}  # initial guesses
kwargs = {}

hc.fit_psds(heights=heights, names=names, bounds=bounds, f_exclude=f_ex,
            fitreport=0, plot_fits=True, use_heights=True,
            plot_kws={'showLegend': False}, **kwargs);

In [ ]:
hc.plot_pc_results()

In [ ]:
hc.exclude_heights_outside(0.8, 10, reset=True)

In [ ]:
hc.fit_rel_drag(plot_fit=True)

In [ ]:
hc.rel_drag_fit.params['h0']

In [ ]:
hc.fit_height_data(fit_drag_first=False, fit_dissens_osci=True, plot_fit=True)

In [ ]:
# save height-dependent data
hc.save_hc_data(basename, directory)

In [ ]:
# save height-fit results
hc.write_results_to_file()

In [ ]: