{ "cells": [ { "cell_type": "markdown", "id": "VSC-3b5cf4a6", "metadata": { "language": "markdown" }, "source": [ "# Temperature, Pressure, and Chemistry\n", "\n", "With the opacity data in place from [Setup and opacity data](https://escience-taurex.github.io/taurex3/examples/01_setup_and_data.html), we can now build the atmosphere itself. This notebook introduces the three interchangeable components that form the physical foundation of every TauREx model: a temperature profile, a pressure grid, and a chemical mixture. The [Transmission spectrum basics](https://escience-taurex.github.io/taurex3/examples/03_transmission_basics.html) and [Emission spectrum basics](https://escience-taurex.github.io/taurex3/examples/04_emission_basics.html) walkthroughs plug these directly into forward models.\n", "\n", "Before any spectrum can be computed, the state of the atmosphere must be specified:\n", "- **Temperature profile** — how temperature varies with altitude.\n", "- **Pressure grid** — the vertical extent and resolution of the atmosphere.\n", "- **Chemistry** — which gases are present and at what mixing ratios.\n", "\n", "Each of these is a separate, swappable object. Changing one — say, switching from an isothermal to a parametric temperature profile — does not require re-building the rest of the model. More information about temperature profiles is [here](../user/taurex/temperature.rst), pressure grids are [here](../user/taurex/pressure.rst), and chemistry options are [here](../user/taurex/chemistry.rst)." ] }, { "cell_type": "markdown", "id": "78345c3a", "metadata": {}, "source": [ "## Data Note\n", "\n", "This notebook uses the opacity and CIA files set up in [Setup and opacity data](https://escience-taurex.github.io/taurex3/examples/01_setup_and_data.html). TauREx provides the software to work with these datasets; the files themselves are third-party products from [ExoMol](https://www.exomol.com) and [HITRAN](https://hitran.org/)." ] }, { "cell_type": "code", "execution_count": 1, "id": "VSC-5133cead", "metadata": { "language": "python" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Built a reusable atmospheric context.\n" ] } ], "source": [ "from _shared import build_base_components\n", "\n", "context = build_base_components(download=False)\n", "iso_t = context['iso_t']\n", "press = context['press']\n", "chemistry = context['chemistry']\n", "\n", "print('Built a reusable atmospheric context.')" ] }, { "cell_type": "markdown", "id": "VSC-59447e99", "metadata": { "language": "markdown" }, "source": [ "## Pressure and Temperature Profiles\n", "\n", "A quick inspection of the vertical grid confirms that the pressure boundaries, layer count, and temperature values are all as expected. These profile objects will be handed directly to the forward models in [Transmission spectrum basics](https://escience-taurex.github.io/taurex3/examples/03_transmission_basics.html) and [Emission spectrum basics](https://escience-taurex.github.io/taurex3/examples/04_emission_basics.html).\n", "\n", "More information about temperature profiles is [here](../user/taurex/temperature.rst), and pressure-grid options are [here](../user/taurex/pressure.rst)." ] }, { "cell_type": "code", "execution_count": 2, "id": "VSC-0d8b4184", "metadata": { "language": "python" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Layers: 100\n", "Pressure range: 1.122e-05 Pa to 8.913e+04 Pa\n", "Isothermal temperature: 2000.0 K\n" ] } ], "source": [ "iso_t, press\n", "\n", "print(f'Layers: {press.nLayers}')\n", "print(f'Pressure range: {press.profile.min():.3e} Pa to {press.profile.max():.3e} Pa')\n", "print(f'Isothermal temperature: {iso_t.isoTemperature} K')" ] }, { "cell_type": "code", "execution_count": 3, "id": "VSC-cc71f730", "metadata": { "language": "python" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "First five pressure levels in bar:\n", "[0.89125094 0.70794578 0.56234133 0.44668359 0.35481339]\n", "Last five pressure levels in bar:\n", "[2.81838293e-10 2.23872114e-10 1.77827941e-10 1.41253754e-10\n", " 1.12201845e-10]\n" ] } ], "source": [ "pressure_bar = press.profile / 1e5\n", "\n", "print('First five pressure levels in bar:')\n", "print(pressure_bar[:5])\n", "print('Last five pressure levels in bar:')\n", "print(pressure_bar[-5:])" ] }, { "cell_type": "markdown", "id": "VSC-dbff8f29", "metadata": { "language": "markdown" }, "source": [ "## Chemistry and Gas Mixtures\n", "\n", "Atmospheric chemistry in TauREx is split into two roles:\n", "- **Active gases** carry explicit absorption cross-sections and imprint molecular features on the spectrum (H₂O, CH₄, CO₂, and similar).\n", "- **Fill gases** (H₂, He) establish the background pressure structure and drive continuum processes such as CIA and Rayleigh scattering.\n", "\n", "The choice of active gases directly determines which molecular signatures will appear in the simulated spectrum. More information about chemistry components is [here](../user/taurex/chemistry.rst)." ] }, { "cell_type": "code", "execution_count": 4, "id": "VSC-a8e704af", "metadata": { "language": "python" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Active gases: ('H2O', 'CH4', 'NH3', 'CO2')\n", "Inactive gases: ('H2', 'He')\n", "H2: 8.495e-01\n", "He: 1.492e-01\n", "H2O: 1.000e-03\n", "CH4: 1.000e-04\n", "NH3: 1.000e-04\n", "CO2: 1.000e-04\n" ] } ], "source": [ "print(f'Active gases: {chemistry.activeGases}')\n", "print(f'Inactive gases: {chemistry.inactiveGases}')\n", "\n", "for gas_name, mix_ratio in zip(chemistry.gases, chemistry.mixProfile[:, 0]):\n", " print(f'{gas_name}: {mix_ratio:.3e}')" ] }, { "cell_type": "code", "execution_count": 5, "id": "VSC-482aea95", "metadata": { "language": "python" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Total mixing ratio in the first layer: 1.000000\n" ] } ], "source": [ "layer0_total = chemistry.mixProfile[:, 0].sum()\n", "print(f'Total mixing ratio in the first layer: {layer0_total:.6f}')" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }