Skip to content

Commit

Permalink
Merge pull request #343 from FormingWorlds/hn/platon
Browse files Browse the repository at this point in the history
Synthetic observables with PLATON
  • Loading branch information
nichollsh authored Feb 27, 2025
2 parents 62436ae + e49ca8d commit f005519
Show file tree
Hide file tree
Showing 37 changed files with 518 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ lovepy
Lovepy
LOVEPY
LovePy
platon
Platon
PLATON

# misc
######
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Development

*PROTEUS* targets Python 3.11 or newer.
PROTEUS targets Python 3.12 or newer.

Clone the repository into the `proteus` directory:

Expand Down
28 changes: 21 additions & 7 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ This can be done via brew on MacOS, or with your package manager on Linux. Alter
If you already have Julia installed, skip this step.
This should only be done using the official installer, not via your package manager.

```console
curl -fsSL https://install.julialang.org | sh
```
```console
curl -fsSL https://install.julialang.org | sh
```

## Download the framework

Expand Down Expand Up @@ -82,7 +82,7 @@ This should only be done using the official installer, not via your package mana
The code can be setup in `./socrates/` using the following script.

```console
source tools/get_socrates.sh
./tools/get_socrates.sh
```

The environemnt variable `RAD_DIR` must always point to the SOCRATES installation path.
Expand Down Expand Up @@ -174,9 +174,23 @@ This should only be done using the official installer, not via your package mana
Lovepy is written in Julia. You can use the same environment as AGNI if you wish, but you
should make sure to follow the installation steps below.

```console
./tools/get_lovepy.sh
```
```console
./tools/get_lovepy.sh
```

### Synthetic observations calculator (**PLATON**)

