output

class pydaddy.output.Output(ddsde, **kwargs)

Bases: pydaddy.preprocessing.Preprocessing, pydaddy.visualize.Visualize

Class to plot and save data and parameters

property A1
property A2
property B11
property B12
property B21
property B22
property F
property G
property _data_avgdiff
property _data_avgdiffX
property _data_avgdiffXY
property _data_avgdiffY
property _data_avgdiffYX
property _data_avgdrift
property _data_avgdriftX
property _data_avgdriftY
property _data_diff_ebar
property _data_drift_ebar
_print_function_diagnostics(f, x, y, name, symbol)
_print_function_diagnostics_2d(f, x, y, z, name, symbol)
_update_slider_data(slider_timescales)
autocorrelation()
cross_diffusion(slider_timescales=None, limits=None, polar=False, **plot_text)

Display diffusion cross correlation slider figure

Parameters

polynomial_order (None or int, default=None) – order of polynomial to fit, if None, no fitting is done.

Returns

opens diffusion slider

Return type

None

data(drift_time_scale=None, diff_time_scale=None)

Get the drift, diffusion and order parameter data for any timescale the analysis is done.

Parameters
  • drift_time_scale (int, optional(default=None)) – time-scale of drift data, if None, returns data analysed for given dt

  • diff_time_scale (int, optional(default=None)) – time-scale of diffusion data, if None, returns data analysed for given delta_t

Returns

  • if vector, [avgdriftX, avgdriftY, avgdiffX, avgdiffY, op_x, op_y]

  • else, [avgdrift, avgdiff, op]

Return type

list

diffusion(slider_timescales=None, limits=None, polar=False, **plot_text)

Display diffusion slider figure

Parameters

polynomial_order (None or int, default=None) – order of polynomial to fit, if None, no fitting is done.

Returns

opens diffusion slider

Return type

None

drift(limits=None, polar=False, slider_timescales=None, **plot_text)

Display drift slider figure

Parameters
  • polynomial_order (None or int, default=None) – order of polynomial to fit, if None, no fitting is done.

  • **plot_text

    plots’ axis and text label

    For scalar analysis

    x_lable : x axis label

    y_label : y axis label

    For vector analysis

    title1 : first plot title

    x_label1 : first plot x label

    y_label1 : first plot y label

    z_label1 : first plot z label

    title2 : second plot title

    x_label2 : second plot x label

    y_label2 : seocnd plot y label

    z_label2 : second plot z label

Returns

opens drift slider

Return type

None

export_data(filename=None, raw=False)

Returns a pandas dataframe containing the drift and diffusion values. :param filename: If provided, the data will be saved as a CSV at the given path. Else, a dataframe will be returned. :type filename: str, optional (default=None). :param raw: If True, the raw, the drift and diffusion will be returned as raw unbinned data. Otherwise (default),

drift and diffusion as binwise-average Kramers-Moyal coefficients are returned.

Returns

df

Return type

Pandas dataframe containing the estimated drift and diffusion coefficients.

fit_diagnostics()
histogram(kde=False, heatmap=False, dpi=150, title_size=14, label_size=15, tick_size=12, label_pad=8, **plot_text)

Show histogram polt chart

Parameters
  • kde (bool, (default=False)) – If True, plots kde for histograms

  • dpi (int, (defautl=150)) – figure resolution

  • title_size (int, (default=14)) – title font size

  • label_size (int, (default=15)) – axis label font size

  • tick_size (int, (default=12)) – axis ticks font size

  • label_pad (int, (default=8)) – axis label padding

  • **plot_text

    plots’ axis and title text

    For scalar analysis histograms:

    hist_title : title

    hist_xlabel : x label

    hist_ylabel : y label

    For vector analysis histograms:

    hist1_title : first histogram title

    hist1_xlabel : first histogram x label

    hist1_ylabel : first histogram y label

    hist2_title : second histogram title

    hist2_xlabel : second histogram x label

    hist2_ylabel : second histogram y label

    hist3_title : third histogram title

    hist3_xlabel : third histogram x label

    hist3_ylabel : third histogram y label

    hist4_title : fourth (3d) histogram title hist4_xlabel : fourth (3d) histogram x label hist4_ylabel : fourth (3d) histogram y label hist4_zlabel : fourth (3d) histogram z label

