Take cues from the above references, then use linters, auto-formatters, and LLMs to enforce the styles.
-
Run
pylintwith thepylintrcfile (from the Google Python Style Guide) in the root directory:pylint --rcfile=pylintrc orbitpy tests examples
-
Run
blackto format the python files.black orbitpy tests examples
-
Run
coverage. The HTML report will be generated in the htmlcov directory. Open htmlcov/index.html in a web browser to view the detailed coverage report.coverage run -m unittest discover -s tests coverage html
-
Use Google style docstrings. https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html. The following configuration option in the
conf.pyenables Sphinx to parse Google style dosctrings:napoleon_google_docstring = True -
All OrbitPy objects (classes) intended for use by external users must support initialization and serialization using Python dictionaries. Each class should provide
from_dict(...)andto_dict(...)methods to allow instantiation from dictionary inputs and export their state or data back into a dictionary format. Use theJsonSerializerclass provided by theeosimutils.basemodule to save and retreive objects (withto_dict(.)andfrom_dict(.)functions) to/from JSON. -
Only classes and functions which are most commonly utiized in Earth Observation mission simulations will be developed.
-
All enum values should be in capital letters and formatted with underscores, e.g.,
GREGORIAN_DATE. -
Imports of classes and/or functions from external libraries must be prefixed by the name of the external library. For example:
from astropy.time import Time as Astropy_Time # for imported classes use upper-case for the first letter in the underscore seperated seperated words from skyfield.positionlib import build_position as skyfield_build_position # for function use all lower case
-
Always use from_dict(...) and other public API functions to initialize EO-Sim objects, including in test functions. Avoid directly calling internal methods or the init(...) constructor. This ensures compatibility with future updates, as internal implementations may change, but the public API is expected to remain stable.
-
A class representing a physical object (e.g., Ground-station, instrument, spacecraft) or a collection of objects (e.g., grid of physical locations) must include an identifier attribute which must be a valid UUID. If no identifier is provided, one will be autogenerated. Providing names of entities will be optional.
-
Python dictionaries used for interfacing should have lowercase, underscore-separated keys. Avoid including units in the keys for physical quantities. For example: use
min_elevation_angleorlatitudeinstead oflatitude_deg. Similarly, class variable names should not indicate units in their names but must be properly documented. -
Seperate tests which take a long time into a seperate long-duration-test folder, to give the flexibility to seperately run the long tests.
-
Numpy arrays are used for storing numerical array-like data (e.g., 3d position, states, trajectories, etc.) At several places functions are built to have two versions: one which takes
eosimutilsobjects and another which takes numpy arrays. -
Use factory methods in modules such as orbits, propagator, etc. This allows for dynamic creation of propagators based on input specifications in a dictionary. It centralizes the registration and creation of propagator types, making the system extensible and maintainable. Use identical implementation for all Factory classes with a class-level registry and decorator pattern.
-
Use randomized tests wherever possible. Save seed for randomized test when it fails.
-
Specify the expected dictionary key names with explicit suffixes when indicating a particular type (e.g.,
orientation_type,orbit_type), and avoid using the generic key nametypeon its own.