Example #1
0
def selectionFunction_sc1324(cat):

	print '\n##############################################################################'
	print '##  WARNING:  DO NOT USE THIS SPATIAL SELECTION FOR SPECTROSCOPIC ANALYSIS  ##'
	print '##############################################################################'

	image = '/Volumes/PHOENIX/atomczak/DATA/ORELSE/catalogs/v001/SC_1324/catalogs/detection_i.fits'
	imwcs = wcs.WCS(image)

	###  center and radius(arcmin) of circle for selection region
	ra_center1, dec_center1, radius1 = 201.19367, 30.378647, 7.5
	ra_center2, dec_center2, radius2 = 201.19789, 30.797195, 7.5

	inds = pylab.find((mypy.radec_sep(cat.ra, cat.dec, ra_center1, dec_center1) < (radius1*60)) |
		              (mypy.radec_sep(cat.ra, cat.dec, ra_center2, dec_center2) < (radius2*60)))


	###  calculating the area of the user-defind polygon
	ra12, dec12 = imwcs.wcs_pix2world([0, 0], [0, 1], 1)
	px_scale = mypy.radec_sep(ra12[0], dec12[0], ra12[1], dec12[1])

	###  ra_center, dec_center, radius(arcsec)
	holes = pylab.array([[201.25003,30.730522,47.512735],
                         [201.22212,30.748129,13.458029],
                         [201.27612,30.772911,22.274966],
                         [201.10165,30.812886,23.675712],
                         [201.25291,30.909185,17.122665],
                         [201.15439,30.900116,12.10503],
                         [201.25132,30.829188,9.7452902],
                         [201.13392,30.846507,9.2278058],
                         [201.13487,30.824375,7.6672608],
                         [201.16874,30.769457,6.0614826],
                         [201.26223,30.47085,36.090217],
                         [201.25449,30.462586,12.670795],
                         [201.22354,30.383661,33.454697],
                         [201.20035,30.387129,27.711625],
                         [201.10457,30.344156,28.993961],
                         [201.13763,30.345778,11.809207],
                         [201.30168,30.31483,20.60916],
                         [201.2918,30.32177,8.7791076]])


	area_arcsec2 = pylab.pi * ((radius1*60)**2 + (radius2*60)**2)
	for hole in holes:
		area_arcsec2 -= pylab.pi * hole[2]**2
	area_arcmin2 = area_arcsec2 / 60.**2

	return inds, area_arcmin2
Example #2
0
def selectionFunction_rxj1716(cat):

	image = '/Volumes/PHOENIX/atomczak/DATA/ORELSE/catalogs/v001/RX_1716+6708/catalogs/detection_Riz.fits'
	imwcs = wcs.WCS(image)

	###  center and radius(arcmin) of circle for selection region
	ra_center, dec_center, radius = 259.22971, 67.143098, 7.5

	inds = pylab.find(mypy.radec_sep(cat.ra, cat.dec, ra_center, dec_center) < (radius*60))


	###  calculating the area of the user-defind polygon
	ra12, dec12 = imwcs.wcs_pix2world([0, 0], [0, 1], 1)
	px_scale = mypy.radec_sep(ra12[0], dec12[0], ra12[1], dec12[1])

	###  ra_center, dec_center, radius(arcsec)
	holes = pylab.array([[259.27315,67.137511,25.866736],
                         [259.30226,67.138466,15.023128],
                         [259.09091,67.166876,13.157666],
                         [259.10066,67.218895,13.300506],
                         [259.43251,67.196812,12.558967],
                         [259.30401,67.162694,11.047812],
                         [259.42721,67.163867,10.458859],
                         [259.35307,67.153612,8.4644722],
                         [259.18329,67.193086,8.7346083],
                         [259.15519,67.086793,10.356007],
                         [259.09615,67.113576,11.004811],
                         [259.05713,67.110635,10.120949],
                         [259.03645,67.098984,10.50559],
                         [259.33435,67.234392,10.655293],
                         [259.29348,67.246694,10.491968],
                         [259.31441,67.25702,10.165386],
                         [259.14271,67.101326,5.997919],
                         [259.13191,67.100998,7.3613226],
                         [259.13364,67.081616,9.624462],
                         [259.10055,67.243124,12.539747],
                         [259.04234,67.207214,9.2868871],
                         [259.15655,67.224092,8.8955654]])

	area_arcsec2 = pylab.pi * (radius*60)**2
	for hole in holes:
		area_arcsec2 -= pylab.pi * hole[2]**2
	area_arcmin2 = area_arcsec2 / 60.**2

	return inds, area_arcmin2
Example #3
0
def selectionFunction_sg0023(cat):

	image = '/Volumes/PHOENIX/atomczak/DATA/ORELSE/catalogs/v001/Cl_0023+0423/catalogs/detection_RIsup.fits'
	imwcs = wcs.WCS(image)

	###  center and radius(arcmin) of circle for selection region
	ra_center, dec_center, radius = 5.9679299, 4.371602, 8.

	inds = pylab.find(mypy.radec_sep(cat.ra, cat.dec, ra_center, dec_center) < (radius*60))


	###  calculating the area of the user-defind polygon
	ra12, dec12 = imwcs.wcs_pix2world([0, 0], [0, 1], 1)
	px_scale = mypy.radec_sep(ra12[0], dec12[0], ra12[1], dec12[1])

	###  ra_center, dec_center, radius(arcsec)
	holes = pylab.array([[6.0002043,4.443438,13.101802],
                         [6.0442164,4.4577949,14.926456],
                         [6.0607516,4.4383802,16.134604],
                         [6.0596828,4.4229565,11.242492],
                         [6.0636816,4.4075321,18.773037],
                         [6.0260797,4.4758797,8.532085],
                         [6.0111424,4.4806675,7.0114467],
                         [6.0004691,4.3984959,10.130726],
                         [6.012204,4.3894537,8.1548529],
                         [6.0130024,4.3602015,12.254177],
                         [6.0260685,4.3312143,12.638204],
                         [5.9529946,4.3602027,9.4850712],
                         [5.9439261,4.3796153,6.3277603],
                         [5.945526,4.3926459,7.6725706],
                         [5.9031293,4.2700502,18.44122],
                         [5.8625822,4.365514,11.637917],
                         [5.8505758,4.39636,11.531429],
                         [5.866039,4.4415702,11.457626],
                         [5.8908441,4.4487533,9.8495449],
                         [6.0970164,4.3796046,9.194863],
                         [6.0930157,4.3788075,4.9400946],
                         [5.9988648,4.3016978,7.724253]])

	area_arcsec2 = pylab.pi * (radius*60)**2
	for hole in holes:
		area_arcsec2 -= pylab.pi * hole[2]**2
	area_arcmin2 = area_arcsec2 / 60.**2

	return inds, area_arcmin2
    def __init__(self, name, version, zclust, sigmaz, alpha=50):
        self.name = name  # e.g. "NEP 200"
        self.version = version  # e.g. "nep200_v0.0.4"
        self.zclust = zclust  # cluster redshift
        self.sigmaz = sigmaz  # 1sigma scatter in (zphot-zspec)/(1+zspec)
        self.zspec_lo = 0  # lower redshift bound for specz
        self.zspec_hi = 0  # upper redshift bound for specz
        self.substructures = []

        self.cat = gunzip_read_gzip('%s/%s/%s.cat.gz' %
                                    (data_dir, version, version),
                                    readcat=1)
        self.zout = gunzip_read_gzip('%s/%s/%s.zout.gz' %
                                     (data_dir, version, version),
                                     readzout=1)
        self.fout = gunzip_read_gzip('%s/%s/%s.fout.gz' %
                                     (data_dir, version, version),
                                     readcat=1)

        ###  UPDATING USE FLAG WITH REDUCE CHI**2 > 10
        chi2red = self.zout.chi_p / (self.zout.nfilt - 1.)
        cinds = pylab.find(chi2red > 10)
        self.cat.use[cinds] = 0.

        #print '  reading: %s_voronoi.pickle' % name
        #self.voronoi = pickle.load(open('../data/%s_voronoi.pickle' % name, 'rb'))

        xyrd1 = self.cat.x[0], self.cat.y[0], self.cat.ra[0], self.cat.dec[0]
        xyrd2 = self.cat.x[1], self.cat.y[1], self.cat.ra[1], self.cat.dec[1]
        d_arcsec = mypy.radec_sep(xyrd1[2], xyrd1[3], xyrd2[2], xyrd2[3])
        d_pixel = ((xyrd1[0] - xyrd2[0])**2 + (xyrd1[1] - xyrd2[1])**2)**0.5
        self.px_scale = d_arcsec / d_pixel

        ### getting z band magnitude
        try:
            self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_z)
        except:
            pass
        try:
            self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_Zplus)
        except:
            pass

        ###  setting spatial flag based on Convex Hull method
        #zspecinds = pylab.find(self.cat.z_spec > 0)
        #self.spatial_flag = checkPoint(self.cat.ra[zspecinds], self.cat.dec[zspecinds], self.cat.ra, self.cat.dec)
        #self.inds_spatial = pylab.find(self.spatial_flag == 1)

        ###  setting spatial flag based on Concave Hull method (creates a "tighter" spatial selection than Cnvex Hull)
        zspecinds = pylab.find(self.cat.z_spec > 0)
        points = pylab.array(zip(self.cat.x[zspecinds], self.cat.y[zspecinds]))
        self.concave_hull, self.edge_points = alpha_shape(points, alpha)
        self.inds_spatial = CheckPoints(self.concave_hull.buffer(10),
                                        self.cat.x, self.cat.y)
        self.area_pix2 = self.concave_hull.buffer(10).area
        self.area_arcmin2 = self.area_pix2 * (self.px_scale / 60.)**2
        print ''
