Changeset 1f6d293 in sasview for src/sas


Ignore:
Timestamp:
Aug 18, 2016 5:00:32 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:
8cb1a07
Parents:
1ddf8f0
Message:

Write numerical values correctly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py

    r1ddf8f0 r1f6d293  
    409409            return np.array([np.string_(string)]) 
    410410 
     411        def _h5_float(x): 
     412            if not (isinstance(x, list)): 
     413                x = [x] 
     414            return np.array(x, dtype=np.float32) 
     415 
    411416        # Get run name and number from first Data object 
    412417        data_info = dataset[0] 
     
    469474                    collimation_entry.attrs['canSAS_class'] = 'SAScollimation' 
    470475                    if coll_info.length is not None: 
    471                         collimation_entry['SDD'] = coll_info.length 
     476                        collimation_entry['SDD'] = _h5_float(coll_info.length) 
    472477                        collimation_entry['SDD'].attrs['units'] = coll_info.length_unit 
    473478                    if coll_info.name is not None: 
     
    483488                    detector_entry.attrs['canSAS_class'] = 'SASdetector' 
    484489                    if det_info.distance is not None: 
    485                         detector_entry['SDD'] = det_info.distance 
     490                        detector_entry['SDD'] = _h5_float(det_info.distance) 
    486491                        detector_entry['SDD'].attrs['units'] = det_info.distance_unit 
    487492                    if det_info.name is not None: 
     
    489494                    else: 
    490495                        detector_entry['name'] = _h5_string('') 
     496                    i += 1 
    491497            else: 
    492498                detector_entry = instrument_entry.create_group('sasdetector01') 
Note: See TracChangeset for help on using the changeset viewer.