source: branches/newfiller/test/linefind.py@ 1895

Last change on this file since 1895 was 1757, checked in by Kana Sugimoto, 14 years ago

New Development: Yes

JIRA Issue: Yes (CAS-2211)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: ASAP 3.0.0 interface changes

Test Programs:

Put in Release Notes: Yes

Module(s): all the CASA sd tools and tasks are affected.

Description: Merged ATNF-ASAP 3.0.0 developments to CASA (alma) branch.

Note you also need to update casa/code/atnf.


  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/usr/bin/env python
2# run this script with a command line parameter "wait" in order it to wait
3# pressing enter instead of a time delay
4
5from asap import *
6import time,sys
7
8input_dataset = "data/mopra_g327.3-0.6.sdfits"
9
10# read command line parameter
11wait_str = ""
12if len(sys.argv)>=2:
13 if sys.argv[1].lower() == "wait":
14 wait_str = " Press Enter."
15
16# read scantable
17sc=scantable(input_dataset)
18# this file is already reduced, so we can just plot it
19
20plotter.plot(sc)
21plotter.set_legend('Input spectrum')
22#plotter._plotter.set_line(number=0,label='Input spectrum')
23
24# now set up and run line finder
25fl=linefinder()
26fl.set_scan(sc)
27fl.set_options(avg_limit=1,threshold=4,box_size=0.1,noise_box=0.1,noise_stat='median')
28nlines=fl.find_lines()
29print 'Found %i lines.' % nlines
30
31if nlines!=0:
32 r=fl.get_ranges()
33 print "Channel ranges: %s" % (r,)
34 print wait_str
35 if wait_str == "":
36 time.sleep(1)
37 else:
38 raw_input()
39 for l in range(1,len(r),2):
40 print "Line %i from channel %i to %i.%s" % (l/2+1,r[l-1],r[l],wait_str)
41 #plotter.set_range(r[l-1]-3,r[l]+3)
42 b=int(r[l-1])-3
43 e=int(r[l])+3
44 if b<0:
45 b=0
46 if e>=sc.nchan():
47 e=sc.nchan()
48 add_colours = ['red','blue','pink','brown']
49 if l/2 >= 9:
50 plotter._plotter.set_line(colour=add_colours[(l/2-9)%len(add_colours)])
51 plotter._plotter.set_line(label='Line %i'% (l/2+1))
52 plotter._plotter.plot(range(b,e),sc.get_spectrum(0)[b:e])
53 plotter._plotter.show()
54 if wait_str == "":
55 time.sleep(1)
56 else:
57 raw_input()
58
59
60plotter.save('output/linefinder.png', dpi=80)
61print "Test of line finder is successfull"
Note: See TracBrowser for help on using the repository browser.