Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
restrepo
GitHub Repository: restrepo/ComputationalMethods
Path: blob/master/activities/test2_20142.ipynb
934 views
Kernel: Unknown Kernel

Test 2 - Computational Activity

This activity represents 50%50\% of the test 2. Each student must provide an ipython notebook with the solution of the proposed problems, along with all the performed procedures and related codes, as well as the obtained results.

Due to: Sunday Mar 1, Midnight

Integrated Spectrum of NGC 5947

NGC 5947 is a barred spiral galaxy SBbc located in the Boötes constelation. For this activity, we are going to take an optical integral field spectrum (IFS) obtained by the CALIFA (The Calar Alto Legacy Integral Field Area) survey. These data come usually in the standard FITS format (you can download it from here). You can handle this format in python using for example the library PyFITS (installation).

However, we are going to use a set of ASCII files provided here, where the format spectra_i_j.dat is used for the spectrum of the i,j-th pixel of the image, and where 00\leqi71\leq 71 and 00\leqj77\leq 77, i.e. we have an image of 72×7872\times 78 pixels. Each file contains two columns, one with the wavelenght in units of Å, and the second with the respective flux in units of 1×10161\times 10^{-16} erg s1^{-1} cm2^{-2} Å1^{-1}.

For this activity, we intend to manipulate these spectra and integrate them numerically. For this purpose, we shall use the Composite Simpson's rule covered during class.

Activities

1. (10%) Create a routine that, given a set of points {xi}i\{x_i\}_i and {yi}i\{y_i\}_i, computes the Composite Simpson's rule in the interval of the xx data.

2. (10%) Integrated image of the galaxy: integrating the spectrum of each pixel over the optical range, we obtain the surface brightness of that pixel.

SijO=λ0λ1Iij(λ)dλS^O_{ij} = \int_{\lambda_0}^{\lambda_1} I_{ij}(\lambda)d\lambda

where SijOS^O_{ij} es the optical surface brightness of the i,j-th pixel, given in units of 1×10161\times 10^{-16} erg s1^{-1} cm2^{-2}, IijI_{ij} the optical spectrum of that pixel, given in units of 1×10161\times 10^{-16} erg s1^{-1} cm2^{-2} Å1^{-1}, and λ0\lambda_0 and λ1\lambda_1 are the optical ranges, namely λ0=3749\lambda_0 = 3749 Å and λ1=7501\lambda_1=7501 Å.

Repeating this procedure for each pixel of the image, we obtain the optical surface brightness profile of the galaxy.

Using the previous routine, integrate the spectrum of each pixel, storing each result in a matrix. Finaly, using the function imshow of matplotlib, show the resulting image.

3. (20%) False coloured image: a very common colour model for representating images in a computer is based in three "beams" called components (RGB scheme), namely Red, Green and Blue components. For this activity we shall propose a simple and rough way to calculate these components for each pixel, provided the respective spectrum.

Associating the red component with the range [5800[ 5800 Å, 75007500 Å]], the green component to [4900[ 4900 Å, 58005800 Å]] and the blue component to [4900[ 4900 Å, 37503750 Å]], we can integrate the spectrum of each pixel over these ranges, obtaining the respective surface brightness in each band.

Sijr=58007500Iij(λ)dλS^r_{ij} = \int_{5800}^{7500} I_{ij}(\lambda)d\lambdaSijg=49005800Iij(λ)dλS^g_{ij} = \int_{4900}^{5800} I_{ij}(\lambda)d\lambdaSijb=37504900Iij(λ)dλS^b_{ij} = \int_{3750}^{4900} I_{ij}(\lambda)d\lambda

Calculate the RGB indexes for each pixel of the galaxy (Cijr,Cijg,Cijb)(C^r_{ij}, C^g_{ij}, C^b_{ij}), then, normalize all the red components with the maxim value all over the galaxy. Repeat the same for green and blue components. This step must be done due to RGB indexes must range between 00 and 11.

Cijr=Sijr/max(Sijr)C^r_{ij} = S^r_{ij}/\max(S^r_{ij})Cijg=Sijg/max(Sijg)C^g_{ij} = S^g_{ij}/\max(S^g_{ij})Cijb=Sijb/max(Sijb)C^b_{ij} = S^b_{ij}/\max(S^b_{ij})

Finally, using the same function imshow for showing a false colour of the galaxy. You should obtain something like:

Tip: giving an array object with the components Galaxy[i,j,c], where ii and jj refer to the pixel position and c=0,1,2c=0,1,2 refers to the R(0)-G(1)-B(0) indexes, imshow should give a real colour image.

4. (20%) H-alpha emission: the Hα\alpha emission line is a spectral line of Hydrogen produced when a photon is emitted by an electron passing from the state of energy n=3n=3 to the state n=2n=2. The associated wavelenght is exactly 6562.86562.8 Å. For a spiral galaxy, this emission line normally appears in regions with high star formation rates like arms and bars.

For this activity, we are going to calculate the fully integrated spectra of the galaxy. From this, we can calculate the redshift of the galaxy, the total optical surface brightness and the emission map in the Hα\alpha line.

Take all the spectra of the galaxy (each pixel) and average them in order to produce just one spectrum. This is the integrated spectrum of the galaxy. You should obtain something like:

Integrate this spectrum over all the optical range, this result is the integrated surface brightness of all the galaxy.

The highest line in this spectrum corresponds with the Hα\alpha emission line of all the galaxy. However, due to the expansion of the Universe, this line is shifted toward red. Locate this line of the spectrum λgal\lambda_{gal} and using the exact value of the Hα\alpha line, calculate the redshift of this galaxy using the formula:

z=λgalλHαλHαz = \left| \frac{\lambda_{gal}-\lambda_{H\alpha}}{\lambda_{H\alpha}} \right|

