SchemaConverter

class lsst.ts.scheduler.utils.SchemaConverter

Bases: SchemaConverter

Record how to convert an observation array to the standard opsim schema.

Extends rubin_scheduler.scheduler.utils.SchemaConverter with a method to read an opsim database and return a dataframe instead of an observation array.

Methods Summary

obs2opsim(obs_array[, filename, info, ...])

Convert an array of observations into a pandas dataframe with Opsim schema.

opsim2df(filename)

Read an opsim database and return a pandas data frame.

opsim2obs(filename)

convert an opsim schema dataframe into an observation array.

opsimdf2obs(df)

convert an opsim schema dataframe into an observation array.

Methods Documentation

obs2opsim(obs_array, filename=None, info=None, delete_past=False, if_exists='append')

Convert an array of observations into a pandas dataframe with Opsim schema.

Parameters:
obs_arraynp.array

Numpy array with OpSim observations.

filenamestr, optional

Name of the database file to write to.

infonp.array, optional

Numpy array with database info.

delete_pastbool

Delete past observations (default=False)?

if_existsstr

Flag to pass to to_sql when writting to the database to control strategy when the database already exists.

Returns:
pd.DataFrame or None

Either the converted dataframe or None, if filename is provided.

opsim2df(filename: str) DataFrame

Read an opsim database and return a pandas data frame.

Parameters:
filenamestr

Path to an sqlite3 opsim database.

Returns:
pd.DataFrame

Observations from the database.

opsim2obs(filename)

convert an opsim schema dataframe into an observation array.

Parameters:
filenamestr

Sqlite file containing opsim output observations.

opsimdf2obs(df) recarray

convert an opsim schema dataframe into an observation array.

Parameters:
dfpd.DataFrame

Data frame containing opsim output observations.

Returns:
obsnp.recarray

Numpy array with OpSim observations.