LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Classes | Functions
lsst.meas.algorithms.convertReferenceCatalog Namespace Reference

Classes

class  ConvertReferenceCatalogTask
 

Functions

def build_argparser ()
 
def run_convert (outputDir, configFile, fileglob)
 
def main ()
 

Function Documentation

◆ build_argparser()

def lsst.meas.algorithms.convertReferenceCatalog.build_argparser ( )
Construct an argument parser for the ``convertReferenceCatalog`` script.

Returns
-------
argparser : `argparse.ArgumentParser`
    The argument parser that defines the ``convertReferenceCatalog``
    command-line interface.

Definition at line 92 of file convertReferenceCatalog.py.

92def build_argparser():
93 """Construct an argument parser for the ``convertReferenceCatalog`` script.
94
95 Returns
96 -------
97 argparser : `argparse.ArgumentParser`
98 The argument parser that defines the ``convertReferenceCatalog``
99 command-line interface.
100 """
101 parser = argparse.ArgumentParser(
102 description=__doc__,
103 formatter_class=argparse.RawDescriptionHelpFormatter,
104 epilog='More information is available at https://pipelines.lsst.io.'
105 )
106 parser.add_argument("outputDir",
107 help="Path to write the output shard files, configs, and `ingest-files` table to.")
108 parser.add_argument("configFile",
109 help="File containing the ConvertReferenceCatalogConfig fields.")
110 # Use a "+"-list here, so we can produce a more useful error if the user
111 # uses an unquoted glob that gets shell expanded.
112 parser.add_argument("fileglob", nargs="+",
113 help="Quoted glob for the files to be read in and converted."
114 " Example (note required quotes to prevent shell expansion):"
115 ' "gaia_source/csv/GaiaSource*"')
116 return parser
117
118

◆ main()

def lsst.meas.algorithms.convertReferenceCatalog.main ( )

Definition at line 154 of file convertReferenceCatalog.py.

154def main():
155 args = build_argparser().parse_args()
156 if len(args.fileglob) > 1:
157 raise RuntimeError("Final argument must be a quoted file glob, not a shell-expanded list of files.")
158 # Fileglob comes out as a length=1 list, so we can test it above.
159 run_convert(args.outputDir, args.configFile, args.fileglob[0])
def run_convert(outputDir, configFile, fileglob)

◆ run_convert()

def lsst.meas.algorithms.convertReferenceCatalog.run_convert (   outputDir,
  configFile,
  fileglob 
)
Run `ConvertReferenceCatalogTask` on the input arguments.

Parameters
----------
outputDir : `str`
    Path to write the output files to.
configFile : `str`
    File specifying the ``ConvertReferenceCatalogConfig`` fields.
fileglob : `str`
    Quoted glob for the files to be read in and converted.

Definition at line 119 of file convertReferenceCatalog.py.

119def run_convert(outputDir, configFile, fileglob):
120 """Run `ConvertReferenceCatalogTask` on the input arguments.
121
122 Parameters
123 ----------
124 outputDir : `str`
125 Path to write the output files to.
126 configFile : `str`
127 File specifying the ``ConvertReferenceCatalogConfig`` fields.
128 fileglob : `str`
129 Quoted glob for the files to be read in and converted.
130 """
131 # We have to initialize the logger manually when running from the commandline.
132 logging.basicConfig(level=logging.INFO, format="{name} {levelname}: {message}", style="{")
133
134 config = ConvertReferenceCatalogTask.ConfigClass()
135 config.load(configFile)
136 config.validate()
137 converter = ConvertReferenceCatalogTask(output_dir=outputDir, config=config)
138 files = glob.glob(fileglob)
139 converter.run(files)
140 with open(os.path.join(outputDir, "convertReferenceCatalogConfig.py"), "w") as outfile:
141 converter.config.saveToStream(outfile)
142 msg = ("Completed refcat conversion.\n\n"
143 "Ingest the resulting files with the following commands, substituting the path\n"
144 "to your butler repo for `REPO`, and the ticket number you are tracking this\n"
145 "ingest on for `DM-NNNNN`:\n"
146 f"\n butler register-dataset-type REPO {config.dataset_config.ref_dataset_name} "
147 "SimpleCatalog htm7"
148 "\n butler ingest-files -t direct REPO gaia_dr2 refcats/DM-NNNNN "
149 f"{converter.ingest_table_file}"
150 "\n butler collection-chain REPO --mode extend refcats refcats/DM-NNNNN")
151 print(msg)
152
153