Once identified this line, integrate the spectrum of each pixel over the range [λgalΔλ,λgal+Δλ][\lambda_{gal}-\Delta \lambda, \lambda_{gal}+\Delta \lambda], with λgal\lambda_{gal} the Hα\alpha line of the galaxy and Δλ=5\Delta \lambda=5 Å.

SijHα=λgalΔλλgal+ΔλIij(λ)dλS^{H\alpha}_{ij} = \int_{\lambda_{gal}-\Delta \lambda}^{\lambda_{gal}+\Delta \lambda} I_{ij}(\lambda)d\lambda

** Show the result using the imshow function. You should obtain something like:**

BONUS (+0.5 in theoretical test). Dominant emission line: although the core of the galaxy is far more dominating in the overall surface brightness, there are some regions where specific emission lines are dominant. Make a figure where the colour represents the dominant emission line for a given pixel. This is, take each pixel's spectrum, find the wavelength of maximum flux, and assign that value to that pixel. You should obtain something like:


N Coupled Linear Oscillators

In this activity we shall solve a set of N-coupled linear oscillators. This type of systems are very useful for modelling molecular dynamics and state solid systems. Let's suppose a set of NN mass {mi}i\{m_i\}_i coupled by NN strings of elastic constant kik_i.

Defining the position xi(t)x_i(t) of the iith oscillator as its position of equilibrium (previous figure), each mass follows the next equation:

d2dt2xi(t)=1mi[kixi(t)ki+1(xi(t)xi+1(t))]    for  i=1,2,3,,N\frac{d^2}{dt^2}x_i(t) = \frac{1}{m_i}[ -k_i x_i(t)-k_{i+1}(x_i(t)-x_{i+1}(t)) ] \ \ \ \ \mbox{for}\ \ i=1,2,3,\cdots,N

This is, the iith oscillator is coupled with the next one.

We then have to solve these equations in order to obtain the solutions {x1(t),x2(t),,xN(t)}\{x_1(t),x_2(t),\cdots, x_N(t)\}. In order to do this, we can define the matrix M\mathbf{M}

ParseError: KaTeX parse error: Undefined control sequence: \matrix at position 27: …{ij} = \left\{ \̲m̲a̲t̲r̲i̲x̲{ -\frac{k_i}{…

then, the problem can be rewritten as

d2dt2x(t)+Mx(t)=0\frac{d^2}{dt^2}\mathbf{x}(t) + \mathbf{M}\mathbf{x}(t) = 0

where x(t)\mathbf{x}(t) is the vector of positions for all the oscillators.

If we can find a set of vectors qk\mathbf{q}_k such that

Mqk=λkqk\mathbf{M} \mathbf{q}_k = \lambda_k \mathbf{q}_k

where λk\lambda_k is a eigenvalue of the matrix and qk\mathbf{q}_k the respective eigenvector. There is then a matrix A\mathbf{A} such that

ParseError: KaTeX parse error: Undefined control sequence: \matrix at position 47: …f{A} = \left[ \̲m̲a̲t̲r̲i̲x̲{ \lambda_1 & 0…

and

Aq=x\mathbf{A}\mathbf{q} = \mathbf{x}

The initial problem becomes then:

d2dt2x(t)+Mx(t)=0\frac{d^2}{dt^2}\mathbf{x}(t) + \mathbf{M}\mathbf{x}(t) = 0d2dt2Aq(t)+MAq(t)=0\frac{d^2}{dt^2}\mathbf{A}\mathbf{q}(t) + \mathbf{M}\mathbf{A}\mathbf{q}(t) = 0A1d2dt2Aq(t)+A1MAq(t)=0\mathbf{A}^{-1}\frac{d^2}{dt^2}\mathbf{A}\mathbf{q}(t) + \mathbf{A}^{-1}\mathbf{M}\mathbf{A}\mathbf{q}(t) = 0d2dt2A1Aq(t)+A1MAq(t)=0\frac{d^2}{dt^2}\mathbf{A}^{-1}\mathbf{A}\mathbf{q}(t) + \mathbf{A}^{-1}\mathbf{M}\mathbf{A}\mathbf{q}(t) = 0ParseError: KaTeX parse error: Undefined control sequence: \matrix at position 40: …q}(t) + \left[ \̲m̲a̲t̲r̲i̲x̲{ \lambda_1 & 0…

The solution to this problem is given by

qi(t)=Cisin(λit+δi)q_i(t) = C_i \sin( \sqrt{\lambda_i} t + \delta_i )

where CiC_i and δi\delta_i corresponds with the amplitude and the initial phase. The eigenvalues λi\sqrt{\lambda_i} are then the natural frequencies of the problem.

Activities

1. (10%) Construct the matrix M\mathbf{M} of the problem for N=10N=10 oscillators.

2. (15%) Using the function numpy.linalg.eig, calculate the eigenvalues {λi}i\{\lambda_i\}_i and the respective eigenvectors {ui}i\{\mathbf{u}_i\}_i of the matrix M\mathbf{M}. Construct the diagonalising matrix giving by:

ParseError: KaTeX parse error: Undefined control sequence: \matrix at position 15: \mathbf{A} = [\̲m̲a̲t̲r̲i̲x̲{ \mathbf{u}_1 …

3. (15%) Using the found eigenvalues, plot the functions qi(t)q_i(t) for each normal mode of the oscillators. Then, using the matrix A\mathbf{A}, find the solution to the problem in the original coordinate system. Plot in other figure all the solutions xi(t)x_i(t) for the oscillators.

Tip: use any set of initial conditions you want, i.e. the values CiC_i and δi\delta_i of the functions qi(t)q_i(t).