ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change
on this file since 060413c was
0b1a677,
checked in by lewis, 8 years ago
|
Only perform writing on separate thread
Also move reader/writer classes to sascalc
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | import os |
---|
2 | import time |
---|
3 | from sas.sascalc.dataloader.readers.red2d_reader import Reader as Red2DReader |
---|
4 | |
---|
5 | class Red2DWriter(Red2DReader): |
---|
6 | |
---|
7 | def write(self, filename, data, thread): |
---|
8 | """ |
---|
9 | Write to .dat |
---|
10 | |
---|
11 | :param filename: file name to write |
---|
12 | :param data: data2D |
---|
13 | """ |
---|
14 | # Write the file |
---|
15 | fd = open(filename, 'w') |
---|
16 | t = time.localtime() |
---|
17 | time_str = time.strftime("%H:%M on %b %d %y", t) |
---|
18 | |
---|
19 | header_str = "Data columns are Qx - Qy - I(Qx,Qy)\n\nASCII data" |
---|
20 | header_str += " created at %s \n\n" % time_str |
---|
21 | # simple 2D header |
---|
22 | fd.write(header_str) |
---|
23 | # write qx qy I values |
---|
24 | for i in range(len(data.data)): |
---|
25 | if thread.isquit(): |
---|
26 | fd.close() |
---|
27 | os.remove(filename) |
---|
28 | return False |
---|
29 | |
---|
30 | fd.write("%g %g %g\n" % (data.qx_data[i], |
---|
31 | data.qy_data[i], |
---|
32 | data.data[i])) |
---|
33 | |
---|
34 | fd.close() |
---|
35 | |
---|
36 | return True |
---|
Note: See
TracBrowser
for help on using the repository browser.