Пример #1
0
freqs=[]
imageData=[]
for filename in glob.glob('*.fits'):
    data = getRMS.read_data(pyfits.open(filename)[hdu], plane=None)
    hdulist=pyfits.open(filename)
    prihdr=hdulist[0].header
    freq=int((float(prihdr['CRVAL3'])/1e6))
    imageData.append([filename, freq, getRMS.rms_with_clipped_subregion(data, sigmaClip, f)*1000.])
    if freq not in freqs:
        freqs.append(freq)

thresholds={}

if allFreqs=='T':
    for frequency in freqs:
        noise_avg_log, noise_scatter_log, noise_threshold_log = tools.fit_hist([np.log10(n[2]) for n in imageData if n[1]==frequency], sigmaRej, r'Observed RMS (mJy)', 'rms', frequency)
        noise_avg=10.**(noise_avg_log)
        noise_max=10.**(noise_avg_log+noise_scatter_log)-10.**(noise_avg_log)
        noise_min=10.**(noise_avg_log)-10.**(noise_avg_log-noise_scatter_log)
        print 'Average RMS Noise in images (1 sigma range, frequency='+str(frequency)+' MHz): '+str(frequency)+' MHz): '+str(noise_avg)+' (+'+str(noise_max)+',-'+str(noise_min)+') mJy'
        thresholds[frequency]=[noise_avg,noise_max*sigmaRej,noise_min*sigmaRej*-1.]

frequency='all'
TMPdata = np.array([np.log10(n[2]) for n in imageData])
TMPdata = TMPdata[np.isfinite(TMPdata)]
noise_avg_log, noise_scatter_log, noise_threshold_log = tools.fit_hist(TMPdata, sigmaRej, r'Observed RMS (mJy)', 'rms', frequency)
noise_avg=10.**(noise_avg_log)
noise_max=10.**(noise_avg_log+noise_scatter_log)-10.**(noise_avg_log)
noise_min=10.**(noise_avg_log)-10.**(noise_avg_log-noise_scatter_log)
print 'Average RMS Noise in images (1 sigma range, frequency='+str(frequency)+' MHz): '+str(noise_avg)+' (+'+str(noise_max)+',-'+str(noise_min)+') mJy'
thresholds[frequency]=[noise_avg,noise_max*sigmaRej,noise_min*sigmaRej*-1.]
Пример #2
0
imageData=[]
for filename in glob.glob('*image-pb.fits'):
    print "read: "  + str(filename)
    data = getRMS.read_data(pyfits.open(filename)[hdu],filename, plane=None)
    hdulist=pyfits.open(filename)
    prihdr=hdulist[0].header
    freq=int((float(prihdr['CRVAL3'])/1e6))
    imageData.append([filename, freq, getRMS.rms_with_clipped_subregion(data, sigmaClip, f)*1000.])
    if freq not in freqs:
        freqs.append(freq)

thresholds={}

if allFreqs=='T':
    for frequency in freqs:
        noise_avg_log, noise_scatter_log, noise_threshold_log = tools.fit_hist([np.log10(n[2]) for n in imageData if n[1]==frequency], sigmaRej, r'Observed RMS (mJy)', 'rms', frequency)
        noise_avg=10.**(noise_avg_log)
        noise_max=10.**(noise_avg_log+noise_scatter_log)-10.**(noise_avg_log)
        noise_min=10.**(noise_avg_log)-10.**(noise_avg_log-noise_scatter_log)
        print 'Average RMS Noise in images (1 sigma range, frequency='+str(frequency)+' MHz): '+str(frequency)+' MHz): '+str(noise_avg)+' (+'+str(noise_max)+',-'+str(noise_min)+') mJy'
        thresholds.append([frequency,noise_max*sigma,noise_min*sigma])


frequency='all'
TMPdata = np.array([np.log10(n[2]) for n in imageData])
TMPdata = TMPdata[np.isfinite(TMPdata)]
noise_avg_log, noise_scatter_log, noise_threshold_log = tools.fit_hist(TMPdata, sigmaRej, r'Observed RMS (mJy)', 'rms', frequency)
print noise_avg_log
noise_avg=10.**(noise_avg_log)
noise_max=10.**(noise_avg_log+noise_scatter_log)-10.**(noise_avg_log)
noise_min=10.**(noise_avg_log)-10.**(noise_avg_log-noise_scatter_log)
Пример #3
0
print len(em_energy)

good = res_all

diff1 = 2 * (erad_coreas - erad_ldf) / (erad_coreas + erad_ldf)

binWidth = 0.05
bin_start = -2.0
bin_stop = 2.0
nBins = int((bin_stop - bin_start) / binWidth)
bins = np.arange(bin_start, bin_stop, binWidth)

print nBins

p0, p1, p2, x_hist, y_hist = tools.fit_hist(diff1, bin_start, bin_stop, nBins,
                                            -1.)

fig = plt.figure()
ax1 = fig.add_subplot(1, 2, 1, aspect=1)
ax2 = fig.add_subplot(1, 2, 2)

line = np.arange(1e3, 1e8, 1e7)

ax1.plot(line, line, color='black')
#ax2.plot(line,line,color='black')
#ax3.plot(line,line,color='black')

ax1.plot(erad_coreas, erad_ldf, '.', color='black', alpha=0.1)
#ax1.plot(erad_coreas,erad_ldf,'.')

ax1.set_yscale('log')
Пример #4
0
VirA=[187.705930,12.391123]

min_sep=0. # The absolute minimum allowed separation from the A-Team source, set to zero to enable the code to work independently

###################### MAIN SCRIPT ######################

# Extracting data from the TraP database into a text file
if not os.path.exists('ds_'+dataset_id+'_images.csv'):
    tools.get_data(database, username, password, host, port, databaseType, dataset_id, dataset_id2)

# Extract relevant data from dataset text file
image_info, frequencies, plt_ratios = tools.extract_data(dataset_id, CasA, CygA, VirA)

freq='all'
# RMS noise properties
noise_avg_log, noise_scatter_log, noise_threshold_log = tools.fit_hist([np.log10(image_info[n][4]*1e3) for n in range(len(image_info))], sigma, r'Observed RMS (mJy)', 'ds'+dataset_id+'_rms', freq)
noise_avg=10.**(noise_avg_log)
noise_max=10.**(noise_avg_log+noise_scatter_log)-10.**(noise_avg_log)
noise_min=10.**(noise_avg_log)-10.**(noise_avg_log-noise_scatter_log)
print 'Average RMS Noise in images (1 sigma range, frequency='+str(freq)+' MHz): '+str(round(noise_avg,1))+' (+'+str(round(noise_max,1))+',-'+str(round(noise_min,1))+') mJy'
if plt_ratios:
    # RMS/Theoretical limit for TraP
    ratio_avg_log, ratio_scatter_log, ratio_threshold_log = tools.fit_hist([np.log10(image_info[n][6]) for n in range(len(image_info))], sigma, r'Observed RMS / Theoretical Noise', 'ds'+dataset_id+'_ratio', freq)
    ratio_avg=10.**(ratio_avg_log)
    ratio_threshold = round((10.**ratio_threshold_log),1)
    ratio_threshold2 = round((10.**((ratio_avg_log - ratio_threshold_log)+ratio_avg_log)),1)
    print 'Average RMS/Theoretical in images (frequency='+str(freq)+' MHz): '+str(round(ratio_avg,1))
    print '######## Recommended TraP high_bound threshold: '+str(ratio_threshold)
    print '######## Recommended TraP low_bound threshold: '+str(ratio_threshold2)
    ratio_avg_log, ratio_scatter_log, ratio_threshold_log = tools.fit_hist([np.log10(image_info[n][-1]) for n in range(len(image_info))], sigma, r'Observed RMS / Confusion Noise', 'ds'+dataset_id+'_confratio', freq)
Пример #5
0
plt.close()

######## hist

z = x
x = s_recon

diff = 2 * (x - z) / (x + z)
bin_start = -2.0
bin_stop = 2.0
binWidth = 0.08
#nBins=50.0
nBins = int((bin_stop - bin_start) / binWidth)
bins = np.arange(bin_start, bin_stop, binWidth)

p0, p1, p2, x_hist, y_hist = tools.fit_hist(diff, bin_start, bin_stop,
                                            int(nBins), -100)
'''
fig = plt.figure(figsize=(4,4))
ax1 = fig.add_subplot(1,1,1)

ax1.hist(diff,bins=bins,alpha=0.5)
ax1.plot(x_hist,y_hist,color='green',label='mean {0:.2f}\n spread {1:.2f}'.format(p1,p2))

ax1.set_xlabel(hist_label,fontsize=12)

ax1.legend(numpoints=1,loc='upper left')
ax1.set_xlim([-1.0, 1.0])

plt.tight_layout()
plt.show()
raw_input()