Ejemplo n.º 1
0
def gunzip_read_gzip(path2file, readcat=0, readzout=0, dtype=float, delimiter=None, comments='#'):

	if readcat == readzout:
		raise IOError('Need to specify either readcat or readzout!')

	print '  reading: %s' % os.path.basename(path2file)
	subprocess.call('gunzip %s' % path2file, shell=1)
	if readcat:
		outer = mypy.readcat(path2file[:-3], dtype=dtype, delimiter=delimiter, comments=comments)
	elif readzout:
		outer = mypy.readzout(path2file[:-3])
	subprocess.call('gzip %s' % path2file[:-3], shell=1)

	return outer
Ejemplo n.º 2
0
	sub_ylo = ylo + dy * rect[1]

	inset = subplot.figure.add_axes([sub_xlo, sub_ylo, sub_dx, sub_dy])
	return inset










version = 'sg0023+0423_v0.1.5'
cat = mypy.readzout('/Users/atomczak/DATA/ORELSE/%s.zspec.cat' % version)
zout = mypy.readzout('/Users/atomczak/DATA/ORELSE/EAZY/%s.zout' % version)
fout = mypy.readcat('/Users/atomczak/DATA/ORELSE/%s.fout' % version)


imnames = ['B', 'V', 'R$_+$', 'I$_+$', 'r\'', 'i\'', 'z\'', 'J', 'K', '[3.6]', '[4.5]']
i_red, i_grn, i_blu = 3, 2, 1

imdats = [fits.getdata('/Users/atomczak/DATA/ORELSE/Cl_0023+0423_tomczak_B_zp25.fits'),
          fits.getdata('/Users/atomczak/DATA/ORELSE/Cl_0023+0423_tomczak_V_zp25.fits'),
          fits.getdata('/Users/atomczak/DATA/ORELSE/wreg_CL0023_tomczak_R.fits'),
          fits.getdata('/Users/atomczak/DATA/ORELSE/wreg_CL0023_tomczak_I.fits'),
          fits.getdata('/Users/atomczak/DATA/ORELSE/wreg_cl0023_r_shift_norm_unwarp.fits'),
          fits.getdata('/Users/atomczak/DATA/ORELSE/wreg_cl0023_i_shift_norm_unwarp.fits'),
          fits.getdata('/Users/atomczak/DATA/ORELSE/wreg_cl0023_z_shift_norm_unwarp.fits'),
          fits.getdata('/Users/atomczak/DATA/ORELSE/wreg_Cl_0023+0423_J.fits'),
Ejemplo n.º 3
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 ''
Ejemplo n.º 4
0
def readzout_gzip(catname):
	subprocess.call('gunzip %s.gz' % catname, shell=1)
	output = mypy.readzout(catname)
	subprocess.call('gzip %s' % catname, shell=1)
	return output
voronoi_map = rxj1716_voronoi_maps[ind].data
voronoi_wcs = wcs.WCS(rxj1716_voronoi_maps[18].header)
z1, z2 = rxj1716_voronoi_maps[ind].header['Z1'], rxj1716_voronoi_maps[ind].header['Z2']

xgrid = pylab.arange(0., voronoi_map.shape[0], 1)
ygrid = pylab.arange(0., voronoi_map.shape[1], 1)
ragrid, decgrid = voronoi_wcs.wcs_pix2world(xgrid, ygrid, 1)

kernel = mypy.gauss2d(3, 3, 1, 1, 1, 0.5, 0.5)
kernel /= kernel.sum()
voronoi_map = signal.convolve2d(voronoi_map, kernel, mode='same')


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











###  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)