powerdart 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 57

powerdart #

A Flutter package to compute the Power Spectral Density and analyze its result.

Usage #

To use this package add powerdart as a dependency in your pubspec.yaml file.

Import the library.

import 'package:powerdart/powerdart.dart';

Then create use the methods in the library.

void main() {
  final double fs = 100.0;
  List<double> x;

  // Generate a sinusoidal wave of 100 samples with frequency of 10Hz   
  List<double> t = linspace(0, 1, num: fs.toInt(), endpoint: false);
  x = t.map((e) => cos(2 * pi * 87 * e)).toList();
  
  // Compute his PSD
  final psdRes = psd(x, fs);
  
  // Find where the 70% of the power is
  final area = cumtrapz(psdRes["pxx"], psdRes["f"]);
  final powerDistribution = find(area, (e) => e >= 0.70 * area.last);
}

0.0.2 - 2020/05/11 Fix PSD algorithm #

  • Fix the generation of the normalized frequency vector in psd
  • Replace the return type of psd from a map to PsdResult
  • Replace the return type of maxIndexed from a list to MaxIndexedResult

0.0.1 - 2020/05/11 Initial Release #

  • This is the first release of the package

example/main.dart

import 'dart:math';

import 'package:powerdart/powerdart.dart';

void main() {
  final double fs = 100.0;
  List<double> x;

  // Generate a sinusoidal wave of 100 samples with frequency of 10Hz
  List<double> t = linspace(0, 1, num: fs.toInt(), endpoint: false);
  x = t.map((e) => cos(2 * pi * 87 * e)).toList();

  // Compute his PSD
  final psdRes = psd(x, fs);

  // Find where the 70% of the power is
  final area = cumtrapz(psdRes.pxx, psdRes.f);
  final powerDistribution = find(area, (e) => e >= 0.70 * area.last);
}

Use this package as a library

1. Depend on it

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


dependencies:
  powerdart: ^0.0.2

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:powerdart/powerdart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
18
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
57
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
complex ^0.5.0 0.5.0
Dev dependencies
test ^1.14.3