コード例 #1
0
def gen_rand_cat_inMOC(n, RAmax, RAmin, DECmax, DECmin, catmoc):
    ''' 
    generate a random catalogue of positions within the given MOC
    the positions are generated within the RA and DEC defined and
    then removed if not within the given MOC. This is repeated 
    until n points lie within the MOC
    
    
    '''

    randfieldinmoc = 0
    randfieldra = []
    randfielddec = []
    randfield = []

    while n != 0:
        #print (n)
        randfieldtemp = generate_random_catalogue(n, RAmin, RAmax, DECmin,
                                                  DECmax)
        randfieldtempra = randfieldtemp.ra.value
        randfieldtempdec = randfieldtemp.dec.value

        randfieldtempinmoc = (inMoc(randfieldtempra, randfieldtempdec, catmoc))

        randfieldra = np.append(randfieldra,
                                randfieldtempra[randfieldtempinmoc])
        randfielddec = np.append(randfielddec,
                                 randfieldtempdec[randfieldtempinmoc])

        n = n - sum(randfieldtempinmoc)

    return (SkyCoord(randfieldra, randfielddec, unit='deg'))
コード例 #2
0
 def filter_catalogue(self, catalogue, colnames=("ra", "dec")):
     """
     Filter a catalogue to the 
     """
     # TODO: Check if colnames in the catalogue
     
     if self.moc == None:
         print('filtering in a rectangular sky area')
         return catalogue[
             ((catalogue[colnames[0]] >= self.ra_down)  & 
              (catalogue[colnames[0]] <= self.ra_up)    & 
              (catalogue[colnames[1]] >= self.dec_down) & 
              (catalogue[colnames[1]] <= self.dec_up))]
     else:
         print('filtering in a MOC')
         return catalogue[ ( inMoc(catalogue[colnames[0]],catalogue[colnames[1]],self.moc) ) ]
コード例 #3
0
n = (np.int(os.environ['SGE_TASK_ID']) - 1) * 10

ras = lofar_orig['RA'][n:n + 1]
decs = lofar_orig['DEC'][n:n + 1]
ID = lofar_orig['Source_Name'][n:n + 1]

from astropy.coordinates import SkyCoord
from astropy import units as u

c = SkyCoord(ra=ras * u.degree, dec=decs * u.degree)
import pymoc

moc_near = pymoc.util.catalog.catalog_to_moc(c, 60, 15)

moc_mask = inMoc(lofar_orig['RA'], lofar_orig['DEC'], moc_near)
moc = pymoc.util.catalog.catalog_to_moc(c, 120, 15)

prior = xidplus.prior(
    radim_data, radim_err, radim_header, radim_header, moc=moc
)  #Initialise with map, uncertianty map, wcs info and primary header
prior.prior_cat(lofar_orig['RA'][moc_mask],
                lofar_orig['DEC'][moc_mask],
                'prior_cat',
                ID=lofar_orig['Source_Name'][moc_mask],
                moc=moc)  #Set input catalogue
prior.prior_bkg(
    -5.0, 5)  #Set prior on background (assumes Gaussian pdf with mu and sigma)

pind = np.arange(0, n_size)  #*(1.0/radim_pixsize)
prior.set_prf(prf.array, pind, pind)
コード例 #4
0
def gen_rand_cat_inMOC(n,RAmax,RAmin,DECmax,DECmin,catmoc):

    ''' 
    generate a random catalogue of positions within the given MOC
    the positions are generated within the RA and DEC defined and
    then removed if not within the given MOC. This is repeated 
    until n points lie within the MOC
    
    
    '''
    
    '''randfieldinmoc = 0
    randfieldra = []
    randfielddec = []
    randfield = []

    while n!=0:
        #print (n)
        randfieldtemp = generate_random_catalogue(n,RAmin,RAmax,DECmin,DECmax)
        randfieldtempra  = randfieldtemp.ra.value
        randfieldtempdec = randfieldtemp.dec.value

        randfieldtempinmoc = (inMoc(randfieldtempra,randfieldtempdec,catmoc))

        randfieldra = np.append( randfieldra,randfieldtempra[randfieldtempinmoc])
        randfielddec = np.append( randfielddec,randfieldtempdec[randfieldtempinmoc])

        n = n - sum(randfieldtempinmoc)

    return(SkyCoord(randfieldra,randfielddec,unit='deg'))'''

    moc_area = catmoc.area_sq_deg
    area = (abs(RAmax-RAmin)) * (abs(DECmax-DECmin))
    ratio = area/moc_area
    if ratio<1:
        print('area ratio is less than 1 so something is wrong')
    print('ratio of the random generation area compared to the moc area is: {}'.format(area/moc_area))
    ra = []
    dec = []
    #randcoords = generate_random_catalogue(int(n*5*ratio),RAmin,RAmax,DECmin,DECmax)
    #randra  = randcoords.ra.value
    #randdec = randcoords.dec.value
    randra = np.random.uniform(RAmin, RAmax, int(2*n*ratio))
    randdec = np.random.uniform(DECmin, DECmax, int(2*n*ratio))
    mask = inMoc(randra,randdec,catmoc)
    if np.sum(mask)>=n:
        coords = SkyCoord(randra[mask][:n],randdec[mask][:n],unit='deg')
        assert len(coords)==n,print('the number of coordinates generated is not equal to the number of radio sources in the moc. Something is wrong')
            
        return(coords)
    if np.sum(mask)<n:
        while len(ra)<n:
            ra = np.append(ra,randra[mask])
            dec = np.append(dec,randdec[mask])
            randcoords = generate_random_catalogue(n*5*ratio,RAmin,RAmax,DECmin,DECmax)
            randra  = randcoords.ra.value
            randdec = randcoords.dec.value
            mask = inMoc(randra,randdec,catmoc)
            ra = np.append(ra,randra[mask])
            dec = np.append(dec,randdec[mask])

        coords = SkyCoord(ra[:n],dec[:n],unit='deg')
        return(coords)
