calibpipe.utils package#

class calibpipe.utils.Observatory(**kwargs: Any)[source]#

Bases: Component

Class, defining an observatory object.

latitude#

Observatory latitude in degrees

longitude#

Observatory longitude in degrees

elevation#

Observatory elevation in meters

seasons#

Observatory meteorological seasons

version#

Observatory configuration version

__init__(config=None, parent=None, **kwargs)[source]#
Parameters:
configtraitlets.loader.Config

Configuration specified by config file or cmdline arguments. Used to set traitlet values.

parent: Tool or Component

If a Component is created by another Component or Tool, you need to pass the creating Component as parent, e.g. parent=self. This makes sure the config is correctly handed down to the child components. Do not pass config in this case.

kwargs

Traitlets to be overridden. TraitError is raised if kwargs contains a key that does not correspond to a traitlet.

name#

Observatory name

classmethod from_db(database_configuration, site, version)[source]#

Create Observatory object from the DB record.

property coordinates#

Observatory coordinates.

Returns:
astropy.coordinates.Latitude

Observatory’s latitude.

astropy.coordinates.Longitude

Observatory’s longitude.

property containers#

Observatory containers.

Returns:
tuple(ObservatoryContainer, SeasonContainer)

Containers with observatory and season configuration data used to store the observatory configuration in the DB.

select_season_data(data, season_name)[source]#

Select data that belongs to a given season.

Parameters:
dataastropy.table.Table

Astropy table with meteorological data. Must contain ‘Timestamp’ column with astropy.time.Time

season_namestr

Season name.

Returns:
astropy.table.Table

Selected data table according to provided season.

get_astronomical_night(timestamp)[source]#

Calculate astronomical night.

Calculates the astronomical dusk and dawn (i.e. when the Sun is 18deg below the horizon) for this observatory around a given timestamp. Returned values represent the UTC timestamps of dusk and dawn.

Parameters:
timestamp: datetime

The date for which we want to request for data.

Returns:
tuple(datetime, datetime)

The astronomical dusk and dawn.

Raises:
ValueError

If the provided timestamp corresponds to daytime.

get_season_from_timestamp(timestamp)[source]#

Get the name of the season corresponding to the timestamp.

Parameters:
timestampdatetime
Returns:
str

Season name.

class calibpipe.utils.Season(**kwargs: Any)[source]#

Bases: Component

Class, describing nature seasons.

start_month#

Start month of the season

stop_month#

Stop month of the season

start_day#

Start day of the season

stop_day#

Stop day of the season

__init__(config=None, parent=None, **kwargs)[source]#
Parameters:
configtraitlets.loader.Config

Configuration specified by config file or cmdline arguments. Used to set traitlet values.

parent: Tool or Component

If a Component is created by another Component or Tool, you need to pass the creating Component as parent, e.g. parent=self. This makes sure the config is correctly handed down to the child components. Do not pass config in this case.

kwargs

Traitlets to be overridden. TraitError is raised if kwargs contains a key that does not correspond to a traitlet.

name#

Season name (e.g. summer)

static cfg_from_record(record)[source]#

Return configuration dictionary from the DB record.

classmethod from_record(record)[source]#

Create Season object from the DB record or container as_dict() representation.

Parameters:
recorddict

Dictionary representation of a SeasonContainer.

property start#

Start of the season.

Returns:
tuple(int, int)

Season start (month, day).

property stop#

End of the season.

Returns:
tuple(int, int)

Season stop (month, day).

property months#

List of months in the season.

Returns:
list(int)

List of month numbers in the season.

property reference_dates#

Reference season start and stop dates based on internal leap year.

Returns:
tuple(date, date)

Tuple of datetime.date objects (start, stop).

container(observatory_name, observatory_version)[source]#

Season container.

Parameters:
observatory_namestr

Name of the observatory, to which the season belongs.

observatory_versionint

Version of the observatory, to which the season belongs.

