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 | |
---|
7 | path="/archive/ndxsans2d/instrument/data/cycle_13_2/" |
---|
8 | #path="Y:/cycle_12_1/" |
---|
9 | # put this at end of file runlist=[11972,11981] |
---|
10 | |
---|
11 | def add_runs(path,runlist): |
---|
12 | print "here we go" |
---|
13 | # assume pathout, assume runs are all integers, will crash at present if try adding to an nnn-add |
---|
14 | # U:/ needs to point to //isis/inst$/ndxSans2d/user/ |
---|
15 | # |
---|
16 | # 25/03/10 BUG - at least from RKH's office, python insists on putting an extra "\user" in the output path ! |
---|
17 | # so is saving to u:\user\processed\ instead of u:\processed thereby creating u:\user\user\processed\ |
---|
18 | # it does this regardless of which of the two versions of "pathout" I use below. |
---|
19 | # so you may need to move the created add files ! |
---|
20 | # |
---|
21 | pathout="" |
---|
22 | #pathout="//isis/inst$/ndxSans2d/processed/" |
---|
23 | pfix="SANS2D" |
---|
24 | sfix=".nxs" |
---|
25 | b=range(len(runlist)-1) |
---|
26 | # |
---|
27 | # get the first file in list |
---|
28 | nzeros=8-len(str(runlist[0])) |
---|
29 | fpad="" |
---|
30 | for ii in range(nzeros): |
---|
31 | fpad+="0" |
---|
32 | # |
---|
33 | filename=path+pfix+fpad+str(runlist[0])+sfix |
---|
34 | print "reading file: "+filename |
---|
35 | m1=LoadNexus(Filename=filename,OutputWorkspace="added") |
---|
36 | |
---|
37 | for i in b: |
---|
38 | snum=str(runlist[i+1]) |
---|
39 | nzeros=8-len(snum) |
---|
40 | fpad="" |
---|
41 | for ii in range(nzeros): |
---|
42 | fpad+="0" |
---|
43 | filename=path+pfix+fpad+snum |
---|
44 | print "reading file: "+filename+sfix |
---|
45 | m2=LoadNexus(Filename=filename+sfix,OutputWorkspace="wtemp") |
---|
46 | Plus("added","wtemp","added") |
---|
47 | mantid.deleteWorkspace("wtemp") |
---|
48 | # now save the added file |
---|
49 | #print "pathout="+pathout |
---|
50 | print "writing file: "+pathout+pfix+fpad+snum+"-add"+sfix |
---|
51 | SaveNexusProcessed("added",pathout+pfix+fpad+snum+"-add"+sfix) |
---|
52 | mantid.deleteWorkspace("added") |
---|
53 | # copy the log file for last run to U:/ , though search list should find it in orgianal space also. |
---|
54 | copyfile(path+pfix+fpad+snum+".log",pathout+pfix+fpad+snum+".log") |
---|
55 | |
---|
56 | |
---|
57 | # Rob's code |
---|
58 | #def fname(rnum): |
---|
59 | # path=nr.isisDataDir |
---|
60 | #inst=nr.isisInstrument |
---|
61 | # ext=nr.isisExt |
---|
62 | # |
---|
63 | #nzeros=8-len(str(rnum)) |
---|
64 | # fpad="" |
---|
65 | #for i in range(nzeros): |
---|
66 | #fpad+="0" |
---|
67 | |
---|
68 | #filename=path+inst+fpad+str(rnum)+ext |
---|
69 | #return filename |
---|
70 | |
---|
71 | # In the interests of sanity run the stuff from the bottom so that function gets redefined before it is run |
---|
72 | # Just run the two lines below for subseqent additions |
---|
73 | |
---|
74 | runlist=[19675, 19682, 19689] |
---|
75 | add_runs(path,runlist) |
---|