Last change
on this file since 1804 was 1415, checked in by Malte Marquarding, 17 years ago |
added example for waterfall plots
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/usr/bin/env python
|
---|
2 |
|
---|
3 | from asap import *
|
---|
4 | from numpy import array
|
---|
5 |
|
---|
6 | # don't print any messages
|
---|
7 | rcParams['verbose'] = 0
|
---|
8 | # load data unaveraged
|
---|
9 |
|
---|
10 | scan = scantable("../test/data/tid-t002.rpf", average=False)
|
---|
11 | print scan
|
---|
12 | # select only one IF/Pol/Beam
|
---|
13 | sel = selector()
|
---|
14 | sel.set_ifs(0)
|
---|
15 | sel.set_polarisations(0)
|
---|
16 | sel.set_beams(0)
|
---|
17 | scan.set_selection(sel)
|
---|
18 |
|
---|
19 | # plot in GHz
|
---|
20 | scan.set_unit("GHz")
|
---|
21 |
|
---|
22 | # get all spectra into a matrix [ ncycle x nchan ]
|
---|
23 | mat = array([ spectrum for spectrum in scan ])
|
---|
24 |
|
---|
25 | # find the min/max values
|
---|
26 | xax = scan.get_abcissa()
|
---|
27 | xmin = min(xax[0])
|
---|
28 | xmax = max(xax[0])
|
---|
29 |
|
---|
30 | # a bit more complicate because we want to plot nice time axis labels
|
---|
31 | yax = scan.get_time(asdatetime=True)
|
---|
32 | ymin = min(xyplotter.date2num(yax))
|
---|
33 | ymax = max(xyplotter.date2num(yax))
|
---|
34 |
|
---|
35 |
|
---|
36 | # the date labels are a bit wide, so set the viewport
|
---|
37 | xyplotter.axes([0.2,0.1,0.7,0.8])
|
---|
38 |
|
---|
39 | # plot the waterfall
|
---|
40 | xyplotter.imshow(mat,
|
---|
41 | aspect='auto', # scale to fill the plot
|
---|
42 | origin='lower', # start at the bottom-left
|
---|
43 | extent=[xmin,xmax,ymin,ymax], # give the axes coordinates
|
---|
44 | interpolation='nearest'
|
---|
45 | )
|
---|
46 | xyplotter.gca().yaxis_date() # tell the plotter that the yaxis is using dates
|
---|
47 |
|
---|
48 | # display axis labels
|
---|
49 | xyplotter.xlabel(xax[1])
|
---|
50 | xyplotter.ylabel("Obs. Time")
|
---|
51 |
|
---|
52 | #xyplotter.savefig("test.ps",orientation="landscape")
|
---|
Note:
See
TracBrowser
for help on using the repository browser.