base = '/home/cblakemore/opt_lev_analysis/spin_beads_sim/processed_results/'

# filename = os.path.join(base, 'libration_ringdown.p')
filename = os.path.join(base, 'sdeint_ringdown_manyp_3.p')

### load that data
results = pickle.load( open(filename, 'rb') )

### Subselect some results so the plot is comprehensible
# results_cut = results[:8:2]
results_cut = results

### Define some constants. Later simulations will have these saved with the
### data, but I forgot on the first few so....
mbead_dic = {'val': 84.3e-15, 'sterr': 1.0e-15, 'syserr': 1.5e-15}
Ibead = bu.get_Ibead(mbead=mbead_dic)['val']
kappa = bu.get_kappa(mbead=mbead_dic)['val']
m0 = 18.0 * constants.atomic_mass  # residual gas particle mass, in kg


### Define an exponential for fitting the rindown
def exponential(x, a, b, c):
    return a * np.exp(-1.0 * b * x) + c

# plt.figure(figsize=(10,8))

### Colors for plotting
colors = bu.get_color_map(len(results_cut), cmap='plasma')

# fig = plt.figure(figsize=(8,5))
### Loop over the simulation results and fit each one
#         paths.append(base_path + dirname)
#         save_paths.append(base_save_path + dirname + '.npy')
# bu.make_all_pardirs(save_paths[0])
npaths = len(paths)

save = False
load = True
no_fits = True

lin_fit_seconds = 10
exp_fit_seconds = 500

############################

rbead, rbead_err = bu.get_rbead(mbead, mbead_err)
Ibead, Ibead_err = bu.get_Ibead(mbead, mbead_err)


def gauss(x, A, mu, sigma, c):
    return A * np.exp(-1.0 * (x - mu)**2 / (2.0 * sigma**2)) + c


def ngauss(x, A, mu, sigma, c, n=2):
    return A * np.exp(-1.0 * np.abs(x - mu)**n / (2.0 * sigma**n)) + c


def lorentzian(x, A, mu, gamma, c):
    return (A / np.pi) * (gamma**2 / ((x - mu)**2 + gamma**2)) + c


def line(x, a, b):
示例#3
0
path_dict['XX'] = {}
path_dict['XX'][1] = (paths, save_paths)
gases = ['XX']
inds = [1]

save = True
load = False

#####################################################

if plot_raw_dat or plot_demod or plot_phase or plot_sideband_fit:
    ncore = 1

bu.make_all_pardirs(save_paths[0])

Ibead = bu.get_Ibead(date=date)
# Ibead = bu.get_Ibead(date=date, rhobead={'val': 1850.0, 'sterr': 0.0, 'syserr': 0.0})


def sqrt(x, A, x0, b):
    return A * np.sqrt(x - x0)  #+ b


def gauss(x, A, mu, sigma, c):
    return A * np.exp(-1.0 * (x - mu)**2 / (2.0 * sigma**2)) + c


def lorentzian(x, A, mu, gamma, c):
    return (A / np.pi) * (gamma**2 / ((x - mu)**2 + gamma**2)) + c

#         paths.append(base_path + dirname)
#         save_paths.append(base_save_path + dirname + '.npy')
# bu.make_all_pardirs(save_paths[0])
npaths = len(paths)

save = True
load = False

if plot_raw_dat or plot_fit:
    ncore = 1

############################

rbead, rbead_sterr, rbead_syserr = bu.get_rbead(mbead, mbead_sterr,
                                                mbead_syserr)
Ibead, Ibead_sterr, Ibead_syserr = bu.get_Ibead(mbead, mbead_sterr,
                                                mbead_syserr)


def gauss(x, A, mu, sigma, c):
    return A * np.exp(-1.0 * (x - mu)**2 / (2.0 * sigma**2)) + c


def ngauss(x, A, mu, sigma, c, n=2):
    return A * np.exp(-1.0 * np.abs(x - mu)**n / (2.0 * sigma**n)) + c


def lorentzian(x, A, mu, gamma, c):
    return A * (gamma**2 / ((x - mu)**2 + gamma**2)) + c


def line(x, a, b):
示例#5
0
one_path = False

base_path = '/data/old_trap_processed/spinning/wobble/'

date = '20200727'
meas = 'wobble_slow_2/'

# date = '20200924'
# meas = 'dipole_meas/initial/'

gases = ['XX']
path_dict = {'XX': [os.path.join(base_path, '{:s}/{:s}'.format(date, meas))]}



Ibead = bu.get_Ibead(date=date, verbose=True)

def sqrt(x, A, x0, b):
    return A * np.sqrt(x-x0) + b


for gas in gases:
    fig, ax = plt.subplots(1,1)
    paths = path_dict[gas]
    for pathind, path in enumerate(paths):

        dipole_filename = path[:-1] + '.dipole'

        color = 'C' + str(pathind)

        files, lengths = bu.find_all_fnames(path, ext='.npy')
    1,
    1,  #gridspec_kw = {'height_ratios':[1,1]}, \
    sharex=True,
    figsize=(6, 3),
    dpi=200)

kb = constants.Boltzmann
T = 297

## Assuming base pressure limited by water
m0 = 18.0 * constants.atomic_mass

mbead = bu.get_mbead(date)

rbead = bu.get_rbead(mbead)
Ibead = bu.get_Ibead(mbead)

print('Optical torque estimate: ', Ibead['val'] * 20.0e3 / 1500.0)

kappa = {}
kappa['val'] = 6.47e11
kappa['sterr'] = 0.06e11
kappa['syserr'] = 0.25e11

kappa_calc = bu.get_kappa(mbead)

#colors = bu.get_color_map(len(newpaths)*2 + 1, cmap='plasma')
colors = bu.get_color_map(len(newpaths), cmap='plasma')

two_point_times = []
two_point_estimates = []
true_fspin = np.average(full_freqs[inds], weights=np.abs(elec3_fft)[inds])

if not libration_guess:

    try:
        elec3_cut = 100.0 * (50000.0 / 53000.0) * elec3[:int(fsamp)]
        zeros = np.zeros_like(elec3_cut)
        voltages = [
            zeros, zeros, zeros, elec3_cut, -1.0 * elec3_cut, zeros, zeros,
            zeros
        ]
        efield = bu.trap_efield(voltages, only_x=True)[0]
        efield_amp, _ = bu.get_sine_amp_phase(efield)

        dipole = np.load(dipole_file)[0]
        Ibead = bu.get_Ibead(date=date, rhobead=rhobead)['val']

        libration_guess = np.sqrt(efield_amp * dipole / Ibead) / (2.0 * np.pi)

    except:

        amp, phase_mod = bu.demod(vperp, true_fspin, fsamp, plot=plot_carrier_demod, \
                                  filt=True, bandwidth=bandwidth,
                                  tukey=True, tukey_alpha=5.0e-4, \
                                  detrend=True, detrend_order=1, harmind=2.0)

        phase_mod_fft = np.fft.rfft(phase_mod) * fac

        fig, ax = plt.subplots(1, 1)
        ax.loglog(full_freqs, np.abs(phase_mod_fft))
        ax.set_xlabel('Frequency [Hz]')