Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 22, 2024
1 parent ba97c30 commit 39a232a
Show file tree
Hide file tree
Showing 38 changed files with 3,451 additions and 932 deletions.
7 changes: 7 additions & 0 deletions _sources/api/astraeus.hdf5IO.Data.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Data
====

.. currentmodule:: astraeus.hdf5IO

.. autoclass:: Data
:show-inheritance:
6 changes: 6 additions & 0 deletions _sources/api/astraeus.hdf5IO.readH5.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
readH5
======

.. currentmodule:: astraeus.hdf5IO

.. autofunction:: readH5
6 changes: 6 additions & 0 deletions _sources/api/astraeus.hdf5IO.writeH5.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
writeH5
=======

.. currentmodule:: astraeus.hdf5IO

.. autofunction:: writeH5
6 changes: 6 additions & 0 deletions _sources/api/astraeus.xarrayIO.concat.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
concat
======

.. currentmodule:: astraeus.xarrayIO

.. autofunction:: concat
6 changes: 6 additions & 0 deletions _sources/api/astraeus.xarrayIO.makeDataset.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
makeDataset
===========

.. currentmodule:: astraeus.xarrayIO

.. autofunction:: makeDataset
6 changes: 6 additions & 0 deletions _sources/api/astraeus.xarrayIO.makeFluxLikeDA.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
makeFluxLikeDA
==============

.. currentmodule:: astraeus.xarrayIO

.. autofunction:: makeFluxLikeDA
6 changes: 6 additions & 0 deletions _sources/api/astraeus.xarrayIO.makeLCDA.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
makeLCDA
========

.. currentmodule:: astraeus.xarrayIO

.. autofunction:: makeLCDA
6 changes: 6 additions & 0 deletions _sources/api/astraeus.xarrayIO.makeTimeLikeDA.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
makeTimeLikeDA
==============

.. currentmodule:: astraeus.xarrayIO

.. autofunction:: makeTimeLikeDA
6 changes: 6 additions & 0 deletions _sources/api/astraeus.xarrayIO.makeWaveLikeDA.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
makeWaveLikeDA
==============

.. currentmodule:: astraeus.xarrayIO

.. autofunction:: makeWaveLikeDA
6 changes: 6 additions & 0 deletions _sources/api/astraeus.xarrayIO.readXR.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
readXR
======

.. currentmodule:: astraeus.xarrayIO

.. autofunction:: readXR
6 changes: 6 additions & 0 deletions _sources/api/astraeus.xarrayIO.writeXR.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
writeXR
=======

.. currentmodule:: astraeus.xarrayIO

.. autofunction:: writeXR
150 changes: 143 additions & 7 deletions _sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,156 @@
.. No Errors Test Project documentation master file, created by
sphinx-quickstart on Fri Aug 30 17:07:56 2019.
.. Astraeus documentation master file, created by
sphinx-quickstart on Tue Mar 22 13:13:41 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to No Errors Test Project's documentation!
==================================================
Documentation for Astraeus
=========================

.. toctree::
:maxdepth: 2
:caption: Hello World!
:caption: Contents:

`Astraeus` is a general-purpose tool that manages your data using Xarray structures and reads/writes data from/to your exoplanet data reduction pipeline. By using consistent formats and keywords across pipelines, users will be able to exchange and compare results easier than ever before! `Astraeus` makes use of `Xarray`, an open source Python package that uses labelled multi-dimensional arrays (think of Pandas in N dimensions).

`Xarray` is commonly used for data analysis in geoscience and makes use of two core data structures, called a `DataArray` and a `Dataset`. The former is like a NumPy array, except with coordinates, labels, and attributes. The latter is simply a collection of DataArrays. Both structures can easily be written to and loaded from HDF5 files. This means, even if you are not using Python, you can still read an HDF5 file written by `Astraeus` and maintain the full useability of your data.

Indices and tables
==================

