source: branches/newfiller/test/simple_linefind.py@ 2072

Last change on this file since 2072 was 1757, checked in by Kana Sugimoto, 15 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.5 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
8wait_str = ""
9if len(sys.argv)>=2:
10 if sys.argv[1].lower() == "wait":
11 wait_str = " Press Enter."
12
13# read the spectrum from ascii file
14f = open('data/atca_spectrum.dat')
15spc=[]
16try:
17 for line in f:
18 parts=line.split()
19 if len(parts)!=3:
20 raise RuntimeError, "Expect 3 parts, you have %s"% (parts,)
21 spc.append(float(parts[2]))
22finally:
23 f.close()
24
25
26#run the line finder
27
28lf = simplelinefinder()
29rng=lf.find_lines(spc,threshold=3,splitFeatures=False)
30
31print "Found %i lines.%s" % (len(rng),wait_str)
32b=len(spc)/4
33e=len(spc)*3/4
34plotter._plotter.plot(range(b,e),spc[b:e])
35plotter._plotter.set_line(number=0,label='Input spectrum')
36plotter._plotter.show()
37if wait_str == "":
38 time.sleep(1.5)
39else:
40 raw_input()
41cnt = 1
42for line in rng:
43 if len(line)!=2:
44 raise RuntimeError, "Line is supposed to have two parameters"
45 b = line[0]-1
46 if b<0:
47 b=0
48 e = line[1]+1
49 if e>len(spc):
50 e=len(spc)
51 print "Showing line %i located at %s.%s" % (cnt,line,wait_str)
52 plotter._plotter.set_line(label='Line %i' % cnt)
53 cnt = cnt + 1
54 plotter._plotter.plot(range(b,e),spc[b:e])
55 plotter._plotter.show()
56 if wait_str == "":
57 time.sleep(1.5)
58 else:
59 raw_input()
60
61plotter.save('output/simple_linefinder.png', dpi=80)
62print "Test of simple line finder is successful"
Note: See TracBrowser for help on using the repository browser.