getting started with PyOTC -- Exercise 1


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

import pyotc

set working directory


In [ ]:
from os.path import join
from os.path import expanduser

directory = '../exampleData/height_calibration_single_psds/'
#home = expanduser('~')
#directory = join(home, 'Downloads/exampleData/height_calib_lvfiles/converted_data/')

create PSDMeasurement object and load data from text-file(s)


In [ ]:
dfile = 'B01_1000.dat'

pm = pyotc.PSDMeasurement(warn=False)
pm.load(directory, dfile)

Where's my data?


In [ ]:
pm.freq_x

In [ ]:
pm.psd_x

In [ ]:
pm.ex_amplitude

In [ ]:
pm.exp_setting.radius

PyOTC deals with real physical units

to making sure you don't crash the aircraft


In [ ]:
pm._freq_unit

In [ ]:
pm._psd_unit

In [ ]:
pm.exp_setting.get_radius(unit='ly')

Plot the data


In [ ]:
pm.plot_psds()

PSD fitting


In [ ]:
# active calibration?
pm.active_calibration

In [ ]:
# active oscillations at
pm.ex_freq

In [ ]:
# create a PSDfit object from the loaded psd measurement
pf = pyotc.PSDFit(pm)
# setup the fit model - include low pass filtering or aliasing
pf.setup_fit(model='lorentzian')
pf.fit_psds()

In [ ]:
# show the fits
pf.plot_fits()

In [ ]:
# did not work out? Tweak the model
pf.setup_fit(model='lorentzian', lp_filter=True, lp_fixed=True, f3dB=8000, alpha=0.33)

bounds = {'x': (10, 35e3), 'y': (10, 35e3), 'z': (10, 35e3)}

pf.fit_psds(bounds=bounds)
pf.plot_fits(showLegend=False)

is fit an outlier?


In [ ]:
conf_level = 0.95
pf.is_outlier()

getting the results


In [ ]:
# where are the fits located?
pf.fits

In [ ]:
# get the fit parameters
f = pf.fits['x']
f.params.pretty_print()

In [ ]:
pf.print_results()

In [ ]:
pf.print_pc_results()

Need values in specific units?


In [ ]:
pf.ac_results['x'].get_dissens(unit='nm/V')

save the results


In [21]:
# default writes the results to the parameter files of the psdmeasurement
pf.write_results_to_file()

In [ ]: