forsyde-atom-0.3.0.0: Shallow-embedded DSL for modeling cyber-physical systems
Copyright(c) George Ungureanu KTH/ICT/ESY 2015-2017
LicenseBSD-style (see the file LICENSE)
Maintainerugeorge@kth.se
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010
Extensions
  • UndecidableInstances
  • TypeSynonymInstances
  • FlexibleInstances

ForSyDe.Atom.Utility.Plot

Description

This module imports plotting and data dumping functions working with "plottable" data types, i.e. instances of the Plot and Plottable type classes.

Synopsis

User API

The following commands are frequently used as part of the normal modeling routine.

Configuration settings

data Config Source #

Record structure containing configuration settings for the plotting commands.

Constructors

Cfg 

Fields

  • verbose :: Bool

    verbose printouts on terminal

  • path :: String

    directory where all dumped files will be found

  • title :: String

    base name for dumped files

  • rate :: Float

    sample rate if relevant. Useful for explicit-tagged signals, ignored otherwise.

  • xmax :: Float

    Maximum X coordinate. Mandatory for infinite structures, optional otherwise.

  • labels :: [String]

    list of labels with the names of the structures plotted

  • fire :: Bool

    if relevant, fires a plotting or compiling program.

  • other :: Bool

    if relevant, dumps additional scripts and plots.

Instances

Instances details
Show Config Source # 
Instance details

Defined in ForSyDe.Atom.Utility.Plot

defaultCfg :: Config Source #

Default configuration: verbose, dump everything possible, fire whatever program needed. Check source for settings.

Example usage:

>>> defaultCfg {xmax = 15, verbose = False, labels = ["john","doe"]}
Cfg {verbose = False, path = "./fig", title = "plot", rate = 1.0e-2, xmax = 15.0, labels = ["john","doe"], fire = True, other = True}

silentCfg :: Config Source #

Silent configuration: does not fire any program or print our unnecessary info. Check source for settings.

noJunkCfg :: Config Source #

Clean configuration: verbose, does not dump more than necessary, fire whatever program needed. Check source for settings.

Data preparation

prepare Source #

Arguments

:: Plot a 
=> Config

configuration settings

-> a

plottable data type

-> PlotData

structure ready for dumping

Prepares a single plottable data structure to be dumped and/or plotted.

prepareL :: Plot a => Config -> [a] -> PlotData Source #

Prepares a list of plottable data structures to be dumped and/or plotted. See prepare.

prepareV :: Plot a => Config -> Vector a -> PlotData Source #

Prepares a vector of plottable data structures to be dumped and/or plotted. See prepare.

Dumping and plotting data

showDat :: PlotData -> IO () Source #

Prints out the sampled contents of a prepared data set.

dumpDat :: PlotData -> IO [String] Source #

Dumps the sampled contents of a prepared data set into separate .dat files.

plotGnu :: PlotData -> IO () Source #

Generates a GNUplot script and .dat files for plotting the sampled contents of a prepared data set. Depending on the configuration settings, it also dumps LaTeX and PDF plots, and fires the script.

OBS: needless to say that GNUplot needs to be installed in order to use this command. Also, in order to fire GNUplot from a ghci session you might need to install gnuplot-x11.

heatmapGnu :: PlotData -> IO () Source #

Similar to plotGnu but creates a heatmap plot using the GNUplot engine. For this, the input needs to contain at least two columns of data, otherwise the plot does not show anything, i.e. the samples need to be lists or vectors of two or more elements.

OBS: same dependencies are needed as for plotGnu.

showLatex :: PlotData -> IO () Source #

Prints out a LaTeX environment from a prepared data set. This environment should be paste inside a tikzpicture in a document title which imports the ForSyDe-LaTeX package.

dumpLatex :: PlotData -> IO [String] Source #

Dumps a set of formatted data files with the extension .flx that can be imported by a LaTeX document which uses the ForSyDe-LaTeX package.

plotLatex :: PlotData -> IO () Source #

Creates a standalone LaTeX document which uses the ForSyDe-LaTeX package, plotting a prepared data set. Depending on the configuration settings, the command pdflatex may also be invoked to compile a pdf image.

OBS: A LaTeX compiler is required to run the pdflatex command. The ForSyDe-LaTeX package also needs to be installed according to the instructions on the project web page.

The data types

Below the data types involved are shown and the plottable structures are documented.

class Plottable a where Source #

This class gathers types which can be sampled and converted to a numerical string which can be read and interpreted by a plotter engine.

Methods

toCoord :: a -> String Source #

Transforms the input type into a coordinate string.

Instances

Instances details
(Show a, Real a) => Plottable a Source #

Real numbers that can be converted to a floating point representation

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Methods

toCoord :: a -> String Source #

Plottable TimeStamp Source #

Time stamps

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Plottable a => Plottable (Vector a) Source #

Vectors of plottable types

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Methods

toCoord :: Vector a -> String Source #

(Show a, Plottable a) => Plottable (AbstExt a) Source #

Absent-extended plottable types

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Methods

toCoord :: AbstExt a -> String Source #

class Plot a where Source #

This class gathers all ForSyDe-Atom structures that can be plotted.

Minimal complete definition

(sample | sample'), takeUntil, getInfo

Methods

sample :: Float -> a -> Samples Source #

Samples the data according to a given step size.

sample' :: a -> Samples Source #

Samples the data according to the internal structure.

takeUntil :: Float -> a -> a Source #

Takes the first samples until a given tag.

getInfo :: a -> PInfo Source #

Returns static information about the data type.

Instances

Instances details
Plot Histogram Source #

For plotting vectors of coordinates

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Plottable a => Plot (Vector a) Source #

For plotting vectors of coordinates

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Plottable a => Plot (Signal a) Source #

SY signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Plottable a => Plot (Signal a) Source #

For plotting SDF signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Plottable a => Plot (Signal a) Source #

For plotting CT signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

(Plottable a, Show t, Real t, Fractional t, Num t, Ord t, Eq t) => Plot (SignalBase t a) Source #

For plotting RE signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

(Plottable a, Show t, Real t, Fractional t, Num t, Ord t, Eq t) => Plot (SignalBase t a) Source #

For plotting DE signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

data PInfo Source #

Static information of each plottable data type.

Constructors

Info 

Fields

Instances

Instances details
Show PInfo Source # 
Instance details

Defined in ForSyDe.Atom.Utility.Plot

Methods

showsPrec :: Int -> PInfo -> ShowS #

show :: PInfo -> String #

showList :: [PInfo] -> ShowS #

type Samples = [(String, String)] Source #

Alias for sampled data

type PlotData = (Config, PInfo, [(String, Samples)]) Source #

Alias for a data set prepared to be plotted.