1 | from mantidsimple import * |
---|
2 | from shutil import copyfile |
---|
3 | # mantidinstall/bin/mantid.user.properties needs e.g. |
---|
4 | # datasearch.directories = U:/Processed ; N:/cycle_09_4 |
---|
5 | # defaultsave.directory = C:/Mantidinstall/genie |
---|
6 | def add_runs(path,runlist): |
---|
7 | # assume pathout, assume runs are all integers, will crash at present if try adding to an nnn-add |
---|
8 | # U:/ needs to point to //isis/inst$/ndxSans2d/user/ |
---|
9 | # |
---|
10 | # 25/03/10 BUG - at least from RKH's office, python insists on putting an extra "\user" in the output path ! |
---|
11 | # so is saving to u:\user\processed\ instead of u:\processed thereby creating u:\user\user\processed\ |
---|
12 | # it does this regardless of which of the two versions of "pathout" I use below. |
---|
13 | # so you may need to move the created add files ! |
---|
14 | # |
---|
15 | # pathout="u:/Processed/" |
---|
16 | pathout="//isis/inst$/ndxSans2d/user/processed" |
---|
17 | pfix="sans2d" |
---|
18 | sfix=".nxs" |
---|
19 | b=range(len(runlist)-1) |
---|
20 | # |
---|
21 | # get the first file in list |
---|
22 | nzeros=8-len(str(runlist[0])) |
---|
23 | fpad="" |
---|
24 | for ii in range(nzeros): |
---|
25 | fpad+="0" |
---|
26 | # |
---|
27 | filename=path+pfix+fpad+str(runlist[0])+sfix |
---|
28 | print "reading file: "+filename |
---|
29 | m1=LoadNexus(Filename=filename,OutputWorkspace="added") |
---|
30 | |
---|
31 | for i in b: |
---|
32 | snum=str(runlist[i+1]) |
---|
33 | nzeros=8-len(snum) |
---|
34 | fpad="" |
---|
35 | for ii in range(nzeros): |
---|
36 | fpad+="0" |
---|
37 | filename=path+pfix+fpad+snum |
---|
38 | print "reading file: "+filename+sfix |
---|
39 | m2=LoadNexus(Filename=filename+sfix,OutputWorkspace="wtemp") |
---|
40 | Plus("added","wtemp","added") |
---|
41 | mantid.deleteWorkspace("wtemp") |
---|
42 | # now save the added file |
---|
43 | print "writing file: "+pathout+pfix+fpad+snum+"-add"+sfix |
---|
44 | SaveNexusProcessed("added",pathout+pfix+fpad+snum+"-add"+sfix) |
---|
45 | mantid.deleteWorkspace("added") |
---|
46 | # copy the log file for last run to U:/ , though search list should find it in orgianal space also. |
---|
47 | copyfile(path+pfix+fpad+snum+".log",pathout+pfix+fpad+snum+".log") |
---|
48 | |
---|
49 | |
---|
50 | # Rob's code |
---|
51 | #def fname(rnum): |
---|
52 | # path=nr.isisDataDir |
---|
53 | #inst=nr.isisInstrument |
---|
54 | # ext=nr.isisExt |
---|
55 | # |
---|
56 | #nzeros=8-len(str(rnum)) |
---|
57 | # fpad="" |
---|
58 | #for i in range(nzeros): |
---|
59 | #fpad+="0" |
---|
60 | |
---|
61 | #filename=path+inst+fpad+str(rnum)+ext |
---|
62 | #return filename |
---|