Skip to content

Commit

Permalink
Updated docs with class and method identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
hover2pi committed Feb 19, 2021
1 parent 1f2a9cc commit 27dff8d
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 130 deletions.
Binary file modified source/_build/doctrees/catalog.doctree
Binary file not shown.
Binary file modified source/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified source/_build/doctrees/modelgrid.doctree
Binary file not shown.
Binary file modified source/_build/doctrees/sed.doctree
Binary file not shown.
Binary file modified source/_build/doctrees/spectrum.doctree
Binary file not shown.
20 changes: 10 additions & 10 deletions source/_build/html/_sources/catalog.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Catalog
=======

Collections of :ref:`SED` objects can be stored and analyzed in a :ref:`Catalog` object. One can be initialized and populated with an :ref:`SED` object using the ``add_SED`` method.
Collections of :py:class:`~sed.SED` objects can be stored and analyzed in a :py:class:`~catalog.Catalog` object. One can be initialized and populated with an :py:class:`~sed.SED` object using the :py:meth:`~catalog.Catalog.add_SED` method.

.. code:: python
Expand All @@ -22,7 +22,7 @@ Catalogs can be merged with the addition operator.
cat2.add_SED(sirius)
cat = cat1 + cat2
To check the table of data and calculated parameters, just call the ``results`` property. The wavelength and flux density units of all the SEDs can be checked and set with the ``wave_units`` and ``flux_units`` properties.
To check the table of data and calculated parameters, just call the :py:attr:`~catalog.Catalog.results`` property. The wavelength and flux density units of all the SEDs can be checked and set with the :py:attr:`~catalog.Catalog.wave_units`` and :py:attr:`~catalog.Catalog.flux_units`` properties.

.. code:: python
Expand All @@ -31,27 +31,27 @@ To check the table of data and calculated parameters, just call the ``results``
cat.wave_units = q.AA
cat.flux_units = q.W / q.m**3
Additional columns of data can be added to the results table with the ``add_column`` method.
Additional columns of data can be added to the results table with the :py:meth:`~catalog.Catalog.add_column` method.

.. code:: python
rv = np.array([-13.9, -5.5]) * q.km / q.s
rv_unc = np.array([0.9, 0.1]) * q.km / q.s
cat.add_column('radial_velocity', rv, rv_unc)
Data for individual columns (and associated uncertainties when applicable) can be retrieved by passing the desired column names to the ``get_data`` method.
Data for individual columns (and associated uncertainties when applicable) can be retrieved by passing the desired column names to the :py:meth:`~catalog.Catalog.get_data` method.

.. code:: python
spt_data, plx_data = cat.get_data('spectral_type', 'parallax')
The ``SED`` object for a source can be retrieved with the ``get_SED`` method.
The :py:class:`~sed.SED` object for a source can be retrieved with the :py:meth:`~catalog.Catalog.get_SED` method.

.. code:: python
vega = cat.get_SED('Vega')
An interactive scatter plot of any two numeric columns can be made by passing the desired `x` and `y` parameter names from the results table to the ``plot`` method. Photometric colors can be calculated by passing two photometric band names with a ``-`` sign. The ``order`` argument accepts an integer and plots a polynomial of the given order. For busy plots, individual sources can be identified by passing the SED name to the ``identify`` argument. Similarly, setting the argument ``label_points=True`` prints the name of each source next to its data point.
An interactive scatter plot of any two numeric columns can be made by passing the desired `x` and `y` parameter names from the results table to the :py:meth:`~catalog.Catalog.plot` method. Photometric colors can be calculated by passing two photometric band names with a ``-`` sign. The ``order`` argument accepts an integer and plots a polynomial of the given order. For busy plots, individual sources can be identified by passing the SED name to the ``identify`` argument. Similarly, setting the argument ``label_points=True`` prints the name of each source next to its data point.

.. code:: python
Expand All @@ -60,20 +60,20 @@ An interactive scatter plot of any two numeric columns can be made by passing th
cat.plot('age', 'distance', identify=['Vega']) # Age v. Dist with Vega circled in red
cat.plot('parallax', 'mbol', label_points=True) # Plx v. mbol with labeled points
The SEDs can be plotted for visual comparison with the ``plot_SEDs`` method. The can be normalized to 1 by setting the argument ``normalize=True``.
The SEDs can be plotted for visual comparison with the :py:meth:`~catalog.Catalog.plot_SEDs` method. The can be normalized to 1 by setting the argument ``normalize=True``.

.. code:: python
cat.plot_SEDs('*', normalize=True) # Plot of all SEDs
cat.plot_SEDs(['Vega', 'Sirius']) # Normalized plot of Vega and Sirius
The results table, photometry, and plots of each SED can be exported to a zip file or directory with the ``export`` method.
The results table, photometry, and plots of each SED can be exported to a zip file or directory with the :py:meth:`~catalog.Catalog.export` method.

.. code:: python
cat.export('/path/to/target/dir', zip=True)
The whole :ref:`Catalog` object can be serialized and loaded with the ``save`` and ``load`` methods, respectively.
The whole :py:class:`~catalog.Catalog` object can be serialized and loaded with the :py:meth:`~catalog.Catalog.save` and :py:meth:`~catalog.Catalog.load` methods, respectively.

.. code:: python
Expand All @@ -82,7 +82,7 @@ The whole :ref:`Catalog` object can be serialized and loaded with the ``save`` a
new_cat = Catalog('A-type stars')
new_cat.load(cat_file)
A catalog can also be made from an ASCII file with column names ``name``, ``ra``, and ``dec`` by passing the filepath to the ``from_file`` method. For each source in the list, an SED is created, the methods in the ``run_methods`` argument are run, and the SED is added to the catalog.
A catalog can also be made from an ASCII file with column names ``name``, ``ra``, and ``dec`` by passing the filepath to the :py:meth:`~catalog.Catalog.from_file` method. For each source in the list, an SED is created, the methods in the ``run_methods`` argument are run, and the SED is added to the catalog.

.. code:: python
Expand Down
18 changes: 9 additions & 9 deletions source/_build/html/_sources/modelgrid.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
ModelGrid
=========

Theoretical model atmosphere grids and spectral atlases are useful tools for characterizing stellar and substellar atmospheres. These data can be managed in ``sedkit`` with the :ref:`ModelGrid` class.
Theoretical model atmosphere grids and spectral atlases are useful tools for characterizing stellar and substellar atmospheres. These data can be managed in ``sedkit`` with the :py:class:`~modelgrid.ModelGrid` class.

To use this resource, create a :ref:`ModelGrid` object, specify the parameters to track, and load it with data from a directory of XML files.
To use this resource, create a :py:class:`~modelgrid.ModelGrid` object, specify the parameters to track, and load it with data from a directory of XML files.

.. code:: python
Expand All @@ -15,7 +15,7 @@ To use this resource, create a :ref:`ModelGrid` object, specify the parameters t
mgrid = ModelGrid('BT-Settl', params, q.AA, q.erg/q.s/q.cm**2/q.AA, ref='2014IAUS..299..271A', **kwargs)
mgrid.load('/path/to/data/models')
The table of model data can be viewed via the ``index`` property and the parameter values can be returned via a parameter name + '_vals' property.
The table of model data can be viewed via the :py:attr:`~modelgrid.ModelGrid.index`` property and the parameter values can be returned via a parameter name + '_vals' property.