Example #5
0
def selectionFunction_nep5281(cat):

	image = '/Volumes/PHOENIX/atomczak/DATA/ORELSE/catalogs/v001/NEP5281/catalogs/detection_iz.fits'
	imwcs = wcs.WCS(image)

	###  center and radius(arcmin) of circle for selection region
	ra_center, dec_center, radius = 275.36968, 68.44678, 7.5

	inds = pylab.find(mypy.radec_sep(cat.ra, cat.dec, ra_center, dec_center) < (radius*60))


	###  calculating the area of the user-defind polygon
	ra12, dec12 = imwcs.wcs_pix2world([0, 0], [0, 1], 1)
	px_scale = mypy.radec_sep(ra12[0], dec12[0], ra12[1], dec12[1])

	###  ra_center, dec_center, radius(arcsec)
	holes = pylab.array([[275.27978,68.520525,46.056259],
                         [275.53037,68.517381,40.509531],
                         [275.50134,68.477453,24.628801],
                         [275.26677,68.477929,23.442467],
                         [275.268,68.46827,16.965804],
                         [275.59468,68.47603,26.884972],
                         [275.60796,68.486988,28.267962],
                         [275.42581,68.432277,25.402459],
                         [275.50188,68.374711,30.164172],
                         [275.47205,68.365075,27.880421],
                         [275.42809,68.39759,25.101274],
                         [275.63699,68.413618,36.739731],
                         [275.30528,68.383986,17.026886],
                         [275.27421,68.405926,17.166376],
                         [275.49268,68.43092,18.095503],
                         [275.38766,68.489806,16.166629],
                         [275.23104,68.445854,13.20395],
                         [275.32431,68.409895,15.990675],
                         [275.33392,68.352819,21.671266]])

	area_arcsec2 = pylab.pi * (radius*60)**2
	for hole in holes:
		area_arcsec2 -= pylab.pi * hole[2]**2
	area_arcmin2 = area_arcsec2 / 60.**2

	return inds, area_arcmin2
Example #6
0
def selectionFunction_nep200(cat):

	image = '/Volumes/PHOENIX/atomczak/DATA/ORELSE/catalogs/v001/NEP200/catalogs/detection_ri.fits'
	imwcs = wcs.WCS(image)

	###  center and radius(arcmin) of circle for selection region
	ra_center, dec_center, radius = 269.34685, 66.517873, 7.5

	inds = pylab.find(mypy.radec_sep(cat.ra, cat.dec, ra_center, dec_center) < (radius*60))


	###  calculating the area of the user-defind polygon
	ra12, dec12 = imwcs.wcs_pix2world([0, 0], [0, 1], 1)
	px_scale = mypy.radec_sep(ra12[0], dec12[0], ra12[1], dec12[1])

	###  ra_center, dec_center, radius(arcsec)
	holes = pylab.array([[269.46246,66.429833,70.075997],
                         [269.43695,66.446738,40.164039],
                         [269.46396,66.517388,42.679144],
                         [269.15691,66.559085,29.881235],
                         [269.13197,66.599941,20.804753],
                         [269.42969,66.613853,24.66493],
                         [269.26007,66.457846,15.792927],
                         [269.25119,66.452952,15.792927],
                         [269.32334,66.592537,13.907813],
                         [269.53687,66.57243,17.460344],
                         [269.29668,66.505863,16.241715],
                         [269.26984,66.532962,14.637499],
                         [269.22505,66.561377,11.433118],
                         [269.55164,66.462634,14.754796]])

	area_arcsec2 = pylab.pi * (radius*60)**2
	for hole in holes:
		area_arcsec2 -= pylab.pi * hole[2]**2
	area_arcmin2 = area_arcsec2 / 60.**2

	return inds, area_arcmin2
Example #7
0
	###  of any substructure center. If there are two such
	###  substructures, then the nearest is chosen.

	zspec = []
	zphot = []
	zlss = []
	lmass = []
	truefalse_array = []

	for i_gal in range(len(zinds)):
		ra0, dec0 = ra_spec[i_gal], dec_spec[i_gal]

		###  measuring distance of galaxy to all substructure centroids
		rproj_list = []
		for ss in f.substructures:
			rproj_arcsec = mypy.radec_sep(ra0, dec0, ss.ra, ss.dec)
			asecperkpc = cosmo.arcsec_per_kpc_proper(ss.zmean)
			rproj_kpc = rproj_arcsec / asecperkpc.value
			rproj_list.append(rproj_kpc)

		if min(rproj_list) <= 1000*rproj_search:
			rind = rproj_list.index(min(rproj_list))
			zspec.append(f.cat.z_spec[zinds][i_gal])
			zphot.append(f.zout.z_peak[zinds][i_gal])
			lmass.append(f.fout.lmass[zinds][i_gal])
			zlss.append(f.substructures[rind].zmean)

			### now that we've grabbed the galaxy, determine if it is:
			###   0 = true +
			###   1 = true -
			###   2 = false +
	def __init__(self, name, version, zclust, sigmaz, alpha=50, chi2red_thresh=10):
		self.name = name          # e.g. "NEP 200"
		self.version = version    # e.g. "nep200_v0.0.4"
		self.zclust = zclust      # cluster redshift
		self.sigmaz = sigmaz      # 1sigma scatter in (zphot-zspec)/(1+zspec)
		self.zspec_lo = 0         # lower redshift bound for specz
		self.zspec_hi = 0         # upper redshift bound for specz
		self.substructures = []
		self.alpha = alpha

		self.cat = gunzip_read_gzip('%s/%s/%s.cat.gz' % (github_dir, version, version), readcat=1)
		self.zout = gunzip_read_gzip('%s/%s/%s.zout.gz' % (github_dir, version, version), readzout=1)
		self.fout = gunzip_read_gzip('%s/%s/%s.fout.gz' % (github_dir, version, version), readcat=1)
		self.restframe = gunzip_read_gzip('%s/%s/%s.restframe.gz' % (github_dir, version, version), readcat=1)
		self.rfcolors = gunzip_read_gzip('%s/%s/%s.restframe_colors.gz' % (github_dir, version, version), readcat=1)


		###  SETTING OBJECTS IDENTIFIED AS SECURE STARS FROM SPECTROSCOPY TO use=0
		self.crossmatch = gunzip_read_gzip('%s/%s/%s.crossmatch.gz' % (github_dir, version, version), readcat=1, dtype=str)
		self.star_inds = pylab.find(self.crossmatch.Q == '-1')
		for i_star in self.star_inds:
			id_phot_arr = self.crossmatch.id_phot[i_star].split(',')
			for id_phot in id_phot_arr:
				if id_phot != '-1':
					self.cat.use[int(id_phot)-1] *= 0


		print '  reading: %s_voronoi.pickle' % name
		self.voronoi = pickle.load(open('../data/%s_voronoi.pickle' % name, 'rb'))
		self.overdens_max = []
		for vi in range(len(self.voronoi.overdens_matrix)):
			self.overdens_max.append(self.voronoi.overdens_matrix[vi].max())
		self.overdens_max = pylab.array(self.overdens_max)


		###  UPDATING USE FLAG WITH REDUCE CHI**2 THRESHOLD
		chi2red = self.zout.chi_p / (self.zout.nfilt - 1.)
		cinds = pylab.find((chi2red > chi2red_thresh) & (self.cat.z_spec < 0))
		self.cat.use[cinds] = 0.


		###  UVJ classification
		self.UV_color = -2.5 * pylab.log10(self.restframe.restflux_U / self.restframe.restflux_V)
		self.VJ_color = -2.5 * pylab.log10(self.restframe.restflux_V / self.restframe.restflux_J)
		self.uvj_class = mypy.uvj_select(self.UV_color, self.VJ_color, self.fout.z)

		###  UVJ classification based on EAZY in 2-filter mode
		self.UV_color_2filter = self.rfcolors.U_V_color
		self.VJ_color_2filter = self.rfcolors.V_J_color
		self.uvj_class_2filter = mypy.uvj_select(self.UV_color_2filter, self.VJ_color_2filter, self.fout.z)

		###  NUVrJ classification
		self.NUVr_color = -2.5 * pylab.log10(self.restframe.restflux_NUV / self.restframe.restflux_r)
		self.rJ_color = -2.5 * pylab.log10(self.restframe.restflux_r / self.restframe.restflux_J)
		self.nuvrj_class = mypy.nuvrj_select(self.NUVr_color, self.rJ_color, self.fout.z)



		xyrd1 = self.cat.x[0], self.cat.y[0], self.cat.ra[0], self.cat.dec[0]
		xyrd2 = self.cat.x[1], self.cat.y[1], self.cat.ra[1], self.cat.dec[1]
		d_arcsec = mypy.radec_sep(xyrd1[2], xyrd1[3], xyrd2[2], xyrd2[3])
		d_pixel = ((xyrd1[0]-xyrd2[0])**2 + (xyrd1[1] - xyrd2[1])**2)**0.5 
		self.px_scale = d_arcsec / d_pixel

		### getting z band magnitude
		try: self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_z)
		except: pass
		if name != 'SC1324':
			try: self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_Zplus)
			except: pass

		###  setting spatial flag based on Convex Hull method
		#zspecinds = pylab.find(self.cat.z_spec > 0)
		#self.spatial_flag = checkPoint(self.cat.ra[zspecinds], self.cat.dec[zspecinds], self.cat.ra, self.cat.dec)
		#self.inds_spatial = pylab.find(self.spatial_flag == 1)

		###  setting spatial flag based on Concave Hull method (creates a "tighter" spatial selection than Cnvex Hull)
		zspecinds = pylab.find(self.cat.z_spec > 0)
		points = pylab.array(zip(self.cat.x[zspecinds], self.cat.y[zspecinds]))
		self.concave_hull, self.edge_points = alpha_shape(points, alpha)
		self.inds_spatial = CheckPoints(self.concave_hull.buffer(10), self.cat.x, self.cat.y)
		self.area_pix2 = self.concave_hull.buffer(10).area
		self.area_arcmin2 = self.area_pix2 * (self.px_scale/60.)**2
		print ''
    def __init__(self,
                 name,
                 version,
                 zclust,
                 sigmaz,
                 imname,
                 alpha=50,
                 chi2red_thresh=10):
        self.name = name  # e.g. "NEP 200"
        self.version = version  # e.g. "nep200_v0.0.4"
        self.zclust = zclust  # cluster redshift
        self.sigmaz = sigmaz  # 1sigma scatter in (zphot-zspec)/(1+zspec)
        self.zspec_lo = 0  # lower redshift bound for specz
        self.zspec_hi = 0  # upper redshift bound for specz
        self.alpha = alpha
        self.imname = imname

        self.cat = gunzip_read_gzip('%s/%s/%s.cat.gz' %
                                    (data_dir, version, version),
                                    readcat=1)
        self.zout = gunzip_read_gzip('%s/%s/%s.zout.gz' %
                                     (data_dir, version, version),
                                     readzout=1)
        self.fout = gunzip_read_gzip('%s/%s/%s.fout.gz' %
                                     (data_dir, version, version),
                                     readcat=1)

        print '  reading: %s_voronoi.pickle' % name
        self.voronoi = pickle.load(
            open('../data/%s_voronoi.pickle' % name, 'rb'))

        ###  UPDATING USE FLAG WITH REDUCE CHI**2 THRESHOLD
        chi2red = self.zout.chi_p / (self.zout.nfilt - 1.)
        cinds = pylab.find((chi2red > chi2red_thresh) & (self.cat.z_spec < 0))
        self.cat.use[cinds] = 0.

        xyrd1 = self.cat.x[0], self.cat.y[0], self.cat.ra[0], self.cat.dec[0]
        xyrd2 = self.cat.x[1], self.cat.y[1], self.cat.ra[1], self.cat.dec[1]
        d_arcsec = mypy.radec_sep(xyrd1[2], xyrd1[3], xyrd2[2], xyrd2[3])
        d_pixel = ((xyrd1[0] - xyrd2[0])**2 + (xyrd1[1] - xyrd2[1])**2)**0.5
        self.px_scale = d_arcsec / d_pixel

        ### getting z band magnitude
        try:
            self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_z)
        except:
            pass
        if name != 'SC1324':
            try:
                self.zmagnitude = 25 - 2.5 * pylab.log10(
                    self.cat.fluxauto_Zplus)
            except:
                pass

        ###  setting spatial flag based on Convex Hull method
        #zspecinds = pylab.find(self.cat.z_spec > 0)
        #self.spatial_flag = checkPoint(self.cat.ra[zspecinds], self.cat.dec[zspecinds], self.cat.ra, self.cat.dec)
        #self.inds_spatial = pylab.find(self.spatial_flag == 1)

        ###  setting spatial flag based on Concave Hull method (creates a "tighter" spatial selection than Cnvex Hull)
        zspecinds = pylab.find(self.cat.z_spec > 0)
        points = pylab.array(zip(self.cat.x[zspecinds], self.cat.y[zspecinds]))
        self.concave_hull, self.edge_points = alpha_shape(points, alpha)
        self.inds_spatial = CheckPoints(self.concave_hull.buffer(10),
                                        self.cat.x, self.cat.y)
        self.area_pix2 = self.concave_hull.buffer(10).area
        self.area_arcmin2 = self.area_pix2 * (self.px_scale / 60.)**2

        ###  SEGMENTATION IMAGE
        image = fits.open(imname)
        segmap = image[0].data * 0.
        xpoints, ypoints = [], []
        for x in range(segmap.shape[1]):
            mypy.progress_bar(x, segmap.shape[1])
            for y in range(segmap.shape[0]):
                xpoints.append(x)
                ypoints.append(y)
        xpoints = pylab.array(xpoints)
        ypoints = pylab.array(ypoints)

        concave_hull_segmap, edge_points_segmap = alpha_shape(points, alpha)
        inds_segmap = CheckPoints(concave_hull_segmap.buffer(10), xpoints,
                                  ypoints)
        inds_segmap_spatial = (ypoints[inds_segmap] - 1,
                               xpoints[inds_segmap] - 1)
        segmap[inds_segmap_spatial] += 1
        fits.writeto('../data/zspec_segmentation_maps/%s_segmap.fits' %
                     version,
                     segmap,
                     header=image[0].header,
                     clobber=1)
        print ''
    def __init__(self,
                 name,
                 version,
                 zclust,
                 sigmaz,
                 alpha=50,
                 chi2red_thresh=10):
        self.name = name  # e.g. "NEP 200"
        self.version = version  # e.g. "nep200_v0.0.4"
        self.zclust = zclust  # cluster redshift
        self.sigmaz = sigmaz  # 1sigma scatter in (zphot-zspec)/(1+zspec)
        self.zspec_lo = 0  # lower redshift bound for specz
        self.zspec_hi = 0  # upper redshift bound for specz
        self.substructures = []
        self.alpha = alpha
        self.chi2red_thresh = chi2red_thresh

        self.cat = gunzip_read_gzip('%s/%s/%s.cat.gz' %
                                    (data_dir, version, version),
                                    readcat=1)
        self.zout = gunzip_read_gzip('%s/%s/%s.zout.gz' %
                                     (data_dir, version, version),
                                     readzout=1)
        self.fout = gunzip_read_gzip('%s/%s/%s.fout.gz' %
                                     (data_dir, version, version),
                                     readcat=1)
        self.restframe = gunzip_read_gzip('%s/%s/%s.restframe.gz' %
                                          (data_dir, version, version),
                                          readcat=1)

        self.masslimits = mypy.readcat(
            '../data/completeness/masslimits_%s.dat' % name)

        ###  UPDATING USE FLAG WITH REDUCE CHI**2 THRESHOLD
        chi2red = self.zout.chi_p / (self.zout.nfilt - 1.)
        cinds = pylab.find((chi2red > chi2red_thresh) & (self.cat.z_spec < 0))
        self.cat.use[cinds] = 0.

        ###  UVJ classification
        self.UV_color = -2.5 * pylab.log10(
            self.restframe.restflux_U / self.restframe.restflux_V)
        self.VJ_color = -2.5 * pylab.log10(
            self.restframe.restflux_V / self.restframe.restflux_J)
        self.uvj_class = mypy.uvj_select(self.UV_color, self.VJ_color,
                                         self.fout.z)

        xyrd1 = self.cat.x[0], self.cat.y[0], self.cat.ra[0], self.cat.dec[0]
        xyrd2 = self.cat.x[1], self.cat.y[1], self.cat.ra[1], self.cat.dec[1]
        d_arcsec = mypy.radec_sep(xyrd1[2], xyrd1[3], xyrd2[2], xyrd2[3])
        d_pixel = ((xyrd1[0] - xyrd2[0])**2 + (xyrd1[1] - xyrd2[1])**2)**0.5
        self.px_scale = d_arcsec / d_pixel

        ### getting z band magnitude
        try:
            self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_z)
        except:
            pass
        if name != 'SC1324':
            try:
                self.zmagnitude = 25 - 2.5 * pylab.log10(
                    self.cat.fluxauto_Zplus)
            except:
                pass

        ###  setting spatial flag based on Convex Hull method
        #zspecinds = pylab.find(self.cat.z_spec > 0)
        #self.spatial_flag = checkPoint(self.cat.ra[zspecinds], self.cat.dec[zspecinds], self.cat.ra, self.cat.dec)
        #self.inds_spatial = pylab.find(self.spatial_flag == 1)

        ###  setting spatial flag based on Concave Hull method (creates a "tighter" spatial selection than Cnvex Hull)
        zspecinds = pylab.find(self.cat.z_spec > 0)
        points = pylab.array(zip(self.cat.x[zspecinds], self.cat.y[zspecinds]))
        self.concave_hull, self.edge_points = alpha_shape(points, alpha)
        self.inds_spatial = CheckPoints(self.concave_hull.buffer(10),
                                        self.cat.x, self.cat.y)
        self.area_pix2 = self.concave_hull.buffer(10).area
        self.area_arcmin2 = self.area_pix2 * (self.px_scale / 60.)**2
        print ''
