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

Cleanup after second pass through stellarphot.io documentation. #100

Merged
merged 17 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
4 changes: 4 additions & 0 deletions stellarphot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@


class UnsupportedPythonError(Exception):
"""
Wraps an exception to raise if a user tries to use stellarphot
with an unsupported version of Python.
"""
pass


Expand Down
8 changes: 4 additions & 4 deletions stellarphot/analysis/exotic.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def make_checker(indicator_widget, value_widget):
Parameters
----------

indicator_widget : MyCheck widget
indicator_widget : `~stellarphot.analysis.MyValid` widget
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure we need the full package name in this case because the class is in the package. I.e. MyValid might work just fine.

Reading through https://numpydoc.readthedocs.io/en/latest/index.html now to try to see....and after reading the (genuinely useful) documentation I'm still not sure.

The widget that indicates to the user whether or not the value is
reasonable.

Expand Down Expand Up @@ -143,7 +143,7 @@ def validate_exposure_time(indicator_widget, value_widget):

Parameters
----------
indicator_widget : `MyValid` widget
indicator_widget : `~stellarphot.analysis.MyValid` widget
The widget that indicates to the user whether or not the value is
reasonable.

Expand Down Expand Up @@ -219,10 +219,10 @@ def populate_TOI_boxes(toi, exotic_widget):
Parameters
----------

toi : stellarphot.io.tess.TOI
toi : `~stellarphot.io.tess.TOI`
Information about the TIC object.

exotic_widget: ipywidget
exotic_widget: ipywidget
JuanCab marked this conversation as resolved.
Show resolved Hide resolved
This widget should be generated by exotic_settings_widget.

Returns
Expand Down
93 changes: 58 additions & 35 deletions stellarphot/analysis/transit_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@

