def waterfall_stdev_of_avg(dats: Iterable[DatHDF]) -> go.Figure:
    dats = list(dats)

    data = np.array([dat.Transition.avg_data_std for dat in dats])
    xs = [dat.Transition.avg_x for dat in dats]

    data, xs = [
        U.resample_data(data=arr, max_num_pnts=500, resample_method='bin')
        for arr in [data, xs]
    ]

    plotter = TwoD(dats=dats)
    fig = plotter.figure(
        title=f'Dat{dats[0].datnum}-{dats[-1].datnum}: '
        f'Standard deviation of averaged I_sense data after centering')
    fig.add_traces([
        go.Scatter3d(mode='lines',
                     x=x,
                     y=[dat.Logs.fds['ESS']] * len(dat.Transition.avg_x),
                     z=row,
                     name=f'Dat{dat.datnum}')
        for x, row, dat in zip(xs, data, dats)
    ])
    fig.update_layout(scene=dict(
        xaxis_title=dats[0].Logs.xlabel,
        yaxis_title=f'ESS /mV',
        zaxis_title=f'{dat_analysis.dat_analysis.characters.SIG}I_sense /nA',
    ))
    return fig
def plot_2d(dat: DatHDF, differentiated=True) -> go.Figure:
    plotter = TwoD(dat=dat)

    x, y, data = _get_data(dat, dat.Logs.measure_freq, differentiated=differentiated)

    title_prepend = ''
    if differentiated:
        title_prepend = 'Differentiated '

    fig = plotter.plot(x=x, y=y, data=data, title=f'Dat{dat.datnum}: {title_prepend}Res Potential vs ACC<br>'
                                             f'ESC={dat.Logs.fds["ESC"]:.1f}mV')
    return fig
Beispiel #3
0
def plot_nrg(which: str,
             nrg: Optional[NRGData] = None, plot=True,
             x_axis_type: str = 'energy') -> go.Figure:
    @dataclass
    class PlotInfo:
        data: np.ndarray
        title: str

    if nrg is None:
        nrg = NRGData.from_old_mat()

    x = nrg.ens
    if x_axis_type == 'energy':
        xlabel = 'Energy'
    elif x_axis_type == 'gate':
        xlabel = 'Gate /Arbitrary mV'
        x = np.flip(x)
    else:
        raise NotImplementedError
    y = nrg.ts / 0.001
    ylabel = f'{THETA}/Gamma'

    if which == 'conductance':
        pi = PlotInfo(data=nrg.conductance,
                      title='NRG Conductance')
    elif which == 'dndt':
        pi = PlotInfo(data=nrg.dndt,
                      title='NRG dN/dT')
    elif which == 'entropy':
        pi = PlotInfo(data=nrg.entropy,
                      title='NRG Entropy')
    elif which == 'occupation':
        pi = PlotInfo(data=nrg.occupation,
                      title='NRG Occupation')
    elif which == 'i_sense':
        pi = PlotInfo(data=1 - nrg.occupation,
                      title='NRG I_sense (1-Occ)')
    elif which == 'int_dndt':
        pi = PlotInfo(data=nrg.int_dndt,
                      title='NRG Integrated dN/dT')
    else:
        raise KeyError(f'{which} not recognized')

    plotter = TwoD(dat=None)
    fig = plotter.figure(xlabel=xlabel, ylabel=ylabel, title=pi.title)
    fig.add_trace(plotter.trace(data=pi.data, x=x, y=y))
    fig.update_yaxes(type='log')
    if plot:
        fig.show()
    return fig
                       params=params,
                       nan_policy='omit')
        fig = plotter.figure(
            xlabel=dat.Logs.xlabel,
            ylabel=f'{C.DELTA}Gate /mV',
            title=
            f'Dat{dat.datnum}: After mapping and subtracting line fit (using Dat{csq_dat})<br>'
            f'ESS={dat.Logs.fds["ESS"]:.1f}mV, '
            f'ESC={dat.Logs.fds["ESC"]:.1f}mV, '
            f'ESP={dat.Logs.fds["ESP"]:.1f}mV')
        fig.add_trace(plotter.trace(x=x, data=data - fit.eval(x=x)))
        fig.show()

    if plot_dot_tune:
        dat = get_dat(3063)
        plotter = TwoD(dat=dat)
        fig = plotter.plot(data=dat.Data.i_sense,
                           title=f'Dat{dat.datnum}: Dot Tune')
        fig.show()

        data = dat.Data.i_sense
        diff_data = np.diff(dat_analysis.hdf_util.T, axis=0)
        # x = U.get_matching_x(dat.Data.x, diff_data)
        x = dat.Data.x
        y = U.get_matching_x(dat.Data.y, shape_to_match=diff_data.shape[0])
        fig = plotter.plot(diff_data,
                           x=x,
                           y=y,
                           title=f'Dat{dat.datnum}: Differentiated Dot Tune',
                           trace_kwargs=dict(zmin=-0.1,
                                             zmax=np.nanmax(diff_data)))