Example #11
0
	def __init__(self, name, version, zclust, sigmaz, alpha=50, chi2red_thresh=10, 
		         uvj_slope=0.88, uvj_intercept=0.59, radio_AGN_filename=None, readcats=True):
		self.name = name          # e.g. "NEP 200"
		self.version = version    # e.g. "nep200_v0.0.4"
		self.zclust = zclust      # cluster redshift
		self.sigmaz = sigmaz      # 1sigma scatter in (zphot-zspec)/(1+zspec)
		self.zspec_lo = 0         # lower redshift bound for specz
		self.zspec_hi = 0         # upper redshift bound for specz
		self.alpha = alpha

		if readcats:
			print '  reading: %s.cat' % version
			self.cat = mypy.readcat('%s/%s/%s/%s.cat.gz' % (github_dir, github_photo_cats, version, version))
			print '  reading: %s.zout' % version
			self.zout = mypy.readzout('%s/%s/%s/%s.zout.gz' % (github_dir, github_photo_cats, version, version))
			print '  reading: %s_ZFparams.fout' % version
			self.fout = mypy.readcat('%s/%s/%s/%s_ZFparams.fout.gz' % (github_dir, github_photo_cats, version, version))
			print '  reading: %s.fir' % version
			self.fir = mypy.readcat('%s/%s/%s/%s.fir.gz' % (github_dir, github_photo_cats, version, version))
			print '  reading: %s.restframe' % version
			self.restframe = mypy.readcat('%s/%s/%s/%s.restframe.gz' % (github_dir, github_photo_cats, version, version))
			#print '  reading: %s.restframe_colors' % version
			#self.rfcolors = mypy.readcat('%s/%s/%s/%s.restframe_colors.gz' % (github_dir, github_photo_cats, version, version))


			###  SETTING OBJECTS IDENTIFIED AS SECURE STARS FROM SPECTROSCOPY TO use=0
			self.crossmatch = mypy.readcat('%s/%s/%s/%s.crossmatch.gz' % (github_dir, github_photo_cats, version, version), dtype=str)
			self.star_inds = self.crossmatch.Q == '-1'
			for i_star in self.star_inds:
				id_phot_arr = self.crossmatch.id_phot[i_star].split(',')
				for id_phot in id_phot_arr:
					if id_phot != '-1':
						self.cat.use[int(id_phot)-1] *= 0


			print '  reading: %s_voronoi.pickle' % name
			self.voronoi = pickle.load(open('/Users/atomczak/Dropbox/ORELSE/DATA/VORONOI/%s_voronoi.pickle' % name, 'rb'))
			self.overdens_max = []
			for vi in range(len(self.voronoi.overdens_matrix)):
				self.overdens_max.append(self.voronoi.overdens_matrix[vi].max())
			self.overdens_max = numpy.array(self.overdens_max)


			###  UPDATING USE FLAG WITH REDUCE CHI**2 THRESHOLD
			chi2red = self.zout.chi_p / (self.zout.nfilt - 1.)
			cinds = (chi2red > chi2red_thresh) & (self.cat.z_spec < 0)
			self.cat.use[cinds] = 0.


			###  UVJ classification
			self.UV_color = -2.5 * numpy.log10(self.restframe.restflux_U / self.restframe.restflux_V)
			self.VJ_color = -2.5 * numpy.log10(self.restframe.restflux_V / self.restframe.restflux_J)
			self.uvj_class = mypy.uvj_select(self.UV_color, self.VJ_color, self.fout.z)
			#self.uvj_class = uvj_select(self.UV_color, self.VJ_color, self.fout.z, uvj_slope=uvj_slope, uvj_intercept=uvj_intercept)

			###  UVJ classification based on EAZY in 2-filter mode
			#self.UV_color_2filter = self.rfcolors.U_V_color
			#self.VJ_color_2filter = self.rfcolors.V_J_color
			#self.uvj_class_2filter = mypy.uvj_select(self.UV_color_2filter, self.VJ_color_2filter, self.fout.z)

			###  NUVrJ classification
			self.NUVr_color = -2.5 * numpy.log10(self.restframe.restflux_NUV / self.restframe.restflux_r)
			self.rJ_color = -2.5 * numpy.log10(self.restframe.restflux_r / self.restframe.restflux_J)
			self.nuvrj_class = mypy.nuvrj_select(self.NUVr_color, self.rJ_color, self.fout.z)


			###########################
			###  adding Radio AGN flag
			###########################

			self.radio_AGN_cat = None
			self.AGN_flag_radio = numpy.zeros(len(self.cat.id))
			if radio_AGN_filename != None:
				self.radio_AGN_cat = mypy.readcat('%s/%s/%s' % (github_dir, github_radio_cats, radio_AGN_filename), dtype=str)
				ids_radio_AGN = self.radio_AGN_cat.id_phot.astype(int)
				self.AGN_flag_radio[ids_radio_AGN - 1] = 1


			###########################
			###  adding Xray AGN flag
			###########################

			self.xray_AGN_cat = None
			self.AGN_flag_xray = numpy.zeros(len(self.cat.id))



			xyrd1 = self.cat.x[0], self.cat.y[0], self.cat.ra[0], self.cat.dec[0]
			xyrd2 = self.cat.x[1], self.cat.y[1], self.cat.ra[1], self.cat.dec[1]
			d_arcsec = mypy.radec_sep(xyrd1[2], xyrd1[3], xyrd2[2], xyrd2[3])
			d_pixel = ((xyrd1[0]-xyrd2[0])**2 + (xyrd1[1] - xyrd2[1])**2)**0.5 
			self.px_scale = d_arcsec / d_pixel

			### getting z band magnitude
			try: self.zmagnitude = 25 - 2.5 * numpy.log10(self.cat.fluxauto_z)
			except: pass
			if name != 'SC1324':
				try: self.zmagnitude = 25 - 2.5 * numpy.log10(self.cat.fluxauto_Zplus)
				except: pass

			###  setting spatial flag based on Convex Hull method
			#zspecinds = self.cat.z_spec > 0
			#self.spatial_flag = checkPoint(self.cat.ra[zspecinds], self.cat.dec[zspecinds], self.cat.ra, self.cat.dec)
			#self.inds_spatial = self.spatial_flag == 1

			###  setting spatial flag based on Concave Hull method (creates a "tighter" spatial selection than Cnvex Hull)
			zspecinds = self.cat.z_spec > 0
			points = numpy.array(zip(self.cat.x[zspecinds], self.cat.y[zspecinds]))
			self.concave_hull, self.edge_points = mypy.alpha_shape(points, alpha)
			self.inds_spatial = mypy.CheckPoints(self.concave_hull.buffer(10), self.cat.x, self.cat.y)
			self.area_pix2 = self.concave_hull.buffer(10).area
			self.area_arcmin2 = self.area_pix2 * (self.px_scale/60.)**2
			print ''
