import datetime
import pyaurorax
aurorax = pyaurorax.PyAuroraX()
at = aurorax.tools
at.set_theme("dark")
# download an hour of THEMIS ASI data
dataset_name = "THEMIS_ASI_RAW"
start_dt = datetime.datetime(2021, 11, 4, 9, 0)
end_dt = datetime.datetime(2021, 11, 4, 9, 59)
site_uid = "atha"
r = aurorax.data.ucalgary.download(dataset_name, start_dt, end_dt, site_uid=site_uid)
Downloading THEMIS_ASI_RAW files: 0%| | 0.00/128M [00:00<?, ?B/s]
# read in the hour of data
data = aurorax.data.ucalgary.read(r.dataset, r.filenames, n_parallel=5)
# scale all the images
#
# NOTE: you can scale all images or just one image
images_scaled = at.scale_intensity(data.data, min=1000, max=10000)
# create the montage
montage = at.montage.create(images_scaled[:, :, 0:10], data.timestamp[0:10])
# plot the montage
montage.plot(2, 5, figsize=(13, 6), cmap="gray")
# we'll use the first frame of each minute, so let's extract the appropriate data
# object with that data
import numpy as np
first_minute_frames = np.empty((data.data.shape[0], data.data.shape[1], 60), dtype=data.data.dtype)
first_minute_timestamps = []
counter = 0
for i in range(0, len(data.timestamp)):
if (data.timestamp[i].second == 0):
# 0-th second frame
#
# add to our batch
first_minute_frames[:,:,counter] = data.data[:,:,i]
first_minute_timestamps.append(data.timestamp[i])
counter += 1
# now that we have our data, let's create a montage object
montage = at.montage.create(first_minute_frames, first_minute_timestamps)
montage
Montage(data=array(dims=(256, 256, 60), dtype=uint16), timestamp=[60 datetime objects])
montage.plot(6, 10, figsize=(11, 7), cmap="gray", timestamps_format="%H:%M", timestamps_fontsize=10)
# we can leverage the first_record parameter of the read function to do the work for us
# of extracting the first minute's data
data = aurorax.data.ucalgary.read(r.dataset, r.filenames, n_parallel=5, first_record=True)
# scale the data
images_scaled = at.scale_intensity(data.data, min=1000, max=10000)
# create the montage
montage = at.montage.create(data.data, data.timestamp)
# plot the montage
montage.plot(6, 10, figsize=(11, 7), cmap="gray", timestamps_format="%H:%M", timestamps_fontsize=10)