smart_signal_processing 2.0.5

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 64

Smart Signal Processing #

What the package can do for you #

This package provides frequently used functions for signal processing:

  • Computes mean values, variance, standard deviation.
  • Applies windowing (apodization functions) with exponential or Gaussian shapes to an array
  • Applies the Fast Fourier Transform to an array.
  • Calculates the power or magnitude of a complex-valued array.
  • Phase-shifts (rotates in the complex plane) a complex-valued array.

The major API functionalities #

  • classes Sigma, BaseLine, WinFunc,FFT, Phase.

Examples:

  • Multiplication with an exponential:

    WinFunc.expMult(array, decayFactor, false, "0");

  • Compute Fourier Transform:

    FFT.transform(reals, imags);

  • Compute magnitude:

    Phase.magnitude(reals, imags, true)

  • Compute variance in a region:
    Sigma.variance(array, ixstart, ixend)

Detailed API #

Please view the detailed API documentation in the API reference of this package (sidebar at the right of this page).

smart_arrays_base: Basic functions for 1D and 2D arrays

smart_arrays_numerics: Numerics with 1D and 2D arrays

smart_arrays_compress: Compress 1D and 2D arrays to a smaller size.

smart_arrays_dbstore: Store 1D and 2D arrays along with metadata on the local device.

smart_arrays_peaks: Detect peaks in 1D and 2D arrays.

smart_arrays_lmfit: Fits (x, y) data given as arrays to a specified model function using the Levenberg-Marquardt algorithm.

smart_lorentz-gauss: Compute Lorentz-Gauss (pseudo-Voigt) line shapes.

smart_dialogs: Easy-to-use dialogs in Web applications

Smart Signal Processing #

Version history #

2.0.0 - 2019-03-23 First version available on pub site.

2.0.1 - 2019-03-24 Docu updates.

2.0.2 - 2019-04-04 Docu updates.

2.0.3 - 2019-04-04 Docu updates.

2.0.4 - 2019-04-05 Added Sigma.sigma2D().

2.0.5 - 2019-05-06 Docu updates.

example/example.dart

// Copyright (c) 2019, Dr. Bruno Guigas. All rights reserved. Use of this source
// code is governed by a BSD-style license that can be found in the LICENSE file.
import 'package:smart_signal_processing/smart_signal_processing.dart';
import 'dart:typed_data';
import 'dart:math' as math;

