Skip to content

Commit

Permalink
Merge pull request #154 from bmorris3/plot-am
Browse files Browse the repository at this point in the history
Plot airmass
  • Loading branch information
Brett M. Morris committed Mar 24, 2016
2 parents 4d00280 + 47d257f commit c830beb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion astroplan/plots/time_dependent.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ def _secz_to_altitude(secant_z):
"""
return np.degrees(np.pi/2 - np.arccos(1./secant_z))


def _has_twin(ax):
"""
Solution for detecting twin axes built on `ax`. Courtesy of
Jake Vanderplas http://stackoverflow.com/a/36209590/1340208
"""
for other_ax in ax.figure.axes:
if other_ax is ax:
continue
if other_ax.bbox.bounds == ax.bbox.bounds:
return True
return False


def plot_airmass(target, observer, time, ax=None, style_kwargs=None,
style_sheet=None, brightness_shading=False,
altitude_yaxis=False):
Expand Down Expand Up @@ -171,7 +185,7 @@ def plot_airmass(target, observer, time, ax=None, style_kwargs=None,
ax.set_ylabel("Airmass")
ax.set_xlabel("Time from {0} [UTC]".format(min(time).datetime.date()))

if altitude_yaxis:
if altitude_yaxis and not _has_twin(ax):
altitude_ticks = np.array([90, 60, 50, 40, 30, 20])
airmass_ticks = 1./np.cos(np.radians(90 - altitude_ticks))

Expand Down

0 comments on commit c830beb

Please sign in to comment.