Browse Source

Merge branch 'add_rotation'

master
Joschka 1 year ago
parent
commit
62ad8157b9
  1. 852
      20230630_Data_Analysis copy.ipynb
  2. 28
      Analyser/FitAnalyser.py
  3. 843
      Analyser/Joschka/20230630_Data_Analysis copy.ipynb
  4. 1236
      Analyser/Joschka/test_rotation.ipynb

852
20230630_Data_Analysis copy.ipynb
File diff suppressed because one or more lines are too long
View File

28
Analyser/FitAnalyser.py

@ -26,7 +26,8 @@ from scipy.special import gamma as gamfcn
from scipy.special import wofz from scipy.special import wofz
from scipy.optimize import curve_fit from scipy.optimize import curve_fit
from scipy.interpolate import CubicSpline from scipy.interpolate import CubicSpline
from scipy.ndimage import gaussian_filter
from scipy.ndimage import gaussian_filter, rotate
import scipy.constants as const
import xarray as xr import xarray as xr
@ -159,9 +160,23 @@ def polylog2_2d(x, y=0.0, centerx=0.0, centery=0.0, amplitude=1.0, sigmax=1.0, s
## Approximation of the polylog function with 2D gaussian as argument. -> discribes the thermal part of the cloud ## Approximation of the polylog function with 2D gaussian as argument. -> discribes the thermal part of the cloud
return amplitude/1.643 * polylog_int(np.exp( -((x-centerx)**2/(2 * sigmax**2))-((y-centery)**2/( 2 * sigmay**2)) )) return amplitude/1.643 * polylog_int(np.exp( -((x-centerx)**2/(2 * sigmax**2))-((y-centery)**2/( 2 * sigmay**2)) ))
def rotate_coord(x,y, rot_angle):
rot_angle *= 2*np.pi/360
x_og = x
x = x_og * np.cos(rot_angle) + y * np.sin(rot_angle)
y = -x_og * np.sin(rot_angle) + y * np.cos(rot_angle)
return x, y
def density_profile_BEC_2d(x, y=0.0, amp_bec=1.0, amp_th=1.0, x0_bec=0.0, y0_bec=0.0, x0_th=0.0, y0_th=0.0, def density_profile_BEC_2d(x, y=0.0, amp_bec=1.0, amp_th=1.0, x0_bec=0.0, y0_bec=0.0, x0_th=0.0, y0_th=0.0,
sigmax_bec=1.0, sigmay_bec=1.0, sigma_th=1.0):
sigmax_bec=1.0, sigmay_bec=1.0, sigma_th=1.0, rot_angle=None):
if rot_angle is not None:
x, y = rotate_coord(x,y, rot_angle)
x0_bec, y0_bec = rotate_coord(x0_bec, y0_bec, rot_angle)
x0_th, y0_th = rotate_coord(x0_th, y0_th, rot_angle)
return ThomasFermi_2d(x=x, y=y, centerx=x0_bec, centery=y0_bec, return ThomasFermi_2d(x=x, y=y, centerx=x0_bec, centery=y0_bec,
amplitude=amp_bec, sigmax=sigmax_bec, sigmay=sigmay_bec amplitude=amp_bec, sigmax=sigmax_bec, sigmay=sigmay_bec
) + polylog2_2d(x=x, y=y, centerx=x0_th, centery=y0_th, ) + polylog2_2d(x=x, y=y, centerx=x0_th, centery=y0_th,
@ -403,11 +418,13 @@ class DensityProfileBEC2dModel(lmfit.Model):
self.set_param_hint('sigmay_bec', min=0) self.set_param_hint('sigmay_bec', min=0)
self.set_param_hint('sigma_th', min=0) self.set_param_hint('sigma_th', min=0)
self.set_param_hint('rot_angle', min=-90, max=90)
self.set_param_hint('atom_number_bec', expr=f'{self.prefix}amp_bec / 5 * 2 * 3.14159265359 * {self.prefix}sigmax_bec * {self.prefix}sigmay_bec') self.set_param_hint('atom_number_bec', expr=f'{self.prefix}amp_bec / 5 * 2 * 3.14159265359 * {self.prefix}sigmax_bec * {self.prefix}sigmay_bec')
self.set_param_hint('atom_number_th', expr=f'{self.prefix}amp_th * 2 * 3.14159265359 * 1.20206 / 1.643 * {self.prefix}sigma_th * {self.prefix}sigma_th') self.set_param_hint('atom_number_th', expr=f'{self.prefix}amp_th * 2 * 3.14159265359 * 1.20206 / 1.643 * {self.prefix}sigma_th * {self.prefix}sigma_th')
self.set_param_hint('condensate_fraction', expr=f'{self.prefix}atom_number_bec / ({self.prefix}atom_number_bec + {self.prefix}atom_number_th)') self.set_param_hint('condensate_fraction', expr=f'{self.prefix}atom_number_bec / ({self.prefix}atom_number_bec + {self.prefix}atom_number_th)')
def guess(self, data, x, y, pre_check=False, post_check=False, **kwargs):
def guess(self, data, x, y, rot_angle=0, vary_rot=False, pre_check=False, post_check=False, **kwargs):
"""Estimate and create initial model parameters for 2d bimodal fit, by doing a 1d bimodal fit along an integrated slice of the image """Estimate and create initial model parameters for 2d bimodal fit, by doing a 1d bimodal fit along an integrated slice of the image
:param data: Flattened 2d array, in form [a_00, a_10, a_20, ..., a_01, a_02, .. ,a_XY] with a_xy, x_dim=X, y_dim=Y :param data: Flattened 2d array, in form [a_00, a_10, a_20, ..., a_01, a_02, .. ,a_XY] with a_xy, x_dim=X, y_dim=Y
@ -437,6 +454,9 @@ class DensityProfileBEC2dModel(lmfit.Model):
data = np.reshape(data, (y_width, x_width)) data = np.reshape(data, (y_width, x_width))
data = data.T data = data.T
if rot_angle != 0:
data = rotate(data, rot_angle, reshape=False)
shape = np.shape(data) shape = np.shape(data)
if self.is_debug: if self.is_debug:
print(f'shape: {shape}') print(f'shape: {shape}')
@ -582,6 +602,8 @@ class DensityProfileBEC2dModel(lmfit.Model):
else: else:
print('Error in small width BEC recogintion, s_width_ind should be 0 or 1') print('Error in small width BEC recogintion, s_width_ind should be 0 or 1')
params[f'{self.prefix}rot_angle'].set(value=-rot_angle, min=-rot_angle-30, max=-rot_angle+30, vary=vary_rot)
if self.is_debug: if self.is_debug:
print('') print('')
print('Init Params') print('Init Params')

843
Analyser/Joschka/20230630_Data_Analysis copy.ipynb
File diff suppressed because one or more lines are too long
View File

1236
Analyser/Joschka/test_rotation.ipynb
File diff suppressed because one or more lines are too long
View File

Loading…
Cancel
Save