A Python interface to the NEMESIS spectral inversion tool
Project description
Eleos - A Python interface to NEMESIS
Please note, this is a WIP project and features may be added/removed at any time. Full documentation will be added in due course.
Installation
Eleos is available on PyPI so it can be installed as any other python package. On Unix-like systems:
pip install nemesis_eleos
And on Windows:
py -m pip install nemesis_eleos
Eleos only creates file for, and reads files created by, NEMESIS. Therefore, it is not mandatory to have NEMESIS installed for this package to work. In order to use the cores however, it is necessary. See the NEMESIS GitHub page for full instructions on how to download the software and how to compile it.
This library was built with the intention of running on the University of Leicester’s HPC system ALICE3. Therefore, functions like cores.generate_alice_job and cores.run_alice_job are only
guaranteed to work on ALICE3, which uses the SLURM job scheduler. Other HPC facilities will require their own template submission files in data/statics and functions in cores.
Working Directory Structure
This library will function best with the following structure in your working directory:
parent_directory
|-- core_1
|-- core_2
| ...
generate.py
analyse.py
where parent_directory/ contains a set of cores for a retrieval, core_N/ is the core folder that NEMESIS is run from, generate.py is the code that generates these cores using eleos.cores, and analyse.py is the code that analyses the results using eleos.results .
Core Generation Example (generate.py)
This code generates 4 cores, each with a different forward modelling error factor. Scattering is off by default, so these consider only thermla emission from the planet. It retrieves the temeprature profile using a prior from a pre-loaded file (tempapr.dat), the ammonia profile represented as a knee pressure (model 1 in NEMESIS), and an aerosol layer represented as model 32. It then generates a submission script to run NEMESIS using those cores on ALICE.
from eleos import shapes, profiles, cores
# Create the profile shapes - see the class docstring for a brief description or NEMESIS manual for a full description of each one
nh3_shape = shapes.Shape1(knee_pressure=0.1,
deep_vmr=1e-4,
deep_vmr_error=1e-4,
fsh=0.3,
fsh_error=0.3)
aero_shape = shapes.Shape32(base_pressure=0.8,
base_pressure_error=0.5,
opacity=1,
opacity_error=0.3,
fsh=0.4,
fsh_error=0.2)
# Create the profiles to retrieve
nh3_profile = profiles.GasProfile(gas_name="NH3",
isotope_id=0,
shape=nh3_shape)
aero_profile = profiles.AerosolProfile(aerosol_id=1,
shape=aero_shape)
temp_profile = profiles.TemperatureProfile(filepath="./data/jupiter/tempapr.dat")
# Generate a set of 4 cores. Each one is identical apart from the forward modelling error is multiplied by a factor of n
core_list = []
for n in range(1, 5):
core = cores.NemesisCore(parent_directory=f"cores/",
spx_file="/home/s/scat2/JWST/2022_JupSouthPole/zonal_spectra/sparse_55.0degS.spx",
ref_file="data/jupiter/jupiter.ref",
profiles=[temp_profile, nh3_profile, aero_profile],
fmerror_factor=n)
core_list.append(core)
# Generate a SLURM job submission script for use on the University of Leicester ALICE3 HPC cluster
cores.generate_alice_job(cores=core_list, username="scat2")
Result Analysis Example (analyse.py)
This code takes the result of running NEMESIS on the output of the above example and plots the retrieved spectrum and temperature profile for the first of the cores, then saves it to a file.
import matplotlib.pyplot as plt
from eleos import results
# Read in the core after NEMESIS has been run successfully
res = results.NemesisResult("cores/core_1/")
# Create a new Figure object with two Axes
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12,5))
# Plot the model spectrum on one and the retrieved temperature profile oin the other
res.plot_spectrum(ax=ax1)
res.plot_temperature(ax=ax2)
# Save the figure
plt.tight_layout()
fig.savefig("nosync/temp.png", dpi=500)
Limitations and future work
Currently, this library only supports Jupiter (although expansion should be fairly easy when providing .ref files) and a single aerosol mode. In the future, these restrictions will be lifted once the basics of the library have been debugged and tested for both forward and retrieval modes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nemesis_eleos-0.6.2.tar.gz.
File metadata
- Download URL: nemesis_eleos-0.6.2.tar.gz
- Upload date:
- Size: 40.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaed0c889a3a996d30007aca1799b30c6fffb74c766cb2c6244ae8a4a1db7f63
|
|
| MD5 |
e3c8d8ae9ff91772c70809d83a676eea
|
|
| BLAKE2b-256 |
10fcc79d33875683bf40ea8f7de17cf6e7213deafd2b86d2769ecade245d8711
|
Provenance
The following attestation bundles were made for nemesis_eleos-0.6.2.tar.gz:
Publisher:
publish.yml on simon-toogood/eleos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nemesis_eleos-0.6.2.tar.gz -
Subject digest:
eaed0c889a3a996d30007aca1799b30c6fffb74c766cb2c6244ae8a4a1db7f63 - Sigstore transparency entry: 153659979
- Sigstore integration time:
-
Permalink:
simon-toogood/eleos@644279b750b04d6c5f729c02d8f81fcc898e8ade -
Branch / Tag:
refs/heads/main - Owner: https://github.com/simon-toogood
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@644279b750b04d6c5f729c02d8f81fcc898e8ade -
Trigger Event:
push
-
Statement type:
File details
Details for the file nemesis_eleos-0.6.2-py3-none-any.whl.
File metadata
- Download URL: nemesis_eleos-0.6.2-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
277593e509129392c5a021399c478432c5366bf2de3d5644b55d4a99109f4b69
|
|
| MD5 |
eb4296e266adcff84ffce6294a2c9653
|
|
| BLAKE2b-256 |
16b5785dae6cb7a95be4f8e02f0cb8b1f862f886b5e61dc07b844c8131fcc1af
|
Provenance
The following attestation bundles were made for nemesis_eleos-0.6.2-py3-none-any.whl:
Publisher:
publish.yml on simon-toogood/eleos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nemesis_eleos-0.6.2-py3-none-any.whl -
Subject digest:
277593e509129392c5a021399c478432c5366bf2de3d5644b55d4a99109f4b69 - Sigstore transparency entry: 153659980
- Sigstore integration time:
-
Permalink:
simon-toogood/eleos@644279b750b04d6c5f729c02d8f81fcc898e8ade -
Branch / Tag:
refs/heads/main - Owner: https://github.com/simon-toogood
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@644279b750b04d6c5f729c02d8f81fcc898e8ade -
Trigger Event:
push
-
Statement type: