def continuum(self, dx=1e30, dy=-1, noBeam=False, rms=-1, immax=-1, solid=True, title=True, wedge=True, lightBackground=True): if(dy == -1): dy = dx if(self.xunit == 'seconds'): dy = dy/3600. dx = dx/3600. if(self.vaxis.any()): sys.exit(self.fileName + " is not a continuum image") if(rms<0): rms = self.getRMS() xc,yc,vc = self._getIndices(self,dx,dy) ax,cmap,fig = plots.createFigure(self.xaxis, self.yaxis, xc, yc, self.header, title) if(immax == -1): immax = np.nanmax(self.image) cx = cubehelix.cmap(start=0, rot=-0.5, reverse=lightBackground) if(solid): im=ax.imshow(self.image, cmap=cx, alpha=1.0, interpolation='nearest', origin='lower', extent=[np.max(self.xaxis), np.min(self.xaxis), np.min(self.yaxis), np.max(self.yaxis)], vmin=np.nanmin(3*rms), vmax=immax, aspect='auto') if(wedge): cbar = plt.colorbar(im) cbar.set_label('Intensity ('+self.header['BUNIT']+')') else: im=ax.imshow(self.image, cmap=cx, alpha=0.0, interpolation='nearest', origin='lower', extent=[np.max(self.xaxis), np.min(self.xaxis), np.min(self.yaxis), np.max(self.yaxis)], vmin=np.nanmin(3*rms), vmax=immax, aspect='auto') im=ax.contour(self.xaxis, self.yaxis, self.image, colors='black', aspect='auto', interpolation='nearest', linewidths=1.5, levels=np.arange(150)*3*rms+3*rms) if(not noBeam): self._plotBeam(self, ax, xc, yc, lightBackground) return ax, fig
def moment(self, dx=1e30, dy=-1, dv=1e30, sysvel=0, nobeam=False, mom=0, rms=-1, overplot=False, title=True): if not self.vaxis.any(): sys.exit(self.fileName + " is not a line image") if(dy == -1): dy = dx if(rms<0): rms = self.getRMS() self.vaxis = self.vaxis-sysvel xc,yc,vc = self._getIndices(self, dx, dy, dv) ax,cmap,fig = plots.createFigure(self.xaxis, self.yaxis, xc, yc, self.header, title) moment0 = (self.image[vc[0]]*(np.abs(self.vaxis[1] -self.vaxis[0]))).sum(axis=0) moment1 = np.zeros((self.header['NAXIS2'], self.header['NAXIS1']), float) for j in range(self.header['NAXIS1']): for i in range(self.header['NAXIS2']): if (moment0[i,j] > 3*rms): moment1[i,j] = (self.image[vc[0],i,j]* self.vaxis[vc[0]]).sum()/moment0[i,j] else: moment1[i,j] = np.nan if(mom == 1): moment = moment1 else: moment = moment0 # make custom colormap cdict = {'red': ((0.0, 0.0, 0.0), (1.0, 0.3, 0.3)), 'green':((0.0, 0.0, 0.0), (1.0, 0.5, 0.5)), 'blue': ((0.0, 0.0, 0.0), (1.0, 1.0, 1.0)) } myBu = cols.LinearSegmentedColormap('myBu', cdict, 256) # add ramp alpha channel myBuT = cols.LinearSegmentedColormap('myBuT', cdict, 256) myBuT._init() alphas = np.linspace(0, 1, 256+3) myBuT._lut[:,-1] = alphas im = ax.imshow(moment, cmap=plt.cm.jet, alpha=1.0, interpolation='nearest', origin='lower', extent=[np.max(self.xaxis), np.min(self.xaxis), np.min(self.yaxis), np.max(self.yaxis)], vmin=np.nanmin(moment), vmax=np.nanmax(moment), aspect='auto') plt.subplots_adjust(bottom=0.15, left=0.15) cbar = plt.colorbar(im) cbar.set_label('Intensity integrated velocity') ax.contour(self.xaxis, self.yaxis, moment0, colors='black', levels=np.arange(25)*2*rms+3*rms)