observing_conditions#

Methods for dealing with observing conditions.

class hsr4hci.observing_conditions.ObservingConditions[source]#

This class provides a wrapper around different representations of the observing conditions (dictionary, numpy array and pandas data frame), and provides the option to select a subset of them.

Parameters:

observing_conditions – The observing conditions in the form of a dictionary where each key maps onto a 1D numpy array that contains, for example, the wind speed.

__init__(observing_conditions)[source]#
Parameters:

observing_conditions (Dict[str, ndarray]) –

as_array(selected_keys='all')[source]#

Return the subset of observing conditions selected by selected_keys as a numpy array.

Parameters:

selected_keys (Optional[Union[List[str], str]]) – A valid specification of a subset of observing conditions. Either None (to select no OC at all), or a list of keys, or “all” (to select all available observing conditions).

Returns:

A 2D numpy array of shape (n_frames, n_obscon) containing the selected observing conditions.

Return type:

ndarray

as_dataframe(selected_keys='all')[source]#

Return the subset of observing conditions selected by selected_keys as a pandas data frame.

Parameters:

selected_keys (Optional[Union[List[str], str]]) – A valid specification of a subset of observing conditions. Either None (to select no OC at all), or a list of keys, or “all” (to select all available observing conditions).

Returns:

A pandas data frame containing the selected observing conditions.

Return type:

DataFrame

as_dict(selected_keys='all')[source]#

Return the subset of observing conditions selected by selected_keys as a dictionary.

Parameters:

selected_keys (Optional[Union[List[str], str]]) – A valid specification of a subset of observing conditions. Either None (to select no OC at all), or a list of keys, or “all” (to select all available observing conditions).

Returns:

A dictionary containing the selected observing conditions.

Return type:

Dict[str, ndarray]

property available_keys: List[str]#

Return a sorted list of the available observing conditions.

Returns:

A sorted list of the available observing conditions.

property n_frames: int#

Get the number of frames from the observing conditions.

Returns:

An integer containing the number of frames.

hsr4hci.observing_conditions.get_observing_conditions(parameter_name, timestamps)[source]#

This is a convenience wrapper to query the ESO ambient condition archives for a given parameter, interpolate the results, and evaluate them at the requested timestamps.

Parameters:
  • parameter_name (str) – Name of the parameter to retrieve from the archive. This needs to be resolvable into a parameter key and archive by resolve_parameter_name().

  • timestamps (ndarray) – A 1D numpy array of floats, containing the UTC timestamps of the frames in the stack.

Returns:

A 1D numpy array with shape (n_frames, ) which contains an interpolated value of the target parameter for every frame.

Return type:

Tuple[ndarray, Dict[str, ndarray]]

hsr4hci.observing_conditions.interpolate_observing_conditions(timestamps, df, parameter_key)[source]#

Take the values of the observing conditions in the data frame df and interpolate them temporally so that we get values for the timestamp of each frame.

The interpolation procedure is based on Cubic splines. See https://stats.stackexchange.com/a/511394 for the original idea.

Parameters:
  • timestamps (ndarray) – A 1D numpy array of floats, containing the UTC timestamps of the frames in the stack.

  • df (DataFrame) – A data frame containing the result from querying one of the ESO archives (e.g., query_meteo()).

  • parameter_key (str) – The key under which a parameter is available from the respective archive. (See also query_archive()).

Returns:

A 1D numpy array with shape (n_frames, ) which contains an interpolated value of the target parameter for every frame.

Return type:

ndarray

hsr4hci.observing_conditions.query_archive(start_date, end_date, archive, parameter_key)[source]#

Send a request to one of ESO’s ambient condition query forms [1] to retrieve the values of a particular observing condition.

[1]: https://archive.eso.org/cms/eso-data/ambient-conditions/paranal-ambient-query-forms.html

Parameters:
  • start_date (str) – The start datetime (in UTC) as a string in ISO 8061 format. Example: “2012-12-20T20:00:00.0000”.

  • end_date (str) – The end datetime (in UTC) as a string in ISO 8061 format. Example: “2012-12-21T10:00:00.0000”.

  • archive (str) –

    The name of the archive to which to send the query. Currently, the following archives are supported:

    • ”meteo”

    • ”dimm_old”

    • ”dimm_new”

    • ”mass”

    • ”lhatpro”

    • ”lhatpro_irt”

    See [1] for more information about these archives.

  • parameter_key (str) – The key under which a parameter is available from the respective archive. These keys can be reverse-engineered from the source code of the respective archive. For example, “press” will get you the air pressure, or more precisely, the “temporal (1 minute) mean of observatory site ambient barometric air pressure measured at ground during measurement period [hPa].” For the default parameters, resolve_parameter_name() will resolve “intuitive” parameter names (such as, e.g., “air_pressure”) to the correct, archive-specific keys.

Returns:

A data frame with the datetime and timestamp, the integration time (in seconds) and the value of the requested parameter averaged over the integration time.

Return type:

DataFrame

hsr4hci.observing_conditions.resolve_parameter_name(parameter_name, obs_date)[source]#

Resolves a parameter_name into a dictionary that contains information about which archive the parameter can be obtained from, using which parameter_key.

Parameters:
  • parameter_name (str) – Name of a parameter (e.g., “air_pressure”).

  • obs_date (datetime) – Date at which the data set was observed.

Returns:

A 3-tuple (archive, parameter_key, description) which tells us from which ESO ambient server we can retrieve the parameter and which key we have to use for the query.

Return type:

Tuple[str, str, str]