Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Restructured project and improved docstrings for the documentation pa…
Browse files Browse the repository at this point in the history
…ge. Changed the structure of the imports so that the _bindings module is only imported when it needs to be run, so that the documentation can be built without it.
  • Loading branch information
daminton committed Dec 20, 2023
1 parent d489200 commit 4301f6b
Show file tree
Hide file tree
Showing 9 changed files with 591 additions and 400 deletions.
118 changes: 117 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Setting Simulation Parameters
Simulation.set_init_cond_files
Simulation.set_output_files
Simulation.set_unit_system
Simulation.update_param_units
Simulation.set_distance_range
Simulation.set_ephemeris_date

Expand Down Expand Up @@ -88,6 +87,123 @@ File Input and Output
Simulation.convert
Simulation.clean


Initial Conditions Generation Functions
=======================================

.. autosummary::
:toctree: generated/

swiftest.init_cond.solar_system_horizons
swiftest.init_cond.horizons_query
swiftest.init_cond.horizons_get_physical_properties
swiftest.init_cond.vec2xr


Input/Output Processing Functions
==================================

A collection of functions for processing simulation files.

Reading and writing simulation parameter and initial conditions files
---------------------------------------------------------------------

.. autosummary::
:toctree: generated/

swiftest.io.process_netcdf_input
swiftest.io.read_swiftest_param
swiftest.io.read_swifter_param
swiftest.io.read_swift_param
swiftest.io.write_swift_param
swiftest.io.write_labeled_param
swiftest.io.select_active_from_frame
swiftest.io.swiftest_xr2infile

Tools for fixing differences between NetCDF-Fortran and xarray data structures
------------------------------------------------------------------------------

.. autosummary::
:toctree: generated/

swiftest.io.swiftest2xr
swiftest.io.reorder_dims
swiftest.io.fix_types


Conversions between legacy integrator formats and Swiftest
----------------------------------------------------------

.. autosummary::
:toctree: generated/

swiftest.io.swifter2swiftest
swiftest.io.swifter2xr
swiftest.io.swifter_xr2infile
swiftest.io.swiftest2swifter_param
swiftest.io.swift2swifter
swiftest.io.swift2swiftest

Tools
=====

Miscellaneous helper functions

.. autosummary::
:toctree: generated/

swiftest.tool.magnitude
swiftest.tool.wrap_angle
swiftest.tool.follow_swift
swiftest.tool.danby
swiftest.tool.el2xv_one
swiftest.tool.el2xv_vec
swiftest.tool.xv2el_one
swiftest.tool.xv2el_vec

Constants
=========

The `constants` module defines several astronomical and physical constants. Below is a description of each constant:

.. list-table::
:widths: 25 75
:header-rows: 1

* - Constant
- Description
* - ``GC``
- The gravitational constant (G) from Astropy constants, in SI units (m^3 kg^-1 s^-2).
* - ``AU2M``
- Astronomical Unit in meters, representing the average distance from the Earth to the Sun.
* - ``GMSun``
- Standard gravitational parameter for the Sun in m^3 s^-2.
* - ``MSun``
- Mass of the Sun in kilograms.
* - ``RSun``
- Radius of the Sun in meters.
* - ``MEarth``
- Mass of the Earth in kilograms.
* - ``REarth``
- Radius of the Earth in meters.
* - ``GMEarth``
- Standard gravitational parameter for the Earth in m^3 s^-2.
* - ``JD2S``
- Number of seconds in a Julian day.
* - ``YR2S``
- Number of seconds in a Julian year (365.25 days).
* - ``einsteinC``
- Speed of light in vacuum in meters per second.
* - ``J2Sun``
- Solar quadrupole moment coefficient (J2), indicating the extent of the Sun's equatorial bulge.
* - ``J4Sun``
- Higher order coefficient (J4) for the Sun's shape, indicating asymmetry in its mass distribution.
* - ``rotpoleSun``
- SkyCoord object representing the rotation pole of the Sun in right ascension (ra) and declination (dec), converted to Cartesian coordinates.
* - ``rotSun``
- Angular velocity of the Sun's rotation in radians per second, considering an average rotational period of 25.05 days.


Fortran API Documentation
=========================

Expand Down
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from sphinx.util import logging

# Disable import of swiftest._bindings so that we don't have to build the Fortran code when building the docs
import swiftest
autodoc_mock_imports = ['swiftest._bindings']

import swiftest
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'Swiftest'
Expand Down
31 changes: 9 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "swiftest"
version = "2023.12.0"
version = "2023.12.1"
authors=[
{name = 'David A. Minton', email='daminton@purdue.edu'},
{name = 'Carlisle Wishard'},
Expand Down Expand Up @@ -115,12 +115,7 @@ before-all = [
"LIBS=\"\" buildscripts/build_dependencies.sh -p ${PREFIX} -d ${HOME}/Downloads -m ${MACOSX_DEPLOYMENT_TARGET}"
]

[tool.cibuildwheel.linux]
skip = "cp312-* pp* -manylinux_i686* *-musllinux*"
before-all = [
"yum install doxygen libxml2-devel libcurl-devel -y",
"buildscripts/build_dependencies.sh -p /usr/local"
]

[tool.cibuildwheel.linux.environment]
PREFIX="/usr/local"
NCDIR="${PREFIX}"
Expand All @@ -138,22 +133,14 @@ HDF5_DIR="${HDF5_ROOT}/cmake"
PATH="${HDF5_ROOT}/bin:${PATH}"
CMAKE_INSTALL_LIBDIR="lib"

[tool.cibuildwheel.linux]
skip = "cp312-* pp* -manylinux_i686* *-musllinux*"
before-all = [
"yum install doxygen libxml2-devel libcurl-devel -y",
"buildscripts/build_dependencies.sh -p /usr/local"
]

[[tool.scikit-build.generate]]
path = "version.txt"
location = "source"
template = '''${version}'''

[project.optional-dependencies]
docs = [
"sphinx",
"sphinx-autosummary-accessors",
"sphinx-book-theme >= 0.3.0",
"sphinx-copybutton",
"sphinx-design",
"sphinx-inline-tabs",
"sphinxext-rediraffe",
"sphinxext-opengraph",
"nbsphinx",
"ipython",
"ford"
]
2 changes: 1 addition & 1 deletion src/globals/globals_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module globals
integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper
!! conversion - offset between upper and lower

character(*), parameter :: VERSION = "2023.12.0" !! Swiftest version
character(*), parameter :: VERSION = "2023.12.1" !! Swiftest version

!> Symbolic name for integrator types
character(*), parameter :: UNKNOWN_INTEGRATOR = "UKNOWN INTEGRATOR"
Expand Down
5 changes: 3 additions & 2 deletions swiftest/init_cond.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def horizons_get_physical_properties(altid,**kwargs):
**kwargs: Any
Additional keyword arguments to pass to the query method (see https://astroquery.readthedocs.io/en/latest/jplhorizons/jplhorizons.html)
Returns
-------
MSun_over_Mpl : float
Expand Down Expand Up @@ -184,7 +183,6 @@ def horizons_query(id, ephemerides_start_date, exclude_spacecraft=True, verbose=
An astroquery.jplhorizons HorizonsClass object. Or None if no match was found.
altid: string list | None
A list of alternate ids if more than one object matches the list
"""

def get_altid(errstr,exclude_spacecraft=True):
Expand Down Expand Up @@ -416,6 +414,7 @@ def solar_system_horizons(name: str,

return id,name,a,e,inc,capom,omega,capm,rh,vh,Gmass,Rpl,rhill,Ip,rot,J2,J4


def vec2xr(param: Dict, **kwargs: Any):
"""
Converts and stores the variables of all bodies in an xarray dataset.
Expand Down Expand Up @@ -458,9 +457,11 @@ def vec2xr(param: Dict, **kwargs: Any):
instead of passing Ip1, Ip2, and Ip3 separately
time : array of floats
Time at start of simulation
Returns
-------
ds : xarray dataset
Dataset containing the variables of all bodies passed in kwargs
"""
scalar_dims = ['id']
vector_dims = ['id','space']
Expand Down
Loading

0 comments on commit 4301f6b

Please sign in to comment.