This document provides a high-level overview of the workflow and usage
of the QuicklookGenerator system. It is intended to help developers
understand how quicklook plots are produced from IMAP instrument data files.
Each instrument implements its own plotting logic while sharing a common initialization, data-loading, and dispatch workflow.
The system is built around four major components:
- Dataset loading – converting a CDF file into an
xarray.Dataset. - Instrument detection – determining the correct quicklook generator class.
- Abstract quicklook interface – common API for all instruments.
- Instrument-specific subclasses – actual plotting implementations.
User supplies a CDF file path:
quicklook = get_instrument_quicklook("path/to/file.cdf")The filename is parsed using
ScienceFilePath.extract_filename_componentsto extract theinstrumentfield.The correct Quicklook subclass is selected via the
QuicklookGeneratorTypeenum. For example:MAG → MagQuicklookGenerator
The pattern continues for each individual instrument.
The chosen class is instantiated, and the constructor:
- Loads the dataset using
dataset_into_xarray. - Stores instrument metadata (such as the instrument name).
- Initializes plotting-related attributes.
- Loads the dataset using
The user calls
two_dimensional_plot(variable="..."). This method is implemented by each subclass and acts as a routing mechanism that decides which quicklook plot to generate.Example for MAG:
mag_ql = MagQuicklookGenerator("imap_mag_20250101_v01.cdf") mag_ql.two_dimensional_plot(variable="mag sensor co-ord")The requested plot function runs, accessing data from the internal
xarray.Datasetand generating figures using Matplotlib.Plots are displayed, and the workflow ends. No data is returned— the quicklook system produces visualizations only.
The QuicklookGenerator abstract base class provides:
- Unified dataset loading via
dataset_into_xarray. - Common metadata attributes (instrument, title, axis labels, etc.).
- Basic validation to ensure that a dataset is present.
- An abstract method
two_dimensional_plot, which each instrument subclass must implement as a dispatch mechanism.
Instrument data often stores time in J2000 nanoseconds. These values are converted to UTC timestamps using:
convert_j2000_to_utc(time_array)
This conversion internally uses:
- A fixed epoch:
2000-01-01 11:58:55.816 - NumPy
timedelta64arithmetic - Output as
datetime64[ns]UTC timestamps
This routine is used across all instruments providing an epoch field.
Users should begin quicklook generation by calling:
quicklook = get_instrument_quicklook(filename)
This function:
- Extracts the instrument identifier from the filename.
- Uses
QuicklookGeneratorTypeto map the instrument to a class. - Returns an instantiated quicklook object.
Example:
>>> ql = get_instrument_quicklook("imap_swapi_20250101_v02.cdf")
>>> ql.two_dimensional_plot("count rates")
To extend the quicklook system:
Create a new subclass:
class NewInstQuicklookGenerator(QuicklookGenerator): ...Implement
two_dimensional_plotas a dispatch method.Add plot functions as needed.
Register the class in the
QuicklookGeneratorTypeenum.Ensure that
ScienceFilePath.extract_filename_componentscorrectly identifies the instrument.
To implement a new instrument-specific quicklook, instrument teams must provide a minimal set of information that defines what plots are required and how the underlying data should be interpreted.
- List of quicklook plots - A high-level description of each plot to be generated. - Whether each plot is 1-D (line), 2-D (spectrogram), or multi-panel.
- Variables required for each plot - CDF variable names. - Which CDF files contain the required variables.
- Time-axis requirements (if applicable) - Desired time range (full file, event-based selection, rolling window).
- Plot formatting preferences - Preferred units or scaling (linear, log). - Desired titles, axis labels, and annotations.
- Special processing rules - Required calibrations or unit conversions. - Masking rules for invalid ranges or quality flags. - Any filtering or smoothing applied before plotting.