.. code:: python
Expand All @@ -25,28 +25,28 @@ The table of model data can be viewed via the ``index`` property and the paramet
mgrid.meta_vals
mgrid.alpha_vals
An individual model can be retrieved as a :ref:`Spectrum` object by passing the desired parameter values as keyword arguments to the ``get_spectrum`` method. If the given parameter values do not correspond to a point on the grid, the spectrum can be interpolated or the closest grid point spectrum can be retrieved.
An individual model can be retrieved as a :py:class:`~spectrum.Spectrum` object by passing the desired parameter values as keyword arguments to the :py:meth:`~modelgrid.ModelGrid.get_spectrum` method. If the given parameter values do not correspond to a point on the grid, the spectrum can be interpolated or the closest grid point spectrum can be retrieved.

.. code:: python
spec1 = mgrid.get_spectrum(teff=3500, logg=5.5, meta=0, alpha=0)
spec2 = mgrid.get_spectrum(teff=3534, logg=5.3, meta=0.1, alpha=0, interp=True)
spec3 = mgrid.get_spectrum(teff=3500, logg=5.5, meta=0, alpha=0, closest=True)
The :ref:`ModelGrid` can be resampled to new parameter values by passing arrays to the desired keyword arguments.
The :py:class:`~modelgrid.ModelGrid`. can be resampled to new parameter values by passing arrays to the desired keyword arguments.

