Changeset def97a0 in sasview
- Timestamp:
- Apr 4, 2017 9:11:22 AM (8 years ago)
- 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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 388bd51
- Parents:
- ecc8d1a8
- git-author:
- Adam Washington <adam.washington@…> (04/04/17 08:44:01)
- git-committer:
- Adam Washington <adam.washington@…> (04/04/17 09:11:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/sesans_reader.py
recc8d1a8 rdef97a0 18 18 _ZERO = 1e-16 19 19 20 20 21 class Reader: 21 22 """ 22 23 Class to load sesans files (6 columns). 23 24 """ 24 # #File type25 # File type 25 26 type_name = "SESANS" 26 27 27 # #Wildcards28 # Wildcards 28 29 type = ["SESANS files (*.ses)|*.ses", 29 30 "SESANS files (*..sesans)|*.sesans"] 30 # #List of allowed extensions31 # List of allowed extensions 31 32 ext = ['.ses', '.SES', '.sesans', '.SESANS'] 32 33 33 # #Flag to bypass extension check34 # Flag to bypass extension check 34 35 allow_all = True 35 36 36 37 def read(self, path): 37 38 # print "reader triggered"39 40 38 """ 41 39 Load data file … … 79 77 if lam_unit == "AA": 80 78 lam_unit = "A" 81 p_unit = headers["polarisation"]82 79 83 x, x_unit = self._unit_conversion( x, lam_unit,84 _fetch_unit(headers,85 86 dx, dx_unit = self._unit_conversion( dx, lam_unit,87 _fetch_unit(headers,88 89 dlam, dlam_unit = self._unit_conversion( dlam, lam_unit,90 _fetch_unit(headers,91 80 x, x_unit = self._unit_conversion( 81 x, lam_unit, 82 _fetch_unit(headers, "spin echo length")) 83 dx, dx_unit = self._unit_conversion( 84 dx, lam_unit, 85 _fetch_unit(headers, "error SEL")) 86 dlam, dlam_unit = self._unit_conversion( 87 dlam, lam_unit, 88 _fetch_unit(headers, "error wavelength")) 92 89 y_unit = r'\AA^{-2} cm^{-1}' 93 90 94 output = Data1D(x=x, y=y, lam=lam, dy = dy, dx=dx, dlam=dlam, isSesans=True) 91 output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, 92 isSesans=True) 95 93 self.filename = output.filename = basename 96 94 output.xaxis(r"\rm{z}", x_unit) 97 output.yaxis(r"\rm{ln(P)/(t \lambda^2)}", y_unit) # Adjust label to ln P/(lam^2 t), remove lam column refs 95 # Adjust label to ln P/(lam^2 t), remove lam column refs 96 output.yaxis(r"\rm{ln(P)/(t \lambda^2)}", y_unit) 98 97 # Store loading process information 99 98 output.meta_data['loader'] = self.type_name 100 #output.sample.thickness = float(paramvals[6])101 99 output.sample.name = params["Sample"] 102 100 output.sample.ID = params["DataFileTitle"] 103 101 104 output.sample.zacceptance = (float(_header_fetch(params, "Q_zmax")), 105 _fetch_unit(params, "Q_zmax")) 102 output.sample.zacceptance = ( 103 float(_header_fetch(params, "Q_zmax")), 104 _fetch_unit(params, "Q_zmax")) 106 105 107 output.sample.yacceptance = (float(_header_fetch(params, "Q_ymax")), 108 _fetch_unit(params, "Q_ymax")) 106 output.sample.yacceptance = ( 107 float(_header_fetch(params, "Q_ymax")), 108 _fetch_unit(params, "Q_ymax")) 109 109 110 110 if len(output.x) < 1: 111 raise RuntimeError , "%s is empty" % path111 raise RuntimeError("%s is empty" % path) 112 112 return output 113 113 114 114 else: 115 raise RuntimeError , "%s is not a file" % path115 raise RuntimeError("%s is not a file" % path) 116 116 return None 117 117 118 118 def _unit_conversion(self, value, value_unit, default_unit): 119 if has_converter == Trueand value_unit != default_unit:119 if has_converter and value_unit != default_unit: 120 120 data_conv_q = Converter(value_unit) 121 121 value = data_conv_q(value, units=default_unit) … … 131 131 return headers[index] 132 132 133 133 134 def _fetch_unit(params, key): 134 135 index = [k for k in params.keys()
Note: See TracChangeset
for help on using the changeset viewer.