-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added possbility to scale compton + fix small bugs
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
Showing
3 changed files
with
72 additions
and
30 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
53 changes: 42 additions & 11 deletions
53
data/mama_spectra/Smooth.sh → data/mama_spectra/Smooth_and_Multiply.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |