os.chdir('/data/lofar/DR2/fields') g = glob.glob('*') a1l = [] a2l = [] sdb = SurveysDB() for d in g: infile = d + '/image_full_ampphase_di_m.NS.cat.fits_NVSS_match.fits' if os.path.isfile(infile): t = Table.read(infile) t = t[t['Total_flux'] > 0.01] l1 = len(t) #alpha1=np.median(np.log(t['Total_flux']/t['NVSS_Total_flux'])/np.log(1400/144.0)) alpha1 = np.median(t['Total_flux'] / t['NVSS_Total_flux']) t = t[t['Total_flux'] > 0.03] l2 = len(t) #alpha2=np.median(np.log(t['Total_flux']/t['NVSS_Total_flux'])/np.log(1400/144.0)) alpha2 = np.median(t['Total_flux'] / t['NVSS_Total_flux']) print d, alpha1, alpha2, l1, l2 a1l.append(alpha1) a2l.append(alpha2) r = sdb.get_quality(d) r['nvss_scale'] = alpha2 sdb.set_quality(r) print np.mean(a1l), np.mean(a2l) sdb.close()
# now find whether we have got these pointings somewhere! mosaicdirs = [] missingpointing = False scales = [] sdb = SurveysDB() for p in mosaicpointings: if p in ignorepointings: continue print('Wanting to put pointing %s in mosaic' % p) for d in args.directories: rd = d + '/' + p print(rd) if os.path.isfile(rd + '/' + fname): mosaicdirs.append(rd) try: qualitydict = sdb.get_quality(p) currentdict = sdb.get_field(p) print(qualitydict) #scale=qualitydict['scale'] scale = 1.0 / (qualitydict['nvss_scale'] / 5.9124) if scale is None: print('Missing scaling factor for', p) missingpointing = True scale = 1.0 scales.append(scale) except TypeError: missingpointing = True print('No scaling factor for ', p) scales.append(1.0) break
print lotssdr2['Mosaic_ID'][0] else: if nodatabase: print 'Scaling factor being used for field catalogue', fieldfactor lotssdr2['Peak_flux'] = lotssdr2[ 'Peak_flux'] * fieldfactor * 1000.0 #1000 scaling is to match mJy which is the units of LoTSS-DR2 cat lotssdr2['Total_flux'] = lotssdr2[ 'Total_flux'] * fieldfactor * 1000.0 #1000 scaling is to match mJy which is the units of LoTSS-DR2 cat lotssdr2['E_Peak_flux'] = lotssdr2[ 'E_Peak_flux'] * fieldfactor * 1000.0 #1000 scaling is to match mJy which is the units of LoTSS-DR2 cat lotssdr2['E_Total_flux'] = lotssdr2[ 'E_Total_flux'] * fieldfactor * 1000.0 #1000 scaling is to match mJy which is the units of LoTSS-DR2 cat else: from surveys_db import SurveysDB sdb = SurveysDB() qualitydict = sdb.get_quality(fieldname) sdb.close() nvssfactor = 1.0 / (qualitydict['nvss_scale'] / 5.9124) tgssscale = qualitydict['tgss_scale'] print 'Scaling comparison catalogue by nvssfactor', nvssfactor lotssdr2['Peak_flux'] = lotssdr2[ 'Peak_flux'] * nvssfactor * 1000.0 #1000 scaling is to match mJy which is the units of LoTSS-DR2 cat lotssdr2['Total_flux'] = lotssdr2[ 'Total_flux'] * nvssfactor * 1000.0 #1000 scaling is to match mJy which is the units of LoTSS-DR2 cat lotssdr2['E_Peak_flux'] = lotssdr2[ 'E_Peak_flux'] * nvssfactor * 1000.0 #1000 scaling is to match mJy which is the units of LoTSS-DR2 cat lotssdr2['E_Total_flux'] = lotssdr2[ 'E_Total_flux'] * nvssfactor * 1000.0 #1000 scaling is to match mJy which is the units of LoTSS-DR2 cat #lotssdr2=select_isolated_sources(lotssdr2,45) print 'isolated sources', len(lotssdr2)