Example #12
0
print 'searching for spectroscopic matches...'
inds_match_tomczak = []
inds_match_lemaux = []
nmatch = []



for i in range(len(speccat.id)):
	
	###  Skipping serendipitous objects with no previously identified photometric counterpart
	if i > 0 and speccat.ra[i] == speccat.ra[i-1] and speccat.dec[i] == speccat.dec[i-1]:
		continue

	ra, dec = float(speccat.ra[i]), float(speccat.dec[i])
	seps = mypy.radec_sep(ra, dec, sexcats[0].x_world, sexcats[0].y_world)

	inds = pylab.find(seps < 0.75)
	nmatch.append(len(inds))

	if len(inds) == 1:
		id_specs[inds[0]] = speccat.id[i]
		z_specs[inds[0]] = float(speccat.z_spec[i])
		z_spec_errs[inds[0]] = float(speccat.z_spec_err[i])
		Q_specs[inds[0]] = int(speccat.Q[i])
		inds_match_tomczak.append(inds[0])
		inds_match_lemaux.append(i)

	if len(inds) == 0:
		print speccat.ra[i], speccat.dec[i], speccat.Q[i], speccat.slitnum[i], speccat.id[i]
try: os.mkdir('./catalogs')
except: pass
try: os.mkdir('./psfs')
except: pass





