Last change
on this file since 1821 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.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 |
|
---|
5 | from asap import *
|
---|
6 | import time,sys
|
---|
7 |
|
---|
8 | wait_str = ""
|
---|
9 | if len(sys.argv)>=2:
|
---|
10 | if sys.argv[1].lower() == "wait":
|
---|
11 | wait_str = " Press Enter."
|
---|
12 |
|
---|
13 | # read the spectrum from ascii file
|
---|
14 | f = open('data/atca_spectrum.dat')
|
---|
15 | spc=[]
|
---|
16 | try:
|
---|
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]))
|
---|
22 | finally:
|
---|
23 | f.close()
|
---|
24 |
|
---|
25 |
|
---|
26 | #run the line finder
|
---|
27 |
|
---|
28 | lf = simplelinefinder()
|
---|
29 | rng=lf.find_lines(spc,threshold=3,splitFeatures=False)
|
---|
30 |
|
---|
31 | print "Found %i lines.%s" % (len(rng),wait_str)
|
---|
32 | b=len(spc)/4
|
---|
33 | e=len(spc)*3/4
|
---|
34 | plotter._plotter.plot(range(b,e),spc[b:e])
|
---|
35 | plotter._plotter.set_line(number=0,label='Input spectrum')
|
---|
36 | plotter._plotter.show()
|
---|
37 | if wait_str == "":
|
---|
38 | time.sleep(1.5)
|
---|
39 | else:
|
---|
40 | raw_input()
|
---|
41 | cnt = 1
|
---|
42 | for 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 |
|
---|
61 | plotter.save('output/simple_linefinder.png', dpi=80)
|
---|
62 | print "Test of simple line finder is successful"
|
---|
Note:
See
TracBrowser
for help on using the repository browser.