Python for Homework 2 - Advance Astronomical Data Analysis | AST 5765, Assignments of Astronomy

Material Type: Assignment; Class: ADV ASTRONOMICAL DATA ANALYSIS; Subject: Astronomy; University: University of Central Florida; Term: Fall 2009;

Typology: Assignments

Pre 2010

Uploaded on 02/25/2010

koofers-user-0qo
koofers-user-0qo 🇺🇸

8 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
UCF Physics: AST 5765/4762: (Advanced) Astronomical Data Analysis
Fall 2009 Homework 2
Due Tuesday 8 September 2009
Work:
Become sufficiently familiar with Python to:
1. Start Python,
2. Allocate, manipulate, and get information about arrays,
3. Print the value of any cell in an array,
4. Change values in an array according to given mathematical or positional criteria (e.g., zero
every 5th pixel, set all values greater than 100 to -2000, set a given rectangular sub-array to
a given value, insert one array into another),
5. View images and manipulate image colormaps interactively from Python,
6. Make line plots and figures with images, write them in standard formats,
7. Use available resources to find functions, packages, and any instructions you need.
Resources:
1. Do the Matplotlib tutorial.
2. Do sections 1 and 2 of the Using Python for Interactive Data Analysis tutorial. The exercises
are for your edification (don’t hand them in).
3. See handout for other suggested readings.
Hand in:
Do not use loops for any problem on this assignment. The files you hand in should include a
text file that provides all the commands to do the exercises, named as instructed on the syllabus.
Put images (plots, screendumps, etc.) in separate files as described on the syllabus. Finding the
right documentation is part of the assignment!
NOTE: The problems here can be done with much less than the full reading assignment above.
Be sure you have mastered the material needed to do the problems, and then get as far as you can
in the reading assignment and its exercises. You will be using all of that material, and more, in the
rest of the course.
1. Write a set of Python commands that:
(a) Create a Float64 array, x, of integers from 0 to 1000 (how many elements do you
need?).
(b) Re-scale xto contain values from 0 to 2π.
1
pf2

Partial preview of the text

Download Python for Homework 2 - Advance Astronomical Data Analysis | AST 5765 and more Assignments Astronomy in PDF only on Docsity!

UCF Physics: AST 5765/4762: (Advanced) Astronomical Data Analysis

Fall 2009 Homework 2

Due Tuesday 8 September 2009

Work: Become sufficiently familiar with Python to:

  1. Start Python,
  2. Allocate, manipulate, and get information about arrays,
  3. Print the value of any cell in an array,
  4. Change values in an array according to given mathematical or positional criteria (e.g., zero every 5th pixel, set all values greater than 100 to -2000, set a given rectangular sub-array to a given value, insert one array into another),
  5. View images and manipulate image colormaps interactively from Python,
  6. Make line plots and figures with images, write them in standard formats,
  7. Use available resources to find functions, packages, and any instructions you need.

Resources:

  1. Do the Matplotlib tutorial.
  2. Do sections 1 and 2 of the Using Python for Interactive Data Analysis tutorial. The exercises are for your edification (don’t hand them in).
  3. See handout for other suggested readings.

Hand in: Do not use loops for any problem on this assignment. The files you hand in should include a text file that provides all the commands to do the exercises, named as instructed on the syllabus. Put images (plots, screendumps, etc.) in separate files as described on the syllabus. Finding the right documentation is part of the assignment! NOTE: The problems here can be done with much less than the full reading assignment above. Be sure you have mastered the material needed to do the problems, and then get as far as you can in the reading assignment and its exercises. You will be using all of that material, and more, in the rest of the course.

  1. Write a set of Python commands that:

(a) Create a Float64 array, x , of integers from 0 to 1000 (how many elements do you need?). (b) Re-scale x to contain values from 0 to 2 π.

(c) Put the sine of the values in a new array, y.

  1. Write a set of Python commands that:

(a) Compute at least 1000 points of an analytic function (ideally the one above, if you got it). (b) Plot y vs. x with reasonable axis labels (remember to capitalize your axis titles!). (c) Save your plot as a PNG file (no screenshots or window dumps from outside Python).

  1. Make a “ramp” array, with 101 elements going from -1 to +1. “Clip” the array so that any value greater than 0.5 is set to 0.5 and any value less than -0.5 is set to -0.5, and plot it on the screen. Save a screen shot that includes both the Python and graphics windows (use gnome-panel-screenshot or the same program from the panel menu). Do not save from within Python. Remember, no loops!
  2. Make a 200×300 Float64 array where each element contains its own y coordinate, starting with y = 0 for row 0 and ending with y = 299 for row 299. When you use print, row 0 is the first row printed, row 1 appears below that, etc., and row 299 is last, at the bottom. When you display with ds9, however, row 0 is the bottom and row 299 is the top. Examine several randomly-placed elements from within python to be sure the values match the y coordinate in the print statements. Be careful that the final array has the correct data type. Take a screen shot showing both your Python and ds9 windows.
  3. Give the URLs to two web sites outside of UCF that provide free astronomical software in Python. Tell a little about each package in your own words.