Copy paste the code snippets below in the online prompt to see the result.
1. Simple Query
Query for the number of the BiasFrame's for a specific instrument.
from astro.main.BiasFrame import BiasFrame
instrument_name = 'WFI'
query = BiasFrame.instrument.name == instrument_name
print "%s has %d BiasFrame's" % (instrument_name, len(query))
2. Defining and Using Methods
Define a method which does the square of a number plus one. Then iterate over a list of values calling this method for each value.
def square_plus_one(num) :
for i in range(10) :
print i, square_plus_one(i)
Plot x versus y, where x = [0,24] and y = x * x. The resulting figure is saved to a file called x_square.png and is saved in your personal directory. Click the 'files' link on the bottom right in the online prompt to see all files.
x = range(25)
y = [i*i for i in x]
More code snippets to come ! Please mail me for suggestions !!