Digestor API
digestor
Scripts and metadata for loading survey data into the Data Lab database.
digestor.base
Base class containing common functionality.
- class digestor.base.Digestor(schema, table, description=None, merge=None, pixels=True, random=True, ecliptic=True, galactic=True)[source]
Base class for FITS+SQL to FITS+SQL conversion.
- Parameters:
schema (
str) – Name of the PostgreSQL schema containing table.table (
str) – Name of the PostgreSQL table.description (
str, optional) – A short description of schema.merge (
str, optional) – Name of a JSON file containing existing TapSchema metadata.pixels (
bool, optional) – IfFalse, don’t HTM and HEALPix columns.random (
bool, optional) – IfFalse, don’t add arandom_idcolumn.ecliptic (
bool, optional) – IfFalse, don’t add ecliptic coordinates (probably because they already exist).galactic (
bool, optional) – IfFalse, don’t add galactic coordinates (probably because they already exist).
- _dlColumns()[source]
Add SQL column definitions of Data Lab-added columns.
- Returns:
A list suitable for appending to an existing list of columns.
- Return type:
- _initTapSchema(description='', merge=None)[source]
Create a dictionary compatible with TapSchema.
- Parameters:
- Returns:
A dictionary compatible with TapSchema.
- Return type:
- Raises:
ValueError – When merging, if the schema names don’t match, or if the table is already loaded.
- addDLColumns(filename, ra='ra', overwrite=False)[source]
Add DL columns to FITS file prior to column reorganization.
- Parameters:
- Returns:
The name of the processed file.
- Return type:
- Raises:
ValueError – If a problem with stilts is detected.
- property colNames
List of columns in the table.
- columnIndex(column)[source]
Find the index of the column in the list of columns.
- Raises:
ValueError – If the column is not found.
- createSQL()[source]
Construct a CREATE TABLE statement from the TapSchema metadata.
- Returns:
A SQL table definition.
- Return type:
- customSTILTS(filename)[source]
Add (prepend) custom STILTS commands to the default command.
- Parameters:
filename (
str) – Name of the YAML configuration file.
- fixColumns(filename)[source]
Fix any table definition oddities “by hand”.
- Parameters:
filename (
str) – Name of the YAML configuration file.- Raises:
ValueError – If the configuration file contains an unknown column.
- logName(method)[source]
Get a logger with name method.
- Parameters:
method (
str) – Name of the log object. Will be appended to the root name.- Returns:
A configured log object.
- Return type:
- mapColumns()[source]
Complete mapping of FITS table columns to SQL columns.
This method may need to be overridden by a subclass.
- Raises:
KeyError – If an expected mapping cannot be found.
- property nColumns
Number of columns in the table.
- processFITS(hdu=1, overwrite=False)[source]
Convert a pre-processed FITS file into one ready for database loading.
This method may be overridden in subclasses with survey-specific requirements.
- Parameters:
- Returns:
The name of the file written.
- Return type:
- Raises:
ValueError – If the FITS data type cannot be converted to SQL.
- property stable
Schema-qualified table name.
- tableIndex()[source]
Find the index of the table in the list of tables.
- Raises:
ValueError – If the table is not found.
digestor.sdss
Convert SDSS SQL (MS SQL Server) table definitions to Data Lab SQL (PostgreSQL).
- class digestor.sdss.SDSS(*args, **kwargs)[source]
Convert SDSS FITS+SQL files into Data Lab-compatible forms.
- _photoFlag(column, table)[source]
Handle photometric flags in SDSS data.
- Parameters:
column (
dict) – A TapSchema column definition.table (
astropy.table.Table) – Table containing the input data.
- Returns:
The combined flags and flags2 data, or
Noneif the column did not match.- Return type:
numpy.ndarray- Raises:
AssertionError – If the required columns are not present in the FITS file.
- fixMapping(filename)[source]
Fix any FITS to SQL mapping problems using the YAML configuration file filename.
- Parameters:
filename (
str) – Name of the YAML configuration file.
- fixNOFITS(filename)[source]
Fix any missing data designated by
--/F NOFITSusing the YAML configuration file filename.- Parameters:
filename (
str) – Name of the YAML configuration file.
- mapColumns()[source]
Complete mapping of FITS table columns to SQL columns.
- Raises:
KeyError – If an expected mapping cannot be found.
- parseLine(line)[source]
Parse a single line from a SQL file.
- Parameters:
line (
str) – A single line from a SQL file.
Notes
Currently, the long description (
--/T) is thrown out.
- parseSQL(filename)[source]
Parse an entire SQL file.
- Parameters:
filename (
str) – Name of the SQL file.
- processFITS(hdu=1, overwrite=False)[source]
Convert a pre-processed FITS file into one ready for database loading.
- Parameters:
- Returns:
The name of the file written.
- Return type:
- Raises:
ValueError – If the FITS data type cannot be converted to SQL.
- digestor.sdss.get_options()[source]
Parse command-line options.
- Returns:
The parsed options.
- Return type:
- digestor.sdss.main()[source]
Entry-point for command-line script.
- Returns:
An integer suitable for passing to
sys.exit().- Return type:
digestor.view
Handle schema metadata for views.
- digestor.view.get_options()[source]
Parse command-line options.
- Returns:
The parsed options.
- Return type:
- digestor.view.main()[source]
Entry-point for command-line script.
- Returns:
An integer suitable for passing to
sys.exit().- Return type: