The level 3 processing code is a command-line program that will run inside of a docker container. The code snippet below will build the docker image and run the container and remove it after execution is completed.
There is a program named imap-data-access which is used to upload and download cdf files from the SDC.
Start by running the following commands in a terminal to create a virtual environment. If you've pulled the repository,
open the terminal from the imap_l3_processing folder.
python -m venv venvsource venv/Scripts/activate
Continue following the installation instructions from the IMAP Science Operations Center. Installation instructions are found at: https://github.com/IMAP-Science-Operations-Center/imap-data-access
The SDC expects cdf files to follow a specific naming
convention: imap_swapi_{data_level}_{descriptor}_{start_date}_{version}.cdf
An example file would be called: imap_swapi_l2_sci_20111231_v001.cdf
Note: Currently the only acceptable descriptor is 'sci'
Note: File versions must be 3 characters long. (i.e. v003)
The command to upload a cdf file and trigger the pipeline
is : imap-data-access upload imap_swapi_l2_sci_20111231_v001.cdf.
The command to see the newly created L3a data files
is : imap-data-access query --instrument swapi --data-level l3a --version v001
You should see two L3a files:
- imap_swapi_l3a_proton-sw-fake-menlo-{GUID}_20111231_v001.cdf
- imap_swapi_l3a_alpha-sw-fake-menlo-{GUID}_20111231_v001.cdf
- Install Docker Desktop
- Start Docker Desktop
- Pull this repository
The arguments passed after the build command describe the inputs to the level 3 processing code. The volume command-line argument mounts the local spice kernel folder to the docker container. The remaining arguments match the inputs that we expect to receive from the SDC batch job run.
docker run --rm --mount type=bind,src="$(pwd)/spice_kernels",dst="/mnt/spice" --mount type=bind,src="$(pwd)/temp_cdf_data",dst="/temp_cdf_data" $(docker build -q -f Dockerfile_run_local .) $@
Alternatively, running run_local_using_docker.sh in Git Bash will execute the above command for you:
./run_local_using_docker.sh {instrument-name} {data-level}
We created a tool to retrieve the latest data from the SDC to assist with testing. The tool takes in command line arguments, the instrument level, and the number of files to retrieve. For example:
python fetch_latest_data.py --instrument swapi --level l3a --count 4
This will copy the .cdf files into your repo folder under the data folder.
This project uses uv for dependency management.
uv sync --extra testinstalls the runtime dependencies plus unit-testing tools (pytest,pytest-xdist).uv sync --extra devinstalls formatting/linting tools (ruff) plus other developer dependencies.uv sync --extra test --extra devinstalls both.
Many test fixtures (.dat, .bsp, .tls, .tsc, .tf files — calibration tables and SPICE
kernels) are stored via Git LFS, not checked directly into git. Before
running the test suite for the first time:
- Install the
git-lfsCLI (e.g.brew install git-lfs, or see the link above). - Run
git lfs installonce per machine to register the LFS filters with git. Without it,git lfs pullsilently fetches objects but does not check them out. - Run
git lfs pullto replace the LFS-tracked files with their real content.
If this step is skipped, those files stay as small text pointer stubs (starting with
version https://git-lfs.github.com/spec/v1), and tests that read them fail with confusing
errors that don't look LFS-related, e.g. ValueError: could not convert string 'version' to float64... or spiceypy errors like SpiceNOLEAPSECONDS/SpiceMISSINGTIMEINFO.
- Running the test suite requires the Git LFS data described above: run
git lfs pullfirst. Skipping this step will cause tests to fail. uv run pytestruns the full suite.uv run python -m unittest discover testsalso works, since the suite is written withunittest.TestCase.- To run tests for a single instrument, point either of the above at its directory, e.g.
uv run pytest tests/swapi. pytest-xdistis installed (-n auto), but is not currently used in CI or recommended locally, as some tests are not yet safe to run in parallel (TODO).
uv run ruff check .lints the codebase.uv run ruff format --check .checks formatting without modifying files (drop--checkto apply formatting).
This repo uses pre-commit to run ruff check and ruff format on
staged files before each commit (see .pre-commit-config.yaml).
uv run pre-commit installsets up the git hook once per clone.uv run pre-commit run --all-filesruns the hooks against the whole repo (useful the first time, or after changing the hook config).
Both hooks also run in CI, so failures caught locally would otherwise fail there too.