Changeset ec02ddd in sasview for DataLoader/readers/red2d_reader.py


Ignore:
Timestamp:
Jan 31, 2011 9:47:23 AM (14 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ed8ad21
Parents:
d5751ac
Message:

added 2D(dat) writer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/readers/red2d_reader.py

    ra7a5886 rec02ddd  
    4545    ## Extension 
    4646    ext=['.DAT', '.dat'] 
     47     
     48    def write(self, filename, data): 
     49        """ 
     50        Write to .dat 
     51         
     52        :param filename: file name to write 
     53        :param data: data2D  
     54        """ 
     55        import time 
     56        st = time.time() 
     57        # Write the file 
     58        fd = open(filename, 'w') 
     59        t = time.localtime() 
     60        time_str = time.strftime("%H:%M on %b %d %y", t) 
     61         
     62        header_str = "Data columns are Qx - Qy - I(Qx,Qy)\n\nASCII data" 
     63        header_str += " created at %s \n\n" % time_str 
     64        # simple 2D header 
     65        fd.write(header_str) 
     66        # write qx qy I values 
     67        for i in range(len(data.data)): 
     68            fd.write("%g  %g  %g\n" % (data.qx_data[i],  
     69                                        data.qy_data[i], 
     70                                       data.data[i])) 
     71        # close 
     72        fd.close()                  
    4773 
    4874    def read(self,filename=None): 
Note: See TracChangeset for help on using the changeset viewer.