if 'RA' in wcs.wcs.ctype[0]: FF.show_markers(coordinate.ra.deg, coordinate.dec.deg, marker='+', facecolor='r', edgecolor='r') FF.show_markers(fitcoord.fk5.ra.deg, fitcoord.fk5.dec.deg, marker='x', facecolor='g', edgecolor='g') elif 'GLON' in wcs.wcs.ctype[0]: FF.show_markers(coordinate.l.deg, coordinate.b.deg, marker='+', facecolor='r', edgecolor='r') FF.show_markers(fitcoord.galactic.l.deg, fitcoord.galactic.b.deg, marker='x', facecolor='g', edgecolor='g') FF.set_tick_labels_format('d.dd') FF.set_tick_labels_xformat('d.dd') FF.set_tick_labels_yformat('d.dd') FF.set_title(sp.specname) FF.save('../figures/mom0_gfit_{0}.png'.format(cubename)) l_rounded, el_rounded = rounded(fitcoord.galactic.l.deg, dx_deg) b_rounded, eb_rounded = rounded(fitcoord.galactic.b.deg, dy_deg) v_rounded, ev_rounded = rounded(sp.specfit.parinfo[1].value, sp.specfit.parinfo[1].error) if 'v0' not in cubename: results[cubename] = [l_rounded, b_rounded, el_rounded, eb_rounded, v_rounded, ev_rounded,] other_masers = Table.read('../data/other_masers.tbl', format='ascii.ecsv') walshtbl = Vizier.query_region(coordinates.SkyCoord(0.38*u.deg, +0.04*u.deg, frame='galactic'), radius=0.5*u.arcmin, catalog='J/MNRAS/442/2240')[0] h2ocoords = coordinates.SkyCoord(walshtbl['_RAJ2000'], walshtbl['_DEJ2000'], frame='fk5', unit=(u.deg, u.deg)) tbl = Table([Column([names[name] for name in results], name='Line'),
ss_c = ss.copy() ss_c.xarr.convert_to_unit(u.GHz) ss_c.xarr.refX = c77a_freq ss_c.xarr.convert_to_unit(u.km/u.s) ss_c.plotter(xmin=-10, xmax=120, axis=pl.subplot(2,1,2), clear=False, color='blue') ss.plotter.savefig(paths.fpath('spectra/h77/'+ss.specname+"_h_he_c.png"), bbox_inches='tight') tbl = table.Table() names = table.Column(data=[sp.specname for sp in spectra], name='ObjectName') tbl.add_column(names) for ii,(parname,unit) in enumerate([('amplitude',u.mJy), ('velocity',u.km/u.s), ('width',u.km/u.s)]): dataerror = [rounded(sp.specfit.parinfo[ii].value, sp.specfit.parinfo[ii].error) for sp in spectra] data,error = zip(*dataerror) #data = [sp.specfit.parinfo[ii].value # for sp in spectra] #error = [sp.specfit.parinfo[ii].error # for sp in spectra] column = table.Column(data=data, name='H77a_'+parname, unit=unit) tbl.add_column(column) column = table.Column(data=error, name='eH77a_'+parname, unit=unit) tbl.add_column(column)
# fitting for thisspec in sp: thisspec.plotter(xmin=30,xmax=90) thisspec.specfit(fittype='gaussian', guesses=[-0.03,thisspec.xarr[thisspec.data.argmin()].value,3], limited=[(False,True),(False,False),(True,False)]) log.info(thisspec.specname+" fitting: {0}".format(thisspec.specfit.parinfo)) thisspec.plotter.ymin -= 0.005 thisspec.plotter.ymax += 0.005 thisspec.specfit.annotate(loc='lower left') thisspec.specfit.plotresiduals(axis=thisspec.plotter.axis,clear=False,yoffset=+0.005,label=False) thisspec.plotter.savefig(paths.fpath('spectra/hiiregionh2co/'+thisspec.specname+"_h2co22absorption_fit.png"), bbox_inches='tight') tbl.add_row([thisspec.specname,]+ list((rounded(thisspec.specfit.parinfo.AMPLITUDE0.value, thisspec.specfit.parinfo.AMPLITUDE0.error)*u.Jy).to(u.mJy))+ list(rounded(thisspec.specfit.parinfo.SHIFT0.value, thisspec.specfit.parinfo.SHIFT0.error)*u.km/u.s)+ list(rounded(thisspec.specfit.parinfo.WIDTH0.value, thisspec.specfit.parinfo.WIDTH0.error)*u.km/u.s)+ [np.round(thisspec.header['APAREA']*(np.pi/180.)**2, int(np.ceil(-np.log10(thisspec.header['APAREA']*(np.pi/180.)**2)))+1)*u.sr]) # sort such that e10 comes after e9 import natsort tbl = tbl[natsort.index_natsorted(tbl['Object Name'])] detection_note = ['-' if name in detections else 'ambig' if name in ambiguousdetections else 'none' for name in tbl['Object Name']] tbl.add_column(table.Column(data=detection_note, name='Detection Status'))
nondetections = tbl['peak_m_background'] < tbl['local_rms_noise']*3 cols_order = ['SourceName', 'Epoch', 'ObservationDate', 'peak_flux', 'peak_m_background', 'local_rms_noise', 'Frequency'] cols = {'SourceName': 'Object', #'FrequencyName': 'Band', 'ObservationDate': 'Obs. Date', 'peak_flux': 'Peak $S_{\\nu}$', 'peak_m_background': 'Peak - Background', 'local_rms_noise': 'RMS', } textbl = tbl.copy()[cols_order] textbl.sort(['SourceName', 'Frequency']) textbl[nondetections]['peak_flux'] = np.nan textbl[nondetections]['peak_m_background'] = np.nan textbl['peak_flux'] = ((list(map(lambda x,y: rounded(x,y,extra=0)[0], textbl['peak_flux'].to(u.mJy/u.beam).value, textbl['local_rms_noise'].to(u.mJy/u.beam).value)))) textbl['peak_m_background'] = ((list(map(lambda x,y: rounded(x,y,extra=0)[0], textbl['peak_m_background'].to(u.mJy/u.beam).value, textbl['local_rms_noise'].to(u.mJy/u.beam).value)))) textbl['local_rms_noise'] = ((list(map(lambda x,y: rounded(x,y,extra=0)[0], textbl['local_rms_noise'].to(u.mJy/u.beam).value, textbl['local_rms_noise'].to(u.mJy/u.beam).value)))) for name in ('peak_flux', 'peak_m_background', 'local_rms_noise'): textbl[name].unit = u.mJy/u.beam textbl['SourceName'] = list(map(lambda x: x.replace("_","-"), textbl['SourceName'])) for old,new in cols.items(): textbl.rename_column(old, new)
] cols = { 'SourceName': 'Object', #'FrequencyName': 'Band', 'ObservationDate': 'Obs. Date', 'peak_flux': 'Peak $S_{\\nu}$', 'peak_m_background': 'Peak - Background', 'local_rms_noise': 'RMS', } textbl = tbl.copy()[cols_order] textbl.sort(['SourceName', 'Frequency']) textbl[nondetections]['peak_flux'] = np.nan textbl[nondetections]['peak_m_background'] = np.nan textbl['peak_flux'] = ((list( map(lambda x, y: rounded(x, y, extra=0)[0], textbl['peak_flux'].to(u.mJy / u.beam).value, textbl['local_rms_noise'].to(u.mJy / u.beam).value)))) textbl['peak_m_background'] = ((list( map(lambda x, y: rounded(x, y, extra=0)[0], textbl['peak_m_background'].to(u.mJy / u.beam).value, textbl['local_rms_noise'].to(u.mJy / u.beam).value)))) textbl['local_rms_noise'] = ((list( map(lambda x, y: rounded(x, y, extra=0)[0], textbl['local_rms_noise'].to(u.mJy / u.beam).value, textbl['local_rms_noise'].to(u.mJy / u.beam).value)))) for name in ('peak_flux', 'peak_m_background', 'local_rms_noise'): textbl[name].unit = u.mJy / u.beam textbl['SourceName'] = list( map(lambda x: x.replace("_", "-"), textbl['SourceName']))
ax2 = thisspec.plotter.axis.twinx() ax2.set_ylim(*(np.array(thisspec.plotter.axis.get_ylim()) * thisspec.header['JYTOK'] / 1e3)) ax2.set_ylabel("$T_B$ (K)") thisspec.plotter.savefig( paths.fpath('spectra/emission/' + thisspec.specname + "_h2co22emisson_baselined.png"), bbox_inches='tight') omega_ap = thisspec.header['APAREA'] * (np.pi / 180.)**2 * u.sr r_eff = ((omega_ap / np.pi)**0.5).to(u.arcsec).value tbl.add_row( [ thisspec.specname, ] + list( (rounded(thisspec.specfit.parinfo.AMPLITUDE0.value, thisspec.specfit.parinfo.AMPLITUDE0.error) * u.Jy).to(u.mJy)) + list( rounded(thisspec.specfit.parinfo.SHIFT0.value, thisspec.specfit.parinfo.SHIFT0.error)) + list( rounded(thisspec.specfit.parinfo.WIDTH0.value, thisspec.specfit.parinfo.WIDTH0.error)) + [np.round(r_eff, 1) * u.arcsec] #[np.round(thisspec.header['APAREA']*(np.pi/180.)**2, int(np.ceil(-np.log10(thisspec.header['APAREA']*(np.pi/180.)**2)))+1)], ) # sort such that e10 comes after e9 import natsort tbl = tbl[natsort.index_natsorted(tbl['Object Name'])] detection_note = [ '-' if name in detections else 'weak' if name in weakdetections else 'none'