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 documentation and __init__ files to make auto importing easier. #13

Merged
merged 1 commit into from
Oct 4, 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
12 changes: 5 additions & 7 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
.. sinusoidal documentation main file.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to Sorcha's community utilities documentation!
========================================================================================

======================================================

Sorcha Community Utils is a collection of plugins for Sorcha that can be used to
model changes to the magnitude of objects in the solar system simulation.

.. toctree::
:hidden:

Home page <self>
Contributing <contributing>
Usage <usage>
Community Modules <community_modules>
Notebooks <notebooks>
Contributing <contributing>
API Reference <autoapi/index>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"import pandas as pd\n",
"\n",
"data_dict = {\n",
" 'FieldMJD': [60277.351867, 60289.319749, 60289.330920, 60292.334497, 60292.346208],\n",
" 'FieldMJD_TAI': [60277.351867, 60289.319749, 60289.330920, 60292.334497, 60292.346208],\n",
" 'LCA': [1, 1, 1, 1, 1],\n",
" 'Period': [0.001, 0.001, 0.001, 0.001, 0.001],\n",
" 'Time0': [60277.351867, 60277.351867, 60277.351867, 60277.351867, 60277.351867],\n",
Expand Down
20 changes: 20 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Using Sorcha Community Utils
============================

In order to use the community utilities, first install this package in your
virtual environment.

.. code:: bash

>> pip install sorcha-community-utils

Once the ``sorcha-community-utils`` is installed, Sorcha will automatically detect
the available plugins and make them available during processing.

To use one of the plugins from the community utilities, simply add the unique
name of the plugin to the configuration file provided to Sorcha, and provide the
complex parameters file on the command line.

For more information about running Sorcha, the configuration file, and providing
arguments on the command line, see the documentation available
`here <https://sorcha.readthedocs.io/en/latest/gettingstarted.html#setting-up-sorcha-s-configuration-file>`_.
4 changes: 4 additions & 0 deletions src/sorcha_community_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__all__ = [
"activity",
"lightcurve",
]
1 change: 1 addition & 0 deletions src/sorcha_community_utils/activity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .lsst_comet import lsst_comet_activity
1 change: 1 addition & 0 deletions src/sorcha_community_utils/lightcurve/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .sinusoidal import sinusoidal_lightcurve
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class SinusoidalLightCurve(AbstractLightCurve):
The observation dataframe provided to the ``compute``
method should have the following columns:

* ``FieldMJD`` - time of observation.
* ``FieldMJD_TAI`` - time of observation.
* ``LCA`` - lightcurve amplitude [magnitudes].
* ``Period`` - period of the sinusoidal oscillation [days]. Should be a positive value.
* ``Time0`` - phase for the light curve [days].
"""

def __init__(self, required_column_names: List[str] = ["FieldMJD", "LCA", "Period", "Time0"]) -> None:
def __init__(self, required_column_names: List[str] = ["FieldMJD_TAI", "LCA", "Period", "Time0"]) -> None:
super().__init__(required_column_names)

def compute(self, df: pd.DataFrame) -> np.array:
Expand All @@ -39,7 +39,7 @@ def compute(self, df: pd.DataFrame) -> np.array:
# Verify that the input data frame contains each of the required columns.
self._validate_column_names(df)

time = 2 * np.pi * (df["FieldMJD"] - df["Time0"]) / df["Period"]
time = 2 * np.pi * (df["FieldMJD_TAI"] - df["Time0"]) / df["Period"]
return df["LCA"] * np.sin(time)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion tests/lightcurve/sinusoidal/test_sinusoidal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_sinusoidal_lightcurve_name():

def test_compute_simple():
data_dict = {
"FieldMJD": [1./4],
"FieldMJD_TAI": [1.0 / 4],
"LCA": [1],
"Period": [1],
"Time0": [0],
Expand Down