module Telescope.Fits
( decode
, encode
, decodeArray
, encodeArray
, lookup
, Header (..)
, Value (..)
, LogicalConstant
, Fits (..)
, PrimaryHDU (..)
, ImageHDU (..)
, DataArray (..)
, Extension (..)
, Axis
, Axes
, Row
, Column
, BitPix (..)
, addComment
, keyword
, emptyDataArray
, Array
, Ix1
, Ix2
, Ix3
, Ix4
, Ix5
, size
, (!>)
, (!?>)
, (<!)
, (<!?)
, (<!>)
, Dim (..)
) where
import Data.Fits (lookup)
import Telescope.Fits.Encoding
import Telescope.Fits.Encoding.DataArray
import Telescope.Fits.Header (addComment, keyword)
import Telescope.Fits.Types
import Prelude hiding (lookup)
import Data.ByteString qualified as BS
test :: IO ()
test :: IO ()
test = do
ByteString
inp <- FilePath -> IO ByteString
BS.readFile FilePath
"samples/simple2x3.fits"
Fits
f <- ByteString -> IO Fits
forall (m :: * -> *). MonadThrow m => ByteString -> m Fits
decode ByteString
inp
Axes Column -> IO ()
forall a. Show a => a -> IO ()
print Fits
f.primaryHDU.dataArray.axes
BitPix -> IO ()
forall a. Show a => a -> IO ()
print Fits
f.primaryHDU.dataArray.bitpix
DataArray -> IO ()
forall a. Show a => a -> IO ()
print Fits
f.primaryHDU.dataArray
Maybe Value -> IO ()
forall a. Show a => a -> IO ()
print (Maybe Value -> IO ()) -> Maybe Value -> IO ()
forall a b. (a -> b) -> a -> b
$ Text -> Header -> Maybe Value
lookup Text
"BTYPE" Fits
f.primaryHDU.header
Array D Ix2 Int
a <- forall ix a (m :: * -> *).
(MonadThrow m, Index ix, AxesIndex ix, Prim a, GetPix a) =>
DataArray -> m (Array D ix a)
decodeArray @Ix2 @Int Fits
f.primaryHDU.dataArray
Sz Ix2 -> IO ()
forall a. Show a => a -> IO ()
print (Sz Ix2 -> IO ()) -> Sz Ix2 -> IO ()
forall a b. (a -> b) -> a -> b
$ Array D Ix2 Int -> Sz Ix2
forall r ix e. Size r => Array r ix e -> Sz ix
forall ix e. Array D ix e -> Sz ix
size Array D Ix2 Int
a
Array D Int Int -> IO ()
forall a. Show a => a -> IO ()
print (Array D Int Int -> IO ()) -> Array D Int Int -> IO ()
forall a b. (a -> b) -> a -> b
$ Array D Ix2 Int
a Array D Ix2 Int -> Int -> Array D (Lower Ix2) Int
forall r ix e.
(HasCallStack, Index ix, Index (Lower ix), Source r e) =>
Array r ix e -> Int -> Array r (Lower ix) e
!> Int
0