Returns

histogam chart

Return type

matplotlib.pyplot.figure

noise_diagnostics(loc=None)
parameters()

Get all given and assumed parameters used for the analysis

Returns

params – all parameters given and assumed used for analysis

Return type

dict, json

plot_data(data_in, ax=None, clear=False, title=None, x_label='x', y_label='y', z_label='z', tick_size=12, title_size=16, label_size=14, label_pad=12, legend_label=None, dpi=150)

Plot and visualize vector drift or diffusion data of a 3d axis

Can be used plot multiple data on the same figure and compare by passing the axis of figure.

Parameters
  • data_in (numpy.array) – vector drift or diffusion data to plot

  • ax (figure axis, (default=None)) – Ia ax is None, a new axis will be created and data will be plotted on it.

  • clear (bool, (default=False)) – if True, clear the figure.

  • title (str, (default=None)) – title of the figure

  • x_label (str, (default='x')) – x-axis label

  • y_label (str, (default='y')) – y-axis label

  • z_label (str, (default='z')) – z-axis label

  • tick_size (int, (default=12)) – axis ticks font size

  • title_size (int, (default=16)) – title font size

  • label_size (int, (default=14)) – axis label font size

  • label_pad (int, (default=12)) – axis label padding

  • legend_label (str, (default=None)) – data legend label

  • dpi (int, (default=150)) – figure resolution

Returns

  • ax (3d figure axis) – axis of the 3d figure.

  • fig (matplotlib figure) – returns figure only if the input ax is None.

release()

Clears the memory, recommended to be used while analysing multiple data files in loop.

Return type

None

simulate(sigma=4, dt=None, T=None, **functions)

Simulate SDE

Takes drift and diffusion functions as input and simuates the SDE using the analysis parameters.

The drift and diffusion functions given must be callable type functions.

For scalar F and G (drift and diffusion) must take one input and return a number

Parameters
  • sigma (float) – magnitude of the noise eta(t)

  • **functions

    drift and diffusion callable functions

    For scalar analysis

    F : drift function

    G : diffusion dunction

    For vector analysis

    A1 : drift X

    A2 : drift Y

    B11 : diffusion X

    B22 : diffusion Y

    B12 : diffusion XY

    B21 : diffusion YX

Returns

simulated timeseries – [M] if scalar

[Mx, My] is vector

Return type

list

Examples

# For scalar analysis def drift_function(x):

return 0.125 * x

def diffusion_function(x):

return -(x**2 + 1)

simulated_data = ddsde.simulate(F=drift_function, G=diffusion_function)

# For vector analysis def drift_x(x, y):

return x*x + y*y * x*y**2

def dirft_y(x, y):

return x*y

def diffusion_x(x,y):

return x**2 + x*y

def diffusion_y(x,y):

return y**2 + x*y

def diffusion_xy(x,y):

return 0

def diffusion_yx(x,y):

rerutn 0

simulated_data = ddsde.simulate(A1=drift_x,

A2=drift_y, B11=diffusion_x, B22=diffusion_y, B12=diffusion_xy. B21=diffusion_yx )

summary(start=0, end=1000, kde=True, tick_size=12, title_size=15, label_size=15, label_pad=8, n_ticks=3, ret_fig=False, **plot_text)

Print summary of data and show summary plots chart