.. code:: python
import numpy as np
new_mgrid = mgrid.resample_grid(teff=np.array())
Models can be inspected by passing the desired parameter values to the ``plot`` method.
Models can be inspected by passing the desired parameter values to the :py:meth:`~modelgrid.ModelGrid.plot` method.

.. code:: python
mgrid.plot(teff=3500, logg=5.5, meta=0, alpha=0)
And a grid can be saved as a pickle file ``save`` method and loaded into a new object with the ``load_ModelGrid`` function.
And a grid can be saved as a pickle file :py:meth:`~modelgrid.ModelGrid.save` method and loaded into a new object with the :py:func:`~modelgrid.load_ModelGrid`` function.

.. code:: python
Expand All @@ -55,12 +55,12 @@ And a grid can be saved as a pickle file ``save`` method and loaded into a new o
mgrid.save(mgrid_path)
new_grid = mg.load_ModelGrid(mgrid_path)
Several :ref:`ModelGrid` child classes exist for convenience.
Several :py:class:`~modelgrid.ModelGrid`. child classes exist for convenience.

.. code:: python
btsettl = mg.BTSettl() # BT-Settl model atmosphere grid
spl = mg.SpexPrismLibrary() # Spex Prism Library substellar spectral atlas
fili15 = mg.Filippazzo2016() # Substellar SED atlas from Filippazzo (2016)
The true utility of the :ref:`ModelGrid` class is that it can be passed to a :ref:`Spectrum` or :ref:`SED` object to find a best fit model or best fit parameters.
The true utility of the :py:class:`~modelgrid.ModelGrid`. class is that it can be passed to a :py:class:`~spectrum.Spectrum` or :py:class:`~sed.SED` object to find a best fit model or best fit parameters.
13 changes: 5 additions & 8 deletions source/_build/html/_sources/sed.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
SED
===

An SED can be constructed by importing and initializing an ``SED``
object.
An SED (spectral energy distribution) can be constructed by importing and initializing an :py:class:`~sed.SED` object.

.. code:: python
Expand Down Expand Up @@ -49,15 +48,13 @@ parameters can be set at any time.
trap1.age = 7.6 * q.Gyr, 2.2 * q.Gyr
trap1.radius = 0.121 * q.R_sun, 0.003 * q.R_sun
Results can be calculated at any time by checking the ``results``
property.
Results can be calculated at any time by checking the :py:attr:`~sed.SED.results` property.

.. code:: python
trap1.results
A variety of evolutionary model grids can be used to infer fundamental
parameters,
A variety of evolutionary model grids can be used to infer fundamental parameters,

.. code:: python
Expand All @@ -84,6 +81,6 @@ Inspect the SED at any time with the interactive plotting method.
trap1.plot()
Entire catalogs of ``SED`` objects can also be created and their
Entire catalogs of :py:class:`~sed.SED` objects can also be created and their
properties can be arbitrarily compared and analyzed with the
:ref:`catalog` object.
:py:class:`~catalog.Catalog` object.
32 changes: 16 additions & 16 deletions source/_build/html/_sources/spectrum.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Spectrum
========

The :ref:`Spectrum` class handles any 1D data representing the light from an astronomical source. A :ref:`Spectrum` object is created by passing the wavelength, flux density, and (optional) uncertainty with ``astropy.units`` to the class.
The :py:class:`~spectrum.Spectrum` class handles any 1D data representing the light from an astronomical source. A :py:class:`~spectrum.Spectrum` object is created by passing the wavelength, flux density, and (optional) uncertainty with ``astropy.units`` to the class.

.. code:: python
Expand All @@ -15,7 +15,7 @@ The :ref:`Spectrum` class handles any 1D data representing the light from an ast
unc = flux / 100.
spec = Spectrum(wavelength, flux, unc, name='My spectrum')
The :ref:`Spectrum` has a number of useful attributes.
The :py:class:`~spectrum.Spectrum` has a number of useful attributes.

.. code:: python
Expand All @@ -33,36 +33,36 @@ The :ref:`Spectrum` has a number of useful attributes.
spec.flux_units # The flux density units
spec.size # The number of data points
After the :ref:`Spectrum` has been created, it be manipulated in a number of ways.
After the :py:class:`~spectrum.Spectrum` has been created, it be manipulated in a number of ways.

It can be trimmed by passing a list of lower and upper bounds to ``trim`` method. The ``include`` argument accepts bounds for wavelength regions to include and the ``exclude`` argument accepts bounds for regions to exclude. A list of :ref:`Spectrum` objects are returned unless the ``concat`` argument is set to ``True``, which simply concatenated the trimmed segment(s) into one :ref:`Spectrum`.
It can be trimmed by passing a list of lower and upper bounds to :py:meth:`~spectrum.Spectrum.trim` method. The ``include`` argument accepts bounds for wavelength regions to include and the ``exclude`` argument accepts bounds for regions to exclude. A list of :py:class:`~spectrum.Spectrum` objects are returned unless the ``concat`` argument is set to ``True``, which simply concatenated the trimmed segment(s) into one :py:class:`~spectrum.Spectrum`.

.. code:: python
trim_spec_include = spec.trim(include=[(1.2 * q.um, 1.6 * q.um)])
trim_spec_exclude = spec.trim(exclude=[(1.2 * q.um, 1.6 * q.um)], concat=True)
The ``interpolate`` method accepts a new wavelength array and returns a new :ref:`Spectrum` object interpolated to those values. The ``resamp`` method accepts the same input and resamples the spectrum onto the new wavelength array while preserving the total flux.
The :py:meth:`~spectrum.Spectrum.interpolate` method accepts a new wavelength array and returns a new :py:class:`~spectrum.Spectrum` object interpolated to those values. The :py:meth:`~spectrum.Spectrum.resamp` method accepts the same input and resamples the spectrum onto the new wavelength array while preserving the total flux.

.. code:: python
new_wav = np.linspace(1.2, 1.6, 50) * q.um
new_wav_interp = spec.interpolate(new_wav)
new_wav_resamp = spec.resamp(new_wav)
The ``integrate`` method integrates the curve to caluclate the area underneath using the trapezoidal rule.
The :py:meth:`~spectrum.Spectrum.integrate` method integrates the curve to calculate the area underneath using the trapezoidal rule.

.. code:: python
area = spec.integrate()
The :ref:`Spectrum` can be smoothed using a Kaiser-Bessel smoothing window of narrowness ``beta`` and a given ``window`` size.
The :py:class:`~spectrum.Spectrum` can be smoothed using a Kaiser-Bessel smoothing window of narrowness ``beta`` and a given ``window`` size.

.. code:: python
smooth_spec = spec.smooth(beta=2, window=11)
A :ref:`Spectrum` may be flux calibrated to a given distance by passing a distance to the ``flux_calibrate`` method.
A :py:class:`~spectrum.Spectrum` may be flux calibrated to a given distance by passing a distance to the :py:meth:`~spectrum.Spectrum.flux_calibrate` method.

.. code:: python
Expand All @@ -79,17 +79,17 @@ A bandpass name or ``svo_filters.svo.Filter`` object can be used to convolve the
jmag = spec.synthetic_magnitude(jband) # Synthetic magnitude
jflux = spec.synthetic_flux(jband) # Synthetic flux
It can also be normalized to a table of photometry weighted by the magnitude uncertainties with the ``norm_to_mags`` method. See the :ref:`SED` class for an example.
It can also be normalized to a table of photometry weighted by the magnitude uncertainties with the :py:meth:`~spectrum.Spectrum.norm_to_mags` method. See the :ref:`SED` class for an example.

A :ref:`Spectrum` object may also interact with another ``Spectrum`` object in a number of ways. The ``norm_to_spec`` method creates a new object normalized to the input :ref:`Spectrum` object and the ``__add__`` operation combines two :ref:`Spectrum` objects in their common wavelength region or concatenates the segments.
A :py:class:`~spectrum.Spectrum` object may also interact with another :py:class:`~spectrum.Spectrum` object in a number of ways. The :py:meth:`~spectrum.Spectrum.norm_to_spec` method creates a new object normalized to the input :py:class:`~spectrum.Spectrum` object and the :py:meth:`~spectrum.Spectrum.__add__` operation combines two :py:class:`~spectrum.Spectrum` objects in their common wavelength region or concatenates the segments.

.. code:: python
spec2 = Spectrum(np.linspace(1.5, 2.5, 100) * q.um, flux * 1E-11, unc * 1E-11, name='Redder spectrum')
normed_spec = spec.norm_to_spec(spec2) # spec normalized to spec2
combined_spec = spec + spec2 # New combined spectrum
Any :ref:`Spectrum` may also be fit by a :ref:`ModelGrid` object to find the best fit model or spectrum. The ``best_fit_model`` method performs a simple goodness of fit test and returns the model with the best fit. The ``mcmc_fit` method performs a MCMC fit to the grid and returns the best fit parameters with uncertainties. The details of any fit are stored as a dictionary in the ``best_fit`` attribute.
Any :py:class:`~spectrum.Spectrum` may also be fit by a :py:class:`~modelgrid.ModelGrid` object to find the best fit model or spectrum. The :py:meth:`~spectrum.Spectrum.best_fit_model` method performs a simple goodness of fit test and returns the model with the best fit. The :py:meth:`~spectrum.Spectrum.mcmc_fit` method performs a MCMC fit to the grid and returns the best fit parameters with uncertainties. The details of any fit are stored as a dictionary in the :py:attr:`~spectrum.Spectrum.best_fit` attribute.