class VariableArgsFitter(LevMarLSQFitter):
"""
A callable class that can be used to fit functions with arbitrary number of positional parameters.
This is a modified version of the astropy.modeling.fitting.LevMarLSQFitter fitter.
A callable class that can be used to fit functions with arbitrary number of
positional parameters. This is a modified version of the
astropy.modeling.fitting.LevMarLSQFitter fitter.
JuanCab marked this conversation as resolved.
Show resolved Hide resolved

"""
def __init__(self):
super().__init__()
Expand Down Expand Up @@ -89,56 +91,55 @@ def __call__(self, model, *args, weights=None,


class TransitModelFit:
"""Transit model fits to observed light curves.

Parameters
----------
batman_params : batman.TransitParams
Parameters for the batman transit model. If not provided, the
default parameters will be used.
"""
Transit model fits to observed light curves.

Attributes
----------
times : array-like
Times at which the light curve is observed. Must be set before
fitting.

airmass : array-like
Airmass at each time. Must be set before fitting.

width : array-like
Width of the star in pixels at each time. Must be set before fitting.

spp : array-like
Sky per pixel at each time. Must be set before fitting.
BIC : float
Bayesian Information Criterion for the fit. This is calculated
after the fit is performed.

data : array-like
Observed fluxes. Must be set before fitting.

model : astropy.modeling.Model
model : `~astropy.modeling.Model`
The model used for fitting. This is a combination of the batman
transit model and any other trends that are included in the fit.
This is set up when the ``setup_model`` method is called.

n_fit_parameters : int
Number of parameters that were fit. This is calculated after the
fit is performed.

spp : array-like
Sky per pixel at each time. Must be set before fitting.

times : array-like
Times at which the light curve is observed. Must be set before
fitting.

width : array-like
Width of the star in pixels at each time. Must be set before fitting.

weights : array-like
Weights to use for fitting. If not provided, all weights are
set to 1.

detrend_parameters : set
Set of parameters to detrend by. This is set when the ``airmass``,
``width``, or ``spp`` attributes are set. If all three are set,
then all three are used for detrending. If ``None`` of them are
set, then no detrending is done.

BIC : float
Bayesian Information Criterion for the fit. This is calculated
after the fit is performed.

n_fit_parameters : int
Number of parameters that were fit. This is calculated after the
fit is performed.
"""
def __init__(self, batman_params=None):
"""
Initialize the transit model fit.

Parameters
----------
batman_params : batman.TransitParams
Parameters for the batman transit model. If not provided, the
default parameters will be used.
"""
self._batman_params = batman.TransitParams()
self._set_default_batman_params()
self._times = None
Expand Down Expand Up @@ -486,6 +487,28 @@ def _detrend(self, model, detrend_by):
return detrended

def data_light_curve(self, data=None, detrend_by=None):
"""
Function to return data light curve, optionally detrended by one or
JuanCab marked this conversation as resolved.
Show resolved Hide resolved
more parameters.

Parameters
----------

data : array-like, optional
Data to use for calculating the light curve. If not provided,
the data used for fitting will be used.

detrend_by : str or list of str
Parameter(s) to detrend by. If ``None``, no detrending is
done. If ``'all'``, all parameters that are set will be
used for detrending.

Returns
-------

data : array-like
Data light curve, detrended if requested.
"""
data = data if data is not None else self.data

if detrend_by is not None:
Expand All @@ -497,18 +520,18 @@ def model_light_curve(self, at_times=None, detrend_by=None):
"""
Calculate the light curve corresponding to the model, optionally
detrended by one or more parameters.

Parameters
----------
at_times : array-like
Times at which to calculate the model. If not provided, the
times used for fitting will be used.

detrend_by : str or list of str
Parameter(s) to detrend by. If ``None``, no detrending is
done. If ``'all'``, all parameters that are set will be
used for detrending.

Returns
-------
model : array-like
Expand Down
40 changes: 26 additions & 14 deletions stellarphot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ class Camera:
"""
A class to represent a CCD-based camera.
JuanCab marked this conversation as resolved.
Show resolved Hide resolved

Parameters
----------
gain : `astropy.quantity.Quantity`
The gain of the camera in units such that the unit of the product `gain` times the image data matches the unit of the `read_noise`.
read_noise : `astropy.quantity.Quantity`
The read noise of the camera in units of electrons.
dark_current : `astropy.quantity.Quantity`
The dark current of the camera in units such that, when multiplied by exposure time, the unit matches the unit of the `read_noise`.

Attributes
----------
gain : float times u.electron / u.adu,
The gain of the camera in units of electrons per ADU.
read_noise : float times u.electron

gain : `~astropy.quantity.Quantity`
The gain of the camera in units such that the unit of the product
`gain` times the image data matches the unit of the `read_noise`.

read_noise : `~astropy.quantity.Quantity`
The read noise of the camera in units of electrons.
dark_current : float times u.electron / u.second
The dark current of the camera in units of electrons per second.

dark_current : `~astropy.quantity.Quantity`
The dark current of the camera in units such that, when multiplied
by exposure time, the unit matches the unit of the `read_noise`.
JuanCab marked this conversation as resolved.
Show resolved Hide resolved

Notes
-----
Expand All @@ -48,6 +44,22 @@ class Camera:
def __init__(self, gain=1.0 * u.electron / u.adu,
read_noise=1.0 * u.electron,
dark_current=0.01 * u.electron / u.second):
"""
JuanCab marked this conversation as resolved.
Show resolved Hide resolved
Initializes a Camera object instance.

Parameters
----------
gain : `~astropy.quantity.Quantity`
The gain of the camera in units such that the unit of the product `gain`
times the image data matches the unit of the `read_noise`.

read_noise : `~astropy.quantity.Quantity`
The read noise of the camera in units of electrons.

dark_current : `~astropy.quantity.Quantity`
The dark current of the camera in units such that, when multiplied by
exposure time, the unit matches the unit of the `read_noise`.
"""
super().__init__()
self.gain = gain
self.read_noise = read_noise
Expand Down
10 changes: 5 additions & 5 deletions stellarphot/differential_photometry/aij_rel_fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,26 @@ def calc_aij_relative_flux(star_data, comp_stars,
the `star_data` and the position in the `comp_stars` table
is too large.

in_place : ``bool``, optional
in_place : bool, optional
If ``True``, add new columns to input table. Otherwise, return
new table with those columns added.

coord_column : ``str``, optional
coord_column : str, optional
If provided, use this column to match comparison stars to coordinates.
If not provided, the coordinates are generated with SkyCoord.

flux_column_name : ``str``, optional
flux_column_name : str, optional
If provided, use this column to find flux.
If not provided, the column 'aperture_net_flux' is used.

star_id_column : ``str``, optional
star_id_column : str, optional
Name of the column that provides a unique identifier for each
comparison star.

Returns
-------

`astropy.table.Table` or None
`~astropy.table.Table` or None
JuanCab marked this conversation as resolved.
Show resolved Hide resolved
The return type depends on the value of ``in_place``. If it is
``False``, then the new columns are returned as a separate table,
otherwise the columns are simply added to the input table.
Expand Down
Loading