Parameters
  • start (int, (default=0)) – starting index, begin plotting timeseries from this point

  • end (int, default=1000) – end point, plots timeseries till this index

  • kde (bool, (default=False)) – if True, plot kde for histograms

  • title_size (int, (default=15)) – title font size

  • tick_size (int, (default=12)) – axis tick size

  • label_size (int, (default=15)) – label font size

  • label_pad (int, (default=8)) – axis label padding

  • n_ticks (int, (default=3)) – number of axis ticks

  • ret_fig (bool, (default=True)) – if True return figure object

  • **plot_text

    plots’ title and axis texts

    For scalar analysis summary plot:

    timeseries_title : title of timeseries plot

    timeseries_xlabel : x label of timeseries

    timeseries_ylabel : y label of timeseries

    drift_title : drift plot title

    drift_xlabel : drift plot x label

    drift_ylabel : drift plot ylabel

    diffusion_title : diffusion plot title

    diffusion_xlabel : diffusion plot x label

    diffusion_ylabel : diffusion plot y label

    For vector analysis summary plot:

    timeseries1_title : first timeseries plot title

    timeseries1_ylabel : first timeseries plot ylabel

    timeseries1_xlabel : first timeseries plot xlabel

    timeseries1_legend1 : first timeseries (Mx) legend label

    timeseries1_legend2 : first timeseries (My) legend label

    timeseries2_title : second timeseries plot title

    timeseries2_xlabel : second timeseries plot x label

    timeseries2_ylabel : second timeseries plot y label

    2dhist1_title : Mx 2d histogram title

    2dhist1_xlabel : Mx 2d histogram x label

    2dhist1_ylabel : Mx 2d histogram y label

    2dhist2_title : My 2d histogram title

    2dhist2_xlabel : My 2d histogram x label

    2dhist2_ylabel : My 2d histogram y label

    2dhist3_title : M 3d histogram title

    2dhist3_xlabel : M 2d histogram x label

    2dhist3_ylabel : M 2d histogram y label

    3dhist_title : 3d histogram title

    3dhist_xlabel : 3d histogram x label

    3dhist_ylabel : 3d histogram y label

    3dhist_zlabel : 3d histogram z label

    driftx_title : drift x plot title

    driftx_xlabel : drift x plot x label

    driftx_ylabel : drift x plot y label

    driftx_zlabel : drift x plot z label

    drifty_title : drift y plot title

    drifty_xlabel : drift y plot x label

    drifty_ylabel : drift y plot y label

    drifty_zlabel : drift y plot z label

    diffusionx_title : diffusion x plot title

    diffusionx_xlabel : diffusion x plot x label

    diffusionx_ylabel : diffusion x plot y label

    diffusionx_zlabel : diffusion x plot z label

    diffusiony_title : diffusion y plot title

    diffusiony_xlabel : diffusion y plot x label

    diffusiony_ylabel : diffusion y plot y label

    diffusiony_zlabel : diffusion y plot z label

Return type

None, or figure

Raises

ValueError – If start is greater than end

timeseries(start=0, end=1000, n_ticks=3, dpi=150, tick_size=12, title_size=14, label_size=14, label_pad=0, **plot_text)

Show plot of input data

Parameters
  • start (int, (default=0)) – starting index, begin plotting timeseries from this point

  • end (int, default=1000) – end point, plots timeseries till this index

  • n_ticks (int, (default=3)) – number of axis ticks

  • dpi (int, (default=150)) – dpi of the figure

  • title_size (int, (default=15)) – title font size

  • tick_size (int, (default=12)) – axis tick size

  • label_size (int, (default=15)) – label font size

  • label_pad (int, (default=8)) – axis label padding

  • **plot_text

    plots’ title and axis texts

    For scalar analysis plot:

    timeseries_title : title

    timeseries_xlabel : x label

    timeseries_ylabel : y label

    For vector analysis plot:

    timeseries1_title : first timeseries plot title

    timeseries1_xlabel : first timeseries plot x label

    timeseries1_ylabel : first timeseries plot y lable

    timeseries2_title : second timeseries plot title

    timeseries2_xlabel : second timeseries plot x label

    timeseries2_ylabel : second timeseries plot y label

    timeseries3_title : third timeseries plot title

    timeseries3_xlabel : third timeseries plot x label

    timeseries3_ylabel : third timeseries plot y label

Returns

time series plot

Return type

matplotlib.pyplot.figure

Raises

ValueError – If start is greater than end

visualize(drift_time_scale=None, diff_time_scale=None)

Display drift and diffusion plots for a time scale.

Parameters

time_scale (int, optional(default=None)) – timescale for which drift and diffusion plots need to be shown. If None, displays the plots for inputed timescale.

Returns

displays plots

Return type

None