.. _constants:
.. create a gold color role
.. raw:: html
.. role:: gold
.. create a role that makes bolded text colored blue as well
.. raw:: html
.. role:: bold
=================
:gold:`Constants`
=================
Last revised by M. Pugliatti on 2025 FEB 4
In SCB, constants are defined in the **constants.py** library and are divided into:
#. **Universal constants**: contains values related to universal constants such as the speed of light **c**, the universal gravitational constant **G**, etc.
#. **Planetary bodies**: contains values related to mass, GM, radius, spice ID, etc. of planetary bodies
Values can be either defined by hand or from the **scipy.constants** method and are saved in dictionaries.
----------------------
:bold:`Load constants`
----------------------
There are 3 methods to load constants in a script:
Method (1): Load all constants
==============================
.. code-block:: python
import scarabaeus as scb
# Import costants
from scarabaeus import Constants
Method (2): Load only the universal constants
=============================================
.. code-block:: python
from scarabaeus.Constants import CONSTANTS
this is used to load only the universal constants.
Method (3): Load constants running an initialization script
===========================================================
Constants are automatically loaded when running an initialization script
.. code-block:: python
from scarabaeus.scb_initialize import *
------------------------
:bold:`Access constants`
------------------------
Once loaded, constants can be accessed in this way:
Universal constants
===================
To access the universal constants saved in the dictionary you can run:
.. code-block:: python
Constants.CONSTANTS["G"]
The dictionary is made of 3 values:
- [0] The value, saved as an ArrayWUnits
- [1] The name, saved as an string
- [2] The reference, saved as an string, that indicates the origin of the value.
You can access these as:
.. code-block:: python
Constants.CONSTANTS["G"][0]
Constants.CONSTANTS["G"][1]
Constants.CONSTANTS["G"][2]
Planetary constants
===================
Planetary constants are called by planetary body's name as dictionary:
.. code-block:: python
Constants.earth
You can access the various fields as:
.. code-block:: python
Constants.earth["name"]
Constants.earth["spice_name"]
Constants.earth["ref_name"]
Constants.earth["SPICE_ID"]
Constants.earth["mass"]
Constants.earth["mu"]
Constants.earth["radius"]