/// Signal processing example:
/// - Computes 8 periods of a cosine shape filling an array of 256 points.
/// - Applies an exponential function, resulting in a decaying oscillation
/// - Applies a real Fourier transform, resulting in a complex-valued line shape
///   whose real part is an absorption mode Lorentzian, and whose imaginary
///   part is a dispersion mode Lorentzian. The real part's maximum is at
///   index 8, corresponding to the number of periods.
/// Paste the printed output into MS Excel, OpenOffice calc, Google tables or
/// similar to view result as a curve.
main() {
  // Generate sine wave consisting of [npoints] with [amplitude] and [phase],
  // and [nperiods] periods within [npoints]. Make the sine "noisy" by adding
  // [noise] a fraction of [amplitude].
  Float64List genSine(
      int npoints, double amplitude, double phase, int nperiods, double noise) {
    math.Random rand = math.Random();
    double xmax = 2 * math.pi * nperiods, x, y;
    Float64List sine = new Float64List(npoints);
    for (int i = 0; i < npoints; i++) {
      x = (i * xmax) / npoints;
      y = amplitude * math.sin(x + phase);
      // add noise between -1 and 1
      sine[i] = y + noise * amplitude * (2 * rand.nextDouble() - 1.0).sign;
    }
    return sine;
  }

  // Generate cosine
  final int NPOINTS = 256, NPERIODS = 8;
  Float64List reals = genSine(NPOINTS, 100.0, math.pi / 2, NPERIODS, 0.0);
  Float64List imags = Float64List(reals.length);

  // Make cosine exponentially decaying
  double decayFactor = -3.0 / (reals.length - 1);
  WinFunc.expMult(reals, decayFactor, false, "0");

  // In-place transform: initally [imags] has only zeroes. After transform,
  // [reals] contains absorption mode and [imags] dispersion mode Lorentzian shape.
  FFT.transform(reals, imags);

  // Print result: Due to the symmetry properties of the FFT only the first
  // halfs play a role. The second halfs contain identical information
  // (corresonding to "negative frequencies")
  for (int i = 0; i < reals.length ~/ 2; i++) {
    print("$i\t ${reals[i].toStringAsFixed(2)}");
  }
  for (int i = 0; i < imags.length ~/ 2; i++) {
    print("$i\t ${imags[i].toStringAsFixed(2)}");
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  smart_signal_processing: ^2.0.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:smart_signal_processing/smart_signal_processing.dart';
  
Version Uploaded Documentation Archive
2.0.5 May 6, 2019 Go to the documentation of smart_signal_processing 2.0.5 Download smart_signal_processing 2.0.5 archive
2.0.4 Apr 5, 2019 Go to the documentation of smart_signal_processing 2.0.4 Download smart_signal_processing 2.0.4 archive
2.0.3 Apr 4, 2019 Go to the documentation of smart_signal_processing 2.0.3 Download smart_signal_processing 2.0.3 archive
2.0.2 Apr 4, 2019 Go to the documentation of smart_signal_processing 2.0.2 Download smart_signal_processing 2.0.2 archive
2.0.1 Mar 24, 2019 Go to the documentation of smart_signal_processing 2.0.1 Download smart_signal_processing 2.0.1 archive
2.0.0 Mar 23, 2019 Go to the documentation of smart_signal_processing 2.0.0 Download smart_signal_processing 2.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
95
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
65
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Jun 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.2
  • pana: 0.12.18

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:smart_signal_processing/smart_signal_processing.dart.

Health suggestions

Fix lib/src/fft.dart. (-5.36 points)

Analysis of lib/src/fft.dart reported 11 hints, including:

line 36 col 7: DO use curly braces for all flow control structures.

line 72 col 7: DO use curly braces for all flow control structures.

line 192 col 7: DO use curly braces for all flow control structures.

line 252 col 9: DO use curly braces for all flow control structures.

line 254 col 9: DO use curly braces for all flow control structures.

Format lib/src/phase.dart.

Run dartfmt to format lib/src/phase.dart.

Maintenance issues and suggestions

Support latest dependencies. (-35 points)

The version constraint in pubspec.yaml does not support the latest published versions for 6 dependencies (1 direct: build_web_compilers).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
build_runner ^1.1.2 1.5.2
build_web_compilers ^1.0.0 1.2.2 2.1.1
pedantic ^1.5.0 1.7.0
smart_arrays_base ^2.0.0 2.0.7
Transitive dependencies
analyzer 0.35.4 0.36.3
archive 2.0.10
args 1.5.2
async 2.2.0
bazel_worker 0.1.21
build 1.1.4
build_config 0.4.0
build_daemon 1.0.0
build_modules 1.0.11 2.3.0
build_resolvers 1.0.5
build_runner_core 3.0.6
built_collection 4.2.2
built_value 6.6.0
charcode 1.1.2
code_builder 3.2.0
collection 1.14.11
convert 2.1.1
crypto 2.0.6
dart_style 1.2.4 1.2.8
fixnum 0.10.9
front_end 0.1.14 0.1.18
glob 1.1.7
graphs 0.2.0
http 0.12.0+2
http_multi_server 2.1.0
http_parser 3.1.3
io 0.3.3
js 0.6.1+1
json_annotation 2.4.0
kernel 0.3.14 0.3.18
logging 0.11.3+2
matcher 0.12.5
meta 1.1.7
mime 0.9.6+3
package_config 1.0.5
package_resolver 1.0.10
path 1.6.2
pool 1.4.0
protobuf 0.13.12
pub_semver 1.4.2
pubspec_parse 0.1.4
quiver 2.0.3
scratch_space 0.0.3+2
shelf 0.7.5
shelf_web_socket 0.2.3
source_maps 0.10.8
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
stream_transform 0.0.19
string_scanner 1.0.4
term_glyph 1.1.0
timing 0.1.1+1
typed_data 1.1.6
watcher 0.9.7+10
web_socket_channel 1.0.13
yaml 2.1.16