.. code:: python
Expand All @@ -98,34 +98,34 @@ Any :ref:`Spectrum` may also be fit by a :ref:`ModelGrid` object to find the bes
spec.best_fit_model(bt) # Goodness of fit
spec.mcmc_fit(bt, params=['teff']) # MCMC fit
For visual inspection of an interactive ``bokeh.plotting.figure``, use the ``plot`` method.
For visual inspection of an interactive ``bokeh.plotting.figure``, use the :py:meth:`~spectrum.Spectrum.plot` method.

.. code:: python
spec.plot()
Several child classes are also available. The ``Blackbody`` class creates a blackbody spectrum for a given wavelength range and effective temperature.
Several child classes are also available. The :py:class:`~spectrum.Blackbody` class creates a blackbody spectrum for a given wavelength range and effective temperature.

.. code:: python
from sedkit.spectrum import Blackbody
bb_spec = Blackbody(np.linspace(1.5, 2.5, 100) * q.um, teff=2456 * q.K)
The ever useful spectrum of ``Vega`` is easily created.
The ever useful spectrum of :py:class:`~spectrum.Vega` is easily created.

.. code:: python
from sedkit.spectrum import Vega
vega = Vega()
And a ``Spectrum`` object can be created directly from a FITS or ASCII file with the ``FileSpectrum`` class.
And a :py:class:`~spectrum.Spectrum` object can be created directly from a FITS or ASCII file with the :py:class:`~spectrum.FileSpectrum` class.

.. code:: python
from sedkit.spectrum import FileSpectrum
file_spec = FileSpectrum('/path/to/the/file.fits', wave_units=q.um, flux_units=q.erg/q.s/q.cm**2/q.AA)
Finally, the data can be exported to an ASCII file by passing a filepath to the ``export`` method.
Finally, the data can be exported to an ASCII file by passing a filepath to the :py:meth:`~spectrum.Spectrum.export` method.

.. code:: python
Expand Down

0 comments on commit 27dff8d

Please sign in to comment.