Day 1 - Introduction
These notes aim to supplement the content covered in the Lectures on Weak Lensing. It will help the readers to understand the tutorial sessions in a better manner. The primary aim is to give the readers a way to write their own weak lensing signal measurement pipelines.
We will start these tutorial sessions with a quick introduction to the SciServer, which will provide us with the appropriate python environment and the data for these sessions. Then we will cover some basic python programming which is useful in the tutorials. We will then cover each part of the pipeline in step by step process. At present, the notes are created to cover the content in 3 days, but the exact structure for the tutorial sessions will depend on the progress of these sessions.
A quick references for weak gravitational lensing are:
Saas-Fee Advanced Course 33: Gravitational Lensing: Strong, Weak & Micro
Also the arxiv version
Lecture notes by Prof Surhud More on the weak lensing is available here
Working on SciServer
Steps to start using SciServer cloud computing
Create an account on SciServer
Share your account user name with us, we will add you to a common group. In this group, you all can access the data shared by us. Also you can collaborate on a coding work with those people added in this common group.
Once we add your username to the common group, you are expected to receive an invitation of the same. This invitation will become visible to you on the Groups tab shown in the image below. Please go ahead and accept the invitation. Once you accept the invitation, you will be able to see directories shared by us with eveyone in the group. Please confirm that you see it.
Go to the Compute and create a container (Containers provide you an interactive jupyter notebook environment to write and save codes,plots and any other data.)
You can choose any arbitrary name for your container, check the appropriate boxes as shown in the image so that your container can access these User volumes shared by “divyar” user.
Make sure to read the storage policy carefully if you want to store your files on SciServer for a long time. It can save you from loosing your valuable data. For the current tutorial, we will store our codes in “Storage” volume named “persistent”.
Your container is ready if it looks something like this -
From here, you have to navigate to Storage/<your_user_name>/persistent directory. You can start creating your files in this directory.
Please avoid making a directory in Storage/ or Storage/<your_user_name>/ locations, as was explained in the point 6.
Congratulations!
You are all set up!
From here on, it’s just knowing how to use jupyter notebook to write your codes.
Reading and Plotting the Data
We will first learn how to read files using pandas and then we will plot them to have a feel of the overlap between the lenses and sources. Some of the useful python packages: pandas, numpy, matplotlib
Please not that in the below codes put the right sciserver paths. For our case the file paths are
lenses, /home/idies/workspace/Storage/divyar/IAGRG_2022/DataStore/redmapper.dat
sources, /home/idies/workspace/Storage/divyar/IAGRG_2022/DataStore/hsc/
[3]:
#loading the required packages
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# we are setting the below params to adjust plots
plt.rcParams['figure.figsize'] = [3,3]
plt.rcParams['figure.dpi'] = 250
[9]:
#putting the path of the lens catalog
len_path = '../../weakpipe/DataStore/redmapper.dat'
lenses = pd.read_csv(len_path, delim_whitespace=1)
#printing the columns in the file
print(lenses.keys())
plt.plot(lenses['ra'], lenses['dec'], '.', ms=1.0)
from glob import glob
# we have given you many many files for sources, below code will capture a list of path for the files
# It looks for the file ending '.dat'
#putting the path of the sources catalog
sflist = glob('../../weakpipe/DataStore/hsc/*.dat')
for fil in sflist:
src = pd.read_csv(fil, delim_whitespace=1)
plt.plot(src['ragal'], src['decgal'], 'g.', ms=1.0)
plt.xlabel('RA (deg)')
plt.ylabel('DEC (deg)')
plt.title('Blue = SDSS, Green = HSC')
Index(['dec', 'lambda', 'ra', 'zred'], dtype='object')
[9]:
Text(0.5, 1.0, 'Blue = SDSS, Green = HSC')
Exercise:
Check of the columns names in one of the source files and print them.
Here we will play with the data to get comfortable with plotting routines and understand the different selection cuts that can be applied on our lens sample, redmapper cluster catalog for these tutorials - arXiv:1303.3562
[4]:
#scatter plot between redshift and richness
plt.plot(lenses['zred'], lenses['lambda'], '.', ms=1.0)
plt.xlabel(r'$z_{\rm red}$')
plt.ylabel(r'$\lambda$')
plt.ylim(10,150)
[4]:
(10, 150)
In these tutorials we will be working with selection cuts used inarXiv:1707.01907
[11]:
#visualizing the individual selection cuts
plt.plot(lenses['zred'], lenses['lambda'], '.', ms=1.0)
plt.plot(np.linspace(0.1,0.33,10),20*np.ones(10) , 'r-')
plt.plot(np.linspace(0.1,0.33,10),30*np.ones(10) , 'r-')
plt.plot(np.linspace(0.1,0.33,10),40*np.ones(10) , 'r-')
plt.plot(np.linspace(0.1,0.33,10),55*np.ones(10) , 'r-')
plt.plot(np.linspace(0.1,0.33,10),100*np.ones(10), 'r-')
plt.plot(0.1*np.ones(10), np.linspace(20,100,10) , 'r-')
plt.plot(0.33*np.ones(10), np.linspace(20,100,10) , 'r-')
plt.xlabel(r'$z_{\rm red}$')
plt.ylabel(r'$\lambda$')
plt.ylim(15,150)
plt.yscale('log')
#printing the number of lenses in a selection cut
idx = (lenses['zred']>0.1) & (lenses['zred']<0.33) & (lenses['lambda']>25) & (lenses['lambda']<40)
print('no of bins in first selection cut : %d'%np.sum(idx))
no of bins in first selection cut : 3642
Exercise:
Compute the number of lenses in each lensing selection cut on redshift and richness as give in the above table and check whether they match with the entries in the table.
As per the table, We will work with last lensing selection cut given as \(0.1<z_{\rm red}<0.33\) and \(55<\lambda<100\).
We will also work with cosmological distances for the weak lensing signal measurements. For computing these distances we will use astropy package. Below we are showing how to get the comoving distance as a function of redshift using astropy.
link to astropy cosmo tools - https://docs.astropy.org/en/stable/api/astropy.cosmology.FlatLambdaCDM.html
[1]:
from astropy.cosmology import FlatLambdaCDM
[8]:
#instance for cosmo distance calculations
cc = FlatLambdaCDM(H0=100, Om0=0.315) # H0=100 so that we can get distance in units of Mpc h-1
zred = np.linspace(0,1,20)
plt.plot(zred, cc.comoving_distance(zred))
plt.xlabel(r'$z_{\rm red}$')
plt.ylabel(r'$d_{\rm com} {\rm [h^{-1}Mpc]}$')
[8]:
Text(0, 0.5, '$d_{\\rm com} {\\rm [h^{-1}Mpc]}$')
Exercise:
Similarly get luminosity distance vs redshift and angular diameter distance vs redshifts plots.
[ ]: