source: branches/asap-3.x/examples/waterfall.py@ 2908

Last change on this file since 2908 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
3from asap import *
4from numpy import array
5
6# don't print any messages
7rcParams['verbose'] = 0
8# load data unaveraged
9
10scan = scantable("../test/data/tid-t002.rpf", average=False)
11print scan
12# select only one IF/Pol/Beam
13sel = selector()
14sel.set_ifs(0)
15sel.set_polarisations(0)
16sel.set_beams(0)
17scan.set_selection(sel)
18
19# plot in GHz
20scan.set_unit("GHz")
21
22# get all spectra into a matrix [ ncycle x nchan ]
23mat = array([ spectrum for spectrum in scan ])
24
25# find the min/max values
26xax = scan.get_abcissa()
27xmin = min(xax[0])
28xmax = max(xax[0])
29
30# a bit more complicate because we want to plot nice time axis labels
31yax = scan.get_time(asdatetime=True)
32ymin = min(xyplotter.date2num(yax))
33ymax = max(xyplotter.date2num(yax))
34
35
36# the date labels are a bit wide, so set the viewport
37xyplotter.axes([0.2,0.1,0.7,0.8])
38
39# plot the waterfall
40xyplotter.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 )
46xyplotter.gca().yaxis_date() # tell the plotter that the yaxis is using dates
47
48# display axis labels
49xyplotter.xlabel(xax[1])
50xyplotter.ylabel("Obs. Time")
51
52#xyplotter.savefig("test.ps",orientation="landscape")
Note: See TracBrowser for help on using the repository browser.