Returns:
SeasonContainer
class calibpipe.utils.SeasonAlias(*values)[source]#

Bases: Enum

Seasons aliases.

SUMMER = 'SUMMER'#
WINTER = 'WINTER'#
SPRING = 'INTERMEDIATE'#
FALL = 'INTERMEDIATE'#
INTERMEDIATE = 'INTERMEDIATE'#
class calibpipe.utils.ObservatoryContainer(prefix=None, **fields)[source]#

Bases: Container

Observatory container.

Attributes:
nameField(default=None)

Observatory name

latitudeField(default=None, unit=deg)

Observatory latitude

longitudeField(default=None, unit=deg)

Observatory longitude

elevationField(default=None, unit=m)

Observatory elevation

versionField(default=None)

Observatory configuration version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

name#
latitude#
longitude#
elevation#
version#
meta#
prefix#
default_prefix = 'observatory'#
fields = {'elevation': Field(default=None, unit=m), 'latitude': Field(default=None, unit=deg), 'longitude': Field(default=None, unit=deg), 'name': Field(default=None), 'version': Field(default=None)}#
class calibpipe.utils.SeasonContainer(prefix=None, **fields)[source]#

Bases: Container

Season container.

Attributes:
startField(default=None)

Season start timestamp

stopField(default=None)

Season stop timestamp

nameField(default=None)

Season name

aliasField(default=None)

Season alias

name_ObservatoryField(default=None)

Reference observatory name

version_ObservatoryField(default=None)

Reference observatory configuration version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

start#
stop#
name#
alias#
name_Observatory#
version_Observatory#
meta#
prefix#
default_prefix = 'season'#
fields = {'alias': Field(default=None), 'name': Field(default=None), 'name_Observatory': Field(default=None), 'start': Field(default=None), 'stop': Field(default=None), 'version_Observatory': Field(default=None)}#

Submodules#

calibpipe.utils.observatory module#

Utility module to manage observatory data.

class calibpipe.utils.observatory.SeasonAlias(*values)[source]#

Bases: Enum

Seasons aliases.

SUMMER = 'SUMMER'#
WINTER = 'WINTER'#
SPRING = 'INTERMEDIATE'#
FALL = 'INTERMEDIATE'#
INTERMEDIATE = 'INTERMEDIATE'#
class calibpipe.utils.observatory.Season(**kwargs: Any)[source]#

Bases: Component

Class, describing nature seasons.

start_month#

Start month of the season

stop_month#

Stop month of the season

start_day#

Start day of the season

stop_day#

Stop day of the season

__init__(config=None, parent=None, **kwargs)[source]#
Parameters:
configtraitlets.loader.Config

Configuration specified by config file or cmdline arguments. Used to set traitlet values.

parent: Tool or Component

If a Component is created by another Component or Tool, you need to pass the creating Component as parent, e.g. parent=self. This makes sure the config is correctly handed down to the child components. Do not pass config in this case.

kwargs

Traitlets to be overridden. TraitError is raised if kwargs contains a key that does not correspond to a traitlet.

name#

Season name (e.g. summer)

static cfg_from_record(record)[source]#

Return configuration dictionary from the DB record.

classmethod from_record(record)[source]#

Create Season object from the DB record or container as_dict() representation.

Parameters:
recorddict

Dictionary representation of a SeasonContainer.

property start#

Start of the season.

Returns:
tuple(int, int)

Season start (month, day).

property stop#

End of the season.

Returns:
tuple(int, int)

Season stop (month, day).

property months#

List of months in the season.

Returns:
list(int)

List of month numbers in the season.

property reference_dates#

Reference season start and stop dates based on internal leap year.

Returns:
tuple(date, date)

Tuple of datetime.date objects (start, stop).

container(observatory_name, observatory_version)[source]#

Season container.

Parameters:
observatory_namestr

Name of the observatory, to which the season belongs.

observatory_versionint

Version of the observatory, to which the season belongs.

