adler.objectdata.AdlerData

Attributes

FILTER_DEPENDENT_KEYS

PHASE_MODEL_DEPENDENT_KEYS

VALID_PHASE_MODELS

AVG_MAG_MODEL_DEPENDENT_KEYS

VALID_AVG_MAG_MODELS

ALL_FILTER_LIST

VALID_MODELS

logger

Classes

AdlerData

Class for storing Adler-calculated values.

PhaseModelDependentAdler

Dataclass containing phase-model-dependent values generated by Adler. Note that NaN indicates a value that has not yet been populated.

AvgMagModelDependentAdler

Dataclass containing model-dependent values for the simple average magnitude model pgenerated by Adler. Note that NaN indicates a value that has not yet been populated.

PhaseParameterOutput

Empty convenience class so that the output of AdlerData.get_phase_parameters_in_filter is an object.

AvgMagParameterOutput

Empty convenience class so that the output of AdlerData.get_avg_mag_parameters_in_filter is an object.

AdlerSourceFlags

Class for storing Adler-determined outlier information.

FilterDependentAdler

Dataclass containing filter-dependent values generated by Adler. Note that NaN indicates a value that has not yet been populated.

Module Contents

FILTER_DEPENDENT_KEYS = ['phaseAngle_min', 'phaseAngle_range', 'observationTime_max', 'nobs', 'arc', 'n_outliers',...[source]
PHASE_MODEL_DEPENDENT_KEYS = ['H', 'H_err', 'phase_parameter_1', 'phase_parameter_1_err', 'phase_parameter_2',...[source]
VALID_PHASE_MODELS = ['HG', 'HG1G2', 'HG12', 'HG12_Pen16', 'LinearPhaseFunc'][source]
AVG_MAG_MODEL_DEPENDENT_KEYS = ['avg_mag', 'std_mag'][source]
VALID_AVG_MAG_MODELS = ['median', 'mean'][source]
ALL_FILTER_LIST = ['u', 'g', 'r', 'i', 'z', 'y'][source]
VALID_MODELS[source]
logger[source]
class AdlerData[source]

Class for storing Adler-calculated values.

Attributes:

ssObjectIdstr

ssObjectId of the object of interest.

filter_listlist of str

List of filters under investigation.

modelIdstr, optional

modelId for the model of interest that has been or is to be computed. Default: Empty str

updatedMJDfloat, optional

Timestamp (in MJD) of the time that this AdlerData object was initialized.

filter_dependent_valueslist of FilterDependentAdler objects, optional

List of FilterDependentAdler objects containing filter-dependent data in order of filter_list. Default empty list.

ssObjectId: str[source]
filter_list: list[source]
modelId: str = ''[source]
updatedMJD: float[source]
filter_dependent_values: list = [][source]
__post_init__()[source]

This runs post-initialisation and creates the class attribute where one dimension is “filters” to ensure the array has the correct size. This makes population a little easier. We also generate the current MJD timestamp to record the time this AdlerData object was initialized.

_MJD_update()[source]

Function for updating the updatedMJD value stored in AdlerData. This should be called whenever an update is made to AdlerData so that it is clear what is the most up-to-date version of AdlerData.

set_modelId(model_name, end_mjd, data_timespan, n_new_nights)[source]

Function for setting the modelId parameter.

Parameters:
  • model_name (str) – The model name for the given model calculated. One of “HG”, “HG1G2”, “HG12”, “HG12_Pen16”, “LinearPhaseFunc”, “median”, “mean”.

  • end_mjd (float) – The MJD set as the maximum MJD to consider in the model.

  • data_timespan (float) – The number of nights of data that is considered for the given model.

  • n_new_nights (float) – The number of nights of data that are considered as “new observations” in calculating outliers.

populate_filter_dependent_parameters(filter_name, **kwargs)[source]

Convenience method to correctly populate the filter-dependent parameters for a given filter. Only the supplied arguments to the method will be updated, allowing for only some values to be populated if desired.

filter_namestr

The one-letter name of the filter of interest.

**kwargsFilterDependentAdler attributes

The attribute names of the parameters you wish to update. See docs for FilterDependentAdler class for definitions of each attribute. Valid keyword arguments are: model_name, phaseAngle_min, phaseAngle_range, observationTime_max, arc, nobs, n_outliers, n_std_outliers, sustained_outliers.

populate_phase_parameters(filter_name, **kwargs)[source]

Convenience method to correctly populate phase curve parameters for a given filter and model. Only the supplied arguments to the method will be updated, allowing for only some values to be populated if desired. This method will automatically populate filter-dependent parameters also.

Parameters:
  • filter_name (str) – The one-letter name of the filter in which the phase curve was calculated.

  • **kwargs (FilterDependentAdler and PhaseModelDependentAdler attributes) – The attribute names of the parameters you wish to update. See docs for FilterDependentAdler and PhaseModelDependentAdler classes for definitions of each attribute. Valid keyword arguments are: model_name, phaseAngle_min, phaseAngle_range, observationTime_max, arc, nobs, n_outliers, n_std_outliers, sustained_outliers, H, H_err, phase_parameter_1, phase_parameter_1_err, phase_parameter_2, phase_parameter_2_err. Note that to update any of the model-dependent parameters (H, H_err, etc.), you WILL need to supply a model_name.

populate_avg_mag_parameters(filter_name, **kwargs)[source]

Convenience method to correctly populate average magnitude model parameters for a given filter and model. Only the supplied arguments to the method will be updated, allowing for only some values to be populated if desired. This method will automatically populate filter-dependent parameters also.

Parameters:
  • filter_name (str) – The one-letter name of the filter in which the model was calculated.

  • **kwargs (FilterDependentAdler and AvgMagModelDependentAdler attributes) – The attribute names of the parameters you wish to update. See docs for FilterDependentAdler and AvgMagModelDependentAdler classes for definitions of each attribute. Valid keyword arguments are: model_name, phaseAngle_min, phaseAngle_range, observationTime_max, arc, nobs, n_outliers, n_std_outliers, sustained_outliers, avg_mag, std_mag. Note that to update any of the model-dependent parameters (avg_mag, std_mag), you WILL need to supply a model_name.

populate_source_flags(filter_name, modelId, df, **kwargs)[source]

Convenience method to correctly populate the source outlier flags for a given filter and modelId. Only the supplied arguments to the method will be updated, allowing for only some values to be populated if desired. Observations detected as outliers (source flags) must be supplied in a pandas.DataFrame. This method will automatically populate filter-dependent parameters also.

Parameters:
  • filter_name (str) – The one-letter name of the filter in which the model was calculated.

  • modelId (str) – modelId that the given outliers correspond to. This is used to check the supplied modelId from the user matches that stored in AdlerData.

  • df (pandas.DataFrame) – DataFrame of the observations that are identified as outliers. Must contain columns diaSourceId, midPointMjdTai, mag_diff, std_diff.

  • **kwargs (FilterDependentAdler and AvgMagModelDependentAdler attributes) – The attribute names of the parameters you wish to update. See docs for FilterDependentAdler classes for definitions of each attribute. Valid keyword arguments are: model_name, phaseAngle_min, phaseAngle_range, observationTime_max, arc, nobs, n_outliers, n_std_outliers, sustained_outliers.

populate_from_database(filepath, modelId=None)[source]

Populates the AdlerData object with information from the most recent timestamped entry for the ssObjectId in a given database.

Parameters:
  • filepath (path-like object) – Filepath with the location of the output SQL database. Note that for now, we assume only one table with all the data.

  • modelId (str, optional) – modelId for the model of interest that should be recovered. Default: None.

print_data()[source]

Convenience method to clearly print the stored values.

get_phase_parameters_in_filter(filter_name, model_name=None)[source]

Convenience method to return the phase parameters in a specific filter and model.

Parameters:
  • filter_name (str) – The filter of interest.

  • model_name (str, optional) – The model name of the model of interest. If this is not supplied, the code will not return any model-dependent parameters. Default None.

Returns:

output_obj – Object containing phase curve parameters for the specified filter and model.

Return type:

PhaseParameterOutput object

get_avg_mag_parameters_in_filter(filter_name, model_name=None)[source]

Convenience method to return the average magnitude parameters in a specific filter and model.

Parameters:
  • filter_name (str) – The filter of interest.

  • model_name (str, optional) – The model name of the model of interest. If this is not supplied, the code will not return any model-dependent parameters. Default None.

Returns:

output_obj – Object containing average magnitude model parameters for the specified filter and model.

Return type:

AvgMagParameterOutput object

_get_database_connection(filepath, table_name=None)[source]

Returns the connection to the output SQL database, creating it and the given table if it does not exist.

Parameters:
  • filepath (path-like object) – Filepath with the location of the output SQL database.

  • table_name (str, optional) – Name of the table to create if it doesn’t exist. (This replaces the create_new argument)

Returns:

con – The connection to the output database.

Return type:

sqlite3 Connection object

_get_row_data_and_columns(table_name)[source]

Collects all of the data present in the AdlerData object as a list with a corresponding list of column names, in preparation for a row to be written to a SQL database in the given table_name.

Returns:

table_name – Name of the table that we want to collect data for in preparation for writing to the database.

Return type:

str

_get_database_columns(con, table_name)[source]

Gets a list of the current columns in a given table in a SQL database.

Parameters:
  • con (sqlite3 Connection object) – The connection to the output SQL database.

  • table_name (str) – The name of the relevant table in the database.

Returns:

List of current columns existing in the table.

Return type:

list of str

_get_tables(con)[source]

Gets a list of the current tables in a SQL database.

Parameters:

con (sqlite3 Connection object) – The connection to the output SQL database.

Returns:

List of current tables existing in the database.

Return type:

list of str

_ensure_columns(con, table_name, current_columns, required_columns)[source]

Creates new columns in a given table of a SQL database as needed by checking the list of current columns against a list of required columns.

Parameters:
  • con (sqlite3 Connection object) – The connection to the output SQL database.

  • table_name (str) – The name of the relevant table in the database.

  • current_columns (list of str) – A list of the columns already existing in the database table.

  • required_columns (list of str) – A list of the columns needed in the database table.

_write_table(filepath, table_name)[source]

Function for writing information to a given table in the given database. Connects to the database and creates table if necessary, gathers data from AdlerData, ensures required columns are present and writes to the database.

Parameters:
  • filepath (path-like object) – Filepath with the location of the output SQL database.

  • table_name (str) – Name of table to write to. Must be one of AdlerData, FilterDependentAdler, PhaseModelDependentAdler, AvgMagModelDependentAdler

_get_model_name()[source]

Returns the model_name by parsing the modelId

Return type:

Name of the model specified in self.modelId

write_to_database(filepath, write_model_data=False)[source]

Writes all of the relevant data contained within the AdlerData object to a SQLite database.

Parameters:
  • filepath (path-like object) – Filepath with the location of the output SQL database.

  • write_model_data (Boolean, optional) – A flag to set whether to write out specific model data to AdlerData. Default: False.

class PhaseModelDependentAdler[source]

Dataclass containing phase-model-dependent values generated by Adler. Note that NaN indicates a value that has not yet been populated.

Attributes:

filter_namestr

The filter for which these values are calculated.

model_namestr

The phase model for which these values were calculated. Example: “HG”, “HG1G2”, “linear”.

Hfloat, optional

The absolute magnitude. Default NaN.

H_errfloat, optional

Error in absolute magnitude. Default NaN.

phase_parameter_1float, optional

The first parameter of the phase model. May be the only parameter. For example, G in the HG model. Default NaN.

phase_parameter_1_errfloat, optional

The error on the first parameter of the phase model. Default NaN.

phase_parameter_2float, optional

The second parameter of the phase model. May not exist for this model. Default NaN.

phase_parameter_2_errfloat, optional

The error on the second parameter of the phase model. Default NaN.

filter_name: str[source]
model_name: str[source]
H: float[source]
H_err: float[source]
phase_parameter_1: float[source]
phase_parameter_1_err: float[source]
phase_parameter_2: float[source]
phase_parameter_2_err: float[source]
class AvgMagModelDependentAdler[source]

Dataclass containing model-dependent values for the simple average magnitude model pgenerated by Adler. Note that NaN indicates a value that has not yet been populated.

Attributes:

filter_namestr

The filter for which these values are calculated.

model_namestr

The model for which these values were calculated. Example: “median”, “mean”.

avg_magfloat, optional

Average magnitude of the measurements used to calculate the model. Default NaN.

std_magfloat, optional

Standard deviation of the measurements used to calculate the model. Default NaN.

filter_name: str[source]
model_name: str[source]
avg_mag: float[source]
std_mag: float[source]
class PhaseParameterOutput[source]

Empty convenience class so that the output of AdlerData.get_phase_parameters_in_filter is an object.

class AvgMagParameterOutput[source]

Empty convenience class so that the output of AdlerData.get_avg_mag_parameters_in_filter is an object.

class AdlerSourceFlags[source]

Class for storing Adler-determined outlier information.

Attributes:

ssObjectIdstr

ssObjectId of the object of interest.

filter_namestr

Filter the observation was taken in.

modelIdstr

modelId for the model that the outliers are compared to.

n_outliersint

Number of observations identified as outliers.

n_std_outliersint, optional

Number of outliers detected for the given model in sigma space.

diaSourceIdarray_like of ints or strs

Unique identifier of the observation.

midPointMjdTaiarray_like of floats

Observation timestamps.

mag_diffarray_like of floats

Differences in (reduced) magnitude between the observations and the model.

std_diffarray_like of floats

Deviation (in terms of the observations uncertainties) between the observations and the model.

ssObjectId: str[source]
filter_name: str[source]
modelId: str[source]
n_outliers: int[source]
n_std_outliers: int[source]
diaSourceId: numpy.ndarray[source]
midPointMjdTai: numpy.ndarray[source]
mag_diff: numpy.ndarray[source]
std_diff: numpy.ndarray[source]
classmethod construct_source_flags_from_data_table(ssObjectId, filter_name, modelId, df)[source]

Method for constructing the AdlerSourceFlags object from a dataframe.

Parameters:
  • ssObjectId (str) – ssObjectId of the object of interest.

  • filter_name (str)

  • in. (Filter the observation was taken)

  • modelId (str) – modelId for the model that the outliers are compared to.

  • df (pandas.DataFrame) – DataFrame of the observations that are identified as outliers. Must contain columns diaSourceId, midPointMjdTai, mag_diff, std_diff

Returns:

Object containing the source flags information on outliers identified.

Return type:

AdlerSourceFlags object

_get_database_connection(filepath, create_new=False)[source]

Returns the connection to the output SQL database, creating it and the AdlerSource Flags table if it does not exist.

Parameters:
  • filepath (path-like object) – Filepath with the location of the output SQL database.

  • create_new (Boolean) – Whether to create the database if it doesn’t already exist. Default is False.

Returns:

con – The connection to the output database.

Return type:

sqlite3 Connection object

write_flags_to_database(filepath, table_name='AdlerSourceFlags')[source]

Writes the information from AdlerSourceFlags to the given database.

Parameters:
  • filepath (path-like object) – Path to the output database.

  • table_name (str, optional) – Name of the table to write the flags to. Default: AdlerSourceFlags.

class FilterDependentAdler[source]

Dataclass containing filter-dependent values generated by Adler. Note that NaN indicates a value that has not yet been populated.

Attributes:

filter_namestr

The filter for which these values are calculated.

phaseAngle_minfloat, optional

Minimum phase angle of observations used in fitting model (degrees).

phaseAngle_rangefloat, optional

Max minus min phase angle range of observations used in fitting model (degrees).

observationTime_maxfloat, optional

Maximum time of observation used in fitting the model (in modified Julian day).

arc: float, optional

Observational arc used to fit model (days).

nobsint, optional

Number of observations used in fitting model.

n_outliersint, optional

Number of outliers detected for the given model.

n_std_outliersint, optional

Number of outliers detected for the given model in sigma space.

sustained_outliersfloat, optional

Magnitude difference between old and new observations.

model_namestr, optional

Name of the model computed. Must be one of “HG”, “HG1G2”, “HG12”, “HG12_Pen16”, “LinearPhaseFunc”, “median”, “mean”.

model_dependent_valuesPhaseModelDependentAdler or AvgMagModelDependentAdler object, optional

PhaseModelDependentAdler or AvgMagModelDependentAdler object storing phase-model or average-magnitude-model parameters for the given model. Default: None.

source_flagsAdlerSourceFlags, optional

AdlerSourceFlags object storing the information on specific observations identified as outliers compared to the given model.

filter_name: str[source]
phaseAngle_min: float[source]
phaseAngle_range: float[source]
observationTime_max: float[source]
arc: float[source]
nobs: int = 0[source]
n_outliers: int = 0[source]
n_std_outliers: int = 0[source]
sustained_outliers: float[source]
model_name: str = ''[source]
model_dependent_values: PhaseModelDependentAdler | AvgMagModelDependentAdler | None = None[source]
source_flags: AdlerSourceFlags | None = None[source]