Skip to content

Commit ff285bb

Browse files
committed
profiles only need one gwcs?
1 parent 5925ec4 commit ff285bb

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/NSO/Image/Asdf.hs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ import Text.Casing (quietSnake)
4848
-- TODO: fix gwcs
4949
-- TODO: labeled meta.axes for profiles
5050

51-
asdfDocument :: Id Inversion -> Dataset -> [Dataset] -> PixelsPerBin -> UTCTime -> Arms (Arm SpectralLine L1Asdf) -> Frames L2FitsMeta -> Document
52-
asdfDocument inversionId dscanon dsets bin now l1asdfs metas =
51+
asdfDocument :: Id Inversion -> Dataset -> [Dataset] -> PixelsPerBin -> UTCTime -> L1Asdf -> Frames L2FitsMeta -> Document
52+
asdfDocument inversionId dscanon dsets bin now l1asdf metas =
5353
let frames = Frames $ NE.sort metas.frames
5454
in Document (inversionTree frames)
5555
where
@@ -59,18 +59,15 @@ asdfDocument inversionId dscanon dsets bin now l1asdfs metas =
5959
{ fileuris
6060
, meta = inversionMeta $ fmap (.primary) sorted
6161
, quantities = quantitiesSection (fmap (.quantities) sorted) (qgwcs sorted)
62-
, profiles = profilesSection bin gwcs (head sorted.frames).primary $ fmap (.profiles) sorted
62+
, profiles = profilesSection bin l1asdf.dataset.wcs (head sorted.frames).primary $ fmap (.profiles) sorted
6363
}
6464

65-
gwcs :: Arms (Arm SpectralLine L1GWCS)
66-
gwcs = fmap (fmap (\a -> a.dataset.wcs)) l1asdfs
67-
6865
-- choose a single frame from which to calculate the GWCS
6966
qgwcs :: Frames L2FitsMeta -> QuantityGWCS
7067
qgwcs sorted =
7168
quantityGWCS
7269
bin
73-
(head gwcs.arms).value
70+
l1asdf.dataset.wcs
7471
(fmap (.primary) sorted)
7572
(fmap (\m -> m.quantities.items.opticalDepth) sorted)
7673

@@ -276,14 +273,10 @@ data QuantityMeta info = QuantityMeta
276273
data ProfilesSection = ProfilesSection
277274
{ axes :: [AxisMeta]
278275
, arms :: Arms (Profiles ProfileTree)
279-
, gwcs :: Arms (Arm SpectralLine ProfileGWCS)
276+
, gwcs :: ProfileGWCS
280277
}
281278

282279

