@@ -5,6 +5,7 @@ import NSO.Image.Headers.WCS (Wav, X, Y)
5
5
import NSO.Prelude hiding (identity )
6
6
import NSO.Types.Common (Stokes )
7
7
import Telescope.Asdf
8
+ import Telescope.Asdf.Core (Quantity (.. ), Unit (.. ))
8
9
import Telescope.Asdf.GWCS as GWCS
9
10
import Telescope.Data.Parser
10
11
@@ -64,8 +65,8 @@ instance ToAsdf L1WCSTransform where
64
65
toValue (L1WCSTransform n) = n. value
65
66
66
67
67
- l1WCSTransform :: L1WCSTransform -> Transform (Scale X , Zero Wav , Pix Y , Zero Stokes ) (HPLon , HPLat , Time , Zero Wav , Zero Stokes )
68
- l1WCSTransform t = originalL1Transform |> reorderOutput
68
+ varyingTransform :: L1WCSTransform -> Transform (Scale X , Zero Wav , Pix Y , Zero Stokes ) (HPLon , HPLat , Time , Zero Wav , Zero Stokes )
69
+ varyingTransform t = originalL1Transform |> reorderOutput
69
70
where
70
71
originalL1Transform :: Transform (Scale X , Zero Wav , Pix Y , Zero Stokes ) (HPLon , Wav , HPLat , Time , Stokes )
71
72
originalL1Transform = transform t
@@ -74,16 +75,47 @@ l1WCSTransform t = originalL1Transform |> reorderOutput
74
75
reorderOutput = transform $ Mapping [0 , 2 , 3 , 1 , 4 ]
75
76
76
77
77
- -- "fix" inputs to unused input axes in the l1 transform: wavlength and stokes
78
- l1FixInputs :: Transform (Pix X , Pix Y ) (Pix X , Pix Wav , Pix Y , Pix Stokes )
79
- l1FixInputs = transform $ Mapping [0 , 0 , 1 , 0 ]
80
-
81
-
82
- l1ScaleAxes :: PixelsPerBin -> Transform (Pix X , Pix Wav , Pix Y , Pix Stokes ) (Scale X , Zero Wav , Pix Y , Zero Stokes )
83
- l1ScaleAxes (PixelsPerBin p) = binX <&> zero <&> identity @ (Pix Y ) <&> zero
78
+ scaleZeroAxes :: PixelsPerBin -> Transform (Pix X , Pix Wav , Pix Y , Pix Stokes ) (Scale X , Zero Wav , Pix Y , Zero Stokes )
79
+ scaleZeroAxes (PixelsPerBin p) = binX <&> zero <&> identity @ (Pix Y ) <&> zero
84
80
where
85
81
binX :: Transform (Pix X ) (Scale X )
86
82
binX = scale (fromIntegral p)
87
83
88
84
zero :: (ToAxes a ) => Transform (Pix a ) (Zero a )
89
- zero = transform $ Scale 0
85
+ zero = transform $ Const1D $ Quantity Pixel (Integer 0 )
86
+
87
+
88
+ fixInputs :: Transform (Pix X , Pix Y ) (Pix X , Pix Wav , Pix Y , Pix Stokes )
89
+ fixInputs = transform $ Mapping [0 , 0 , 1 , 0 ]
90
+
91
+
92
+ data Const1D = Const1D Quantity
93
+ instance ToAsdf Const1D where
94
+ schema _ = " !transform/constant-1.2.0"
95
+ toValue (Const1D q) =
96
+ Object
97
+ [ (" dimensions" , toNode $ Integer 1 )
98
+ , (" value" , toNode q)
99
+ ]
100
+ instance FromAsdf Const1D where
101
+ parseValue val = do
102
+ o <- parseValue @ Object val
103
+ Const1D <$> o .: " value"
104
+
105
+ -- fixWavStokes0 :: (ToAxes out) => Transform (Pix X, Pix Wav, Pix Y, Pix Stokes) out -> Transform (Pix X, Pix Y) out
106
+ -- fixWavStokes0 (Transform t) = transform $ FixInputs t [(1, 0), (3, 0)]
107
+ --
108
+ --
109
+ -- -- This ONLY works with integers for some reason (doesn't like quantities)
110
+ -- -- combine with Const1D or Scale or something to convert it to a quantity?
111
+ -- data FixInputs = FixInputs Transformation [(Int, Int)]
112
+ -- instance ToAsdf FixInputs where
113
+ -- schema _ = "!transform/fix_inputs-1.2.0"
114
+ -- toValue (FixInputs t fs) =
115
+ -- Object [("forward", toNode [toNode t, toNode forward])]
116
+ -- where
117
+ -- forward =
118
+ -- Object
119
+ -- [ ("keys", toNode $ fmap fst fs)
120
+ -- , ("values", toNode $ fmap snd fs)
121
+ -- ]
0 commit comments