Changeset 5d1e040 in sasview


Ignore:
Timestamp:
Apr 9, 2017 3:47:08 AM (7 years ago)
Author:
Adam Washington <adam.washington@…>
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:
8938502
Parents:
e962d85 (diff), 5b2b04d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of github.com:SasView/sasview

Files:
9 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/data_processor.py

    r9a5097c re645bbb  
    1818 
    1919""" 
    20 import wx 
    21 import numpy 
    22 import math 
    23 import re 
    2420import os 
    2521import sys 
    2622import copy 
    27 from wx.lib.scrolledpanel import ScrolledPanel 
     23import math 
     24import re 
     25import wx 
     26import numpy as np 
     27 
    2828import wx.aui 
    2929from wx.aui import AuiNotebook as nb 
    3030import wx.lib.sheet as sheet 
     31from wx.lib.scrolledpanel import ScrolledPanel 
     32 
    3133from sas.sasgui.guiframe.panel_base import PanelBase 
    3234from sas.sasgui.guiframe.events import NewPlotEvent 
  • sasview/test/sesans_data/sphere2micron.ses

    r2a2b43a rd3bce8c  
    1 DataFileTitle   "Polystyrene of Markus Strobl,  Full Sine, ++ only "                                             
    2 Sample  "Polystyrene 2 um in 53% H2O, 47% D2O "                                          
    3 Settings        "D1=D2=20x8 mm,Ds = 16x10 mm (WxH), GF1 =scanning, GF2 = 2.5 A. 2 um polystyrene in 53% H2O, 47% D2O; 8.55% contrast "                                           
    4 Operator        CPD                                              
    5 Date    do 10 jul 2014 16:37:30                                                  
    6 ScanType        sine one element scan                                            
    7 Thickness [cm]  2.00E-01                                                 
    8 Q_zmax [\A^-1]  0.05                                             
    9 Q_ymax [\A^-1]  0.05                                             
    10                                                          
    11 spin echo length [A]     Depolarisation [A-2 cm-1]       error depol [A-2 cm-1]          error SEL [A]   wavelength [A]          error wavelength [A]    polarisation    error pol  
    12 391.56  0.0041929       0.0036894       19.578  2.11    0.1055  1.0037  0.0032974 
    13 1564    -0.0046571      0.0038185       78.2    2.11    0.1055  0.99586 0.003386 
    14 2735.6  -0.017007       0.0038132       136.78  2.11    0.1055  0.98497 0.0033444 
    15 3907.9  -0.033462       0.0035068       195.39  2.11    0.1055  0.97064 0.0030309 
    16 5080.2  -0.047483       0.0038208       254.01  2.11    0.1055  0.9586  0.0032613 
    17 6251.8  -0.070375       0.00376 312.59  2.11    0.1055  0.93926 0.0031446 
    18 7423.2  -0.092217       0.0037927       371.16  2.11    0.1055  0.92117 0.0031108 
    19 8595.5  -0.10238        0.004006        429.77  2.11    0.1055  0.91287 0.0032562 
    20 9767.7  -0.12672        0.0038534       488.39  2.11    0.1055  0.8933  0.0030651 
    21 10940   -0.1374 0.004243        546.98  2.11    0.1055  0.88484 0.003343 
    22 12112   -0.16072        0.0045837       605.58  2.11    0.1055  0.86666 0.0035372 
    23 13284   -0.16623        0.0045613       664.2   2.11    0.1055  0.86242 0.0035027 
    24 14456   -0.18468        0.0044918       722.79  2.11    0.1055  0.84837 0.0033931 
    25 15628   -0.19143        0.0048967       781.38  2.11    0.1055  0.84328 0.0036768 
    26 16800   -0.20029        0.0045421       840.02  2.11    0.1055  0.83666 0.0033837 
    27 17971   -0.19798        0.0046642       898.56  2.11    0.1055  0.83838 0.0034819 
    28 19143   -0.21442        0.0047052       957.17  2.11    0.1055  0.82619 0.0034614 
    29 20316   -0.20885        0.0044931       1015.8  2.11    0.1055  0.8303  0.0033218 
    30 21488   -0.21393        0.0049186       1074.4  2.11    0.1055  0.82655 0.00362 
    31 22660   -0.20685        0.004423        1133    2.11    0.1055  0.83179 0.0032758 
    32 23832   -0.20802        0.0046979       1191.6  2.11    0.1055  0.83092 0.0034758 
    33 25003   -0.19848        0.0045953       1250.2  2.11    0.1055  0.838   0.0034289 
    34 26175   -0.21117        0.0044567       1308.8  2.11    0.1055  0.82859 0.0032881 
    35 27347   -0.21283        0.004137        1367.4  2.11    0.1055  0.82736 0.0030477 
    36 28520   -0.2042 0.0044587       1426    2.11    0.1055  0.83375 0.0033101 
    37 29692   -0.2112 0.0042852       1484.6  2.11    0.1055  0.82857 0.0031615 
    38 30864   -0.20319        0.0043483       1543.2  2.11    0.1055  0.8345  0.003231 
    39 32036   -0.20752        0.0044297       1601.8  2.11    0.1055  0.83129 0.0032788 
    40 33207   -0.20654        0.0043188       1660.4  2.11    0.1055  0.83201 0.0031995 
    41 34380   -0.20126        0.0046375       1719    2.11    0.1055  0.83593 0.0034518 
    42 35551   -0.20924        0.0042871       1777.6  2.11    0.1055  0.83001 0.0031684 
    43 36724   -0.21323        0.0045471       1836.2  2.11    0.1055  0.82707 0.0033487 
    44 37895   -0.21324        0.0045354       1894.7  2.11    0.1055  0.82706 0.00334 
    45 39067   -0.19905        0.0044141       1953.4  2.11    0.1055  0.83758 0.003292 
    46 40239   -0.1991 0.0047441       2012    2.11    0.1055  0.83754 0.003538 
    47 41411   -0.20359        0.0050136       2070.5  2.11    0.1055  0.8342  0.003724 
    48 42583   -0.21032        0.0049474       2129.1  2.11    0.1055  0.82922 0.0036529 
    49 43755   -0.20689        0.0048203       2187.8  2.11    0.1055  0.83176 0.00357 
    50 44927   -0.21075        0.0052337       2246.4  2.11    0.1055  0.8289  0.0038628 
    51 46099   -0.19956        0.0047827       2304.9  2.11    0.1055  0.8372  0.0035653 
     1FileFormatVersion       1.0 
     2DataFileTitle           Polystyrene of Markus Strobl,  Full Sine, ++ only 
     3Sample                  Polystyrene 2 um in 53% H2O, 47% D2O 
     4Settings                D1=D2=20x8 mm,Ds = 16x10 mm (WxH), GF1 =scanning, GF2 = 2.5 A. 2 um polystyrene in 53% H2O, 47% D2O; 8.55% contrast 
     5Operator                CPD 
     6Date                    do 10 jul 2014 16:37:30 
     7ScanType                sine one element scan 
     8Thickness               2.00E-01 
     9Thickness_unit          cm 
     10Theta_zmax              0.0168 
     11Theta_zmax_unit         radians 
     12Theta_ymax              0.0168 
     13Theta_ymax_unit         radians 
     14Orientation             Z 
     15SpinEchoLength_unit     A 
     16Depolarisation_unit     A-2 cm-1 
     17Wavelength_unit         A 
     18 
     19BEGIN_DATA 
     20SpinEchoLength Depolarisation Depolarisation_error SpinEchoLength_error Wavelength Wavelength_error Polarisation  Polarisation_error 
     21391.56 0.0041929 0.0036894 19.578 2.11 0.1055 1.0037 0.0032974 
     221564 -0.0046571 0.0038185 78.2 2.11 0.1055 0.99586 0.003386 
     232735.6 -0.017007 0.0038132 136.78 2.11 0.1055 0.98497 0.0033444 
     243907.9 -0.033462 0.0035068 195.39 2.11 0.1055 0.97064 0.0030309 
     255080.2 -0.047483 0.0038208 254.01 2.11 0.1055 0.9586 0.0032613 
     266251.8 -0.070375 0.00376 312.59 2.11 0.1055 0.93926 0.0031446 
     277423.2 -0.092217 0.0037927 371.16 2.11 0.1055 0.92117 0.0031108 
     288595.5 -0.10238 0.004006 429.77 2.11 0.1055 0.91287 0.0032562 
     299767.7 -0.12672 0.0038534 488.39 2.11 0.1055 0.8933 0.0030651 
     3010940 -0.1374 0.004243 546.98 2.11 0.1055 0.88484 0.003343 
     3112112 -0.16072 0.0045837 605.58 2.11 0.1055 0.86666 0.0035372 
     3213284 -0.16623 0.0045613 664.2 2.11 0.1055 0.86242 0.0035027 
     3314456 -0.18468 0.0044918 722.79 2.11 0.1055 0.84837 0.0033931 
     3415628 -0.19143 0.0048967 781.38 2.11 0.1055 0.84328 0.0036768 
     3516800 -0.20029 0.0045421 840.02 2.11 0.1055 0.83666 0.0033837 
     3617971 -0.19798 0.0046642 898.56 2.11 0.1055 0.83838 0.0034819 
     3719143 -0.21442 0.0047052 957.17 2.11 0.1055 0.82619 0.0034614 
     3820316 -0.20885 0.0044931 1015.8 2.11 0.1055 0.8303 0.0033218 
     3921488 -0.21393 0.0049186 1074.4 2.11 0.1055 0.82655 0.00362 
     4022660 -0.20685 0.004423 1133 2.11 0.1055 0.83179 0.0032758 
     4123832 -0.20802 0.0046979 1191.6 2.11 0.1055 0.83092 0.0034758 
     4225003 -0.19848 0.0045953 1250.2 2.11 0.1055 0.838 0.0034289 
     4326175 -0.21117 0.0044567 1308.8 2.11 0.1055 0.82859 0.0032881 
     4427347 -0.21283 0.004137 1367.4 2.11 0.1055 0.82736 0.0030477 
     4528520 -0.2042 0.0044587 1426 2.11 0.1055 0.83375 0.0033101 
     4629692 -0.2112 0.0042852 1484.6 2.11 0.1055 0.82857 0.0031615 
     4730864 -0.20319 0.0043483 1543.2 2.11 0.1055 0.8345 0.003231 
     4832036 -0.20752 0.0044297 1601.8 2.11 0.1055 0.83129 0.0032788 
     4933207 -0.20654 0.0043188 1660.4 2.11 0.1055 0.83201 0.0031995 
     5034380 -0.20126 0.0046375 1719 2.11 0.1055 0.83593 0.0034518 
     5135551 -0.20924 0.0042871 1777.6 2.11 0.1055 0.83001 0.0031684 
     5236724 -0.21323 0.0045471 1836.2 2.11 0.1055 0.82707 0.0033487 
     5337895 -0.21324 0.0045354 1894.7 2.11 0.1055 0.82706 0.00334 
     5439067 -0.19905 0.0044141 1953.4 2.11 0.1055 0.83758 0.003292 
     5540239 -0.1991 0.0047441 2012 2.11 0.1055 0.83754 0.003538 
     5641411 -0.20359 0.0050136 2070.5 2.11 0.1055 0.8342 0.003724 
     5742583 -0.21032 0.0049474 2129.1 2.11 0.1055 0.82922 0.0036529 
     5843755 -0.20689 0.0048203 2187.8 2.11 0.1055 0.83176 0.00357 
     5944927 -0.21075 0.0052337 2246.4 2.11 0.1055 0.8289 0.0038628 
     6046099 -0.19956 0.0047827 2304.9 2.11 0.1055 0.8372 0.0035653 
  • src/sas/sascalc/data_util/qsmearing.py

    r9a5097c re962d85  
    6565            raise ValueError('one or more of your dx values are negative, please check the data file!') 
    6666 
    67     if _found_sesans == True: 
    68         #Pre-compute the Hankel matrix (H) 
    69         qmax, qunits = data.sample.zacceptance 
     67    if _found_sesans: 
     68        # Pre-compute the Hankel matrix (H) 
    7069        SElength = Converter(data._xunit)(data.x, "A") 
    71         zaccept = Converter(qunits)(qmax, "1/A"), 
     70 
     71        theta_max = Converter("radians")(data.sample.zacceptance)[0] 
     72        q_max = 2 * np.pi / np.max(data.source.wavelength) * np.sin(theta_max) 
     73        zaccept = Converter("1/A")(q_max, "1/" + data.source.wavelength_unit), 
     74 
    7275        Rmax = 10000000 
    73         hankel = SesansTransform(data.x, SElength, zaccept, Rmax) 
     76        hankel = SesansTransform(data.x, SElength, 
     77                                 data.source.wavelength, 
     78                                 zaccept, Rmax) 
    7479        # Then return the actual transform, as if it were a smearing function 
    7580        return PySmear(hankel, model, offset=0) 
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    r9a5097c rf6c2555  
    11""" 
    22    SESANS reader (based on ASCII reader) 
    3      
     3 
    44    Reader for .ses or .sesans file format 
    5      
    6     Jurrian Bakker  
     5 
     6    Jurrian Bakker 
    77""" 
    88import numpy as np 
     
    1818_ZERO = 1e-16 
    1919 
     20 
    2021class Reader: 
    2122    """ 
    2223    Class to load sesans files (6 columns). 
    2324    """ 
    24     ## File type 
     25    # File type 
    2526    type_name = "SESANS" 
    26      
    27     ## Wildcards 
     27 
     28    # Wildcards 
    2829    type = ["SESANS files (*.ses)|*.ses", 
    2930            "SESANS files (*..sesans)|*.sesans"] 
    30     ## List of allowed extensions 
     31    # List of allowed extensions 
    3132    ext = ['.ses', '.SES', '.sesans', '.SESANS'] 
    32      
    33     ## Flag to bypass extension check 
     33 
     34    # Flag to bypass extension check 
    3435    allow_all = True 
    35      
     36 
    3637    def read(self, path): 
    37          
    38 #        print "reader triggered" 
    39          
    4038        """ 
    4139        Load data file 
    42          
     40 
    4341        :param path: file path 
    44          
     42 
    4543        :return: SESANSData1D object, or None 
    46          
     44 
    4745        :raise RuntimeError: when the file can't be opened 
    4846        :raise ValueError: when the length of the data vectors are inconsistent 
     
    5149            basename = os.path.basename(path) 
    5250            _, extension = os.path.splitext(basename) 
    53             if self.allow_all or extension.lower() in self.ext: 
    54                 try: 
    55                     # Read in binary mode since GRASP frequently has no-ascii 
    56                     # characters that brakes the open operation 
    57                     input_f = open(path,'rb') 
    58                 except: 
    59                     raise  RuntimeError, "sesans_reader: cannot open %s" % path 
    60                 buff = input_f.read() 
    61                 lines = buff.splitlines() 
    62                 x  = np.zeros(0) 
    63                 y  = np.zeros(0) 
    64                 dy = np.zeros(0) 
    65                 lam  = np.zeros(0) 
    66                 dlam = np.zeros(0) 
    67                 dx = np.zeros(0) 
    68                  
    69                #temp. space to sort data 
    70                 tx  = np.zeros(0) 
    71                 ty  = np.zeros(0) 
    72                 tdy = np.zeros(0) 
    73                 tlam  = np.zeros(0) 
    74                 tdlam = np.zeros(0) 
    75                 tdx = np.zeros(0) 
    76                 output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, isSesans=True) 
    77                 self.filename = output.filename = basename 
     51            if not (self.allow_all or extension.lower() in self.ext): 
     52                raise RuntimeError( 
     53                    "{} has an unrecognized file extension".format(path)) 
     54        else: 
     55            raise RuntimeError("{} is not a file".format(path)) 
     56        with open(path, 'r') as input_f: 
     57            line = input_f.readline() 
     58            params = {} 
     59            while not line.startswith("BEGIN_DATA"): 
     60                terms = line.split() 
     61                if len(terms) >= 2: 
     62                    params[terms[0]] = " ".join(terms[1:]) 
     63                line = input_f.readline() 
     64            self.params = params 
    7865 
    79                 paramnames=[] 
    80                 paramvals=[] 
    81                 zvals=[] 
    82                 dzvals=[] 
    83                 lamvals=[] 
    84                 dlamvals=[] 
    85                 Pvals=[] 
    86                 dPvals=[] 
     66            if "FileFormatVersion" not in self.params: 
     67                raise RuntimeError("SES file missing FileFormatVersion") 
     68            if float(self.params["FileFormatVersion"]) >= 2.0: 
     69                raise RuntimeError("SASView only supports SES version 1") 
    8770 
    88                 for line in lines: 
    89                     # Initial try for CSV (split on ,) 
    90                     line=line.strip() 
    91                     toks = line.split('\t') 
    92                     if len(toks)==2: 
    93                         paramnames.append(toks[0]) 
    94                         paramvals.append(toks[1]) 
    95                     if len(toks)>5: 
    96                         zvals.append(toks[0]) 
    97                         dzvals.append(toks[3]) 
    98                         lamvals.append(toks[4]) 
    99                         dlamvals.append(toks[5]) 
    100                         Pvals.append(toks[1]) 
    101                         dPvals.append(toks[2]) 
    102                     else: 
    103                         continue 
     71            if "SpinEchoLength_unit" not in self.params: 
     72                raise RuntimeError("SpinEchoLength has no units") 
     73            if "Wavelength_unit" not in self.params: 
     74                raise RuntimeError("Wavelength has no units") 
     75            if params["SpinEchoLength_unit"] != params["Wavelength_unit"]: 
     76                raise RuntimeError("The spin echo data has rudely used " 
     77                                   "different units for the spin echo length " 
     78                                   "and the wavelength.  While sasview could " 
     79                                   "handle this instance, it is a violation " 
     80                                   "of the file format and will not be " 
     81                                   "handled by other software.") 
    10482 
    105                 x=[] 
    106                 y=[] 
    107                 lam=[] 
    108                 dx=[] 
    109                 dy=[] 
    110                 dlam=[] 
    111                 lam_header = lamvals[0].split() 
    112                 data_conv_z = None 
    113                 default_z_unit = "A" 
    114                 data_conv_P = None 
    115                 default_p_unit = " " # Adjust unit for axis (L^-3) 
    116                 lam_unit = lam_header[1].replace("[","").replace("]","") 
    117                 if lam_unit == 'AA': 
    118                     lam_unit = 'A' 
    119                 varheader=[zvals[0],dzvals[0],lamvals[0],dlamvals[0],Pvals[0],dPvals[0]] 
    120                 valrange=range(1, len(zvals)) 
    121                 for i in valrange: 
    122                     x.append(float(zvals[i])) 
    123                     y.append(float(Pvals[i])) 
    124                     lam.append(float(lamvals[i])) 
    125                     dy.append(float(dPvals[i])) 
    126                     dx.append(float(dzvals[i])) 
    127                     dlam.append(float(dlamvals[i])) 
     83            headers = input_f.readline().split() 
    12884 
    129                 x,y,lam,dy,dx,dlam = [ 
    130                     np.asarray(v, 'double') 
    131                    for v in (x,y,lam,dy,dx,dlam) 
    132                 ] 
     85            self._insist_header(headers, "SpinEchoLength") 
     86            self._insist_header(headers, "Depolarisation") 
     87            self._insist_header(headers, "Depolarisation_error") 
     88            self._insist_header(headers, "Wavelength") 
    13389 
    134                 input_f.close() 
     90            data = np.loadtxt(input_f) 
    13591 
    136                 output.x, output.x_unit = self._unit_conversion(x, lam_unit, default_z_unit) 
    137                 output.y = y 
    138                 output.y_unit = r'\AA^{-2} cm^{-1}'  # output y_unit added 
    139                 output.dx, output.dx_unit = self._unit_conversion(dx, lam_unit, default_z_unit) 
    140                 output.dy = dy 
    141                 output.lam, output.lam_unit = self._unit_conversion(lam, lam_unit, default_z_unit) 
    142                 output.dlam, output.dlam_unit = self._unit_conversion(dlam, lam_unit, default_z_unit) 
    143                  
    144                 output.xaxis(r"\rm{z}", output.x_unit) 
    145                 output.yaxis(r"\rm{ln(P)/(t \lambda^2)}", output.y_unit)  # Adjust label to ln P/(lam^2 t), remove lam column refs 
     92            if data.shape[1] != len(headers): 
     93                raise RuntimeError( 
     94                    "File has {} headers, but {} columns".format( 
     95                        len(headers), 
     96                        data.shape[1])) 
    14697 
    147                 # Store loading process information 
    148                 output.meta_data['loader'] = self.type_name 
    149                 #output.sample.thickness = float(paramvals[6]) 
    150                 output.sample.name = paramvals[1] 
    151                 output.sample.ID = paramvals[0] 
    152                 zaccept_unit_split = paramnames[7].split("[") 
    153                 zaccept_unit = zaccept_unit_split[1].replace("]","") 
    154                 if zaccept_unit.strip() == r'\AA^-1' or zaccept_unit.strip() == r'\A^-1': 
    155                     zaccept_unit = "1/A" 
    156                 output.sample.zacceptance=(float(paramvals[7]),zaccept_unit) 
    157                 output.vars = varheader 
     98            if data.size < 1: 
     99                raise RuntimeError("{} is empty".format(path)) 
     100            x = data[:, headers.index("SpinEchoLength")] 
     101            if "SpinEchoLength_error" in headers: 
     102                dx = data[:, headers.index("SpinEchoLength_error")] 
     103            else: 
     104                dx = x*0.05 
     105            lam = data[:, headers.index("Wavelength")] 
     106            if "Wavelength_error" in headers: 
     107                dlam = data[:, headers.index("Wavelength_error")] 
     108            else: 
     109                dlam = lam*0.05 
     110            y = data[:, headers.index("Depolarisation")] 
     111            dy = data[:, headers.index("Depolarisation_error")] 
    158112 
    159                 if len(output.x) < 1: 
    160                     raise RuntimeError, "%s is empty" % path 
    161                 return output 
     113            lam_unit = self._unit_fetch("Wavelength") 
     114            x, x_unit = self._unit_conversion(x, "A", 
     115                                              self._unit_fetch( 
     116                                                  "SpinEchoLength")) 
     117            dx, dx_unit = self._unit_conversion( 
     118                dx, lam_unit, 
     119                self._unit_fetch("SpinEchoLength")) 
     120            dlam, dlam_unit = self._unit_conversion( 
     121                dlam, lam_unit, 
     122                self._unit_fetch("Wavelength")) 
     123            y_unit = self._unit_fetch("Depolarisation") 
    162124 
    163         else: 
    164             raise RuntimeError, "%s is not a file" % path 
    165         return None 
     125            output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, 
     126                            isSesans=True) 
    166127 
    167     def _unit_conversion(self, value, value_unit, default_unit): 
    168         if has_converter == True and value_unit != default_unit: 
    169             data_conv_q = Converter(value_unit) 
    170             value = data_conv_q(value, units=default_unit) 
     128            output.y_unit = y_unit 
     129            output.x_unit = x_unit 
     130            output.source.wavelength_unit = lam_unit 
     131            output.source.wavelength = lam 
     132            self.filename = output.filename = basename 
     133            output.xaxis(r"\rm{z}", x_unit) 
     134            # Adjust label to ln P/(lam^2 t), remove lam column refs 
     135            output.yaxis(r"\rm{ln(P)/(t \lambda^2)}", y_unit) 
     136            # Store loading process information 
     137            output.meta_data['loader'] = self.type_name 
     138            output.sample.name = params["Sample"] 
     139            output.sample.ID = params["DataFileTitle"] 
     140            output.sample.thickness = self._unit_conversion( 
     141                float(params["Thickness"]), "cm", 
     142                self._unit_fetch("Thickness"))[0] 
     143 
     144            output.sample.zacceptance = ( 
     145                float(params["Theta_zmax"]), 
     146                self._unit_fetch("Theta_zmax")) 
     147 
     148            output.sample.yacceptance = ( 
     149                float(params["Theta_ymax"]), 
     150                self._unit_fetch("Theta_ymax")) 
     151            return output 
     152 
     153    @staticmethod 
     154    def _insist_header(headers, name): 
     155        if name not in headers: 
     156            raise RuntimeError( 
     157                "Missing {} column in spin echo data".format(name)) 
     158 
     159    @staticmethod 
     160    def _unit_conversion(value, value_unit, default_unit): 
     161        """ 
     162        Performs unit conversion on a measurement. 
     163 
     164        :param value: The magnitude of the measurement 
     165        :param value_unit: a string containing the final desired unit 
     166        :param default_unit: string with the units of the original measurement 
     167        :return: The magnitude of the measurement in the new units 
     168        """ 
     169        # (float, string, string) -> float 
     170        if has_converter and value_unit != default_unit: 
     171            data_conv_q = Converter(default_unit) 
     172            value = data_conv_q(value, units=value_unit) 
    171173            new_unit = default_unit 
    172174        else: 
    173175            new_unit = value_unit 
    174176        return value, new_unit 
     177 
     178    def _unit_fetch(self, unit): 
     179        return self.params[unit+"_unit"] 
Note: See TracChangeset for help on using the changeset viewer.