Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/hst/training/events/Python/readPlot1-DSpectra_script.html
Дата изменения: Unknown
Дата индексирования: Mon Apr 11 19:43:06 2016
Кодировка:

Поисковые слова: п п п п п п п п п п п п п п
Python T2: Reading and Plotting 1-D Spectral Data: Demo Script
STScI Logo

Hubble Space Telescope
Python T2: Reading and Plotting 1-D Spectral Data: Demo Script

 

Script for use with Python Tutorial #2 4-19-2005
----------------------------------------------------

>>> import pyfits
>>> import sys
>>> sys.path
>>> pyfits.__file__
>>> pyfits.info('fuse.fits')
>>> tab = pyfits.getdata('fuse.fits')
>>> tab.names
>>> tab.formats
>>> tab.shape
>>> wave = tab.field('wave')
>>> flux = tab.field('flux)
>>> flux.shape
>>> tab2 = pyfits.getdata('table2.fits')
>>> tab2.shape
>>> tab2
>>> col3 = tab2.field('nobs')
>>> col3
>>> col3[2] = 99
>>> tab2
>>> from pylab import *
>>> plot(wave,flux)
>>> xlabel(r'$\lambda (\angstrom)$', size=13)
>>> ylabel('Flux')
>>> from numarray.convolve import boxcar
>>> sflux = boxcar(flux.flat, (100,))
>>> plot(wave, sflux, '--r', hold=True)
>>> subwave = wave.flat[::100]
>>> subflux = flux.flat[::100]
>>> plot(subwave, subflux, 'og', hold=True)
>>> error = tab.field('error')
>>> suberror = error.flat[::100]
>>> errorbar(subwave, subflux, suberror, fmt='.k', hold=True)
>>> legend('unsmoothed', 'smoothed', 'every 100')
>>> text(1007., 0.5e-12, 'Hi There')
>>> savefig('fuse.png')
>>> savefig('fuse.ps')
>>> s = '''This is an example
of a multi-line string that
goes on and on and on'''
>>> s
>>> print s
>>> print "two lines \n in this example"
>>> print r"but not \n this one"
>>> 'hello world'.upper()
>>> s = "hello world"
>>> s.find("world")
>>> s.endwith("ld")
>>> s.split()
>>> mylist = [1, "hello", [2,3]]
>>> mylist = []
>>> mytuple = (1, "hello", [2,3])
>>> mytuple = (2)
>>> mytuple = (2,)
>>> mytuple = ()
>>> s[0]
>>> mylist2 = mylist[1:]
>>> mylist2
>>> mylist[0] = 99
>>> mylist
>>> mylist2
>>> mylist[1:2] = [2,3,4]
>>> mylist
>>> len(s)
>>> x = array([1,2], [3,4])
>>> print x
>>> len(x)
>>> "hello" + "world"
>>> [1,2,3] + [4,5]
>>> 5*"hello "
>>> thisdict = {'a':26.7, 1:['random string', 66.4], -6.3:''}
>>> zeropoints = {'F435W':25.779, 'F475W':26.168, 'F502N':22.352,
'F550M':24.867, 'F555W':25.724, 'F606W':26.398, 'F625W':25.731,
'F658N':22.365, 'F660N':21.389, 'F775W':25.256, 'F814W':25.501,
'F850LP':24.326, 'F892N':21.865}
>>> filter = hdr['filter1']
>>> if filter.find('CLEAR') != -1: filter = hdr['filter2']
>>> zp = zeropoints[filter]
>>> x = arange(100.)
>>> y = (x/100.)**2
>>> plot(x,y,'r')
>>> plot(x,y,c='red')
>>> plot(x,y,'#ff0000')
>>> lines = plot(x,y)
>>> set(lines, 'color', (1.,0.,0.))
>>> lines[0].set_color('red') ; draw()
>>> plot(y[::10], 'g>:', markersize=20)
>>> textobj = xlabel('hello', color='red', ha='right')
>>> set(textobj, 'color', 'wheat')
>>> set(textobj, 'size', 5)
>>> pixdata = pyfits.getdata('pix.fits')
>>> plot(pixdata[100], hold=False)
>>> plot(pixdata[:,200], hold=True)
>>> import numdisplay
>>> numdisplay.open()
>>> numdisplay.display(pixdata, z1=0,z2=1000)
>>> clf()
>>> imshow(pixdata, vmin=0, vmax=1000)
>>> gray()
>>> imshow(pixdata, vmin=0, vmax=1000, interpolation='nearest')
>>> pixdata[pixdata>256] = 256
>>> hist(pixdata, bins=256)
>>> levels = [100,200,400,800]
>>> imshow(pixdata, vmin=0, vmax=1000)
>>> contour(pixdata, levels, colors=[1., 1., 1., 0.])
>>> err = err*1.0e12
>>> flux = flux*1.0e12
>>> subplot(211)
>>> plot(wave, flux)
>>> subplot(212)
>>> plot(wave, error)
>>> imshow(pixdata, vmin=0, vmax=1000)
>>> def clicker(event):
... if event.inaxes:
... print event.xdata, event.ydata
...
>>> cid = connect('button_press_event', clicker)
>>> disconnect(cid)