Returns:
SeasonContainer
class calibpipe.utils.observatory.Observatory(**kwargs: Any)[source]#

Bases: Component

Class, defining an observatory object.

latitude#

Observatory latitude in degrees

longitude#

Observatory longitude in degrees

elevation#

Observatory elevation in meters

seasons#

Observatory meteorological seasons

version#

Observatory configuration version

__init__(config=None, parent=None, **kwargs)[source]#
Parameters:
configtraitlets.loader.Config

Configuration specified by config file or cmdline arguments. Used to set traitlet values.

parent: Tool or Component

If a Component is created by another Component or Tool, you need to pass the creating Component as parent, e.g. parent=self. This makes sure the config is correctly handed down to the child components. Do not pass config in this case.

kwargs

Traitlets to be overridden. TraitError is raised if kwargs contains a key that does not correspond to a traitlet.

name#

Observatory name

classmethod from_db(database_configuration, site, version)[source]#

Create Observatory object from the DB record.

property coordinates#

Observatory coordinates.

Returns:
astropy.coordinates.Latitude

Observatory’s latitude.

astropy.coordinates.Longitude

Observatory’s longitude.

property containers#

Observatory containers.

Returns:
tuple(ObservatoryContainer, SeasonContainer)

Containers with observatory and season configuration data used to store the observatory configuration in the DB.

select_season_data(data, season_name)[source]#

Select data that belongs to a given season.

Parameters:
dataastropy.table.Table

Astropy table with meteorological data. Must contain ‘Timestamp’ column with astropy.time.Time

season_namestr

Season name.

Returns:
astropy.table.Table

Selected data table according to provided season.

get_astronomical_night(timestamp)[source]#

Calculate astronomical night.

Calculates the astronomical dusk and dawn (i.e. when the Sun is 18deg below the horizon) for this observatory around a given timestamp. Returned values represent the UTC timestamps of dusk and dawn.

Parameters:
timestamp: datetime

The date for which we want to request for data.

Returns:
tuple(datetime, datetime)

The astronomical dusk and dawn.

Raises:
ValueError

If the provided timestamp corresponds to daytime.

get_season_from_timestamp(timestamp)[source]#

Get the name of the season corresponding to the timestamp.

Parameters:
timestampdatetime
Returns:
str

Season name.

calibpipe.utils.observatory_containers module#

class calibpipe.utils.observatory_containers.ObservatoryContainer(prefix=None, **fields)[source]#

Bases: Container

Observatory container.

Attributes:
nameField(default=None)

Observatory name

latitudeField(default=None, unit=deg)

Observatory latitude

longitudeField(default=None, unit=deg)

Observatory longitude

elevationField(default=None, unit=m)

Observatory elevation

versionField(default=None)

Observatory configuration version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

name#
latitude#
longitude#
elevation#
version#
meta#
prefix#
default_prefix = 'observatory'#
fields = {'elevation': Field(default=None, unit=m), 'latitude': Field(default=None, unit=deg), 'longitude': Field(default=None, unit=deg), 'name': Field(default=None), 'version': Field(default=None)}#
class calibpipe.utils.observatory_containers.SeasonContainer(prefix=None, **fields)[source]#

Bases: Container

Season container.

Attributes:
startField(default=None)

Season start timestamp

stopField(default=None)

Season stop timestamp

nameField(default=None)

Season name

aliasField(default=None)

Season alias

name_ObservatoryField(default=None)

Reference observatory name

version_ObservatoryField(default=None)

Reference observatory configuration version

metadict

dict of attached metadata

prefixstr

Prefix attached to column names when saved to a table or file

start#
stop#
name#
alias#
name_Observatory#
version_Observatory#
meta#
prefix#
default_prefix = 'season'#
fields = {'alias': Field(default=None), 'name': Field(default=None), 'name_Observatory': Field(default=None), 'start': Field(default=None), 'stop': Field(default=None), 'version_Observatory': Field(default=None)}#