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

DM-29810: Numpydoc conversion of meas_algorithms through simple_curve.py #246

Merged
merged 2 commits into from
Jul 2, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. lsst-task-topic:: lsst.meas.algorithms.ReserveSourcesTask

##################
ReserveSourcesTask
##################

``ReserveSourcesTask`` randomly selects a fraction of sources that will be reserved from analysis to allow evaluation of the quality of model fits using sources not involved in the fitting process.

.. _lsst.meas.algorithms.ReserveSourcesTask-api:

Python API summary
==================

.. lsst-task-api-summary:: lsst.meas.algorithms.ReserveSourcesTask

.. _lsst.meas.algorithms.ReserveSourcesTask-subtasks:

Retargetable subtasks
=====================

.. lsst-task-config-subtasks:: lsst.meas.algorithms.ReserveSourcesTask

.. _lsst.meas.algorithms.ReserveSourcesTask-configs:

Configuration fields
====================

.. lsst-task-config-fields:: lsst.meas.algorithms.ReserveSourcesTask
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.. lsst-task-topic:: lsst.meas.algorithms.readFitsCatalogTask.ReadFitsCatalogTask

###################
ReadFitsCatalogTask
###################

``ReadFitsCatalogTask`` reads an object catalog from a FITS file into a numpy array object suitable for use with `lsst.meas.algorithms.IngestIndexReferenceTask`.

.. _lsst.meas.algorithms.readFitsCatalogTask.ReadFitsCatalogTask-api:

Python API summary
==================

.. lsst-task-api-summary:: lsst.meas.algorithms.readFitsCatalogTask.ReadFitsCatalogTask

.. _lsst.meas.algorithms.readFitsCatalogTask.ReadFitsCatalogTask-subtasks:

Retargetable subtasks
=====================

.. lsst-task-config-subtasks:: lsst.meas.algorithms.readFitsCatalogTask.ReadFitsCatalogTask

.. _lsst.meas.algorithms.readFitsCatalogTask.ReadFitsCatalogTask-configs:

Configuration fields
====================

.. lsst-task-config-fields:: lsst.meas.algorithms.readFitsCatalogTask.ReadFitsCatalogTask

.. _lsst.meas.algorithms.readFitsCatalogTask.ReadFitsCatalogTask-examples:

Examples
========

A complete example of using ReadFitsCatalogTask:

.. code-block:: python

from lsst.meas.algorithms.readFitsCatalogTask import ReadFitsCatalogTask
filePath = "tests/data/testReadFitsCatalog.fits"
task = ReadFitsCatalogTask()
catalogArray = task.run(filePath)

The resulting `catalogArray` is a numpy structured array containing fields such as "name", "ra" and "dec"
and a few rows of data. For more complicated cases config parameters allow you to rename columns
and choose which HDU to read.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.. lsst-task-topic:: lsst.meas.algorithms.readTextCatalogTask.ReadTextCatalogTask

###################
ReadTextCatalogTask
###################

``ReadTextCatalogTask`` reads an object catalog from a UTF-8 encoded text file into a numpy array object suitable for use with `lsst.meas.algorithms.IngestIndexReferenceTask`.

.. _lsst.meas.algorithms.readTextCatalogTask.ReadTextCatalogTask-api:

Python API summary
==================

.. lsst-task-api-summary:: lsst.meas.algorithms.readTextCatalogTask.ReadTextCatalogTask

.. _lsst.meas.algorithms.readTextCatalogTask.ReadTextCatalogTask-subtasks:

Retargetable subtasks
=====================

.. lsst-task-config-subtasks:: lsst.meas.algorithms.readTextCatalogTask.ReadTextCatalogTask

.. _lsst.meas.algorithms.readTextCatalogTask.ReadTextCatalogTask-configs:

Configuration fields
====================

.. lsst-task-config-fields:: lsst.meas.algorithms.readTextCatalogTask.ReadTextCatalogTask

.. _lsst.meas.algorithms.readTextCatalogTask.ReadTextCatalogTask-examples:

Examples
========

Given a file named `table.csv` containing the following:
ra, dec, flux
5.5, -45.2, 12453
19.6, 34.2, 32123

you can read this file with the following code:

.. code-block:: py

from lsst.meas.algorithms.readTextCatalogTask import ReadTextCatalogTask
task = ReadTextCatalogTask()
catalogArray = task.run("table.csv")

The resulting `catalogArray` is a numpy structured array containing three fields
("ra", "dec" and "flux") and two rows of data. For more complex cases,
config parameters allow you to specify the names of the columns (instead of using automatic discovery)
and set the number of rows to skip.
51 changes: 10 additions & 41 deletions python/lsst/meas/algorithms/readFitsCatalogTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,47 +43,9 @@ class ReadFitsCatalogConfig(pexConfig.Config):
default={},
)

