Safe Haskell | None |
---|---|
Language | Haskell2010 |
Read Binary NutMeg Data
Synopsis
- type NutMeg = [(String, Plot)]
- type Plot = Map String Wave
- type RealPlot = Map String (Vector Double)
- type ComplexPlot = Map String (Vector (Complex Double))
- data Wave
- = RealWave !(Vector Double)
- | ComplexWave !(Vector (Complex Double))
- data Flag
- data Field
- readFile :: FilePath -> IO NutMeg
- extractPlots :: ByteString -> NutMeg -> NutMeg
- extractPlot :: Flag -> Int -> Int -> ByteString -> [Wave]
- parseHeader :: [ByteString] -> ((String, Flag, Int, Int), [String])
- readField :: Field -> ByteString -> String
- asVector :: Wave -> Either (Vector (Complex Double)) (Vector Double)
- vectorize :: Plot -> Either ComplexPlot RealPlot
- flattenPlots :: [String] -> NutMeg -> Plot
- flattenPlots' :: NutMeg -> Plot
- asRealPlot :: Plot -> RealPlot
- asComplexPlot :: Plot -> ComplexPlot
- concat :: Wave -> Wave -> Wave
- isReal :: Plot -> Bool
- isComplex :: Plot -> Bool
- isReal' :: Wave -> Bool
- isComplex' :: Wave -> Bool
- byteSwap :: ByteString -> ByteString
- castByteStringToVector :: Storable a => ByteString -> Vector a
Data Types
type Plot = Map String Wave Source #
A Plot inside a
file consists of uniquely identified waveforms:
NutMeg
[(Variable Name, Waveform)]
Wrapper around Real or Complex valued Vector, so they can be stored in the same List.
RealWave !(Vector Double) | Real valued ( |
ComplexWave !(Vector (Complex Double)) | Complex valued ('Complex Double') wave form |
Instances
Eq Wave Source # | |
Show Wave Source # | |
Generic Wave Source # | |
NFData Wave Source # | |
Defined in Data.NutMeg | |
type Rep Wave Source # | |
Defined in Data.NutMeg type Rep Wave = D1 ('MetaData "Wave" "Data.NutMeg" "hnutmeg-0.3.7.0-ELSBlxD0euVIEs9ZoUwVOs" 'False) (C1 ('MetaCons "RealWave" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (Vector Double))) :+: C1 ('MetaCons "ComplexWave" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (Vector (Complex Double))))) |
Flag indicating whether a plot is real or complex valued
Data Field identifier in NutMeg (binary) Files
Title | Title of the |
Date | Date of creation |
Plotname | Name of a |
Flags | |
NoVariables | No. Variables in the |
NoPoints | No. Points per Variable |
Variables | String representation of Variables in the |
Binary | Binary Data, |
Instances
Bounded Field Source # | |
Enum Field Source # | |
Eq Field Source # | |
Ord Field Source # | |
Show Field Source # | |
Generic Field Source # | |
NFData Field Source # | |
Defined in Data.NutMeg | |
type Rep Field Source # | |
Defined in Data.NutMeg type Rep Field = D1 ('MetaData "Field" "Data.NutMeg" "hnutmeg-0.3.7.0-ELSBlxD0euVIEs9ZoUwVOs" 'False) (((C1 ('MetaCons "Title" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Date" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Plotname" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Flags" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "NoVariables" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NoPoints" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Variables" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Binary" 'PrefixI 'False) (U1 :: Type -> Type)))) |
Read raw binary data
Parsing NutMeg binary data
extractPlots :: ByteString -> NutMeg -> NutMeg Source #
Read The first plot encountered in ByteString String:
((Plotname,
Plot
), Remianing ByteString)
:: Flag | Real or Complex Data |
-> Int | No. Variables |
-> Int | No. Points |
-> ByteString | Binary Data |
-> [Wave] | Wave forms |
Extract the wave forms from binary data given header information
parseHeader :: [ByteString] -> ((String, Flag, Int, Int), [String]) Source #
Accessing Plot data
asVector :: Wave -> Either (Vector (Complex Double)) (Vector Double) Source #
Convert Waveform to unboxed Vector
, fails horribly if types are incorrect
flattenPlots' :: NutMeg -> Plot Source #
asRealPlot :: Plot -> RealPlot Source #
asComplexPlot :: Plot -> ComplexPlot Source #
Utilities
concat :: Wave -> Wave -> Wave Source #
Joins two
s of the same type: Wave
wave1 ++ wave2
Attempting to concatenate a Real and Complex wave will result in an error
isComplex' :: Wave -> Bool Source #
Check whether waveform is complex valued
byteSwap :: ByteString -> ByteString Source #
Swap Bytes of Big-Endian encoded ByteString Thanks Noughtmare: https://stackoverflow.com/a/71341067
castByteStringToVector :: Storable a => ByteString -> Vector a Source #
Swap bytes and cast to vector (slow)