source: branches/hpc34/examples/waterfall.py@ 2701

Last change on this file since 2701 was 2517, checked in by Malte Marquarding, 12 years ago

More updates to get a distutils/scons build going

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
13# select only one IF/Pol/Beam
14scan.set_selection(ifs=0, beams=0, pols=0)
15
16# plot in GHz
17scan.set_unit("GHz")
18
19# get all spectra into a matrix [ ncycle x nchan ]
20mat = array([ spectrum for spectrum in scan ])
21
22# find the min/max values
23xax = scan.get_abcissa()
24xmin = min(xax[0])
25xmax = max(xax[0])
26
27# a bit more complicate because we want to plot nice time axis labels
28yax = scan.get_time(asdatetime=True)
29ymin = min(xyplotter.date2num(yax))
30ymax = max(xyplotter.date2num(yax))
31
32
33# the date labels are a bit wide, so set the viewport
34xyplotter.axes([0.2,0.1,0.7,0.8])
35
36# plot the waterfall
37xyplotter.imshow(mat,
38 aspect='auto', # scale to fill the plot
39 origin='lower', # start at the bottom-left
40 extent=[xmin,xmax,ymin,ymax], # give the axes coordinates
41 interpolation='nearest'
42 )
43xyplotter.gca().yaxis_date() # tell the plotter that the yaxis is using dates
44
45# display axis labels
46xyplotter.xlabel(xax[1])
47xyplotter.ylabel("Obs. Time")
48
49xyplotter.savefig("test.png",orientation="landscape")
Note: See TracBrowser for help on using the repository browser.