Add of the function get_nearest_valid_exposure_position
@@ -23,3 +23,12 @@ def get_axes(ax1, ax2, width, height, args1, args2, kwargs1=None, kwargs2=None):
raise ValueError("Either both or no Axes must be provided")
return ax1, ax2
+
+
+def get_nearest_valid_exposure_position(exposure, position=None):
+ import numpy as np
+ mask_exposure = exposure > 0.0*exposure.unit
+ mask_exposure = mask_exposure.reduce_over_axes(func=np.logical_or)
+ if not position:
+ position = mask_exposure.geom.center_skydir
+ return mask_exposure.mask_nearest_position(position)