コード例 #5
0
#Read in the Ldust predictions needed to increase the coerage of the prior list
ldust = Table.read('../../../../../HELP/dmu_products/dmu28/dmu28_Lockman-SWIRE/data/Lockman-SWIRE_Ldust_prediction_results.fits') 
ldust.rename_column('id','help_id')
ldust['help_id'] = ldust['help_id'].astype(str)
#join Ldust predictions with the help table
ldust_id = [name[:-6] for name in list(ldust['help_id'])]
ldust['help_id'] = np.array(ldust_id)
ldust_cols = ['help_id','bayes.dust.luminosity','bayes.dust.luminosity_err','best.universe.redshift']
ldust = ldust[ldust_cols]
help_masterlist_ldust = join(help_masterlist,ldust,keys='help_id',join_type='outer')

#create a moc so that only radio sources in the prior area are selected
c = SkyCoord(ra=help_masterlist_ldust['ra'], dec=help_masterlist_ldust['dec'])
prior_moc=pymoc.util.catalog.catalog_to_moc(c,60,15)

radio_in_moc = inMoc(ra,dec,prior_moc)
#if radio_in_moc==False:
#    sys.exit()

lofar_coords = SkyCoord(ra,dec,unit='deg')
help_coords = SkyCoord(help_masterlist['ra'],help_masterlist['dec'],unit='deg')
radius = 2
idx_help, idx_lofar, d2d, d3d = lofar_coords.search_around_sky(
    help_coords, radius*u.arcsec)

#compute the predicted flux from the dust and usethis to construct the prior
from astropy.cosmology import Planck15 as cosmo
from astropy import units as u
f_pred=help_masterlist_ldust['bayes.dust.luminosity']/(4*np.pi*cosmo.luminosity_distance(help_masterlist_ldust['best.universe.redshift']).to(u.cm))
mask = np.isfinite(f_pred)
ldust_mask = (np.log10(f_pred)>8.5) & (np.isfinite(f_pred))
コード例 #6
0
im500hdu=hdulist['image'].header 
im500=hdulist['image'].data*1.0E3 #convert to mJy
nim500=hdulist['error'].data*1.0E3 #convert to mJy
w_500 = wcs.WCS(hdulist['image'].header)
pixsize500=3600.0*w_500.wcs.cd[1,1] #pixel size (in arcseconds)
hdulist.close()

from astropy.coordinates import SkyCoord
from astropy import units as u
c = SkyCoord(ra=ras*u.degree, dec=decs*u.degree)  
import pymoc
moc=pymoc.util.catalog.catalog_to_moc(c,60,15)

#read in the prior cat and cut it down using the moc
prior_cat = Table.read('data/data_release/xidplus_prior_cat.fits')
mask = inMoc(prior_cat['ra'],prior_cat['dec'],moc)
prior_cat = prior_cat[mask]

#create a skycoord object with no radio source in it
#Then crossmatch with the radio source positions to find the nearest HELP source.
#if the nearest HELP source is within 2" remove it
mask = np.array(['ILTJ' not in name for name in prior_cat['help_id']])
prior_coords = SkyCoord(ra=prior_cat['ra'][mask],dec=prior_cat['dec'][mask])

idx,d2d,_ = c.match_to_catalog_sky(prior_coords)
mask = (d2d.value*3600)<2
help_id_near = prior_cat[idx]['help_id'][mask]
mask = np.array([name in help_id_near for name in prior_cat['help_id']])
prior_cat = prior_cat[~mask]

#---prior250--------