Beispiel #5
0
from typing import Optional, TYPE_CHECKING
from progressbar import progressbar

from dat_analysis.analysis_tools.general_fitting import FitInfo
from dat_analysis.dat_analysis.characters import DELTA
from dat_analysis.plotting.plotly.dat_plotting import OneD, TwoD
from dat_analysis.core_util import Data1D
from dat_analysis.analysis_tools.nrg import NRGParams, NrgUtil
import dat_analysis.useful_functions as U
from temp import get_avg_entropy_data, get_avg_i_sense_data, get_linear_theta, get_initial_params, get_2d_data

if TYPE_CHECKING:
    from dat_analysis.dat_object.make_dat import DatHDF

p1d = OneD(dat=None)
p2d = TwoD(dat=None)

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

NRG_OCC_FIT_NAME = 'csq_forced_theta'
CSQ_DATNUM = 2197


class StrongGammaNoise:
    def __init__(self, dat: DatHDF):
        self.dat = dat

        # The averaged data which does show some signal, but quite small given the number of repeats and duration
        self.avg_data = get_avg_entropy_data(self.dat, lambda _: False,
                                             CSQ_DATNUM)
Beispiel #6
0
from scipy.interpolate import interp1d
import lmfit as lm

import dat_analysis.analysis_tools.nrg
from dat_analysis.dat_analysis.characters import DELTA
from dat_analysis.plotting.plotly.dat_plotting import OneD, TwoD
from dat_analysis.core_util import Data1D, Data2D
from dat_analysis.analysis_tools.nrg import NRG_func_generator
from dat_analysis.analysis_tools.nrg import NRGParams, NrgUtil, get_x_of_half_occ
import dat_analysis.useful_functions as U
from temp import get_avg_entropy_data, get_avg_i_sense_data, _center_func

kb = 0.08617

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,
 def transition_2d(self) -> go.Figure:
     if not self._correct_call_args():
         logger.warning(f'Bad call args to GraphCallback')
         return go.Figure()
     if not self.calculated_triggered or self.calculated.analysis_params.transition_only_datnum is None:
         dat = self.dat
         plotter = TwoD(dat=dat)
         out = dat.SquareEntropy.get_row_only_output(name='default',
                                                     calculate_only=True)
         x = out.x
         y = dat.Data.get_data('y')
         data = np.nanmean(out.cycled[:, (
             0,
             2,
         ), :], axis=1)
         fig = plotter.plot(data=data,
                            x=x,
                            y=y,
                            title=f'Dat{dat.datnum}: 2D Cold Transition')
         if self.calculated_triggered:
             out = self.calculated.calculated_entropy_fit.output
             x = out.x
             data = np.nanmean(out.cycled[:, (
                 0,
                 2,
             ), :], axis=1)
             ys = y_from_rows(
                 self.calculated.analysis_params.entropy_data_rows,
                 y,
                 mode='values')
             fig.add_trace(
                 plotter.trace(data=data,
                               x=x,
                               y=np.linspace(ys[0], ys[1],
                                             out.entropy_signal.shape[0])))
             for h in ys:
                 plotter.add_line(fig, h, mode='horizontal', color='black')
     else:
         dat = get_dat(
             self.calculated.analysis_params.transition_only_datnum)
         plotter = TwoD(dat=dat)
         x = dat.Transition.x
         y = dat.Data.get_data('y')
         data = dat.Transition.data
         ys = y_from_rows(
             self.calculated.analysis_params.transition_data_rows,
             y,
             mode='values')
         fig = plotter.plot(data=data,
                            x=x,
                            y=y,
                            title=f'Dat{dat.datnum}: 2D Transition only')
         for h in ys:
             plotter.add_line(fig, h, mode='horizontal', color='black')
     return fig
Beispiel #8
0
from deprecation import deprecated

import dat_analysis.useful_functions as U
from dat_analysis.dat_analysis.characters import DELTA
from dat_analysis.dat_object.make_dat import get_dat
from dat_analysis.plotting.plotly.dat_plotting import OneD, TwoD
from dat_analysis.analysis_tools.general_fitting import calculate_fit
from dat_analysis.analysis_tools.nrg import NRG_func_generator
from OLD.new_dash.pages import invert_nrg_fit_params

import plotly.io as pio

pio.renderers.default = 'browser'

p1d = OneD(dat=None)
p2d = TwoD(dat=None)


@dataclass
class Params:
    gamma: float
    theta: float
    center: float
    amp: float
    lin: float
    const: float
    lin_occ: float
    vary_theta: bool = False
    vary_gamma: bool = False
    datnum: Optional[int] = None