Download dataset https://github.com/spacetelescope/scientific-python-training-2012/tree/master/data/o67501020_flt.fits
Download Session 5 Lecture from https://github.com/spacetelescope/scientific-python-training-2012/tree/master/lecture_notebooks/Session5_STIS_Spec.ipynb , save it under a different name called "Session5_Modified_Lecture_USERID.ipynb".
Run it.
In the section "Fit a gaussian to a point > 2*median smoothed background", turn the relevant codes into a function that returns "pix_bestfit". Hint: Use "collapsed_img, loc_start, loc_end" as input parameters. Then, call your function to get "pix_bestfit".
Insert a new cell below your function. Hint: Click Insert, then Insert Cell Below.
In the new cell, use your function to calculate pix_bestfit for all the spectrum locations in "sp_start" and "sp_end". Hint:
pix_list = []
for i, j in zip(sp_start, sp_end):
pix = your_function(collapsed_img, i, j)
pix_list.append(pix)
The solution above does not exclude any erroneous results when fitting fails. Modify it so that pix_list
only contains real results. Hint: Use "if" statement.
Replace this command using Python "subprocess" module:
!which cs6.e
import subprocess
# Put your solution here
Use Numpy indexing/slicing to turn this "original_array"
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
to this
[9, 7, 5, 3, 1]
import numpy as np
original_array = np.arange(10)
# Put your solution here
my_array = something
# If your solution is right, this test will pass,
# else it raises AssertionError
np.testing.assert_array_equal(my_array, [9, 7, 5, 3, 1])
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-8-1c9553bf39ce> in <module>() 4 # Put your solution here 5 ----> 6 my_array = something 7 8 # If your solution is right, this test will pass, NameError: name 'something' is not defined
Email your solutions (that should these 2 notebooks below) to dencheva[at]stsci.edu (Nadia Dencheva)