Indices and Searching
=====================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`


Installation
============

The fastest way to install `Astraeus` is to use ``pip``::

pip install git+https://github.com/kevin218/Astraeus.git

If you plan on contributing to the package, you should instead clone it via GitHub::

git clone https://github.com/kevin218/Astraeus.git
cd Astraeus
pip install -e .

The ``-e`` flag makes the install editable, which means that you do not have to install the package again and again after each change. Changes to your files inside the project folder will automatically reflect in changes on your installed package. However, if you are working in an interactive environment (e.g., ipython, Jupyter) you will need to re-import any modules that have changed.


Example Usage
=============

`Astraeus` has several templates for creating Xarray DataArrays: `flux-like`, `time-like`, `wavelength-like`, and `light curve` (which makes use of both time and wavelength).

Creating an `flux-like` DataArray requires a 3D array (time, y, x) of flux-like values, a time array, and (of course) units::

# Create 3D DataArray of flux-like values (time, y, x)
import astraeus.xarrayIO as xrio
flux = np.random.rand(10, 5, 20)
time = np.arange(10)
flux_units = 'e-'
time_units = 'MJD'
name = 'flux'
flux_da = xrio.makeFluxLikeDA(flux, time, flux_units, time_units,
name=name)

The `time-like` and `wavelength-like` DataArrays are quite similar, and are helpful for recording time- and wavelength-dependent variables::

# Create 1D DataArray of time-dependent values
temperature = np.random.rand(10)
time = np.arange(10)
units = 'K'
time_units = 'MJD'
name = 'detector_temperature'
temp_da = xrio.makeTimeLikeDA(temperature, time, units,
time_units, name=name)

# Create 1D DataArray of wavelength-dependent values
depth = 1+np.random.rand(20)
wavelength = np.linspace(1,5,20)
units = '%'
wave_units = 'microns'
name = 'transit_depth'
depth_da = xrio.makeWaveLikeDA(depth, wavelength, units,
wave_units, name=name)

A `light curve` DataArray is used to store, for example, a time series of 1D spectra and requires a 2D array (wavelength, time) of flux-like values, a time array, and (of course) units::

#Create 2D DataArray of wavelength- and time-dependent values
spec = np.random.rand(20, 10)
wavelength = np.linspace(1,5,20)
time = np.arange(10)
flux_units = 'e-'
wave_units = 'microns'
time_units = 'MJD'
name = 'light_curves'
lc_da = xrio.makeLCDA(spec, wavelength, time, flux_units,
wave_units, time_units, name=name)

Maintaining all of these DataArrays can be cumbersome, so it is often helpful to combine DataArrays with similar coordinates (i.e., axes) into an Xarray Dataset::

# Create Xarray Dataset from multiple DataArrays
dictionary = dict(flux=flux_da,temp=temp_da,depth=depth_da)
ds = xrio.makeDataset(dictionary)

People often analyze segments (or files) from a larger dataset before combining the results. If need be, one can concatenate multiple Datasets along a given axis (often time)::

# Concatenate two Xarray Datasets along time axis
dictionary = dict(flux=flux_da,temp=temp_da,depth=depth_da)
ds1 = xrio.makeDataset(dictionary)
ds2 = xrio.makeDataset(dictionary)
datasets = [ds1, ds2]
ds = xrio.concat(datasets, dim='time')

Finally, writing and reading Xarray Datasets and DataArrays is straightforward::

filename = "foo.h5"
success = xrio.writeXR(filename, ds)

ds = xrio.readXR(filename)

Alternatively, to read and write generic parameters directly to an HDF5 file, use the functions within ``astraeus.hdf5IO``::

import astraeus.hdf5IO as h5io
flux = np.ones((5,5))
time = np.arange(5)
filename = "foo.hdf5"
success = h5io.writeH5(filename, flux=flux, time=time)

data = h5io.readH5(filename)

Results are returned in a `data` object and can be accessed using ``data.flux`` and ``data.time``.


Code
====

.. The following will add the signature of the individual functions and pull their docstrings.
.. automodapi:: astraeus.xarrayIO
.. automodapi:: astraeus.hdf5IO

..
Recipes
-------
To save generic outputs directly to an HDF5 file,
you can use the ``astraeus.hdf5IO.writeH5()`` function:

.. py:function:: astraeus.hdf5IO.writeH5(filename, verbose=True, **kwargs)
Save keyword arguments to a generic HDF5 file.

:param filename: File name to save data, with our without extension
:type filename: str
:param verbose: Set True to enable print statements declaring success/failure, and optional error message
:param **kwargs: Parameters to save
:return: Return True is file was saved successfully
:rtype: boolean

..
More about how to describe code can be hound
`here <https://www.sphinx-doc.org/en/master/tutorial/describing-code.html>`_
27 changes: 17 additions & 10 deletions _static/alabaster.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ div.relations {
}


div.sphinxsidebar {
max-height: 100%;
overflow-y: auto;
}

div.sphinxsidebar a {
color: #444;
text-decoration: none;
Expand Down Expand Up @@ -155,6 +160,14 @@ div.sphinxsidebar input {
font-size: 1em;
}

div.sphinxsidebar #searchbox input[type="text"] {
width: 160px;
}

div.sphinxsidebar .search > div {
display: table-cell;
}

div.sphinxsidebar hr {
border: none;
height: 1px;
Expand Down Expand Up @@ -419,7 +432,9 @@ table.footnote td {
}

dl {
margin: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0;
padding: 0;
}

Expand Down Expand Up @@ -636,15 +651,7 @@ a:hover tt, a:hover code {
display: none!important;
}

/* Make nested-list/multi-paragraph items look better in Releases changelog
* pages. Without this, docutils' magical list fuckery causes inconsistent
* formatting between different release sub-lists.
*/
div#changelog > div.section > ul > li > p:only-child {
margin-bottom: 0;
}

/* Hide fugly table cell borders in ..bibliography:: directive output */
/* Hide ugly table cell borders in ..bibliography:: directive output */
table.docutils.citation, table.docutils.citation td, table.docutils.citation th {
border: none;
/* Below needed in some edge cases; if not applied, bottom shadows appear */
Expand Down
Loading

0 comments on commit 39a232a

Please sign in to comment.