Skip to content

Commit

Permalink
fixed: instrument cryo
Browse files Browse the repository at this point in the history
  • Loading branch information
seanhess committed Dec 10, 2024
1 parent 0e99848 commit 172e38f
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 12 deletions.
49 changes: 49 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

- [ ] Download - skip the step?
- [ ] Interface - Search/filter on /proposals/
- [ ] Interface - from proposals screen, ahrd to click in
- [ ] Fits Gen - reduce parallel down from 16, it's too slow
- [ ] Cryo-NIRSP - Invalid instrument


BUGS
-----

- [ ] Inversion - upload error, see below
- [ ] /proposal/N - should be /proposals/ ??


Error after upload

VanillaHttpException (HttpExceptionRequest Request {
host = "transfer.api.globus.org"
port = 443
secure = True
requestHeaders = [("Authorization","<REDACTED>"),("Accept","application/json")]
path = "/v0.10/task/f855c1e6-b729-11ef-b839-115107518ebc"
queryString = ""
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
proxySecureMode = ProxySecureWithConnect
}
(StatusCodeException (Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, responseVersion = HTTP/1.1, responseHeaders = [("Server","nginx"),("Date","Tue, 10 Dec 2024 19:07:16 GMT"),("Content-Type","application/json"),("Transfer-Encoding","chunked"),("Connection","keep-alive"),("x-transfer-api-version","0.10"),("x-transfer-api-koa-version","5.8"),("cache-control","no-cache"),("pragma","no-cache"),("expires","0"),("x-transfer-api-error","ClientError.NotFound"),("Access-Control-Allow-Origin","*"),("Content-Encoding","gzip")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose, responseOriginalRequest = Request {
host = "transfer.api.globus.org"
port = 443
secure = True
requestHeaders = [("Authorization","<REDACTED>"),("Accept","application/json")]
path = "/v0.10/task/f855c1e6-b729-11ef-b839-115107518ebc"
queryString = ""
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
proxySecureMode = ProxySecureWithConnect
}
, responseEarlyHints = []}) "{\n \"code\": \"ClientError.NotFound\",\n \"message\": \"No task found with id 'f855c1e6-b729-11ef-b839-115107518ebc'\",\n \"request_id\": \"ZJJXZkYJj\",\n \"resource\": \"/task/f855c1e6-b729-11ef-b839-115107518ebc\"\n}"))

6 changes: 3 additions & 3 deletions nso-level2.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ library
, string-conversions
, string-interpolate
, tagged
, telescope
, telescope ==0.2.*
, text
, time
, unordered-containers
Expand Down Expand Up @@ -198,7 +198,7 @@ executable level2
, string-conversions
, string-interpolate
, tagged
, telescope
, telescope ==0.2.*
, text
, time
, unordered-containers
Expand Down Expand Up @@ -268,7 +268,7 @@ test-suite spec
, string-conversions
, string-interpolate
, tagged
, telescope
, telescope ==0.2.*
, text
, time
, unordered-containers
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencies:
- http-api-data
- globus >= 0.1.3
- massiv
- telescope
- telescope >= 0.2 && < 0.3
- uuid
- megaparsec
- monad-loops
Expand Down
1 change: 1 addition & 0 deletions src/App/Page/Proposals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ viewProposals now fs exs = do
case ip.program.instrument of
VBI -> fs.isVBI
VISP -> fs.isVISP
CRYO_NIRSP -> False

checkInvertible :: InversionFilter -> ProgramStatus -> Bool
checkInvertible Any _ = True
Expand Down
5 changes: 5 additions & 0 deletions src/App/View/ProposalDetails.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ viewCriteria ip gd = do
case ip.program.instrument of
VISP -> vispCriteria gd ip.program.spectralLines
VBI -> vbiCriteria
CRYO_NIRSP -> cryoCriteria
where
vispCriteria :: Grouped InstrumentProgram Dataset -> [SpectralLine] -> View c ()
vispCriteria ds sls = do
Expand All @@ -99,6 +100,10 @@ viewCriteria ip gd = do
el bold "VBI Criteria"
criteria "Not Supported" False

cryoCriteria = do
el bold "CRYO NIRSP Criteria"
criteria "Not Supported" False

criteriaRowHeight :: Length
criteriaRowHeight = 32

