Changeset 7fce2bc in sasview for src/sas/sascalc/file_converter


Ignore:
Timestamp:
Aug 23, 2016 8:16:36 AM (8 years ago)
Author:
lewis
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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
be88076
Parents:
0836f77
Message:

Implement writing SASnote in NXcansSASWriter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/file_converter/nxcansas_writer.py

    r0836f77 r7fce2bc  
    3939            compatible with the Reader read() method. 
    4040            """ 
    41             if not isinstance(string, str): 
     41            if isinstance(string, np.ndarray): 
     42                return string 
     43            elif not isinstance(string, str): 
    4244                string = str(string) 
    4345 
     
    224226            detector_entry.attrs['name'] = '' 
    225227 
    226         # TODO: implement writing SASnote 
    227         i = 1 
    228         note_entry = sasentry.create_group('sasnote{0:0=2d}'.format(i)) 
     228        note_entry = sasentry.create_group('sasnote'.format(i)) 
    229229        note_entry.attrs['canSAS_class'] = 'SASnote' 
     230        notes = None 
     231        if len(data_info.notes) > 1: 
     232            notes = [np.string_(n) for n in data_info.notes] 
     233            notes = np.array(notes) 
     234        elif data_info.notes != []: 
     235            notes = _h5_string(data_info.notes[0]) 
     236        if notes is not None: 
     237            note_entry.create_dataset('SASnote', data=notes) 
    230238 
    231239        f.close() 
Note: See TracChangeset for help on using the changeset viewer.