JWST

Adapted from ADASS 2024 workshop.

In this example, we show how to use ASDF.jl to load and view some astronomical data taken from the James Webb Space Telescope (JWST).

Data availability

The sample data for this example can be downloaded here from the data repository of the Space Telescope Science Institute (STScI). Note: it is a moderately large file (~100 MB).

Load

data_dir = joinpath("..", "..", "data")
mkpath(data_dir)
fpath = joinpath(data_dir, "jwst.asdf")

if !isfile(fpath)
    using Downloads: download

    download("https://data.science.stsci.edu/redirect/Roman/Roman_Data_Workshop/ADASS2024/jwst.asdf", fpath)
end
"../../data/jwst.asdf"
using ASDF

af = ASDF.load_file(fpath; extensions = true)

af.metadata
Dict{Any, Any} with 5 entries:
  "history"      => Dict{Any, Any}("extensions"=>Dict{Any, Any}[Dict("software"…
  "meta"         => Dict{Any, Any}("background"=>Dict{Any, Any}("method"=>"matc…
  "data"         => NDArray(LazyBlockHeaders(BlockHeader[BlockHeader(IOStream(<…
  "asdf_library" => Dict{Any, Any}("name"=>"asdf", "author"=>"The ASDF Develope…
  "_fits_hash"   => "93cf4256596bd7a6d20913c3d0f6e1ab9d3a8647c02771c5c752b2311e…

Plot

using CairoMakie

img_sci = let
    img = af.metadata["data"][]
    img[img .< 0] .= 1
    img
end

fig, ax, hm = heatmap(img_sci;
    colorrange = (1, 1e3),
    colorscale = log10,
    colormap = :cividis,
    nan_color = :limegreen, # NaNs are handled automatically
)

Colorbar(fig[1, 2], hm)

fig
Example block output