###  zooming psf to pixel scale of image
psf_pxscale = 0.2

xcen, ycen = pylab.array(imdat.shape) / 2
ra1, dec1 = imwcs.all_pix2world([xcen], [ycen], 1)
ra2, dec2 = imwcs.all_pix2world([xcen+1], [ycen], 1)
imdat_pxscale = mypy.radec_sep(ra1[0], dec1[0], ra2[0], dec2[0])

psfdat_zoom = ndimage.zoom(psfdat, psf_pxscale / imdat_pxscale)

fits.writeto('./psfs/psf_%s' % os.path.basename(imname), psfdat_zoom, clobber=1)
print '\nwrote to ./psfs/psf_%s' % os.path.basename(imname)





###  estimate FWHM
dx, dy = psfdat_zoom.shape
xx, yy = pylab.meshgrid(range(-dx/2+1, dx/2+1), range(-dy/2+1, dy/2+1))
rr = (xx**2 + yy**2)**0.5







###  coordinates and size of large box (size in arcmin)
ra0, dec0, box_size_amin, cutout_size_amin = 259.1919, 67.147616, 14., 2.5
x0, y0 = voronoi_wcs.wcs_world2pix([ra0], [dec0], 1)
x0, y0 = int(x0 + 0.5), int(y0 + 0.5)

###  pixel scale of voronoi map
xs, ys = voronoi_wcs.wcs_pix2world([0, 0], [0, 1], 1)
px_scale = mypy.radec_sep(xs[0], ys[0], xs[1], ys[1])
box_size_px = int(box_size_amin * 60 / px_scale)






fig = pylab.figure(figsize=(18.1125, 8.35))

sp2 = pylab.subplot2grid((5, 12), (1, 3), rowspan=3, colspan=3, aspect=1)
sp1 = pylab.subplot2grid((5, 12), (1, 0), rowspan=3, colspan=3, aspect=1, title='Voronoi Tesselation')
sp3 = pylab.subplot2grid((5, 12), (0, 7), rowspan=5, colspan=5, aspect=1)

fig.subplots_adjust(wspace=0.1, left=0.02)
sp1.xaxis.set_visible(0)
Example #15
0
    def __init__(self,
                 name,
                 version,
                 zclust,
                 sigmaz,
                 alpha=50,
                 chi2red_thresh=10):
        self.name = name  # e.g. "NEP 200"
        self.version = version  # e.g. "nep200_v0.0.4"
        self.zclust = zclust  # cluster redshift
        self.sigmaz = sigmaz  # 1sigma scatter in (zphot-zspec)/(1+zspec)
        self.zspec_lo = 0  # lower redshift bound for specz
        self.zspec_hi = 0  # upper redshift bound for specz
        self.substructures = []
        self.alpha = alpha

        self.cat = gunzip_read_gzip('%s/%s/%s.cat.gz' %
                                    (github_dir, version, version),
                                    readcat=1)
        self.zout = gunzip_read_gzip('%s/%s/%s.zout.gz' %
                                     (github_dir, version, version),
                                     readzout=1)
        self.fout1 = gunzip_read_gzip('%s/%s/%s.fout.gz' %
                                      (github_dir, version, version),
                                      readcat=1)
        self.fout2 = gunzip_read_gzip('%s/%s/%s_ZFparams.fout.gz' %
                                      (github_dir, version, version),
                                      readcat=1)

        ###  SETTING OBJECTS IDENTIFIED AS SECURE STARS FROM SPECTROSCOPY TO use=0
        self.crossmatch = gunzip_read_gzip('%s/%s/%s.crossmatch.gz' %
                                           (github_dir, version, version),
                                           readcat=1,
                                           dtype=str)
        self.star_inds = pylab.find(self.crossmatch.Q == '-1')
        for i_star in self.star_inds:
            id_phot_arr = self.crossmatch.id_phot[i_star].split(',')
            for id_phot in id_phot_arr:
                if id_phot != '-1':
                    self.cat.use[int(id_phot) - 1] *= 0

        ###  UPDATING USE FLAG WITH REDUCE CHI**2 THRESHOLD
        chi2red = self.zout.chi_p / (self.zout.nfilt - 1.)
        cinds = pylab.find((chi2red > chi2red_thresh) & (self.cat.z_spec < 0))
        self.cat.use[cinds] = 0.

        xyrd1 = self.cat.x[0], self.cat.y[0], self.cat.ra[0], self.cat.dec[0]
        xyrd2 = self.cat.x[1], self.cat.y[1], self.cat.ra[1], self.cat.dec[1]
        d_arcsec = mypy.radec_sep(xyrd1[2], xyrd1[3], xyrd2[2], xyrd2[3])
        d_pixel = ((xyrd1[0] - xyrd2[0])**2 + (xyrd1[1] - xyrd2[1])**2)**0.5
        self.px_scale = d_arcsec / d_pixel

        ### getting z band magnitude
        try:
            self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_z)
        except:
            pass
        if name != 'SC1324':
            try:
                self.zmagnitude = 25 - 2.5 * pylab.log10(
                    self.cat.fluxauto_Zplus)
            except:
                pass

        ###  setting spatial flag based on Convex Hull method
        #zspecinds = pylab.find(self.cat.z_spec > 0)
        #self.spatial_flag = checkPoint(self.cat.ra[zspecinds], self.cat.dec[zspecinds], self.cat.ra, self.cat.dec)
        #self.inds_spatial = pylab.find(self.spatial_flag == 1)

        ###  setting spatial flag based on Concave Hull method (creates a "tighter" spatial selection than Cnvex Hull)
        zspecinds = pylab.find(self.cat.z_spec > 0)
        points = pylab.array(zip(self.cat.x[zspecinds], self.cat.y[zspecinds]))
        self.concave_hull, self.edge_points = alpha_shape(points, alpha)
        self.inds_spatial = CheckPoints(self.concave_hull.buffer(10),
                                        self.cat.x, self.cat.y)
        self.area_pix2 = self.concave_hull.buffer(10).area
        self.area_arcmin2 = self.area_pix2 * (self.px_scale / 60.)**2
        print ''
