Skip to content
Snippets Groups Projects
Commit 752c542c authored by ChiWai Chan's avatar ChiWai Chan
Browse files

horizon.py: add global min and max horizon distance properties.

parent 64938148
No related branches found
No related tags found
1 merge request!114Plot horizon distance from ranking statistics
......@@ -57,6 +57,8 @@ class HorizonDistance:
Returns:
An instance of HorizionDistance.
"""
self._min = None
self._max = None
self.verbose = verbose
self.horizon_history_dict = horizon_history_dict
......@@ -133,6 +135,28 @@ class HorizonDistance:
raise UnknownExtensionError("Cannot determine the extension of the input data sources, please prepare files with the following extension: ('.gz' or '.cache').")
@property
def min(self):
"""Return the global minimum of the horizon distance."""
if self._min:
return self._min
gminh = 1e32
for ifo, history in self.horizon_history_dict.items():
gminh = min(gminh, min(history.values()))
self._min = gminh
return gminh
@property
def max(self):
"""Return the global minimum of the horizon distance."""
if self._max:
return self._max
gmaxh = -1e32
for ifo, history in self.horizon_history_dict.items():
gmaxh = max(gmaxh, max(history.values()))
self._max = gmaxh
return gmaxh
def savefig(self, output, figsize=(12,4), limits=None, title=None):
"""Save the horizon distance plot to disk.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment