telescope-0.2.0: Astronomical Observations (FITS, ASDF, WCS, etc)
Safe HaskellNone
LanguageGHC2021

Telescope.Data.Array

Synopsis

Documentation

decodeArray :: (AxesIndex ix, Prim a, BinaryValue a, MonadThrow m, MonadCatch m) => Axes 'Row -> ByteString -> m (Array D ix a) Source #

Decode Big Endian encoded binary data into an Array of arbitrary dimensions ix by specifying the Axes Row

>>> decodeArray @Ix2 @Float [3, 2] input
Array P Seq (Sz (2 :. 3))
  [ [ 1.0, 2.0, 3.0 ]
  , [ 4.0, 5.0, 6.0 ]
  ]

encodeArray :: (Source r a, Stream r Ix1 a, PutArray ix, BinaryValue a, Prim a) => Array r ix a -> ByteString Source #

Encode an Array as a Lazy ByteString based on the type of the element a

>>> myArray = decodeArray @Ix2 @Float BPFloat [3, 2] input
>>> output = encodeArray myArray

decodeArrayOrder :: (AxesIndex ix, BinaryValue a, MonadThrow m, MonadCatch m) => ByteOrder -> Axes 'Row -> ByteString -> m (Array D ix a) Source #

Decode binary data into an Array of arbitrary dimensions ix by specifying the Axes Row and the ByteOrder

>>> decodeArrayOrder @Ix2 @Float BigEndian [3, 2] input
Array P Seq (Sz (2 :. 3))
  [ [ 1.0, 2.0, 3.0 ]
  , [ 4.0, 5.0, 6.0 ]
  ]

decodeVector :: BinaryValue a => Comp -> ByteOrder -> ByteString -> Vector D a Source #

Decode binary data into as a 1d Array

fromVector :: forall ix a m. (AxesIndex ix, MonadThrow m, MonadCatch m) => Axes 'Row -> Vector D a -> m (Array D ix a) Source #

Resize a Vector into an Array

class Index ix => AxesIndex ix where Source #

Convert between an Index and Axes Row

Methods

axesIndex :: MonadThrow m => Axes 'Row -> m ix Source #

indexAxes :: ix -> Axes 'Row Source #

Instances

Instances details
AxesIndex Ix1 Source # 
Instance details

Defined in Telescope.Data.Array

AxesIndex Ix2 Source # 
Instance details

Defined in Telescope.Data.Array

AxesIndex Ix3 Source # 
Instance details

Defined in Telescope.Data.Array

AxesIndex Ix4 Source # 
Instance details

Defined in Telescope.Data.Array

AxesIndex Ix5 Source # 
Instance details

Defined in Telescope.Data.Array

class PutArray ix where Source #

Encode an Array of dimensions up to Ix5

Methods

putArray :: (BinaryValue a, Source r a, Stream r Ix1 a, Prim a) => ByteOrder -> Array r ix a -> Put Source #

Instances

Instances details
PutArray Ix1 Source # 
Instance details

Defined in Telescope.Data.Array

Methods

putArray :: (BinaryValue a, Source r a, Stream r Ix1 a, Prim a) => ByteOrder -> Array r Ix1 a -> Put Source #

PutArray Ix2 Source # 
Instance details

Defined in Telescope.Data.Array

Methods

putArray :: (BinaryValue a, Source r a, Stream r Ix1 a, Prim a) => ByteOrder -> Array r Ix2 a -> Put Source #

PutArray Ix3 Source # 
Instance details

Defined in Telescope.Data.Array

Methods

putArray :: (BinaryValue a, Source r a, Stream r Ix1 a, Prim a) => ByteOrder -> Array r Ix3 a -> Put Source #

PutArray Ix4 Source # 
Instance details

Defined in Telescope.Data.Array

Methods

putArray :: (BinaryValue a, Source r a, Stream r Ix1 a, Prim a) => ByteOrder -> Array r Ix4 a -> Put Source #

PutArray Ix5 Source # 
Instance details

Defined in Telescope.Data.Array

Methods

putArray :: (BinaryValue a, Source r a, Stream r Ix1 a, Prim a) => ByteOrder -> Array r Ix5 a -> Put Source #

axesIndexN :: forall (n :: Nat) m. (AxesIndex (Lower (IxN n)), MonadThrow m) => Axes 'Row -> m (IxN n) Source #

indexAxesN :: forall (n :: Nat). AxesIndex (Lower (IxN n)) => IxN n -> Axes 'Row Source #

sizeAxes :: (AxesIndex ix, Index ix) => Sz ix -> Axes 'Column Source #

Get the Axes for a given array size