Example #16
0
def selectionFunction_cl0910(cat):

	image='/Volumes/PHOENIX/atomczak/DATA/ORELSE/catalogs/v001/Cl_0910+5422/images/sci/wregister/detection_image/my_detection_RcI+Z+.fits'
	imwcs = wcs.WCS(image)

	###  vertices of lines foriming polygon selection region
	ra1_a, dec1_a, ra2_a, dec2_a = 137.46145,54.333665,137.71293,54.468663
	ra1_b, dec1_b, ra2_b, dec2_b = 137.89374,54.400527,137.71354,54.469018
	ra1_c, dec1_c, ra2_c, dec2_c = 137.89313,54.400172,137.6829,54.293655
	ra1_d, dec1_d, ra2_d, dec2_d = 137.35995,54.202896,137.6829,54.293655
	ra1_e, dec1_e, ra2_e, dec2_e = 137.35995,54.202896,137.33306,54.292819
	ra1_f, dec1_f, ra2_f, dec2_f = 137.46145,54.333665,137.33306,54.292819

	(x1_a, y1_a), (x2_a, y2_a) = imwcs.wcs_world2pix(pylab.array(zip([ra1_a, ra2_a], [dec1_a, dec2_a])), 1)
	(x1_b, y1_b), (x2_b, y2_b) = imwcs.wcs_world2pix(pylab.array(zip([ra1_b, ra2_b], [dec1_b, dec2_b])), 1)
	(x1_c, y1_c), (x2_c, y2_c) = imwcs.wcs_world2pix(pylab.array(zip([ra1_c, ra2_c], [dec1_c, dec2_c])), 1)
	(x1_d, y1_d), (x2_d, y2_d) = imwcs.wcs_world2pix(pylab.array(zip([ra1_d, ra2_d], [dec1_d, dec2_d])), 1)
	(x1_e, y1_e), (x2_e, y2_e) = imwcs.wcs_world2pix(pylab.array(zip([ra1_e, ra2_e], [dec1_e, dec2_e])), 1)
	(x1_f, y1_f), (x2_f, y2_f) = imwcs.wcs_world2pix(pylab.array(zip([ra1_f, ra2_f], [dec1_f, dec2_f])), 1)
	xs = pylab.array([x1_a, x2_a, x1_b, x2_b, x1_c, x2_c, x1_d, x2_d, x1_e, x2_e, x1_f, x2_f])
	ys = pylab.array([y1_a, y2_a, y1_b, y2_b, y1_c, y2_c, y1_d, y2_d, y1_e, y2_e, y1_f, y2_f])

	slope_a = (y1_a - y2_a) / (x1_a - x2_a)
	slope_b = (y1_b - y2_b) / (x1_b - x2_b)
	slope_c = (y1_c - y2_c) / (x1_c - x2_c)
	slope_d = (y1_d - y2_d) / (x1_d - x2_d)
	slope_e = (y1_e - y2_e) / (x1_e - x2_e)
	slope_f = (y1_f - y2_f) / (x1_f - x2_f)

	norm_a = y1_a - slope_a * x1_a
	norm_b = y1_b - slope_b * x1_b
	norm_c = y1_c - slope_c * x1_c
	norm_d = y1_d - slope_d * x1_d
	norm_e = y1_e - slope_e * x1_e
	norm_f = y1_f - slope_f * x1_f

	###  selecting galaxies within a user-defind polygon enclosing the spectroscopic coverage
	inds = pylab.find(((cat.y < slope_a * cat.x + norm_a) | (cat.y < slope_f * cat.x + norm_f)) & 
		              (cat.y < slope_b * cat.x + norm_b) & 
		              (cat.y > slope_c * cat.x + norm_c) & 
		              (cat.y > slope_d * cat.x + norm_d) & 
		              (cat.y > slope_e * cat.x + norm_e) & 
		              (cat.use == 1))


	###  calculating the area of the user-defind polygon
	ra12, dec12 = imwcs.wcs_pix2world([0, 0], [0, 1], 1)
	px_scale = mypy.radec_sep(ra12[0], dec12[0], ra12[1], dec12[1])

	###  ra_center, dec_center, radius(arcsec)
	holes = pylab.array([[137.72017,54.439911,11.491746],
                         [137.81728,54.398832,6.7431164],
                         [137.71937,54.409576,9.3121025],
                         [137.76736,54.369088,12.255985],
                         [137.7616,54.351868,9.1073549],
                         [137.68401,54.371568,6.48],
                         [137.67523,54.374569,11.123555],
                         [137.65235,54.358788,9.5279771],
                         [137.64415,54.358564,9.6752827],
                         [137.62866,54.394229,19.453046],
                         [137.65501,54.374567,5.6216075],
                         [137.58682,54.325645,13.965681],
                         [137.5307,54.353927,8.7263942],
                         [137.58229,54.305084,8.101748],
                         [137.5724,54.299409,16.05717],
                         [137.61487,54.295104,6.9433894],
                         [137.59756,54.28876,6.0919288],
                         [137.44301,54.249783,10.550997],
                         [137.46675,54.292829,7.7258551],
                         [137.54163,54.2766,7.7839873],
                         [137.48524,54.330752,7.1368481],
                         [137.52003,54.250906,8.5717222],
                         [137.50938,54.250447,7.4277835],
                         [137.47348,54.241281,11.223961],
                         [137.41227,54.237608,12.044997],
                         [137.34195,54.281106,11.348039],
                         [137.86589,54.391751,6.305658]])

	area_px2 = PolyArea(xs, ys)
	area_arcsec2 = area_px2 * px_scale**2
	for hole in holes:
		area_arcsec2 -= pylab.pi * hole[2]**2
	area_arcmin2 = area_arcsec2 / 60.**2

	return inds, area_arcmin2
		###  finding lower/upper zspec limits
		zlo_spec, zhi_spec = f.zclust, f.zclust
		dr_pkpc_arr = pylab.zeros((len(f.substructures), len(f.cat.id)))
		for ssi in range(len(f.substructures)):
			ss = f.substructures[ssi]
			vmean = vrecess(ss.zmean)
			vlo = vmean - 3*ss.vsigma1mpc
			vhi = vmean + 3*ss.vsigma1mpc
			zlo = zrecess(vlo)
			zhi = zrecess(vhi)
			if zlo < zlo_spec: zlo_spec = zlo
			if zhi > zhi_spec: zhi_spec = zhi

			###  calculating projected distance between SS and each galaxy
			dr_arcsec = mypy.radec_sep(ss.ra, ss.dec, f.cat.ra, f.cat.dec)
			dr_pkpc_arr[ssi] += dr_arcsec * kpc2arcsec


		###  identifying projected radius to nearest substructure for all galaxies
		dr_pkpc_min = pylab.zeros(len(f.cat.id))
		for gi in range(len(f.cat.id)):
			dr_pkpc_min[gi] += min(dr_pkpc_arr[:,gi])






		#print '\nUSING EXPANDED ZSPEC WINDOW !!!\n'
		#zlo_spec = f.zclust - 0.2
