Geostationary Operational Environmental Satellites (GOES)

Example for reading and plotting GOES-R data

Basic Usage

using SpaceWeather
using SpaceWeather.GOES
using Dates

# Download and load XRS data for a single day
xrs = GOES.XRS[id = 16](Date(2020, 6, 1), Date(2020, 6, 2))

# Access X-ray flux data
xrsa = xrs["xrsa_flux"]  # Short wavelength (0.05-0.4 nm)
xrsb = xrs["xrsb_flux"]  # Long wavelength (0.1-0.8 nm)
View:  1:1440
 xrsb_flux  (1440)
   Datatype:    Union{Missing, Float32}
   Dimensions:  time
   Attributes:
    _FillValue           = -9999.0
    long_name            = XRS-B primary average flux.
    comments             = Electron contamination has been removed. xrsb_flux =  xrsb_flux_observed - xrsb_flux_electrons
    units                = W/m2
    valid_min            = 1.0e-9
    valid_max            = 0.2
    ancillary_variables  = xrsb_flag xrsb_num xrsb_flag_excluded electron_correction_flag
# load Magnetospheric Particle Sensor High (MPS-HI)
mpsh_ds = GOES.MPSH[id = 16](Date(2020, 6, 1), Date(2020, 6, 2))
mpsh_ds["AvgDiffProtonFlux"]
View:  Base.Slice(Base.OneTo(11)) × Base.Slice(Base.OneTo(5)) × 1:1440
 AvgDiffProtonFlux  (11 × 5 × 1440)
   Datatype:    Union{Missing, Float32}
   Dimensions:  proton_diff_chans × telescopes × time
   Attributes:
    _FillValue           = -1.0e31
    long_name            = Time-averaged proton fluxes in several differential channels between 80 and 10,000 keV
    units                = protons/(cm^2 sr keV s)
    valid_min            = 0.0
    valid_max            = 460000.0
# load MAG Data
mag_ds = GOES.MAG[id = 16](Date(2020, 6, 1), Date(2020, 6, 2))
mag_ds["b_total"]
View:  1:1440
 b_total  (1440)
   Datatype:    Union{Missing, Float32}
   Dimensions:  time
   Attributes:
    _FillValue           = -9999.0
    long_name            = magnetic_field_total_magnitude
    comments             = Estimated ambient magnetic field in ACRF coordinates (total).
    units                = nT
    valid_min            = 0.0
    valid_max            = 1024.0

Plotting GOES-R XRS Data

using CairoMakie

f = Figure()
ax1 = Axis(f[1, 1]; yscale = log10, xlabel = "Time (UTC)", ylabel = "X-Ray Flux\n($(xrsa.attrib["units"]))")
times = nomissing(xrs["time"][:])
lines!(ax1, times, nomissing(xrsa[:]); label = "GOES-16 XRS-A (0.05-0.4 nm)", color = :mediumorchid)
lines!(ax1, times, nomissing(xrsb[:]); label = "GOES-16 XRS-B (0.1-0.8 nm)", color = :green)

# Plot 1 day of MPSH 1-minute AvgDiffProtonFlux in Telescope 0, Band 0
var = mpsh_ds["AvgDiffProtonFlux"]
ax2 = Axis(f[2, 1]; yscale = log10, xlabel = "Time (UTC)", ylabel = "AvgDiffProtonFlux\n($(var.attrib["units"]))")
times = nomissing(mpsh_ds["time"][:])
lines!(ax2, times, var[1, 1, :])

var = mag_ds["b_total"]
ax3 = Axis(f[3, 1]; ylabel = "b_total\n($(var.attrib["units"]))")
times = nomissing(mag_ds["time"][:])
lines!(ax3, times, var[:])

hidexdecorations!.((ax1, ax2); grid = false)
f
Example block output