## @addtogroup LSST_task_documentation
## @{
## @page ReadFitsCatalogTask
## @ref ReadFitsCatalogTask_ "ReadFitsCatalogTask"
## @copybrief ReadFitsCatalogTask
## @}


class ReadFitsCatalogTask(pipeBase.Task):
r"""!Read an object catalog from a FITS table

@anchor ReadFitsCatalogTask_

@section meas_algorithms_readFitsCatalog_Contents Contents

- @ref meas_algorithms_readFitsCatalog_Purpose
- @ref meas_algorithms_readFitsCatalog_Initialize
- @ref meas_algorithms_readFitsCatalog_Config
- @ref meas_algorithms_readFitsCatalog_Example

@section meas_algorithms_readFitsCatalog_Purpose Description

Read an object catalog from a FITS table. Designed to read foreign catalogs
so they can be written out in a form suitable for IngestIndexedReferenceTask.

@section meas_algorithms_readFitsCatalog_Initialize Task initialisation

@copydoc \_\_init\_\_

@section meas_algorithms_readFitsCatalog_Config Configuration parameters

See @ref ReadFitsCatalogConfig

@section meas_algorithms_readFitsCatalog_Example A complete example of using ReadFitsCatalogTask

Run the following code from the main directory of meas_algorithms:

from lsst.meas.algorithms.readFitsCatalogTask import ReadFitsCatalogTask
filePath = "tests/data/testReadFitsCatalog.fits"
task = ReadFitsCatalogTask()
catalogArray = task.run(filePath)
"""Read an object catalog from a FITS table

The resulting `catalogArray` is a numpy structured array containing fields such as "name", "ra" and "dec"
and a few rows of data. For more complicated cases config parameters allow you to rename columns
Expand All @@ -95,8 +57,15 @@ class ReadFitsCatalogTask(pipeBase.Task):
def run(self, filename):
"""Read an object catalog from the specified FITS file

@param[in] filename path to FITS file
@return a numpy structured array containing the specified columns
Parameters
----------
filename : `str`
Path to specified FITS file

Returns
-------
table : `np.array`
a numpy structured array containing the specified columns
"""

table = Table.read(filename, hdu=self.config.hdu)
Expand Down
62 changes: 9 additions & 53 deletions python/lsst/meas/algorithms/readTextCatalogTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,68 +55,24 @@ class ReadTextCatalogConfig(pexConfig.Config):
"http://docs.astropy.org/en/stable/io/unified.html#built-in-table-readers-writers")
)

## @addtogroup LSST_task_documentation
## @{
## @page ReadTextCatalogTask
## @ref ReadTextCatalogTask_ "ReadTextCatalogTask"
## @copybrief ReadTextCatalogTask
## @}


class ReadTextCatalogTask(pipeBase.Task):
r"""!Read an object catalog from a text file

@anchor ReadTextCatalogTask_

@section meas_algorithms_readTextCatalog_Contents Contents

- @ref meas_algorithms_readTextCatalog_Purpose
- @ref meas_algorithms_readTextCatalog_Initialize
- @ref meas_algorithms_readTextCatalog_Config
- @ref meas_algorithms_readTextCatalog_Example

@section meas_algorithms_readTextCatalog_Purpose Description

Read an object catalog from a text file. Designed to read foreign catalogs
so they can be written out in a form suitable for IngestIndexedReferenceTask.

The file is assumed to be encoded as UTF-8 (which is compatible with ASCII).

@section meas_algorithms_readTextCatalog_Initialize Task initialisation

@copydoc \_\_init\_\_

@section meas_algorithms_readTextCatalog_Config Configuration parameters

See @ref ReadTextCatalogConfig

@section meas_algorithms_readTextCatalog_Example A complete example of using ReadTextCatalogTask

Given a file named `table.csv` containing the following:

ra, dec, flux
5.5, -45.2, 12453
19.6, 34.2, 32123

you can read this file with the following code:

from lsst.meas.algorithms.readTextCatalogTask import ReadTextCatalogTask
task = ReadTextCatalogTask()
catalogArray = task.run("table.csv")

The resulting `catalogArray` is a numpy structured array containing three fields
("ra", "dec" and "flux") and two rows of data. For more complex cases,
config parameters allow you to specify the names of the columns (instead of using automatic discovery)
and set the number of rows to skip.
"""Read an object catalog from a text file
"""
_DefaultName = 'readCatalog'
ConfigClass = ReadTextCatalogConfig

def run(self, filename):
"""Read an object catalog from the specified text file

@param[in] filename path to text file
@return a numpy structured array containing the specified columns
Parameters
----------
filename : `string`
Path to specified text file

Returns
-------
A numpy structured array containing the specified columns
"""
kwargs = {}
if self.config.colnames:
Expand Down