Skip to content

Commit d577fb6

Browse files
authored
Add error message if errorbar variable isn't found
1 parent 8a4f299 commit d577fb6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

hera_pspec/plot.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ def delay_spectrum(uvp, blpairs, spw, pol, average_blpairs=False,
180180
else:
181181
c = cax.get_color()
182182
cax = ax.errorbar(x, np.abs(y), fmt='none', ecolor=c, yerr=cast(errs[i]), **kwargs)
183+
else:
184+
raise KeyError("Error variable '%s' not found in stats_array of UVPSpec object." % error)
183185

184186
# If blpairs were averaged, only the first blpair in the group
185187
# exists any more (so skip the rest)
@@ -384,18 +386,20 @@ def delay_waterfall(uvp, blpairs, spw, pol, component='real', average_blpairs=Fa
384386
Nkeys = len(waterfall)
385387
Nside = int(np.ceil(np.sqrt(Nkeys)))
386388
fig, axes = plt.subplots(Nside, Nside, figsize=figsize)
389+
387390
# Ensure axes is an ndarray
388391
if isinstance(axes, matplotlib.axes._subplots.Axes):
389392
axes = np.array([[axes]])
390393
if isinstance(axes, list):
391394
axes = np.array(axes)
392-
# ensure its 2D and get side lengths
395+
396+
# Ensure its 2D and get side lengths
393397
if axes.ndim == 1:
394398
axes = axes[:, None]
395399
assert axes.ndim == 2, "input axes must have ndim == 2"
396400
Nvert, Nhorz = axes.shape
397401

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

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

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

488493
# Return Axes
489494
if new_plot:

0 commit comments

Comments
 (0)