skyscapes.physical_model.exojax.components.species
==================================================

.. py:module:: skyscapes.physical_model.exojax.components.species

.. autoapi-nested-parse::

   Atmospheric-gas components.

   Each :class:`MolecularSpecies` is a self-contained record for one
   atmospheric molecule: its per-planet log mass-mixing ratio (a PyTree
   leaf, fittable) plus the shared static data needed to evaluate both
   line absorption and Rayleigh scattering for that species. The
   atmosphere holds a tuple of these plus an optional
   :class:`BulkGasResidual` for the implicit residual gas (N2 for
   terrestrial atmospheres, H2 for gas giants).

   To mix and match molecules: just change the tuple. To add a new
   molecule supported by HITRAN, register its recipe in
   :data:`MOLECULE_RECIPES`. The 8-molecule set used by Star+ "Earth
   through time" (H2O, O2, O3, CH4, CO2, CO, N2O, SO2) is preregistered.



Attributes
----------

.. autoapisummary::

   skyscapes.physical_model.exojax.components.species.N2O_POLARIZABILITY_CM3
   skyscapes.physical_model.exojax.components.species.PSG_O3_URL
   skyscapes.physical_model.exojax.components.species.PSG_SO2_URL
   skyscapes.physical_model.exojax.components.species.MOLECULE_RECIPES
   skyscapes.physical_model.exojax.components.species.BULK_GAS_RECIPES


Classes
-------

.. autoapisummary::

   skyscapes.physical_model.exojax.components.species.MolecularSpecies
   skyscapes.physical_model.exojax.components.species.BulkGasResidual
   skyscapes.physical_model.exojax.components.species.MoleculeRecipe
   skyscapes.physical_model.exojax.components.species.BulkGasRecipe


Functions
---------

.. autoapisummary::

   skyscapes.physical_model.exojax.components.species._build_rayleigh_xs
   skyscapes.physical_model.exojax.components.species.build_species_prebuilt
   skyscapes.physical_model.exojax.components.species.recipe_default_molmass
   skyscapes.physical_model.exojax.components.species.build_bulk_prebuilt


Module Contents
---------------

.. py:class:: MolecularSpecies

   Bases: :py:obj:`equinox.Module`


   One atmospheric molecule with an altitude-resolved mixing ratio.

   The mixing ratio is encoded as a profile component (e.g.
   :class:`~skyscapes.physical_model.exojax.components.mmr_profile.ConstantMmr`
   for well-mixed gases, ``StratosphericPeakMmr`` for O3, ``TroposphericMmr``
   for H2O) rather than a single scalar, so altitude variation is
   represented explicitly.

   Attributes:
       profile: Per-species mmr profile. Owns the fittable
           log-mixing-ratio leaves.
       name: Molecule name, e.g. ``"H2O"``.
       molmass: Molar mass [g/mol].
       opa: Opacity engine. Either an ExoJAX ``OpaPremodit`` (for
           HITRAN-backed line-list molecules) or
           :class:`~skyscapes.physical_model.exojax.o3_chappuis.O3ChappuisOpacity`
           (for visible cross-section absorbers like O3). May be
           ``None`` if the species contributes only Rayleigh scattering.
       rayleigh_xs: Pre-computed Rayleigh cross-section
           [cm^2/molecule] on the atmosphere's wavenumber grid, shape
           ``(n_nu,)``. Set to all-zeros to disable per-species
           Rayleigh contribution.


   .. py:attribute:: profile
      :type:  skyscapes.physical_model.exojax.components.mmr_profile.AbstractMmrProfile


   .. py:attribute:: name
      :type:  str


   .. py:attribute:: molmass
      :type:  float


   .. py:attribute:: opa
      :type:  Any


   .. py:attribute:: rayleigh_xs
      :type:  jaxtyping.Array