283-
profileGWCSAnchor :: SpectralLine -> Anchor
284-
profileGWCSAnchor l = Anchor $ "ProfileGWCS" <> cs (show l)
285-
286-
287280
-- data ArmProfileAxes = ArmProfileAxes
288281
-- { arm :: ArmWavMeta
289282
-- , fit :: AlignedAxes Fit
@@ -311,14 +304,16 @@ instance ToAsdf ProfilesSection where
311304
in Arm pfs.fit.meta.spectralLine $ Profiles{fit = AlignedAxesF axs, original = AlignedAxesF axs}
312305

313306
meta =
314-
Object [("axes", toNode section.axes)]
315-
<> toValue section.gwcs
307+
Object
308+
[ ("axes", toNode section.axes)
309+
, ("gwcs", toNode section.gwcs)
310+
]
316311

317312

318-
instance ToAsdf (Arm SpectralLine ProfileGWCS) where
319-
anchor (Arm l _) = Just $ profileGWCSAnchor l
320-
toNode (Arm _ (ProfileGWCS p)) = toNode p
321-
toValue (Arm _ (ProfileGWCS p)) = toValue p
313+
instance ToAsdf ProfileGWCS where
314+
schema (ProfileGWCS g) = schema g
315+
anchor _ = Just $ Anchor $ knownText @ProfileGWCS
316+
toValue (ProfileGWCS g) = toValue g
322317

323318

324319
instance ToAsdf (Arm SpectralLine (Profiles AlignedAxesF)) where
@@ -342,20 +337,21 @@ profileKey line pt = cs $ show line <> "_" <> suffix pt
342337
-- toValue (ProfilesItems arms) = toValue arms
343338

344339
-- we need one ProfileMeta for each arm
345-
profilesSection :: PixelsPerBin -> Arms (Arm SpectralLine L1GWCS) -> PrimaryHeader -> Frames (Arms ArmFrameProfileMeta) -> ProfilesSection
340+
profilesSection :: PixelsPerBin -> L1GWCS -> PrimaryHeader -> Frames (Arms ArmFrameProfileMeta) -> ProfilesSection
346341
profilesSection bin l1gwcs primary profs =
347342
let sampleFrame :: Arms ArmFrameProfileMeta = head profs.frames
348343
in ProfilesSection
349344
{ axes = [AxisMeta "frame_y" True, AxisMeta "slit_x" True, AxisMeta "wavelength" False, AxisMeta "stokes" True]
350345
, arms = profilesArmsTree profs
351-
, gwcs = Arms $ NE.zipWith armGWCS l1gwcs.arms sampleFrame.arms
346+
, gwcs = profileGWCS bin l1gwcs primary (head sampleFrame.arms).fit.wcs
352347
}
353-
where
354-
armGWCS :: Arm SpectralLine L1GWCS -> ArmFrameProfileMeta -> Arm SpectralLine ProfileGWCS
355-
armGWCS ag am =
356-
Arm ag.arm $ profileGWCS bin ag.value primary am.fit.wcs
357348

358349

350+
-- where
351+
-- armGWCS :: Arm SpectralLine L1GWCS -> ArmFrameProfileMeta -> Arm SpectralLine ProfileGWCS
352+
-- armGWCS ag am =
353+
-- Arm ag.arm $ profileGWCS bin ag.value primary am.fit.wcs
354+
359355
profilesArmsTree :: Frames (Arms ArmFrameProfileMeta) -> Arms (Profiles ProfileTree)
360356
profilesArmsTree framesByArms =
361357
let Arms arms = armsFrames framesByArms :: Arms (Frames ArmFrameProfileMeta)
@@ -376,6 +372,7 @@ profilesArmsTree framesByArms =
376372
ProfileTree
377373
{ unit = Count
378374
, data_ = fileManager shape.axes ix
375+
, wcs = Ref
379376
, meta =
380377
ProfileTreeMeta
381378
{ headers = HeaderTable heads
@@ -398,6 +395,7 @@ data ProfileTree fit = ProfileTree
398395
{ unit :: Unit
399396
, data_ :: FileManager
400397
, meta :: ProfileTreeMeta fit
398+
, wcs :: Ref ProfileGWCS
401399
}
402400
deriving (Generic)
403401
instance (KnownText fit) => ToAsdf (ProfileTree fit) where
@@ -408,7 +406,7 @@ instance (KnownText fit) => ToAsdf (ProfileTree fit) where
408406
[ ("unit", toNode p.unit)
409407
, ("data", toNode p.data_)
410408
, ("meta", toNode p.meta)
411-
, ("wcs", toNode $ Alias $ profileGWCSAnchor p.meta.spectralLine)
409+
, ("wcs", toNode p.wcs)
412410
]
413411

414412

src/NSO/Image/GWCS.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,10 @@ newtype ProfileGWCS
337337
(GWCS CoordinateFrame (CompositeFrame (StokesFrame, SpectralFrame, CelestialFrame HelioprojectiveFrame, TemporalFrame)))
338338

339339

340-
-- instance (KnownText fit) => KnownText (ProfileGWCS fit) where
341-
-- knownText = "ProfileGWCS" <> knownText @fit
340+
instance KnownText ProfileGWCS where
341+
knownText = "ProfileGWCS"
342+
343+
342344
--
343345
--
344346
-- instance (KnownText fit) => ToAsdf (ProfileGWCS fit) where

0 commit comments

Comments
 (0)