Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ax is None:
ax = plt.gca()
if style_kwargs is None:
style_kwargs = {}
style_kwargs = dict(style_kwargs)
style_kwargs.setdefault('linestyle', '-')
style_kwargs.setdefault('fmt', '-')
# Populate time window if needed.
time = Time(time)
if time.isscalar:
time = time + np.linspace(-12, 12, 100)*u.hour
elif len(time) == 1:
warnings.warn('You used a Time array of length 1. You probably meant '
'to use a scalar. (Or maybe a list with length > 1?).',
PlotWarning)
# Calculate parallactic angle.
p_angle = observer.parallactic_angle(time, target)
# Some checks & info for labels.
assert len(time) == len(p_angle)
if not hasattr(target, 'name'):
target_name = ''
else:
target_name = target.name
style_kwargs.setdefault('label', target_name)
# Plot data.
ax.plot_date(time.plot_date, p_angle, **style_kwargs)
class TargetNeverUpWarning(AstroplanWarning):
"""Target never rises above horizon"""
pass
class OldEarthOrientationDataWarning(AstroplanWarning):
"""Using old Earth rotation data from IERS"""
pass
class PlotWarning(AstroplanWarning):
"""Warnings dealing with the plotting aspects of astroplan"""
pass
class PlotBelowHorizonWarning(PlotWarning):
"""Warning for when something is hidden on a plot because it's below the horizon"""
pass
style_kwargs.setdefault('fmt', '-')
if hasattr(time, 'utcoffset') and use_local_tz:
tzoffset = time.utcoffset()
tzname = time.tzname()
else:
tzoffset = 0
tzname = 'UTC'
# Populate time window if needed.
time = Time(time)
if time.isscalar:
time = time + np.linspace(-12, 12, 100)*u.hour
elif len(time) == 1:
warnings.warn('You used a Time array of length 1. You probably meant '
'to use a scalar. (Or maybe a list with length > 1?).',
PlotWarning)
if not isinstance(targets, Sequence):
targets = [targets]
for target in targets:
# Calculate airmass
airmass = observer.altaz(time + tzoffset, target).secz
# Mask out nonsense airmasses
masked_airmass = np.ma.array(airmass, mask=airmass < 1)
# Some checks & info for labels.
try:
target_name = target.name
except AttributeError:
target_name = ''