plot_utilities.py   plot_utilities.py 
skipping to change at line 180 skipping to change at line 180
if (plot_likelihood): if (plot_likelihood):
ax.plot(np.exp(-chain['reduced_chi'] )) ax.plot(np.exp(-chain['reduced_chi'] ))
ax.set_ylim([0,1]) ax.set_ylim([0,1])
ax.set_title(r'${\cal L}=\exp$[-$\chi^2$]') ax.set_title(r'${\cal L}=\exp$[-$\chi^2$]')
else: else:
ax.plot(np.log10(chain['reduced_chi'][idx] - np.min(cha in['reduced_chi']))) ax.plot(np.log10(chain['reduced_chi'][idx] - np.min(cha in['reduced_chi'])))
if method == 'MAP': if method == 'MAP':
ax.axvline(idx_map,lw=1) ax.axvline(idx_map,lw=1)
ax.set_title(r'$\log$ [$\chi^2 - \chi^2_{min}$]') ax.set_title(r'$\log$ [$\chi^2 - \chi^2_{min}$]')
if method is 'chi_sorted': if method == 'chi_sorted':
ax.set_xticks([]) ax.set_xticks([])
else: else:
ax.set_xticks(np.arange(2.) / 2 * np.size(idx)) ax.set_xticks(np.arange(2.) / 2 * np.size(idx))
fig.subplots_adjust(wspace=0.3) fig.subplots_adjust(wspace=0.3)
if filename is None: if filename is None:
plot.show() plot.show()
else: else:
plot.savefig(filename) plot.savefig(filename)
skipping to change at line 227 skipping to change at line 227
if filepath is not None: if filepath is not None:
name, extension = os.path.splitext(filepath) name, extension = os.path.splitext(filepath)
supported_extensions = ['.png', '.pdf'] supported_extensions = ['.png', '.pdf']
if not extension in supported_extensions: if not extension in supported_extensions:
raise ValueError("Extension '%s' is not supported, use %s." , raise ValueError("Extension '%s' is not supported, use %s." ,
extension, ', '.join(supported_extensions) ) extension, ', '.join(supported_extensions) )
chain = self.chain.copy() chain = self.chain.copy()
#plot geweke has no meaning with chi_sorted #plot geweke has no meaning with chi_sorted
if self.method is not 'chi_sorted': if self.method != 'chi_sorted':
if fontsize is None: if fontsize is None:
fontsize = plot.rcParams['font.size'] fontsize = plot.rcParams['font.size']
fig = plot.figure(2, figsize=(16, 9)) fig = plot.figure(2, figsize=(16, 9))
names = chain.dtype.names names = chain.dtype.names
short_dict = self.galaxy.short_dict() short_dict = self.galaxy.short_dict()
plot.clf() # clear current figure plot.clf() # clear current figure
plot.subplots_adjust(wspace=0.32, hspace=0.32, plot.subplots_adjust(wspace=0.32, hspace=0.32,
skipping to change at line 362 skipping to change at line 362
for s in show[1:]: for s in show[1:]:
r.append((self.galaxy[s] - self.galaxy.stdev[s] * nsigm a, \ r.append((self.galaxy[s] - self.galaxy.stdev[s] * nsigm a, \
self.galaxy[s] + self.galaxy.stdev[s] * nsigma)) self.galaxy[s] + self.galaxy.stdev[s] * nsigma))
best.append(self.galaxy[s]) best.append(self.galaxy[s])
ls.append(shorts_dict[s]) ls.append(shorts_dict[s])
if fontsize is None: if fontsize is None:
fontsize = plot.rcParams['font.size'] fontsize = plot.rcParams['font.size']
#@fixme how to make onto fig=plot.figure(3) #@fixme how to make onto fig=plot.figure(3)
corner.corner(self.sub_chain[show].as_array().tolist(),\ corner.corner(self.sub_chain[show].to_pandas(),\
labels=ls, truths=best, range=r, \ labels=ls, truths=best, range=r, \
smooth=smooth, label_kwargs={'fontname':'sans -serif', 'fontsize': fontsize}) smooth=smooth, label_kwargs={'fontname':'sans -serif', 'fontsize': fontsize})
if filepath is None: if filepath is None:
plot.show() plot.show()
else: else:
plot.savefig(filepath) plot.savefig(filepath)
plot.close() plot.close()
else: else:
skipping to change at line 535 skipping to change at line 535
if filepath is None: if filepath is None:
fig.show() fig.show()
else: else:
fig.savefig(filepath) fig.savefig(filepath)
plot.close() plot.close()
rotation_curve = [pixscale * xx[good], xx[good]/self.galaxy.rad ius, slice_f[good], slice_v[good], slice_s[good]] rotation_curve = [pixscale * xx[good], xx[good]/self.galaxy.rad ius, slice_f[good], slice_v[good], slice_s[good]]
rotation_name=re.sub('true_maps','true_Vrot',filepath[:-4])+'.d at' rotation_name=re.sub('true_maps','true_Vrot',filepath[:-4])+'.d at'
asciitable.write(rotation_curve, \ asciitable.write(rotation_curve, \
output=rotation_name,Writer=asciitable.FixedWi dth, \ output=rotation_name,format='fixed_width', \
names=['dx_arcsec', 'rad_Re', 'flux_slit', 'v_ kms', 'sig_kms'], overwrite=True) names=['dx_arcsec', 'rad_Re', 'flux_slit', 'v_ kms', 'sig_kms'], overwrite=True)
def plot_obs_vfield(self, filepath=None, mask=None, contours=None, def plot_obs_vfield(self, filepath=None, mask=None, contours=None,
fontsize=10, slitwidth=3): fontsize=10, slitwidth=3):
""" """
plot the observed 2d maps and the 1d along the major axis plot the observed 2d maps and the 1d along the major axis
mask: [optional] 2d nd-array mask: [optional] 2d nd-array
mask for display purposes mask for display purposes
None: [default] default mask is flux>max(flux)/20. None: [default] default mask is flux>max(flux)/20.
skipping to change at line 919 skipping to change at line 919
xaxis = np.where(b!=0, bn.nansum(dist_rot, axis=(0)) / b, 0.) xaxis = np.where(b!=0, bn.nansum(dist_rot, axis=(0)) / b, 0.)
return xaxis, profile return xaxis, profile
def _make_maps_Epinat(self, cube=None, mask=False, cut_level=50, use_co nv='other'): def _make_maps_Epinat(self, cube=None, mask=False, cut_level=50, use_co nv='other'):
""" """
make observed maps from true maps using formulas in Epinat 2010 make observed maps from true maps using formulas in Epinat 2010
:param cube: input cube for computing masking :param cube: input cube for computing masking
:param mask: boolean [default: None] to apply masking :param mask: boolean [default: None] to apply masking
:param use_conv: astropy [default] | scipy :param use_conv: other [default] | scipy | astropy
:param cut_level: 50 [default] cut used if mask=True :param cut_level: 50 [default] cut used if mask=True
:return: :return:
""" """
if (cube is None): if (cube is None):
cube = self.convolved_cube cube = self.convolved_cube
if mask is True: if mask is True:
# default mask is flux>max(flux)/30. # default mask is flux>max(flux)/30.
mask = (bn.nansum(cube.data,0) > bn.nanmax(cube.data.sum(0)) / cut_level ) mask = (bn.nansum(cube.data,0) > bn.nanmax(cube.data.sum(0)) / cut_level )
else: else:
mask = np.ones_like(cube.data[1,:,:]) mask = np.ones_like(cube.data[1,:,:])
#Eq A15 Epinat #Eq A15 Epinat
psf2d = self.instrument.psf3d.sum(axis=0) psf2d = self.instrument.psf3d.sum(axis=0)
if use_conv is 'scipy' : if use_conv == 'scipy' :
logger.debug("Using scipy %s for convolution" % (scipy.__versio n__)) logger.debug("Using scipy %s for convolution" % (scipy.__versio n__))
Fmap = conv2d_scipy(self.true_flux_map.data, psf2d, mode='same' ) Fmap = conv2d_scipy(self.true_flux_map.data, psf2d, mode='same' )
elif use_conv is 'astropy': elif use_conv == 'astropy':
logger.debug("Using astropy %s for convolution" % (astropy.__ve rsion__)) logger.debug("Using astropy %s for convolution" % (astropy.__ve rsion__))
Fmap = conv2d_astro(self.true_flux_map.data, psf2d) Fmap = conv2d_astro(self.true_flux_map.data, psf2d)
else: else:
Fmap, psf2d_fft = conv2d_intern(self.true_flux_map.data, psf2d, compute_fourier=True) Fmap, psf2d_fft = conv2d_intern(self.true_flux_map.data, psf2d, compute_fourier=True)
#Eq A16 Epinat #Eq A16 Epinat
V1 = self.true_velocity_map.data * self.true_flux_map.data # V.M V1 = self.true_velocity_map.data * self.true_flux_map.data # V.M
if use_conv is 'scipy': if use_conv == 'scipy':
Vtemp = conv2d_scipy(V1, psf2d, mode='same') Vtemp = conv2d_scipy(V1, psf2d, mode='same')
elif use_conv is 'astropy': elif use_conv == 'astropy':
Vtemp = conv2d_astro(V1, psf2d) Vtemp = conv2d_astro(V1, psf2d)
else: else:
Vtemp, psf2d_fft = conv2d_intern(V1, psf2d, compute_fourier=Tru e) Vtemp, psf2d_fft = conv2d_intern(V1, psf2d, compute_fourier=Tru e)
Vmap = Vtemp / Fmap Vmap = Vtemp / Fmap
#Eq A17 Epinat #Eq A17 Epinat
S1 = self.true_disp_map.data**2 * self.true_flux_map.data S1 = self.true_disp_map.data**2 * self.true_flux_map.data
if use_conv is 'scipy': if use_conv == 'scipy':
Stemp = conv2d_scipy(S1, psf2d, mode='same') Stemp = conv2d_scipy(S1, psf2d, mode='same')
elif use_conv is 'astropy': elif use_conv == 'astropy':
Stemp = conv2d_astro(S1, psf2d) Stemp = conv2d_astro(S1, psf2d)
else: else:
Stemp, psf2d_fft = conv2d_intern(S1, psf2d, compute_fourier=Tru e) Stemp, psf2d_fft = conv2d_intern(S1, psf2d, compute_fourier=Tru e)
V2 = self.true_velocity_map.data**2 * self.true_flux_map.data V2 = self.true_velocity_map.data**2 * self.true_flux_map.data
if use_conv is 'scipy': if use_conv == 'scipy':
Vtemp = conv2d_scipy(V2, psf2d, mode='same') Vtemp = conv2d_scipy(V2, psf2d, mode='same')
elif use_conv is 'astropy': elif use_conv == 'astropy':
Vtemp = conv2d_astro(V2, psf2d) Vtemp = conv2d_astro(V2, psf2d)
else: else:
Vtemp, psf2d_fft = conv2d_intern(V2, psf2d, compute_fourier=Tru e) Vtemp, psf2d_fft = conv2d_intern(V2, psf2d, compute_fourier=Tru e)
Smap_sq = Stemp / Fmap + Vtemp / Fmap - Vmap**2 Smap_sq = Stemp / Fmap + Vtemp / Fmap - Vmap**2
Smap = np.sqrt(Smap_sq) Smap = np.sqrt(Smap_sq)
self.obs_flux_map = HyperCube(Fmap * mask) self.obs_flux_map = HyperCube(Fmap * mask)
self.obs_velocity_map = HyperCube(Vmap * mask) self.obs_velocity_map = HyperCube(Vmap * mask)
self.obs_disp_map = HyperCube(Smap * mask) self.obs_disp_map = HyperCube(Smap * mask)
 End of changes. 13 change blocks. 
13 lines changed or deleted 13 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/