Expand Down
5 changes: 5 additions & 0 deletions src/NSO/Data/Qualify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ qualify g = do
case (sample g).instrument of
VISP -> qualifyVISP g
VBI -> qualifyVBI g
CRYO_NIRSP -> qualifyCryoNIRSP g


qualifyVISP :: Grouped InstrumentProgram Dataset -> Either String ()
Expand All @@ -59,6 +60,10 @@ qualifyVBI :: Grouped InstrumentProgram Dataset -> Either String ()
qualifyVBI _ = Left "VBI Not supported"


qualifyCryoNIRSP :: Grouped InstrumentProgram Dataset -> Either String ()
qualifyCryoNIRSP _ = Left "CRYO_NIRSP Not supported"


qualifyStokes :: Grouped InstrumentProgram Dataset -> Bool
qualifyStokes g = all (\d -> d.stokesParameters == StokesParameters [I, Q, U, V]) g.items

Expand Down
13 changes: 8 additions & 5 deletions src/NSO/Data/Scan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import NSO.Data.Datasets
import NSO.Error
import NSO.Metadata
import NSO.Prelude
import Text.Read (readMaybe)


-- scanDatasets :: (Time :> es, GraphQL :> es, Rel8 :> es, Error RequestError :> es) => Eff es [Dataset]
Expand Down Expand Up @@ -83,7 +82,7 @@ syncResult old d = fromMaybe New $ do

toDataset :: UTCTime -> [ExperimentDescription] -> DatasetInventory -> Either String Dataset
toDataset scanDate exs d = do
ins <- parseRead "Instrument" d.instrumentName
ins <- parseInstrument d.instrumentName
exd <- parseExperiment d.primaryExperimentId
emb <- parseEmbargo
pure $
Expand Down Expand Up @@ -122,6 +121,10 @@ toDataset scanDate exs d = do
Nothing -> Left "Experiment Description"
(Just e) -> pure e.experimentDescription

parseInstrument :: Text -> Either String Instrument
parseInstrument input =
maybe (Left [i|Invalid Instrument: #{input}|]) Right $ instrumentFromName $ cs input

parseEmbargo :: Either String (Maybe UTCTime)
parseEmbargo =
if d.isEmbargoed
Expand All @@ -134,9 +137,9 @@ toDataset scanDate exs d = do
required n Nothing = Left ("Missing Required: " <> n)
required _ (Just v) = pure v

parseRead :: (Read a) => Text -> Text -> Either String a
parseRead expect input =
maybe (Left [i|Invalid #{expect}: #{input}|]) Right $ readMaybe $ cs input
-- parseRead :: (Read a) => Text -> Text -> Either String a
-- parseRead expect input =
-- maybe (Left [i|Invalid #{expect}: #{input}|]) Right $ instrumentFromName $ cs input

boundingBoxNaN bb =
if isCoordNaN bb.lowerLeft || isCoordNaN bb.upperRight
Expand Down
5 changes: 2 additions & 3 deletions types/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ extra-doc-files:

language: GHC2021


ghc-options:
- -Wall

Expand All @@ -32,7 +31,7 @@ default-extensions:
- StrictData

dependencies:
- base >=4.16 && <5
- base >=4.19 && <5
- time
- text
- tagged
Expand All @@ -55,7 +54,7 @@ dependencies:
- bytestring
- aeson
- globus >= 0.1.3
- telescope
- telescope >= 0.2 && <0.3
- scientific


Expand Down
7 changes: 7 additions & 0 deletions types/src/NSO/Types/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Rel8 (DBEq, DBType, ReadShow (..), TypeInformation, parseTypeInformation,
import System.FilePath qualified as FP
import Telescope.Asdf
import Telescope.Fits
import Text.Read (readMaybe)
import Web.HttpApiData
import Web.Hyperbole (Route)

Expand Down Expand Up @@ -84,10 +85,16 @@ instance Semigroup StokesParameters where
data Instrument
= VBI
| VISP
| CRYO_NIRSP
deriving (Show, Ord, Eq, Read, Generic)
deriving (DBType) via ReadShow Instrument


instrumentFromName :: Text -> Maybe Instrument
instrumentFromName "CRYO-NIRSP" = pure CRYO_NIRSP
instrumentFromName t = readMaybe . cs $ t


newtype Path' (t :: PathType) a = Path {filePath :: FilePath}
deriving newtype (Show, Read, Eq, Ord, IsString)
type Path = Path' File
Expand Down

0 comments on commit 172e38f

Please sign in to comment.