Skip to content

Commit

Permalink
small python fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tgastine committed Jun 3, 2024
1 parent c524ffb commit 179338c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions python/magic/averages.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,21 @@ def __init__(self, tag=None, tstart=None, model=default_model,
self.lut['radial_profiles']['radius'] = rr.radius
for field in params['radial_profiles'][key]:
if hasattr(rr, field):
self.lut['radial_profiles'][field+'_av'] = rr.__dict__[field]
self.lut['radial_profiles'][field+'R_av'] = \
rr.__dict__[field]
setattr(self, field+'R_av', rr.__dict__[field])
if std and hasattr(rr, field + '_SD'):
self.lut['radial_profiles'][field+'_sd'] = \
self.lut['radial_profiles'][field+'R_sd'] = \
rr.__dict__[field + '_SD']
setattr(self, field+'R_sd', rr.__dict__[field+'_SD'])
else: # Set parameters to -1
for key in params['radial_profiles'].keys():
self.lut['radial_profiles']['radius'] = -1 * np.ones(33)
for field in params['radial_profiles'][key]:
self.lut['radial_profiles'][field+'_av'] = -1 * np.ones(33)
self.lut['radial_profiles'][field+'R_av'] = -1 * np.ones(33)
#setattr(self, field+'R_av', rr.__dict__[field])
if std:
self.lut['radial_profiles'][field+'_sd'] = -1 * np.ones(33)
self.lut['radial_profiles'][field+'R_sd'] = -1 * np.ones(33)
#setattr(self, field+'R_sd', rr.__dict__[field+'_SD'])

# Handle theta profiles
Expand Down
8 changes: 5 additions & 3 deletions python/magic/plotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ def equatContour(data, radius, minc=1, label=None, levels=defaultLevels,

if bounds:
ax.plot(radius[0]*np.cos(phi), radius[0]*np.sin(phi), 'k-', lw=1.5)
ax.plot(radius[-1]*np.cos(phi), radius[-1]*np.sin(phi), 'k-', lw=1.5)
if abs(radius[-1]) > 1e-8:
ax.plot(radius[-1]*np.cos(phi), radius[-1]*np.sin(phi), 'k-', lw=1.5)

if not deminc and minc > 1:
ax.plot(radius, np.zeros_like(radius), 'k-', lw=1.5)
Expand Down Expand Up @@ -479,7 +480,8 @@ def merContour(data, radius, label=None, levels=defaultLevels, cm=defaultCm,

if bounds:
ax.plot((radius[0])*np.sin(th), (radius[0])*np.cos(th), 'k-')
ax.plot((radius[-1])*np.sin(th), (radius[-1])*np.cos(th), 'k-')
if abs(radius[-1]) > 1e-8:
ax.plot((radius[-1])*np.sin(th), (radius[-1])*np.cos(th), 'k-')
ax.plot([0., 0.], [radius[-1], radius[0]], 'k-')
ax.plot([0., 0.], [-radius[-1], -radius[0]], 'k-')

Expand Down Expand Up @@ -733,4 +735,4 @@ def radialContour(data, rad=0.85, label=None, proj='hammer', lon_0=0., vmax=None
if rasterized:
c.set_rasterized(True)

return fig
return fig, x, y

0 comments on commit 179338c

Please sign in to comment.