Skip to content

Commit

Permalink
V0.9 GITHUB
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien FOUREST committed Dec 17, 2024
1 parent f510c0e commit cfe0f98
Show file tree
Hide file tree
Showing 42 changed files with 15,677 additions and 818 deletions.
Binary file added data/COSTG_n12_2002_2022.nc
Binary file not shown.
4,210 changes: 4,210 additions & 0 deletions data/GSM-2_2002213-2002243_GRAC_COSTG_BF01_0100.gfc

Large diffs are not rendered by default.

259 changes: 259 additions & 0 deletions data/TN-14_C30_C20_GSFC_SLR.txt

Large diffs are not rendered by default.

Binary file added data/argo.nc
Binary file not shown.
Binary file added data/global_water_budget.nc
Binary file not shown.
Binary file added data/ohc.nc
Binary file not shown.
2 changes: 2 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
pip install ../.
python generate_doc.py
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
18 changes: 15 additions & 3 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ LENAPY API
==========

.. automodule:: lenapy
:members:
:show-inheritance:

.. automodule:: lenapy.readers
:members:
:show-inheritance:

.. automodule:: lenapy.utils
:show-inheritance:

.. automodule:: lenapy.writers
:show-inheritance:

Lenapy constants
^^^^^^^^^^^^^^^^

.. automodule:: lenapy.constants
:noindex:

.. raw:: latex

Expand Down
9 changes: 5 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys, os
import datetime
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../lenapy'))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
Expand All @@ -31,11 +32,12 @@

# autosummaries from source-files : use .. autosummary::
autosummary_generate = True
# autodoc dont show __init__ docstring
# Inherit docstrings from parent classes
autodoc_inherit_docstrings = True
# autodoc don't show __init__ docstring
autoclass_content = "both"
# sort class members
# sort class members by their order in the source
autodoc_member_order = 'bysource'
# autodoc_member_order = "groupwise"

# show all members of a class in the Methods and Attributes sections automatically
numpydoc_show_class_members = True
Expand Down Expand Up @@ -74,7 +76,6 @@
"numpy": ("http://docs.scipy.org/doc/numpy/", None),
"scipy": ("http://docs.scipy.org/doc/scipy/reference", None),
"matplotlib": ("http://matplotlib.org", None),
"sphinx": ("http://www.sphinx-doc.org/en/stable/", None),
"xarray": ("https://docs.xarray.dev/en/stable/", None),
}

Expand Down
59 changes: 59 additions & 0 deletions doc/generate_doc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import os
import importlib
import inspect
import sys


def list_classes_and_functions(package_name):
results = {}
package = importlib.import_module(package_name)
package_path = package.__path__[0]

def walk_package(package_path, package_name):
for root, _, files in os.walk(package_path):
for file in files:
if file.endswith(".py") and file != "__init__.py":
module_path = os.path.join(root, file)
relative_module_path = os.path.relpath(module_path, package_path)
module_name = os.path.splitext(relative_module_path.replace(os.sep, "."))[0]
full_module_name = f"{package_name}.{module_name}"

try:
module = importlib.import_module(full_module_name)
results[full_module_name] = {"classes": {}, "functions": []}

for name, obj in inspect.getmembers(module):
if inspect.isclass(obj) and obj.__module__ == full_module_name:
class_methods = [method_name for method_name, method_obj in inspect.getmembers(obj)
if inspect.isfunction(method_obj)]
results[full_module_name]["classes"][name] = class_methods
elif inspect.isfunction(obj) and obj.__module__ == full_module_name:
results[full_module_name]["functions"].append(name)
except ImportError as e:
print(f"Failed to import module {full_module_name}: {e}", file=sys.stderr)

walk_package(package_path, package_name)
return results


def write_results_to_file(results, output_file):
with open(output_file, 'w') as f:
f.write('.. autosummary::\n :toctree:\n :recursive:\n :nosignatures:\n\n')

for module, members in results.items():
for cls, methods in members["classes"].items():
for method in methods:
if method == "__init__":
f.write(f" {module}.{cls}\n")
f.write(f" {module}.{cls}.{method}\n")
elif method == "__repr__":
f.write(f" {module}.{cls}\n")
else:
f.write(f" {module}.{cls}.{method}\n")
for func in members["functions"]:
f.write(f" {module}.{func}\n")


result = list_classes_and_functions('lenapy')
write_results_to_file(result, os.path.join(os.getcwd(), 'functions_classes.rst'))

1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Welcome to lenapy's documentation!
* lenapy_ocean: encapsulation of the GSW library containing the main ocean thermodynamic calculation routines (TEOS10)
* lenapy_geo: current operations on gridded data (longitude/latitude/depth)
* lenapy_time: common operations on time series (filtering, climatology, regressions, etc.)
* lenapy_harmo: operations related to spherical harmonics decomposition and their projections on latitude/longitude grids

This library is based on the principle of class extension, i.e. functions can be applied directly to Datasets or DataArrays, by adding the extension of the module concerned and the name of the method. Ex: ds.lntime.filter(...), ds.lngeo.mean(...), de.lnocean.gohc, etc.

Expand Down
2 changes: 2 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if errorlevel 9009 (

if "%1" == "" goto help

pip install .
python generate_doc_data.py
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

Expand Down
Loading

0 comments on commit cfe0f98

Please sign in to comment.