AST5731 Activity 00 – Intro to Python solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (8 votes)

0.1 Activity 00
This activity is meant to have you start familiarizing with Python/R programming. Part B is not
required. Complete it if there is enough time.
A.1 Goal: familiarize with different file types and with the matplotlib library.
The matplotlib library provides powerful tools for creating static, animated, and interactive visualizations in Python. Go through the Usage Basic tutorial, down to the
“Backend” section excluded, and have a look at the examples here.
A.2 Goal: learn how to read in different file formats.
In the repository you will find the data for the Globular Cluster system of the galaxy
NGC3379. The files have all the same root name (GCs_NGC3379), but the data are
saved in three different format that are commonly used in astronomy (.fits, .dat, .csv).
Use astropy and pandas to read in the files. You can learn how to read in fits files with
astropy here, and for ascii: astropy.io.ascii. For cvs files, I use pandas.
Use the data to practice vizualization. The file contains magnitude measurements in
three filters (VRI). Specifically, the file includes the following columns:
ID : identification number Xpos : X position relative to center of galaxy
[arcsecs] Ypos : Y position relative to center of galaxy [arcsecs] Dist : Radial
distance [arcsecs] Rmag : R magnitude [mag] V-R : V-R color [mag] R-I : R-I
color [mag]
Use the data in the table to make the following:
a) a scatter plots of Rmag versus V-R
b) a scatter plots of Ypos versus Xpos
in b), colorcode the points according to their V-R. Add a color bar on the right of the
figure.
c) plot a normalized histogram of Rmag (you can use plt.hist)
d) to avoid saturation when you plot many points in a diagram, you can either use
the option alpha, or show 2D histograms. Make both versions for both plots. Add
isodensity contours. In python, you can use seaborn.kdeplot for this task, or the
routines in matplotlib.
B. Goal: familiarize with scipy.stats module.
1
The scipy.stats module provide a a number of classes that allow you to easily work with different kinds of random variables and their probability distributions, as well as a growing library of
statistical functions.
a) Work through the first part of this tutorial, down to “Building specific distribution”
section (included). Use the scipy.stats.norm to work with the Normal distribution
and:
b) Display the probability distribution funtion of a Normal distribution with µ = −1
and σ = 2.
c) Generate N=50 random variates distributed according to this distribution. Plot a
normalized histogram of these random variates. Compute the arithmetic mean of
these variates. How does the arithmetic mean compare with the population mean?
2