Exemplo n.º 1
0
    def _get_datas(self) -> Tuple[List[Data1D], List[float], List[float]]:
        datas = []
        if self.which_plot == 'data':
            gammas = []
            thetas = []
            for k in PARAM_DATNUM_DICT:
                dat = get_dat(k)
                data = get_avg_entropy_data(dat,
                                            center_func=_center_func,
                                            csq_datnum=CSQ_DATNUM)
                occ_data = get_avg_i_sense_data(dat,
                                                CSQ_DATNUM,
                                                center_func=_center_func)
                data.x = occ_data.x
                data.x -= dat.NrgOcc.get_x_of_half_occ(
                    fit_name=NRG_OCC_FIT_NAME)
                fit = dat.NrgOcc.get_fit(name=NRG_OCC_FIT_NAME)
                # data.x = data.x/fit.best_values.theta*kb*0.1  # So that difference in lever arm is taken into account
                gammas.append(fit.best_values.g)
                thetas.append(fit.best_values.theta)
                rescale = max(fit.best_values.g, fit.best_values.theta)
                datas.append(
                    Data1D(x=data.x / rescale, data=data.data * rescale))
        elif self.which_plot == 'nrg':
            gts = [0.1, 1, 5, 10, 25]
            theta = 1
            thetas = [theta] * len(gts)
            gammas = list(np.array(gts) * theta)
            for gamma in gammas:
                x_width = max([gamma, theta]) * 15
                pars = NRGParams(gamma=gamma, theta=theta)
                data = NrgUtil().data_from_params(params=pars,
                                                  x=np.linspace(
                                                      -x_width, x_width, 501),
                                                  which_data='dndt',
                                                  which_x='sweepgate')
                data.x -= get_x_of_half_occ(params=pars.to_lm_params())
                data.x *= 0.0001  # Convert back to NRG units
                data.data = data.data / np.sum(data.data) / np.mean(
                    np.diff(data.x)) * np.log(2)  # Convert to real entropy
                rescale = max(gamma, theta)
                data.x = data.x / rescale
                data.data = data.data * rescale
                datas.append(data)

        else:
            raise NotImplementedError

        return datas, gammas, thetas
Exemplo n.º 2
0
 def _get_params_from_dat(self,
                          datnum,
                          fit_which: str = 'i_sense',
                          hot_or_cold: str = 'cold') -> NRGParams:
     dat = get_dat(datnum)
     orig_fit = dat.NrgOcc.get_fit(name=NRG_OCC_FIT_NAME)
     if fit_which == 'i_sense':
         data = get_avg_i_sense_data(dat,
                                     CSQ_DATNUM,
                                     center_func=_center_func,
                                     hot_or_cold=hot_or_cold)
         if hot_or_cold == 'hot':  # Then allow theta to vary, but hold gamma const
             params = U.edit_params(orig_fit.params, ['g', 'theta'],
                                    [None, None],
                                    vary=[False, True])
         else:
             params = orig_fit.params
         new_fit = dat.NrgOcc.get_fit(calculate_only=True,
                                      x=data.x,
                                      data=data.data,
                                      initial_params=params)
     elif fit_which == 'entropy':
         data = get_avg_entropy_data(dat,
                                     center_func=_center_func,
                                     csq_datnum=CSQ_DATNUM)
         new_fit = NrgUtil(inital_params=orig_fit).get_fit(
             data.x, data.data, which_data='dndt')
     else:
         raise NotImplementedError
     params = NRGParams.from_lm_params(new_fit.params)
     return params
Exemplo n.º 3
0
def get_dndt_vs_occ(dat: DatHDF) -> Data1D:
    data = get_avg_entropy_data(dat, lambda _: False, None)
    fit = dat.NrgOcc.get_fit(name='forced_theta')
    nrg = NrgUtil(NRGParams.from_lm_params(fit.params))
    data.x = nrg.get_occupation_x(data.x)
    data.data = data.data / np.nanmax(
        U.decimate(data.data, measure_freq=dat.Logs.measure_freq, numpnts=100))
    return data
Exemplo n.º 4
0
def get_N_vs_sweepgate(dat: DatHDF, fit_name: str = 'gamma_small') -> Data1D:
    """Quick fn for Josh, to get Occupation vs sweep to see that peak is at 2/3"""
    fit = dat.NrgOcc.get_fit(name=fit_name)
    nrg = NrgUtil(NRGParams.from_lm_params(fit.params))
    x = dat.NrgOcc.avg_x
    occ = nrg.data_from_params(x=x, which_data='occupation')
    occ.x = occ.x / 100  # Convert to real mV
    return occ
Exemplo n.º 5
0
def get_expected_dndt_vs_occ(dat: DatHDF) -> Data1D:
    fit = dat.NrgOcc.get_fit(name='forced_theta')
    nrg = NrgUtil(NRGParams.from_lm_params(fit.params))
    real_data = get_avg_entropy_data(dat, lambda _: False, None)
    data = nrg.data_from_params(x=real_data.x,
                                which_data='dndt',
                                which_x='occupation')
    data.data = data.data / np.max(data.data)
    return data
Exemplo n.º 6
0
 def nrg_data(self,
              params: NRGParams,
              x: np.ndarray,
              which_data: str = 'dndt',
              which_x: str = 'occupation',
              real_data: Optional[np.ndarray] = None,
              which_fit_data: str = 'i_sense') -> Data1D:
     """For NRG data only"""
     nrg_generator = NrgUtil(inital_params=params)
     if real_data is not None:
         fit = nrg_generator.get_fit(x=x,
                                     data=real_data,
                                     which_data=which_fit_data)
         params = NRGParams.from_lm_params(fit.params)
     return nrg_generator.data_from_params(params,
                                           x=x,
                                           which_data=which_data,
                                           which_x=which_x)
Exemplo n.º 7
0
def get_nrg_integrated(dat: DatHDF) -> Data1D:
    from temp import get_avg_i_sense_data, get_centered_x_at_half_occ, get_centers, get_2d_data
    from dat_analysis.analysis_tools.nrg import NrgUtil, NRGParams
    # i_data = get_avg_i_sense_data(dat, None, _center_func, overwrite=False, hot_or_cold='hot')
    data2d = get_2d_data(dat, hot_or_cold='cold', csq_datnum=None)
    if _center_func(dat):
        centers = get_centers(dat, data2d, name=None, overwrite=False)
    else:
        centers = [0] * data2d.data.shape[0]
    hot_data2d = get_2d_data(dat, hot_or_cold='hot', csq_datnum=None)
    avg_data, avg_x = dat.NrgOcc.get_avg_data(x=data2d.x,
                                              data=hot_data2d.data,
                                              centers=centers,
                                              return_x=True,
                                              name='hot_cold_centers',
                                              check_exists=False,
                                              overwrite=False)
    i_data = Data1D(avg_x, avg_data)
    i_data.x = get_centered_x_at_half_occ(dat,
                                          None,
                                          fit_name='csq_forced_theta')
    init_fit = dat.NrgOcc.get_fit(name='csq_forced_theta')
    new_pars = U.edit_params(init_fit.params, ['theta', 'g'], [None, None],
                             vary=[True, False])
    nrg = NrgUtil(None)
    new_fit = nrg.get_fit(i_data.x,
                          i_data.data,
                          initial_params=new_pars,
                          which_data='i_sense')

    expected_data = nrg.data_from_params(NRGParams.from_lm_params(
        new_fit.params),
                                         x=i_data.x,
                                         which_data='dndt')
    expected_data.data = np.cumsum(expected_data.data)
    expected_data.data = expected_data.data / expected_data.data[-1] * np.log(
        2)
    expected_data.x = expected_data.x / 100  # Convert to real mV
    return expected_data
Exemplo n.º 8
0
    fit_names = ['gamma_small', 'forced_theta']
    # all_dats = get_dats([2164, 2216])  # Weak, Strong coupling
    # all_dats = get_dats([7334, 7356])  # Weak, Strong coupling
    # all_dats = get_dats([7334, 7360])  # Weak, Strong coupling
    tonly_dats = get_dats([dat.datnum + 1 for dat in all_dats])

    dndt_datas, gts, nrg_fits, amps = [], [], [], []
    for dat, fit_name in zip(all_dats, fit_names):
        dndt = get_avg_entropy_data(dat,
                                    center_func=_center_func,
                                    csq_datnum=csq_datnum)

        init_fit = dat.NrgOcc.get_fit(name=fit_name)
        # params = NRGParams.from_lm_params(init_fit.params)
        params = NRGParams.from_lm_params(
            U.edit_params(init_fit.params, ['theta', 'g'],
                          [init_fit.best_values.theta, init_fit.best_values.g],
                          [False, False]))
        nrg_fit = NrgUtil(inital_params=params).get_fit(x=dndt.x,
                                                        data=dndt.data,
                                                        which_data='dndt')

        dndt.x = dndt.x / 100  # Convert to real mV
        gt = init_fit.best_values.g / init_fit.best_values.theta

        dndt_datas.append(dndt)
        gts.append(gt)
        nrg_fits.append(nrg_fit)
        amps.append(init_fit.best_values.amp)

    U.save_to_igor_itx(
        file_path=f'fig1_dndt.itx',
Exemplo n.º 9
0
p1d = OneD(dat=None)
p2d = TwoD(dat=None)

p1d.TEMPLATE = 'simple_white'
p2d.TEMPLATE = 'simple_white'

NRG_OCC_FIT_NAME = 'forced_theta'
# NRG_OCC_FIT_NAME = 'csq_forced_theta'
CSQ_DATNUM = None
# CSQ_DATNUM = 2197

GAMMA_EXPECTED_THETA_PARAMS = NRGParams(
    gamma=23.4352,
    theta=4.5,
    center=78.4,
    amp=0.675,
    lin=0.00121,
    const=7.367,
    lin_occ=0.0001453,
)

MORE_GAMMA_EXPECTED_THETA_PARAMS = NRGParams(
    gamma=59.0125,
    theta=4.5,
    center=21.538,
    amp=0.580,
    lin=0.00109,
    const=7.207,
    lin_occ=0.0001884,
)
Exemplo n.º 10
0
    for dat in entropy_dats:
        data = get_avg_i_sense_data(dat, csq_datnum, None, hot_or_cold='hot')
        data.x = get_centered_x_at_half_occ(dat,
                                            csq_datnum=csq_datnum,
                                            fit_name=nrg_fit_name)
        data.data = U.decimate(data.data,
                               measure_freq=dat.Logs.measure_freq,
                               numpnts=200)
        data.x = U.get_matching_x(data.x, data.data)

        start_fit = dat.NrgOcc.get_fit(name=nrg_fit_name)
        fit = dat.NrgOcc.get_fit(initial_params=start_fit.params,
                                 data=data.data,
                                 x=data.x,
                                 calculate_only=True)
        expected_data = nrg.data_from_params(NRGParams.from_lm_params(
            fit.params),
                                             x=data.x,
                                             which_data=which)

        if which == 'occupation':
            bv = fit.best_values
            data.x, data.data = invert_nrg_fit_params(data.x,
                                                      data.data,
                                                      bv.g,
                                                      bv.theta,
                                                      bv.mid,
                                                      bv.amp,
                                                      bv.lin,
                                                      bv.const,
                                                      bv.occ_lin,
                                                      data_type='i_sense')