pypore.sampledata.creator module¶
Module for creating sample data.
- Create a current trace with specified events using create_specified_data.
- Create a current trace with random events using create_random_data.
- pypore.sampledata.creator.create_random_data(filename, seconds, sample_rate, baseline=0.0, noise=None, event_rate=0, event_durations=None, event_depths=None, overwrite=False)[source]¶
Creates random sample data. Leaves the first 200 data points free of events.
Parameters: - filename (str) – Filename for the data. If the file already exists and overwrite=False, an IOError is raised.
- seconds (float) – Number of seconds of data.
- sample_rate (float) – The sampling rate of the data, in Hz.
- baseline (float) – The baseline of the data, in uA.
- noise (scipy.stats.distributions.rv_frozen) –
A frozen scipy.stats probability distribution for the noise. An example normal distribution with mean 2 uA and std dev 3 uA is
from scipy.stats import norm noise = norm(loc=2, scale=3)
Default is no noise.
- event_rate (float) – Rate of events in Hz.
- event_durations (scipy.stats.distributions.rv_frozen) – A frozen scipy.stats probability distribution for the event duration (in seconds).
- event_depths (scipy.stats.distributions.rv_frozen) – A frozen scipy.stats probability distribution for the event depth, in uA.
- overwrite (bool) – Whether overwriting an existing file at filename is allowed. If false, and filename exists. an IOError will be raised.
Raises: IOError - If the filename already exists and overwrite=False.
>>> from pypore.sampledata.creator import create_random_data >>> from scipy import stats >>> seconds = 1. # 1 second of data. >>> sample_rate = 1.e6 # 1 MHz sample rate. >>> event_rate = 100. # 100 events/sec, on average. >>> baseline = 10. # 10 uA baseline. >>> noise = stats.norm(scale=.5) # Normal distributed noise with mean of 0 std dev of 0.5 uA. >>> event_depths = stats.norm(loc=2., scale=1.) # Normal distributed events with mean of 2 and std dev of 1 uA. >>> event_durations = stats.norm(loc=100.e-6, scale=10.e-6) # Normal distributed event durations with mean of 100 us and std dev 10 us. >>> n_events = create_random_data('random_trace.h5', seconds, sample_rate, baseline, noise, event_rate, event_durations, event_depths)
- pypore.sampledata.creator.create_specified_data(filename, n, sample_rate, baseline=0.0, noise_scale=0.0, events=array(, []dtype=float64), overwrite=False)[source]¶
Creates a DataFile with sample event data.
Parameters: - filename – The name for the new DataFile.
- n (int) – The number of samples in the data set.
- sample_rate (float) – The sample rate of the data set.
- baseline (float) – The baseline of the data. Default is 0.0.
- noise_scale (float) – Passed to numpy.random.normal(), it is the standard deviation of the Gaussian noise added to the signal. Default is 0.0.
- events –
- A list of events to add to the baseline. Events are specified as [starting_point, length, current_change]. So for example
events = [[100,200,-.1], [560, 100, .6]]
specifies 2 events:
- Starts at data position 100, with length 200, and current change of -.1.
- Starts at data position 560, with length of 100, and current change of +.6.
Default is no events added.
- overwrite (bool) – Whether to overwrite an existing file at filename, if it exists. If False, and filename already exists, an IOError will be raised. Default False.
Raises: IOError - If the filename already exists and overwrite=False.
>>> from pypore.sampledata.creator import create_specified_data as csd >>> filename = "test.h5" >>> n = 10000 >>> events = [[100, 200, -.5], [3000, 1000, -.8]] # Creates an event starting at position 100, with length 200 and # baseline change of -0.5. >>> create_specified_data(filename, n, 1.e4, baseline=5.0, noise_scale=1.0, events=events)