Example #18
0
def selectionFunction_sc1604(cat):

	image='/Volumes/PHOENIX/atomczak/DATA/ORELSE/catalogs/v001/Cl_1604+4320/catalogs/CL1604_master_Rc.fits'
	imwcs = wcs.WCS(image)

	###  vertices of lines foriming polygon selection region
	ra1_a, dec1_a, ra2_a, dec2_a = 241.18999,43.319742,241.13575,43.032008
	ra1_b, dec1_b, ra2_b, dec2_b = 241.04834,43.042383,241.13575,43.032008
	ra1_c, dec1_c, ra2_c, dec2_c = 241.04834,43.042383,240.91837,43.295081
	ra1_d, dec1_d, ra2_d, dec2_d = 240.75818,43.365714,240.91837,43.295081
	ra1_e, dec1_e, ra2_e, dec2_e = 240.75818,43.365714,240.79529,43.455913
	ra1_f, dec1_f, ra2_f, dec2_f = 241.20824,43.440948,240.79529,43.455913
	ra1_g, dec1_g, ra2_g, dec2_g = 241.20824,43.440948,241.24855,43.325684
	ra1_h, dec1_h, ra2_h, dec2_h = 241.18999,43.319742,241.24855,43.325684



	(x1_a, y1_a), (x2_a, y2_a) = imwcs.wcs_world2pix(pylab.array(zip([ra1_a, ra2_a], [dec1_a, dec2_a])), 1)
	(x1_b, y1_b), (x2_b, y2_b) = imwcs.wcs_world2pix(pylab.array(zip([ra1_b, ra2_b], [dec1_b, dec2_b])), 1)
	(x1_c, y1_c), (x2_c, y2_c) = imwcs.wcs_world2pix(pylab.array(zip([ra1_c, ra2_c], [dec1_c, dec2_c])), 1)
	(x1_d, y1_d), (x2_d, y2_d) = imwcs.wcs_world2pix(pylab.array(zip([ra1_d, ra2_d], [dec1_d, dec2_d])), 1)
	(x1_e, y1_e), (x2_e, y2_e) = imwcs.wcs_world2pix(pylab.array(zip([ra1_e, ra2_e], [dec1_e, dec2_e])), 1)
	(x1_f, y1_f), (x2_f, y2_f) = imwcs.wcs_world2pix(pylab.array(zip([ra1_f, ra2_f], [dec1_f, dec2_f])), 1)
	(x1_g, y1_g), (x2_g, y2_g) = imwcs.wcs_world2pix(pylab.array(zip([ra1_g, ra2_g], [dec1_g, dec2_g])), 1)
	(x1_h, y1_h), (x2_h, y2_h) = imwcs.wcs_world2pix(pylab.array(zip([ra1_h, ra2_h], [dec1_h, dec2_h])), 1)
	xs = pylab.array([x1_a, x2_a, x1_b, x2_b, x1_c, x2_c, x1_d, x2_d, x1_e, x2_e, x1_f, x2_f, x1_g, x2_g, x1_h, x2_h])
	ys = pylab.array([y1_a, y2_a, y1_b, y2_b, y1_c, y2_c, y1_d, y2_d, y1_e, y2_e, y1_f, y2_f, y1_g, y2_g, y1_h, y2_h])

	slope_a = (y1_a - y2_a) / (x1_a - x2_a)
	slope_b = (y1_b - y2_b) / (x1_b - x2_b)
	slope_c = (y1_c - y2_c) / (x1_c - x2_c)
	slope_d = (y1_d - y2_d) / (x1_d - x2_d)
	slope_e = (y1_e - y2_e) / (x1_e - x2_e)
	slope_f = (y1_f - y2_f) / (x1_f - x2_f)
	slope_g = (y1_g - y2_g) / (x1_g - x2_g)
	slope_h = (y1_h - y2_h) / (x1_h - x2_h)

	norm_a = y1_a - slope_a * x1_a
	norm_b = y1_b - slope_b * x1_b
	norm_c = y1_c - slope_c * x1_c
	norm_d = y1_d - slope_d * x1_d
	norm_e = y1_e - slope_e * x1_e
	norm_f = y1_f - slope_f * x1_f
	norm_g = y1_g - slope_g * x1_g
	norm_h = y1_h - slope_h * x1_h

	###  selecting galaxies within a user-defind polygon enclosing the spectroscopic coverage
	inds = pylab.find((cat.y > slope_b * cat.x + norm_b) &
		              (cat.y < slope_e * cat.x + norm_e) &
		              (cat.y < slope_f * cat.x + norm_f) &
		              (cat.y < slope_g * cat.x + norm_g) &
		              ((cat.y > slope_a * cat.x + norm_a) | (cat.y > slope_h * cat.x + norm_h)) &
		              ((cat.y > slope_c * cat.x + norm_c) | (cat.y > slope_d * cat.x + norm_d)))



	###  calculating the area of the user-defind polygon
	ra12, dec12 = imwcs.wcs_pix2world([0, 0], [0, 1], 1)
	px_scale = mypy.radec_sep(ra12[0], dec12[0], ra12[1], dec12[1])

	###  ra_center, dec_center, radius(arcsec)
	holes = pylab.array([[241.05287,43.441308,25.845097],
                         [241.06541,43.41401,32.433931],
                         [241.14686,43.421204,18.177141],
                         [241.16931,43.423087,20.559791],
                         [241.14311,43.316167,33.185926],
                         [241.14619,43.265732,16.692676],
                         [241.01331,43.335491,18.023439],
                         [240.9647,43.396499,14.2458],
                         [240.90351,43.438506,17.323747],
                         [240.86569,43.357668,14.619093],
                         [241.0764,43.323762,13.507682],
                         [241.0665,43.321485,12.243407],
                         [241.16817,43.348006,10.962367],
                         [241.15879,43.351425,10.710095],
                         [240.99444,43.401458,11.073026],
                         [241.13639,43.386322,9.8980624],
                         [241.0962,43.266503,12.931588],
                         [241.05871,43.255123,11.746842],
                         [241.12848,43.252088,14.79412],
                         [241.13003,43.233886,20.697477],
                         [240.96029,43.262636,10.254993],
                         [240.96757,43.267574,8.1846382],
                         [240.88354,43.322437,13.506917],
                         [241.14769,43.195158,20.80547],
                         [241.1222,43.190997,13.509939],
                         [241.0936,43.219441,8.9580593],
                         [241.09204,43.206169,9.7404603],
                         [241.02857,43.204634,11.522894],
                         [241.11335,43.159146,13.839286],
                         [241.09931,43.099992,11.866212],
                         [241.0396,43.082537,15.065785],
                         [240.80567,43.366973,13.366928]])

	area_px2 = PolyArea(xs, ys)
	area_arcsec2 = area_px2 * px_scale**2
	for hole in holes:
		area_arcsec2 -= pylab.pi * hole[2]**2
	area_arcmin2 = area_arcsec2 / 60.**2

	return inds, area_arcmin2
Example #19
0
                master_id_spec = numpy.append(
                    master_id_spec, f.crossmatch.id_spec[ind_crossmatch])
                master_slitmask = numpy.append(
                    master_slitmask, f.crossmatch.slitmask[ind_crossmatch])
            except:
                pass

    digi_lmass = numpy.digitize(master_lmass, lmassbins)
    digi_overdens = numpy.digitize(master_overdens, overdensbins)

###  Creating Xray AGN flag in post
if True:
    master_AGN_flag_xray = []
    for i_gal in range(len(master_id_gal)):
        separations = mypy.radec_sep(xray_ra, xray_dec, master_ra[i_gal],
                                     master_dec[i_gal])
        ind_min_sep = numpy.where(separations == separations.min())[0][0]
        if separations.min() <= 2. and xray_lum_tot[ind_min_sep] > 10**42.5:
            master_AGN_flag_xray.append(True)
        else:
            master_AGN_flag_xray.append(False)
    master_AGN_flag_xray = numpy.array(master_AGN_flag_xray)

    master_id_field = master_id_field[-master_AGN_flag_xray]
    master_id_gal = master_id_gal[-master_AGN_flag_xray]
    master_ra = master_ra[-master_AGN_flag_xray]
    master_dec = master_dec[-master_AGN_flag_xray]
    master_zspec = master_zspec[-master_AGN_flag_xray]
    master_ftot_mips24 = master_ftot_mips24[-master_AGN_flag_xray]
    master_etot_mips24 = master_etot_mips24[-master_AGN_flag_xray]
    master_SFR_UVIR = master_SFR_UVIR[-master_AGN_flag_xray]