Changeset 9220e89c in sasview
- Timestamp:
- Nov 20, 2018 10:55:05 AM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
- Children:
- c7c8143
- Parents:
- c222c27
- Location:
- src/sas
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
ra165bee r9220e89c 14 14 from ..loader_exceptions import FileContentsException, DefaultReaderException 15 15 from ..file_reader_base_class import FileReader, decode 16 17 try: 18 basestring 19 except NameError: # CRUFT: python 2 support 20 basestring = str 16 21 17 22 … … 630 635 :param parent_list: List of names of parent elements 631 636 """ 632 if self._is 2d(value):637 if self._is_2d_not_multi_frame(value): 633 638 self.current_dataset = plottable_2D() 634 639 else: … … 639 644 640 645 @staticmethod 641 def check_is_list_or_array(iterable): 642 try: 643 iter(iterable) 644 if (not isinstance(iterable, np.ndarray) and not isinstance( 645 iterable, list)) or (isinstance(iterable, basestring)): 646 raise TypeError 647 except TypeError: 648 if isinstance(iterable, basestring): 649 iterable = iterable.split(",") 650 else: 651 iterable = [iterable] 646 def as_list_or_array(iterable): 647 """ 648 Return value as a list if not already a list or array. 649 :param iterable: 650 :return: 651 """ 652 if not (isinstance(iterable, np.ndarray) or isinstance(iterable, list)): 653 iterable = iterable.split(",") if isinstance(iterable, basestring)\ 654 else [iterable] 652 655 return iterable 653 656 … … 671 674 i_axes = attrs.get("I_axes", ["Q"]) 672 675 q_indices = attrs.get("Q_indices", [0]) 673 q_indices = map(int, self.check_is_list_or_array(q_indices)) 674 i_axes = self.check_is_list_or_array(i_axes) 676 i_axes = self.as_list_or_array(i_axes) 675 677 keys = value.keys() 676 678 # Assign attributes to appropriate class variables 679 self.q_names = [i_axes[int(v)] for v in self.as_list_or_array(q_indices)] 677 680 self.mask_name = attrs.get("mask") 678 for val in q_indices:679 self.q_names.append(i_axes[val])680 681 self.i_name = signal 681 682 self.i_node = value.get(self.i_name) … … 699 700 self.i_uncertainties_name = i_vals.attrs.get("uncertainty") 700 701 701 def _is 2d(self, value, i_base="", q_base=[]):702 def _is_2d_not_multi_frame(self, value, i_base="", q_base=""): 702 703 """ 703 704 A private class to determine if the data set is 1d or 2d. … … 709 710 i_basename = i_base if i_base != "" else self.i_name 710 711 i_vals = value.get(i_basename) 711 q_basename = q_base if q_base != []else self.q_names712 q_basename = q_base if q_base != "" else self.q_names 712 713 q_vals = value.get(q_basename[0]) 713 self.multi_frame = True if(i_vals is not None and q_vals is not None714 715 and len(q_vals.shape) == 1) else False716 return (i_vals is not None and i_vals.shape is not None717 and len(i_vals.shape) != 1 andnot self.multi_frame)714 self.multi_frame = (i_vals is not None and q_vals is not None 715 and len(i_vals.shape) != 1 716 and len(q_vals.shape) == 1) 717 return (i_vals is not None and len(i_vals.shape) != 1 718 and not self.multi_frame) 718 719 719 720 def _create_unique_key(self, dictionary, name, numb=0): -
src/sas/sascalc/file_converter/nxcansas_writer.py
r2ca5d57b r9220e89c 87 87 entry[names[2]].attrs['units'] = units 88 88 89 valid_data = all([issubclass(d.__class__, (Data1D, Data2D)) for d in 90 dataset]) 89 valid_data = all([isinstance(d, (Data1D, Data2D)) for d in dataset]) 91 90 if not valid_data: 92 91 raise ValueError("All entries of dataset must be Data1D or Data2D" -
src/sas/sasgui/guiframe/gui_manager.py
r9f45f83 r9220e89c 2580 2580 # Instantiate a loader 2581 2581 loader = Loader() 2582 if os.path.splitext(mypath)[1].lower() == '.dat': 2582 ext = os.path.splitext(mypath)[1].lower() 2583 if ext == '.dat': 2583 2584 # Make sure the ext included in the file name 2584 2585 # especially on MAC 2585 2586 fileName = os.path.splitext(path)[0] + ext_format 2586 2587 loader.save(fileName, data, ext_format) 2587 elif os.path.splitext(mypath)[1].lower()== '.h5':2588 elif ext == '.h5': 2588 2589 # Make sure the ext included in the file name 2589 2590 # especially on MAC
Note: See TracChangeset
for help on using the changeset viewer.