def load_switching_data(filename_or_fileobject, start_state=None, group="main", failure=False, threshold=None,
voltage_scale_factor=1.0, duration_scale_factor=1.0, data_name='voltage', data_filter=None, display=False):
data, desc = load_from_HDF5(filename_or_fileobject, reshape=False)
# Regular axes
states = desc[group].axis("state").points
reps = desc[group].axis("attempt").points
# Main data array, possibly unstructured
dat = data[group][:].reshape((-1, reps.size, states.size))
# Filter data if desired
# e.g. filter_func = lambda dat: np.logical_and(dat['field'] == 0.04, dat['temperature'] == 4.0)
if data_filter:
dat = dat[np.where(data_filter(dat))]
Vs = dat[data_name]
durs = dat['pulse_duration'][:,0,0]
amps = dat['pulse_voltage'][:,0,0]
points = np.array([durs, amps]).transpose()
if failure:
return points, reset_failure(Vs, start_state=start_state)
else:
return points, switching_phase(Vs, start_state=start_state, threshold=threshold, display=display)
评论列表
文章目录