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. It is absolutely not guarunteed to be backward compatible until it has matured significantly
Documentation
Documentation can be found on ReadTheDocs here. This is still WIP, 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
While eleos only creates file for and reads files created by NEMESIS, it is mandatory to have NEMESIS installed for this package to work. This is primarily due to required the utilities Makephase and Normxsc on the PATH. 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. This is only a recommendation, and you can structure your working directories however you like.
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
# ------ Gas Profile definitions ------ #
ph3 = profiles.GasProfile(gas_name="PH3",
shape=shapes.Shape2(
scale_factor=1, scale_factor_error=0.5))
nh3 = profiles.GasProfile(gas_name="NH3",
shape=shapes.Shape2(
scale_factor=1, scale_factor_error=0.5))
# ------ Tropospheric clouds ------ #
aero1 = profiles.AerosolProfile(label="Troposphere",
shape=shapes.Shape48(
base_pressure=1, base_pressure_error=1,
top_pressure=0.5, top_pressure_error=0.5,
opacity=5.0, opacity_error=5.0,
fsh=0.8, fsh_error=0.8))
n1 = profiles.ImagRefractiveIndexProfile(label="Troposphere",
shape=shapes.Shape444(
radius=2, radius_error=1,
variance=0.1, variance_error=0.1,
refractive_index=1.3+1e-3j, refractive_index_error=1e-3))
# ------ Stratospheric haze ------ #
aero2 = profiles.AerosolProfile(label="Stratosphere",
shape=shapes.Shape48(
base_pressure=0.1, base_pressure_error=0.1,
top_pressure=0.0001, top_pressure_error=0.0001,
opacity=2.0, opacity_error=2.0,
fsh=0.7, fsh_error=0.7))
# ------ Core creation ------ #
# This is the directory all the cores will live in (ie. it will generate nemesis/example/core_1/nemesis.apr,...
cd = "nemesis/example/"
# It is recommended to clear the parent directory before running
cores.clear_parent_directory(cd)
# For a full list of options to the NemesisCore constructor, see the documentation
core = cores.NemesisCore(parent_directory=cd,
spx_file="data/zonal_spectra/sparse_55.0degS.spx",
profiles=[ph3, nh3],
fmerror_factor=10)
# Multiple aerosol modes can be added, with either a 444 profile or by specifying parameters (if they are not to be fitted).
core.add_aerosol_mode(aero1, n1)
core.add_aerosol_mode(aero2, radius=0.1, variance=0.1, refractive_index=1.3+1e-3j)
# You can set the error in regions of the spectrum to be very small so NEMESIS will always fit the model there
core.fix_peak(4.5, 0.2)
# Create the files required for NEMESIS to run
core.generate_core()
# Generate a SLURM submission script and submit it to the scheduler
cores.generate_alice_job(cores=core, username="none", hours=1)
cores.run_alice_job(cd)
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 chi squared values 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("nemesis/example/core_1/")
# Create a new Figure object with two Axes
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12,5))
# Plot the model and measured spectrum on one axis
res.plot_spectrum(ax=ax1)
res.plot_chisq(ax=ax2)
# Save the figure
plt.tight_layout()
fig.savefig("example.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.7.3.tar.gz.
File metadata
- Download URL: nemesis_eleos-0.7.3.tar.gz
- Upload date:
- Size: 146.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9ef9643a73ba20d6da17236fa6842c108d5ac65a317c27485e59e0a1514246a
|
|
| MD5 |
2d07707d80cb7779374b4c65a5ed8e37
|
|
| BLAKE2b-256 |
dff243892a220f0f3e251c1ef203626b7312adc0a54f1506a86958c136cba9c9
|
Provenance
The following attestation bundles were made for nemesis_eleos-0.7.3.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.7.3.tar.gz -
Subject digest:
a9ef9643a73ba20d6da17236fa6842c108d5ac65a317c27485e59e0a1514246a - Sigstore transparency entry: 169371439
- Sigstore integration time:
-
Permalink:
simon-toogood/eleos@86301c7738c459e3c6a4182176f5876e04b732e9 -
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@86301c7738c459e3c6a4182176f5876e04b732e9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nemesis_eleos-0.7.3-py3-none-any.whl.
File metadata
- Download URL: nemesis_eleos-0.7.3-py3-none-any.whl
- Upload date:
- Size: 148.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d67a997196040de186047f5c5108ca8c87a45398fbf49a3b083bbee9d1c9f134
|
|
| MD5 |
d8524936afd17b49f311fa7fcd63afbb
|
|
| BLAKE2b-256 |
0bd330363f855677ef01d01c60dceb15436d1a592551631ae440d85a413ee3e5
|
Provenance
The following attestation bundles were made for nemesis_eleos-0.7.3-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.7.3-py3-none-any.whl -
Subject digest:
d67a997196040de186047f5c5108ca8c87a45398fbf49a3b083bbee9d1c9f134 - Sigstore transparency entry: 169371440
- Sigstore integration time:
-
Permalink:
simon-toogood/eleos@86301c7738c459e3c6a4182176f5876e04b732e9 -
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@86301c7738c459e3c6a4182176f5876e04b732e9 -
Trigger Event:
push
-
Statement type: