Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstring to jupyter book #81

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/api/

# PyBuilder
target/
Expand Down
13 changes: 13 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,16 @@ repository:
html:
use_issues_button: true
use_repository_button: true

sphinx:
extra_extensions: [
'sphinx_automodapi.automodapi',
'numpydoc',
'sphinxcontrib.autodoc_pydantic',
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
'sphinx.ext.githubpages',
'sphinxcontrib.mermaid'
]
9 changes: 5 additions & 4 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

format: jb-book
root: intro
chapters:
- file: markdown
- file: notebooks
- file: markdown-notebooks
parts:
- caption: Help & reference
chapters:
- file: configs
- file: api
15 changes: 15 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
API reference
==============

API components that are currently available.

**NOTE: This package is still under heavy development, so API listed below will change**

.. automodapi:: gnatss.ops
:no-inheritance-diagram:

.. automodapi:: gnatss.harmonic_mean
:no-inheritance-diagram:

.. automodapi:: gnatss.loaders
:no-inheritance-diagram:
27 changes: 27 additions & 0 deletions docs/configs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Configurations
==============

Pydantic models documentation for application configurations.

**Content**

* `Main`_
* `I/O`_
* `Solver`_

Main
----
.. automodule:: gnatss.configs.main
:members:

I/O
----

.. automodule:: gnatss.configs.io
:members:

Solver
------

.. automodule:: gnatss.configs.solver
:members:
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ docs = [
"sphinx-panels",
"sphinx_rtd_theme",
"sphinxcontrib-mermaid",
"autodoc_pydantic"
]
lint = [
"black",
Expand Down
33 changes: 13 additions & 20 deletions src/gnatss/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,8 @@
import yaml
from pydantic.error_wrappers import ValidationError

from . import constants
from .configs.main import Configuration
from .constants import (
GPS_COV,
GPS_GEOCENTRIC,
GPS_TIME,
SP_DEPTH,
SP_SOUND_SPEED,
TIME_ASTRO,
TT_DATE,
TT_TIME,
TT_TRANSPONDER,
)


def load_configuration(config_yaml: Optional[str] = None) -> Configuration:
Expand Down Expand Up @@ -55,7 +45,7 @@ def load_sound_speed(sv_file: str) -> pd.DataFrame:
pd.DataFrame
Sound speed profile pandas dataframe
"""
columns = [SP_DEPTH, SP_SOUND_SPEED]
columns = [constants.SP_DEPTH, constants.SP_SOUND_SPEED]

# Read sound speed
return pd.read_csv(
Expand Down Expand Up @@ -125,8 +115,8 @@ def load_travel_times(
PARSED_FILE = "parsed"
DATETIME_FORMAT = "%d-%b-%y %H:%M:%S.%f"

transponder_labels = [TT_TRANSPONDER(tid) for tid in transponder_ids]
columns = [TT_DATE, TT_TIME, *transponder_labels]
transponder_labels = [constants.TT_TRANSPONDER(tid) for tid in transponder_ids]
columns = [constants.TT_DATE, constants.TT_TIME, *transponder_labels]
if is_j2k:
# If it's already j2k then pop off date column, idx 0
columns.pop(0)
Expand Down Expand Up @@ -154,19 +144,22 @@ def load_travel_times(
from .utilities.time import AstroTime

# Determine j2000 time from date and time string
all_travel_times.loc[:, TIME_ASTRO] = all_travel_times.apply(
all_travel_times.loc[:, constants.TIME_ASTRO] = all_travel_times.apply(
lambda row: AstroTime.strptime(
f"{row[TT_DATE].lower()} {row[TT_TIME]}", DATETIME_FORMAT
f"{row[constants.TT_DATE].lower()} {row[constants.TT_TIME]}",
DATETIME_FORMAT,
),
axis=1,
)
# Replace time to j2000 rather than time string
all_travel_times[TT_TIME] = all_travel_times.apply(
lambda row: row[TIME_ASTRO].unix_j2000, axis=1
all_travel_times[constants.TT_TIME] = all_travel_times.apply(
lambda row: row[constants.TIME_ASTRO].unix_j2000, axis=1
)

# Drop unused columns for downstream computation
all_travel_times = all_travel_times.drop([TT_DATE, TIME_ASTRO], axis=1)
all_travel_times = all_travel_times.drop(
[constants.TT_DATE, constants.TIME_ASTRO], axis=1
)

return all_travel_times

Expand Down Expand Up @@ -202,7 +195,7 @@ def load_gps_solutions(files: List[str]) -> pd.DataFrame:

These files are often called `POS_FREED_TRANS_TWTT`.
"""
columns = [GPS_TIME, *GPS_GEOCENTRIC, *GPS_COV]
columns = [constants.GPS_TIME, *constants.GPS_GEOCENTRIC, *constants.GPS_COV]
# Real all gps solutions
gps_solutions = [
pd.read_csv(i, delim_whitespace=True, header=None, names=columns) for i in files
Expand Down