[PLATON](https://platon.readthedocs.io/en/latest/intro.html) is a forward modelling and
retrieval tool for exoplanet atmospheres. In PROTEUS, this tool is used to generate
synthetic transmission and secondary eclipse observations. To get PLATON and its
dependencies, use the script below.

```console
./tools/get_platon.sh
```

Note that this script will take some time to run; PLATON will need to download
about 10 GB of opacity data from the internet.

### Chemical kinetics atmosphere model (**VULCAN**)

Expand Down
9 changes: 8 additions & 1 deletion input/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# [interior] magma ocean model selection and parameters
# [outgas] outgassing parameters (fO2) and included volatiles
# [delivery] initial volatile inventory, and delivery model selection
# [observe] synthetic observations

# ----------------------------------------------------
# Metadata
Expand All @@ -26,7 +27,7 @@ author = "Harrison Nicholls, Tim Lichtenberg"
# output files
[params.out]
path = "default"
logging = "INFO"
logging = "DEBUG"
plot_mod = 2 # Plotting frequency, 0: wait until completion | n: every n iterations
plot_fmt = "png" # Plotting image file format, "png" or "pdf" recommended
write_mod = 1 # Write CSV frequency, 0: wait until completion | n: every n iterations
Expand Down Expand Up @@ -274,3 +275,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables (none, platon)
synthesis = "platon"
6 changes: 6 additions & 0 deletions input/demos/aragog.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "none"
6 changes: 6 additions & 0 deletions input/demos/dummy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "none"
6 changes: 6 additions & 0 deletions input/demos/escape.toml
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "none"
6 changes: 6 additions & 0 deletions input/planets/earth.toml
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "none"
6 changes: 6 additions & 0 deletions input/planets/hd63433d.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "none"
6 changes: 6 additions & 0 deletions input/planets/k218b.toml
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "none"
6 changes: 6 additions & 0 deletions input/planets/l9859b.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "none"
6 changes: 6 additions & 0 deletions input/planets/l9859c.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "none"
12 changes: 9 additions & 3 deletions input/planets/l9859d.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ author = "Harrison Nicholls, Tim Lichtenberg"

[params.dt.adaptive]
atol = 0.02 # Step size atol
rtol = 0.07 # Step size rtol
rtol = 0.06 # Step size rtol

# Termination criteria
# Set enabled=true/false in each section to enable/disable that termination criterion
Expand Down Expand Up @@ -195,7 +195,7 @@ author = "Harrison Nicholls, Tim Lichtenberg"
module = "spider" # Which interior module to use

[interior.spider]
num_levels = 80 # Number of SPIDER grid levels
num_levels = 70 # Number of SPIDER grid levels
mixing_length = 2 # Mixing length parameterization
tolerance = 1e-6 # solver tolerance
tsurf_atol = 5.0 # tsurf_poststep_change
Expand Down Expand Up @@ -259,7 +259,7 @@ author = "Harrison Nicholls, Tim Lichtenberg"
NH_ratio = 0.018 # N/H mass ratio in mantle/atmosphere system
# N_ppmw = 2.01 # Nitrogen inventory in ppmw relative to mantle mass

SH_ratio = 3.8 # S/H mass ratio in mantle/atmosphere system
SH_ratio = 4.0 # S/H mass ratio in mantle/atmosphere system
# S_ppmw = 0.0 # Sulfur inventory in ppmw relative to mantle mass

# Set initial volatile inventory by partial pressures in atmosphere
Expand All @@ -274,3 +274,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "platon"
6 changes: 6 additions & 0 deletions input/planets/trappist1c.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,9 @@ author = "Harrison Nicholls, Tim Lichtenberg"
H2 = 0.0
CH4 = 0.0
CO = 0.0

# Calculate simulated observations
[observe]

# Module with which to calculate the synthetic observables
synthesis = "none"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
"attrs",
"cattrs",
"fwl-janus>=24.11.05",
"fwl-mors>=24.11.18",
"fwl-mors>=25.02.26",
"fwl-calliope>=25.02.26",
"fwl-zephyrus>=24.10.15",
"aragog>=0.1.9a0",
Expand Down
2 changes: 1 addition & 1 deletion src/proteus/atmos_clim/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def run_atmosphere(atmos_o:Atmos_t, config:Config, dirs:dict, loop_counter:dict,
hf_row["p_xuv"] = atm_output["p_xuv"] # Closest pressure to Pxuv [bar]
hf_row["R_xuv"] = atm_output["R_xuv"] # Radius at p_xuv [m]

# Calculate observables (measured at infinite distance)
# Calculate bolometric observables (measured at infinite distance)
hf_row["transit_depth"] = (hf_row["R_obs"] / hf_row["R_star"])**2.0
hf_row["contrast_ratio"] = ((hf_row["F_olr"]+hf_row["F_sct"])/hf_row["F_ins"]) * \
(hf_row["R_obs"] / hf_row["separation"])**2.0
Expand Down
9 changes: 9 additions & 0 deletions src/proteus/config/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ._delivery import Delivery
from ._escape import Escape
from ._interior import Interior
from ._observe import Observe
from ._orbit import Orbit
from ._outgas import Outgas
from ._params import Params
Expand All @@ -30,6 +31,11 @@ def tides_enabled_orbit(instance, attribute, value):
if (instance.interior.tidal_heat) and (instance.orbit.module is None):
raise ValueError("Interior tidal heating requires an orbit module to be enabled")

def observe_resolved_atmosphere(instance, attribute, value):
# Synthetic observations require a spatially resolved atmosphere profile
if (instance.observe.synthesis is not None) and (instance.atmos_clim.module == "dummy"):
raise ValueError("Interior tidal heating requires an orbit module to be enabled")

@define
class Config:
"""Root config parameters.
Expand Down Expand Up @@ -58,6 +64,8 @@ class Config:
Outgassing parameters (fO2, etc) and included volatiles.
delivery: Delivery
Initial volatile inventory, and delivery model selection.
observe: Observe
Synthetic observations.
"""

version: str = field(validator=validators.in_(('2.0',)))
Expand All @@ -72,6 +80,7 @@ class Config:
interior: Interior = field(validator=(tides_enabled_orbit,))
outgas: Outgas
delivery: Delivery
observe: Observe

def write(self, out:str):
"""
Expand Down
17 changes: 17 additions & 0 deletions src/proteus/config/_observe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from __future__ import annotations

from attrs import define, field
from attrs.validators import in_

from ._converters import none_if_none


@define
class Observe:
"""Synthetic observations.
synthesis: str
Module to use for calculating synthetic spectra.
"""

synthesis: str = field(validator=in_((None,'platon')), converter=none_if_none)
5 changes: 5 additions & 0 deletions src/proteus/observe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

# from .wrapper import run_interior

__all__ = []
10 changes: 10 additions & 0 deletions src/proteus/observe/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import annotations

import os


def get_transit_fpath(outdir:str):
return os.path.join(outdir, "data", "obs_synth_transit.csv")

def get_eclipse_fpath(outdir:str):
return os.path.join(outdir, "data", "obs_synth_eclipse.csv")
Loading

0 comments on commit f005519

Please sign in to comment.