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.

Python API summary

from lsst.meas.algorithms.readTextCatalogTask import ReadTextCatalogTask
classReadTextCatalogTask(config=None, *, name=None, parentTask=None, log=None)

Read an object catalog from a text file...

attributeconfig

Access configuration fields and retargetable subtasks.

methodrun(filename)

Read an object catalog from the specified text file...

See also

See the ReadTextCatalogTask API reference for complete details.

Retargetable subtasks

No subtasks.

Configuration fields

colnames

Default
[]
Field type

str ListField

An ordered list of column names to use in ingesting the catalog. With an empty list, column names will be discovered from the first line after the skipped header lines.

delimiter

Default
','
Field type

str Field

Delimiter to use when reading text reference files. Comma is default.

fill_values

Default
None
Field type

str ListField (optional)

A list giving [<match_string>, <fill_value>], which is used to mask the given values in the input file. ‘0’ is suggested for the fill value in order to prevent changing the column datatype. The default behavior is to fill empty data with zeros. See https://docs.astropy.org/en/stable/io/ascii/read.html#bad-or-missing-values for more details.Use replace_missing_floats_with_nan to change floats to NaN instead of <fill_value>.

format

Default
'csv'
Field type

str Field

Format of files to read, from the astropy.table I/O list here:http://docs.astropy.org/en/stable/io/unified.html#built-in-table-readers-writers

header_lines

Default
0
Field type

int Field

Number of lines to skip when reading the text reference file.

replace_missing_floats_with_nan

Default
False
Field type

bool Field

If True, replace missing data in float columns with NaN instead of zero. If fill_values is set, this parameter with replace the floats identified as missing by fill_values, and the fill value from fill_values will be overridden with NaN for floats.

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:

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.