24 __all__ = [
"ReadTextCatalogConfig",
"ReadTextCatalogTask"]
27 from astropy.table
import Table
30 import lsst.pipe.base
as pipeBase
34 header_lines = pexConfig.Field(
37 doc=
'Number of lines to skip when reading the text reference file.'
39 colnames = pexConfig.ListField(
42 doc=
"An ordered list of column names to use in ingesting the catalog. "
43 "With an empty list, column names will be discovered from the first line "
44 "after the skipped header lines."
46 delimiter = pexConfig.Field(
49 doc=
'Delimiter to use when reading text reference files. Comma is default.'
51 format = pexConfig.Field(
54 doc=(
"Format of files to read, from the astropy.table I/O list here:"
55 "http://docs.astropy.org/en/stable/io/unified.html#built-in-table-readers-writers")
60 """Read an object catalog from a text file
62 _DefaultName =
'readCatalog'
63 ConfigClass = ReadTextCatalogConfig
65 def run(self, filename):
66 """Read an object catalog from the specified text file
71 Path to specified text file
75 A numpy structured array containing the specified columns
78 if self.config.colnames:
79 kwargs[
'names'] = self.config.colnames
81 kwargs[
'data_start'] = self.config.header_lines
84 kwargs[
'header_start'] = self.config.header_lines
87 return np.array(Table.read(filename, format=self.config.format,
88 delimiter=self.config.delimiter,