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