Skip to content

Omnivanitate/sweep-design

Repository files navigation

sweep-design

Simple way to create sweep signal.

The project is intended for designing sweep signals.

The package is intended to create and develop sweep signals of varying complexity.

The project can be used both for educational and work purposes.

It is convenient to use Jupyter Lab or Jupyter Notebook to speed up the development of signals, to compare their parameters with other signals, and to visualize them.

The project is designed so that you can easily change the creation of sweep signals. For example, write your own methods describing how the frequency and amplitude will change from the time of the sweep signal.

The project was made to be able to create various sweep signals: implemented and not implemented by a vibration source, from simple ones, like a linear sweep signal, to complex ones, like a pseudo-random sweep signal.

Tools have been written with which unrealizable sweep signals could be made realizable.

In addition, documentation consist tutorial how to work with library and examples of ready-made sweeps. You can write own sweep creation.

Installation

To install use:

$ pip install sweep-design

or using poetry

$ poetry add sweep-design

Also you can clone or load project from GitHub, and install requirement packages using the

$ pip install -r requirement.txt

or if you want develop, use

$ pip install -r requirement-dev.txt

or

$ poetry install

or coping pieces of code and create your own.

Usage

The project is a library. Working with it is the same as with other third-part libraries of the python language.
An example of how to include the library is described here.

The library consists sub-modules:

  • sweep_design.config - contains the project configuration Config and SweepConfig.
  • sweep_design.defaults - contains default methods to calculate.
  • sweep_design.prepared_sweep - contains sweep signal templates.
  • sweep_design.utility_functions - contains function to work with signals.
  • sweep_design.core - contains basic classes MathOperation and RelationProtocol.
  • sweep_design.exc - contains exceptions.
  • sweep_design.axis - contains class ArrayAxis
  • sweep_design.relation - contains class Relation
  • sweep_design.signal - contains class Signal
  • sweep_design.spectrum - contains class Spectrum
  • sweep_design.sweep - contains class Sweep
  • sweep_design.uncalculated - contains classes UncalculatedSweep and ApriorUncalculatedSweep
  • sweep_design.spectrogram - contains classes Spectrogram

For convenient base classes: ArrayAxis, Relation, Signal, Spectrum, Sweep, UncalculatedSweep, ApriorUncalculatedSweep, Config, ConfigSweep - can be imported from a sweep_design module.

For example:

from sweep_design import Signal

Utility functions can be imported from sweep_design.utility_functions.
And prepared sweep - from sweep_design.prepared_sweep.

Quick start. Simple work flow.

Below is a simple example of creating a sweep signal and visualizing it. A more extended description of the work of the library in the documentation. Other examples are contained in the examples contains in Tutorial and Prepared sweep sections.

For the following code Matplotlib need be used to visualize a result of work. But Matplotlib can be replaced with another library that you use.

import matplotlib.pyplot as plt

from sweep_design import ArrayAxis, UncalculatedSweep

time = ArrayAxis(start=0., end=10., sample=0.01)

usw = UncalculatedSweep(time=time)
sw = usw()

t_sw, a_sw = sw.get_data()
plt.plot(t_sw, a_sw)
plt.xlabel('Time, s')
plt.ylabel('Amplitude')
plt.title('Sweep-signal')

Result:

sweep_with_matplotlib

Credits

sweep-design was created with
numpy
scipy
EMD-signal

TODO

  1. Merge array axis.