regular backup
This commit is contained in:
parent
43106834a5
commit
2744a57d68
@ -80,6 +80,48 @@ def two_gaussian2d(x, y=0.0, A_amplitude=1.0, A_centerx=0.0, A_centery=0.0, A_si
|
||||
return z
|
||||
|
||||
|
||||
def ThomasFermi_2d(x, y=0.0, centerx=0.0, centery=0.0, amplitude=1.0, sigmax=1.0, sigmay=1.0):
|
||||
res = (1- ((x-centerx)/(sigmax))**2 - ((y-centery)/(sigmay))**2)**(3 / 2)
|
||||
return amplitude * 5 / 2 / np.pi / max(tiny, sigmax * sigmay) * np.where(res > 0, res, 0)
|
||||
|
||||
|
||||
def polylog(power, numerator):
|
||||
|
||||
dataShape = numerator.shape
|
||||
numerator = np.tile(numerator, (20, 1))
|
||||
|
||||
denominator = np.arange(1, 21)
|
||||
denominator = np.tile(denominator, (dataShape[0], 1))
|
||||
denominator = denominator.T
|
||||
|
||||
data = numerator / denominator
|
||||
|
||||
return np.sum(np.power(data, power), axis=0)
|
||||
|
||||
|
||||
def polylog2_2d(x, y=0.0, centerx=0.0, centery=0.0, amplitude=1.0, sigmax=1.0, sigmay=1.0):
|
||||
## Approximation of the polylog function with 2D gaussian as argument. -> discribes the thermal part of the cloud
|
||||
return amplitude / np.pi / 1.59843 / max(tiny, sigmax * sigmay) * polylog(2, np.exp( -((x-centerx)**2/(2 * (sigmax)**2))-((y-centery)**2/( 2 * (sigmay)**2)) ))
|
||||
|
||||
|
||||
def density_profile_BEC_2d(x, y=0.0, amplitude=1.0, condensateFraction=1.0, BEC_centerx=0.0, BEC_centery=0.0, thermal_centerx=0.0, thermal_centery=0.0,
|
||||
BEC_sigmax=1.0, BEC_sigmay=1.0, thermal_sigmax=1.0, thermal_sigmay=1.0):
|
||||
|
||||
return ThomasFermi_2d(x=x, y=y, centerx=BEC_centerx, centery=BEC_centery,
|
||||
amplitude=amplitude*condensateFraction, sigmax=BEC_sigmax, sigmay=BEC_sigmay
|
||||
) + polylog2_2d(x=x, y=y, centerx=thermal_centerx, centery=thermal_centery,
|
||||
amplitude=amplitude * (1 - condensateFraction), sigmax=thermal_sigmax, sigmay=thermal_sigmay)
|
||||
|
||||
|
||||
# def density_profile_BEC_2d(x, y=0.0, BEC_amplitude=1.0, thermal_amplitude=1.0, BEC_centerx=0.0, BEC_centery=0.0, thermal_centerx=0.0, thermal_centery=0.0,
|
||||
# BEC_sigmax=1.0, BEC_sigmay=1.0, thermal_sigmax=1.0, thermal_sigmay=1.0):
|
||||
|
||||
# return ThomasFermi_2d(x=x, y=y, centerx=BEC_centerx, centery=BEC_centery,
|
||||
# amplitude=BEC_amplitude, sigmax=BEC_sigmax, sigmay=BEC_sigmay
|
||||
# ) + polylog2_2d(x=x, y=y, centerx=thermal_centerx, centery=thermal_centery,
|
||||
# amplitude=thermal_amplitude, sigmax=thermal_sigmax, sigmay=thermal_sigmay)
|
||||
|
||||
|
||||
class GaussianWithOffsetModel(Model):
|
||||
|
||||
fwhm_factor = 2*np.sqrt(2*np.log(2))
|
||||
@ -224,6 +266,124 @@ class TwoGaussian2dModel(Model):
|
||||
return pars
|
||||
|
||||
|
||||
class Polylog22dModel(Model):
|
||||
|
||||
fwhm_factor = 2*np.sqrt(2*np.log(2))
|
||||
height_factor = 1./2*np.pi
|
||||
|
||||
def __init__(self, independent_vars=['x', 'y'], prefix='', nan_policy='raise',
|
||||
**kwargs):
|
||||
kwargs.update({'prefix': prefix, 'nan_policy': nan_policy,
|
||||
'independent_vars': independent_vars})
|
||||
super().__init__(polylog2_2d, **kwargs)
|
||||
self._set_paramhints_prefix()
|
||||
|
||||
def _set_paramhints_prefix(self):
|
||||
self.set_param_hint('Rx', min=0)
|
||||
self.set_param_hint('Ry', min=0)
|
||||
|
||||
def guess(self, data, x, y, negative=False, **kwargs):
|
||||
"""Estimate initial model parameter values from data."""
|
||||
pars = guess_from_peak2d(self, data, x, y, negative)
|
||||
return update_param_vals(pars, self.prefix, **kwargs)
|
||||
|
||||
|
||||
class ThomasFermi2dModel(Model):
|
||||
|
||||
fwhm_factor = 1
|
||||
height_factor = 0.5
|
||||
|
||||
def __init__(self, independent_vars=['x', 'y'], prefix='', nan_policy='raise',
|
||||
**kwargs):
|
||||
kwargs.update({'prefix': prefix, 'nan_policy': nan_policy,
|
||||
'independent_vars': independent_vars})
|
||||
super().__init__(ThomasFermi_2d, **kwargs)
|
||||
self._set_paramhints_prefix()
|
||||
|
||||
def _set_paramhints_prefix(self):
|
||||
self.set_param_hint('Rx', min=0)
|
||||
self.set_param_hint('Ry', min=0)
|
||||
|
||||
def guess(self, data, x, y, negative=False, **kwargs):
|
||||
"""Estimate initial model parameter values from data."""
|
||||
pars = guess_from_peak2d(self, data, x, y, negative)
|
||||
|
||||
# amplitude = pars['amplitude'].value
|
||||
# simgax = pars['sigmax'].value
|
||||
# sigmay = pars['sigmay'].value
|
||||
|
||||
# pars['amplitude'].set(value=amplitude/s2pi/simgax/sigmay)
|
||||
|
||||
simgax = pars['sigmax'].value
|
||||
sigmay = pars['sigmay'].value
|
||||
pars['simgax'].set(value=simgax / 2.355)
|
||||
pars['sigmay'].set(value=sigmay / 2.355)
|
||||
|
||||
return update_param_vals(pars, self.prefix, **kwargs)
|
||||
|
||||
|
||||
class DensityProfileBEC2dModel(Model):
|
||||
|
||||
fwhm_factor = 2*np.sqrt(2*np.log(2))
|
||||
height_factor = 1./2*np.pi
|
||||
|
||||
def __init__(self, independent_vars=['x', 'y'], prefix='', nan_policy='raise',
|
||||
**kwargs):
|
||||
kwargs.update({'prefix': prefix, 'nan_policy': nan_policy,
|
||||
'independent_vars': independent_vars})
|
||||
super().__init__(density_profile_BEC_2d, **kwargs)
|
||||
self._set_paramhints_prefix()
|
||||
|
||||
def _set_paramhints_prefix(self):
|
||||
self.set_param_hint('BEC_sigmax', min=0)
|
||||
self.set_param_hint('BEC_sigmay', min=0)
|
||||
self.set_param_hint('thermal_sigmax', min=0)
|
||||
self.set_param_hint('thermal_sigmay', min=0)
|
||||
|
||||
def guess(self, data, x, y, negative=False, **kwargs):
|
||||
"""Estimate initial model parameter values from data."""
|
||||
fitModel = TwoGaussian2dModel()
|
||||
pars = fitModel.guess(data, x=x, y=y, negative=negative)
|
||||
fitResult = fitModel.fit(data, x=x, y=y, params=pars, **kwargs)
|
||||
pars_guess = fitResult.params
|
||||
|
||||
amplitude = (pars_guess['A_amplitude'].value + pars_guess['B_amplitude'].value)
|
||||
# amplitude = amplitude / amplitude * np.max(data)
|
||||
condensateFraction = pars_guess['A_amplitude'].value / (pars_guess['A_amplitude'].value + pars_guess['B_amplitude'].value)
|
||||
|
||||
pars = self.make_params(amplitude=amplitude,
|
||||
condensateFraction=condensateFraction,
|
||||
BEC_centerx=pars_guess['A_centerx'].value, BEC_centery=pars_guess['A_centery'].value,
|
||||
BEC_sigmax=(pars_guess['A_sigmax'].value / 2.355), BEC_sigmay=(pars_guess['A_sigmay'].value / 2.355),
|
||||
thermal_centerx=pars_guess['B_centerx'].value, thermal_centery=pars_guess['B_centery'].value,
|
||||
thermal_sigmax=(pars_guess['B_sigmax'].value * s2), thermal_sigmay=(pars_guess['B_sigmay'].value * s2))
|
||||
|
||||
# BEC_amplitude = pars_guess['A_amplitude'].value
|
||||
# thermal_amplitude = pars_guess['B_amplitude'].value
|
||||
|
||||
# pars = self.make_params(BEC_amplitude=BEC_amplitude,
|
||||
# thermal_amplitude=thermal_amplitude,
|
||||
# BEC_centerx=pars_guess['A_centerx'].value, BEC_centery=pars_guess['A_centery'].value,
|
||||
# BEC_sigmax=(pars_guess['A_sigmax'].value / 2.355), BEC_sigmay=(pars_guess['A_sigmay'].value / 2.355),
|
||||
# thermal_centerx=pars_guess['B_centerx'].value, thermal_centery=pars_guess['B_centery'].value,
|
||||
# thermal_sigmax=(pars_guess['B_sigmax'].value * s2), thermal_sigmay=(pars_guess['B_sigmay'].value * s2))
|
||||
|
||||
# pars[f'{self.prefix}BEC_sigmax'].set(min=0.0)
|
||||
# pars[f'{self.prefix}BEC_sigmay'].set(min=0.0)
|
||||
# pars[f'{self.prefix}thermal_sigmax'].set(min=0.0)
|
||||
# pars[f'{self.prefix}thermal_sigmay'].set(min=0.0)
|
||||
|
||||
if condensateFraction < 0.3:
|
||||
pars[f'{self.prefix}condensateFraction'].set(max=condensateFraction*1.5)
|
||||
if condensateFraction > 0.5:
|
||||
pars[f'{self.prefix}condensateFraction'].set(min=0.9)
|
||||
|
||||
# pars[f'{self.prefix}condensateFraction'].set(max=condensateFraction*1.5)
|
||||
# pars[f'{self.prefix}condensateFraction'].set(min=condensateFraction*0.75)
|
||||
|
||||
return update_param_vals(pars, self.prefix, **kwargs)
|
||||
|
||||
|
||||
class NewFitModel(Model):
|
||||
|
||||
def __init__(self, func, independent_vars=['x'], prefix='', nan_policy='raise',
|
||||
|
@ -207,6 +207,7 @@ def _assign_scan_axis_partial_and_remove_everything(x, datesetOfGlobal, fullFile
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _read_run_time_from_hdf5(x):
|
||||
runTime = datetime.strptime(x.attrs['run time'], '%Y%m%dT%H%M%S')
|
||||
return runTime
|
||||
|
Loading…
Reference in New Issue
Block a user