Skip to content

Commit

Permalink
Add error message if errorbar variable isn't found
Browse files Browse the repository at this point in the history
  • Loading branch information
philbull authored Jul 20, 2018
1 parent 8a4f299 commit d577fb6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions hera_pspec/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ def delay_spectrum(uvp, blpairs, spw, pol, average_blpairs=False,
else:
c = cax.get_color()
cax = ax.errorbar(x, np.abs(y), fmt='none', ecolor=c, yerr=cast(errs[i]), **kwargs)
else:
raise KeyError("Error variable '%s' not found in stats_array of UVPSpec object." % error)

# If blpairs were averaged, only the first blpair in the group
# exists any more (so skip the rest)
Expand Down Expand Up @@ -384,18 +386,20 @@ def delay_waterfall(uvp, blpairs, spw, pol, component='real', average_blpairs=Fa
Nkeys = len(waterfall)
Nside = int(np.ceil(np.sqrt(Nkeys)))
fig, axes = plt.subplots(Nside, Nside, figsize=figsize)

# Ensure axes is an ndarray
if isinstance(axes, matplotlib.axes._subplots.Axes):
axes = np.array([[axes]])
if isinstance(axes, list):
axes = np.array(axes)
# ensure its 2D and get side lengths

# Ensure its 2D and get side lengths
if axes.ndim == 1:
axes = axes[:, None]
assert axes.ndim == 2, "input axes must have ndim == 2"
Nvert, Nhorz = axes.shape

# get LST range: setting y-ticks is tricky due to LST wrapping...
# Get LST range: setting y-ticks is tricky due to LST wrapping...
y = uvp_plt.lst_avg_array[uvp_plt.key_to_indices(waterfall.keys()[0])[1]]
if lst_in_hrs:
lst_units = "Hr"
Expand Down Expand Up @@ -424,7 +428,7 @@ def delay_waterfall(uvp, blpairs, spw, pol, component='real', average_blpairs=Fa
psunits = psunits.replace("beam normalization not specified",
r"{\rm unnormed}")

# iterate over waterfall keys
# Iterate over waterfall keys
keys = waterfall.keys()
k = 0
for i in range(Nvert):
Expand Down Expand Up @@ -483,7 +487,8 @@ def delay_waterfall(uvp, blpairs, spw, pol, component='real', average_blpairs=Fa
units = "$%sP(k_\parallel)$ $[%s]$" % (logunits, psunits)

spwrange = np.around(np.array(uvp_plt.get_spw_ranges()[spw][:2]) / 1e6, 2)
axes[0][0].get_figure().suptitle("{}\n{} polarization | {} -- {} MHz".format(units, pol, *spwrange), y=1.03, fontsize=14)
axes[0][0].get_figure().suptitle("{}\n{} polarization | {} -- {} MHz".format(units, pol, *spwrange),
y=1.03, fontsize=14)

# Return Axes
if new_plot:
Expand Down

0 comments on commit d577fb6

Please sign in to comment.