University of Colorado at Boulder University of Colorado CU Home Search A to Z Index Map
Laboratory for Atmospheric and Space Physics

How to Load and Plot Data

 

Table of Contents

Examples (IDL and Python)
    Loading data
    Plotting data
        1) A single spectrum
        2) A time series of a single bin

. 12

Examples (IDL and Python)

Loading data

First, simply download the mission-length level 1 MinXSS data (minxss1_l1_mission_length.sav). This link takes you to the file that is regenerated daily that folds in all new telemetry received. That processing starts at midnight UTC. It takes ~20 minutes to complete processing, so you can be sure that the file is updated by 01:00 UTC every day.

IDLDE (IDL Workbench)

You can simply double click the minxss1_l1_mission_length.sav file and it will load the minxsslevel1 variable. You can alternatively load the data in the interactive console using the IDL console method below.

IDL console

restore, path + path_sep() + ‘minxss1_l1_mission_length.sav’

where path is the path to the file. The built-in path_sep() function is used above to return a / for Linux/Mac (i.e., Unix)
systems and a \ for Windows systems.

Python (requires scipy)

from scipy.io.idl import readsav
data = readsav(‘path/minxss1_l1_mission_length.sav’)
minxsslevel1 = data.minxsslevel1.copy()

where path is the path to the file. This generates a dictionary (data) containing the variables minxsslevel1 and minxsslevel1meta. We copy minxsslevel1 out for convenience, so that you don’t have to call data.minxsslevelthereafter.

Plotting data

1) A single spectrum

IDL
p =
plot(minxsslevel1[2060].energy, minxsslevel1[2060].irradiance, $

         TITLE = ‘MinXSS Solar SXR Spectrum on ‘ + $
                  minxsslevel1[2060].time.human, $
         XTITLE = ‘Energy [keV]’, XRANGE = [0.8, 2.5], $
         YTITLE = ‘Irradiance [photons / sec / cm$^2$ / keV]’, YRANGE = [1e4, 1e9], /YLOG)

which should result in this plot:

An IDL procedure that loads the data and creates the above plot can be downloaded here.

Python

%matplotlib inline
import matplotlib.pyplot as plt

plt.plot(minxsslevel1[2060][‘energy’], minxsslevel1[2060][‘irradiance’], drawstyle = ‘steps-mid’)
plt.xlim([0.8, 2.5])
plt.xlabel(‘Energy [keV]’)
plt.ylim([1e4, 1e9])
plt.yscale(‘log’)
plt.ylabel(‘Irradiance [photons / sec / cm$^2$ / keV]’)
plt.suptitle(‘MinXSS Solar SXR Spectrum on ‘ + minxsslevel1[2060][‘time’][‘human’][0].decode(“utf-8”))
plt.show()

which should result in this plot:

 

A python notebook that loads the data and creates the above plot can be downloaded here and the raw python code can be found here.

2) A time series of a single bin

You would normally want to do this for an emission line. An emission line may cover multiple bins or multiple emission lines may fill an individual bin. For simplicity, we show you the principle here by plotting just a single bin corresponding to an energy of ~2 keV.

IDL

p1 = plot(minxsslevel1.time.jd, minxsslevel1.irradiance[73], $
          SYMBOL = ‘dot,  SYM_THICK = 3, COLOR = ‘dodger blue’, $
          DIMENSIONS = [800, 600], $
          TITLE = ‘MinXSS Solar SXR ‘ + $
                   strtrim(minxsslevel1[0].energy[73], 2) + keV Over Time’, $
          XTITLE = ‘Time [UTC]’, $
          XTICKFORMAT = [‘LABEL_DATE’, ‘LABEL_DATE’], $
          XTICKUNITS = [‘Month’, ‘Year’], $
XTICKINTERVAL = 1, $
          YTITLE = ‘Irradiance [photons / sec / cm$^2$ / keV]’) 

which should result in this plot:

 

An IDL procedure that loads the data and creates the above plot can be downloaded here.

Python
%
matplotlib inline
from scipy.io.idl import readsav
import matplotlib.pyplot as plt
import numpy as np
import datetime
import matplotlib.dates as mdates

# Extract irradiance for the 73th bin corresponding to energy 2.0 keV
irradiance = minxsslevel1[‘irradiance’]
irradianceBin73 = np.zeros(len(irradiance))
for i in range(len(irradiance)):
  irradianceBin73[i]
= irradiance[i][73]

# Extract time and convert it so that matplotlib can understand it
time_human = []
for i in range(len(irradiance)):
  time_human.append(minxsslevel1[i][
‘time’][‘human’][0].decode(“utf-8”))
datetimes = [datetime.datetime.strptime(t, “%Y-%m-%d %H:%M:%S”) forin time_human]

# Make the plot
fig, ax = plt.subplots(1)
plt.plot(datetimes, irradianceBin73, ‘b-o’, markersize = 3)
fig.autofmt_xdate()
ax.xaxis.set_major_formatter(mdates.DateFormatter(“%Y-%b-%d))
plt.xlabel(‘Time [UTC]’)
plt.ylabel(‘Irradiance [photons / sec / cm$^2$ / keV]’)
plt.ylim([0, 8e8])
plt.suptitle(‘MinXSS Solar SXR ‘ + str(minxsslevel1[0][‘energy’][73]) + keV Over Time’)
plt.show()

which should result in this plot:

A python notebook that loads the data and creates the above plot can be downloaded here and the raw python code can be found here.