.. py:class:: BulkGasResidual

   Bases: :py:obj:`equinox.Module`


   Implicit residual gas filling the unallocated mass fraction.

   The mass-mixing ratio is computed dynamically as
   ``max(0, 1 - sum(tracked species mmrs))``. Contributes only to
   Rayleigh scattering (no line-list absorption is associated with
   the bulk gas in this model -- N2 is essentially transparent across
   300--1100 nm, H2/He likewise).

   Attributes:
       name: Gas name, e.g. ``"N2"`` for Earth or ``"H2"`` for gas giants.
       molmass: Molar mass [g/mol].
       rayleigh_xs: Rayleigh cross-section [cm^2/molecule] on the
           atmosphere's wavenumber grid, shape ``(n_nu,)``.


   .. py:attribute:: name
      :type:  str


   .. py:attribute:: molmass
      :type:  float


   .. py:attribute:: rayleigh_xs
      :type:  jaxtyping.Array


.. py:data:: N2O_POLARIZABILITY_CM3
   :value: 3.03e-24


.. py:class:: MoleculeRecipe

   Build instructions for one molecule.

   Attributes:
       name: Molecule name (must match ExoJAX's HITRAN / polarizability
           keys when those tables apply).
       psg_xs_url: If set, use a PSG cross-section file at this URL
           (:class:`~skyscapes.physical_model.exojax.psg_xs.PsgCrossSectionOpacity`)
           instead of an ExoJAX line-list opa. Required for species
           whose absorption is dominated by electronic transitions in
           the visible/NIR (e.g. O3 Chappuis, SO2 UV).
       psg_xs_molmass: Molar mass [g/mol]; required when ``psg_xs_url``
           is set since we can't extract it from HITRAN in that case.
       polarizability_override: Explicit polarizability [cm^3] for the
           Rayleigh cross-section, used when ExoJAX's table doesn't
           have an entry. ``None`` lets ``OpaRayleigh`` look it up.


   .. py:attribute:: name
      :type:  str


   .. py:attribute:: psg_xs_url
      :type:  str | None
      :value: None



   .. py:attribute:: psg_xs_molmass
      :type:  float | None
      :value: None



   .. py:attribute:: polarizability_override
      :type:  float | None
      :value: None



.. py:data:: PSG_O3_URL
   :value: 'https://psg.gsfc.nasa.gov/data/linelists/xuv/data/o3.txt'


.. py:data:: PSG_SO2_URL
   :value: 'https://psg.gsfc.nasa.gov/data/linelists/xuv/data/so2.txt'


.. py:data:: MOLECULE_RECIPES
   :type:  dict[str, MoleculeRecipe]

.. py:class:: BulkGasRecipe

   Build instructions for the implicit residual gas.

   Attributes:
       name: Gas name; must match an ExoJAX polarizability key (or
           provide ``polarizability_override``).
       molmass: Molar mass [g/mol].
       polarizability_override: Override polarizability if missing
           from ExoJAX's table.


   .. py:attribute:: name
      :type:  str


   .. py:attribute:: molmass
      :type:  float


   .. py:attribute:: polarizability_override
      :type:  float | None
      :value: None



.. py:data:: BULK_GAS_RECIPES
   :type:  dict[str, BulkGasRecipe]

.. py:function:: _build_rayleigh_xs(nu_grid, name, polarizability_override)

   Compute Rayleigh cross-section [cm^2/molecule] vs wavenumber.


.. py:function:: build_species_prebuilt(*, name, nu_grid, nu_min, nu_max, databases_dir, crit)

   Construct (molmass, opa, rayleigh_xs) for one molecule.

   Used by ``build_exojax_engines``; not typically called by users
   directly. Returns the static parts of a :class:`MolecularSpecies`
   (everything except ``log_mmr``).


.. py:function:: recipe_default_molmass(name)

   Fallback molar mass [g/mol] when HITRAN provides no entry.

   Uses ExoJAX's ``molinfo.molmass`` lookup. Used when the species
   has no HITRAN lines in the configured wavenumber range and we
   therefore can't construct an MdbHitran to get the value from.


.. py:function:: build_bulk_prebuilt(*, name, nu_grid)

   Construct (molmass, rayleigh_xs) for the implicit residual gas.


