Skip to content

Commit

Permalink
Added possbility to scale compton + fix small bugs
Browse files Browse the repository at this point in the history
Fix some small bugs in the smoothed spectra that are created via replacement with vim
  • Loading branch information
fzeiser committed Aug 7, 2018
1 parent 030e078 commit 3a14ec7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 30 deletions.
19 changes: 0 additions & 19 deletions data/mama_spectra/RunSmooth.py

This file was deleted.

30 changes: 30 additions & 0 deletions data/mama_spectra/RunSmooth_and_Multiply.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python

import glob, os

multFactor = 1.15 # multiplication factor for cmp_bg

def createFolder(directory):
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print('Error: Creating directory. ' + directory)

outfolder = "../mama_spectra_smooth/"

createFolder(outfolder)

for file in glob.glob("cmp*"):
os.system("cp %s %s/%s" % (file, outfolder, file))
command = "./Smooth_and_Multiply.sh %s %s %f" % (outfolder, file, multFactor)
os.system(command)

# correct for some mistakes in writing the mama file
command ="""vim -E -s {} <<-EOF
:%s/\\n\\n!CAL/\\r!CAL/g
:x
EOF
""".format(outfolder+file)
# print command
os.system(command)
Original file line number Diff line number Diff line change
@@ -1,54 +1,85 @@
#!/usr/bin/expect

set SleepTime 0.5


set multFactor [lindex $argv 2];
set filename [lindex $argv 1];
set prefix [lindex $argv 0];
set outfile "$prefix$filename"

set timeout 2

spawn mama
sleep 1.5
expect "mama>"
sleep $SleepTime
send "re\r"
expect "Destination spectrum <1>:"
send "1\r"
sleep $SleepTime
expect "Filename <TEST>:"
send "$filename\r"
#expect "mama>"
#send "ds2\r"

# Applying the smoothing
expect "mama>"
# sleep $SleepTime
send "sm\r"
expect "Destination spectrum <2>:"
# sleep $SleepTime
send "2\r"
expect "Source spectrum <1>:"
# sleep $SleepTime
send "1\r"
expect "Dimension of spectrum <4200>:"
send "4200\r"
expect "Write FWHMx (ch) around ch x= 420 < 1.0>:"
expect "Dimension of spectrum"
# sleep $SleepTime
send "\r"
expect "Write FWHMx (ch) around ch "
# sleep $SleepTime
send "20\r"
expect "Write FWHMx (ch) around ch x= 3780 < 3.0>:"
expect "Write FWHMx (ch) around ch "
# sleep $SleepTime
send "30\r"
expect "Smoothing-matrix OK? (y/n) <y>:"
sleep $SleepTime
send "y\r"
expect "mama>"

# multiplication by "arb." factor
# sleep $SleepTime
# send "ar\r"
# expect "Write your expression:"
# sleep $SleepTime
# send "2=2*$multFactor \r"
# expect "mama>"

# write file
sleep $SleepTime
send "wr\r"
expect "Spectrum to write <2>:"
# sleep $SleepTime
send "2\r"
expect "Please, choose your type <1>:"
# sleep $SleepTime
send "1\r"
expect "Cal. coeff. a0 (keV) on x-axis < 0.0>:"
send "0.0\r"
expect "Cal. coeff. a1 (keV/ch) on x-axis < 5.000>:"
send "5.000\r"
# sleep $SleepTime
send "\r"
expect "Cal. coeff. a1 (keV/ch) on x-axis "
# sleep $SleepTime
send "\r"
expect "Cal. coeff. a2 (keV/ch2) on x-axis < 0.0000E+00>:"
send "0.0000E+00\r"
expect "Length of output-spectrum <4200>:"
send "4200\r"
# sleep $SleepTime
send "\r"
expect "Length of output-spectrum"
# sleep $SleepTime
send "\r"
expect "Filename <SPEC>:"
# sleep $SleepTime
send "$outfile\r"
expect "mama>"
sleep $SleepTime
send "st\r"
expect "Are you sure you want to exit? (y/n)"
send "y\r"

0 comments on commit 3a14ec7

Please sign in to comment.