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_array (np.array) – Numpy array with OpSim observations.

  • filename (str, optional) – Name of the database file to write to.

  • info (np.array, optional) – Numpy array with database info.

  • delete_past (bool) – Delete past observations (default=False)?

  • if_exists (str) – Flag to pass to to_sql when writting to the database to control strategy when the database already exists.

Returns:

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

Return type:

pd.DataFrame or None

opsim2df(filename)

Read an opsim database and return a pandas data frame.

Parameters:

filename (str) – Path to an sqlite3 opsim database.

Returns:

Observations from the database.

Return type:

pd.DataFrame

opsim2obs(filename)

convert an opsim schema dataframe into an observation array.

Parameters:

filename (str) – Sqlite file containing opsim output observations.

opsimdf2obs(df)

convert an opsim schema dataframe into an observation array.

Parameters:

df (pd.DataFrame) – Data frame containing opsim output observations.

Returns:

obs – Numpy array with OpSim observations.

Return type:

np.recarray