Changeset 1fac6c0 in sasview


Ignore:
Timestamp:
Oct 10, 2016 4:32:09 PM (8 years ago)
Author:
jhbakker
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:
392056d
Parents:
51a4d78
Message:

SESANS is almost working, but this is NOT a stable version!

Location:
src/sas
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/data_util/qsmearing.py

    rf7bc948 r1fac6c0  
    1313import logging 
    1414import sys 
    15 import sasmodels.sesans 
     15from sasmodels import sesans 
    1616 
    1717from sasmodels.resolution import Slit1D, Pinhole1D, SESANS1D 
     
    5050    # Look for resolution smearing data 
    5151    _found_sesans = False 
    52     if data.dx is not None and data.lam is not None: 
     52    if data.dx is not None and data.meta_data['loader']=='SESANS': 
    5353        if data.dx[0] > 0.0: 
    5454            _found_sesans = True 
     
    101101        self.model = model 
    102102        self.resolution = resolution 
    103         self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     103        if hasattr(self.resolution, 'data'): 
     104            if self.resolution.data.meta_data['loader'] == 'SESANS': 
     105                self.offset = 0 
     106            # This is default behaviour, for future resolution/transform functions this needs to be revisited. 
     107            else: 
     108                self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     109        else: 
     110            self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
     111 
     112        #self.offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 
    104113 
    105114    def apply(self, iq_in, first_bin=0, last_bin=None): 
     
    135144        q[first:last+1]. 
    136145        """ 
     146 
    137147        q = self.resolution.q 
    138148        first = numpy.searchsorted(q, q_min) 
     
    158168    #Here assume a number 
    159169    Rmax = 50000 
    160     q_calc = sesans.make_q(data.sample.z, Rmax) 
     170    q_calc = sesans.make_q(data.sample.zacceptance, Rmax) 
    161171    return PySmear(SESANS1D(data,q_calc),model) 
  • src/sas/sascalc/dataloader/data_info.py

    r51a4d78 r1fac6c0  
    2525import numpy 
    2626import math 
    27  
    2827class plottable_1D(object): 
    2928    """ 
     
    696695    1D data class 
    697696    """ 
    698     if plottable_1D.lam is None: # This means it's SANS data! 
    699         x_unit = '1/A' 
    700         y_unit = '1/cm' 
    701     elif plottable_1D.lam is not None: # This means it's SESANS data! 
    702         x_unit = 'A' 
    703         y_unit = 'pol' 
    704     else: # and if it's neither, you get punished! 
    705         raise(TypeError,'This is neither SANS nor SESANS data, what the hell are you doing??') 
    706  
    707     def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None): 
     697    #if plottable_1D.lam is None: # This means it's SANS data! 
     698     #   x_unit = '1/A' 
     699      #  y_unit = '1/cm' 
     700    #elif plottable_1D.lam is not None: # This means it's SESANS data! 
     701     #   x_unit = 'A' 
     702      #  y_unit = 'pol' 
     703    #else: # and if it's neither, you get punished! 
     704     #   raise(TypeError,'This is neither SANS nor SESANS data, what the hell are you doing??') 
     705 
     706    def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False): 
     707        self.isSesans = isSesans 
    708708        DataInfo.__init__(self) 
    709709        plottable_1D.__init__(self, x, y, dx, dy,None, None, lam, dlam) 
    710         if self.lam is None: # This means the lam param was not detected in the data: it's SANS data! 
     710        if self.isSesans: 
     711            x_unit = 'A' 
     712            y_unit = 'pol' 
     713        elif not self.isSesans: # it's SANS data! (Could also be simple else statement, but i prefer exhaustive conditionals...-JHB) 
    711714            x_unit = '1/A' 
    712715            y_unit = '1/cm' 
    713         elif self.lam is not None: # This means lam was detected (should be an empty ndarray): it's SESANS data! 
    714             x_unit = 'A' 
    715             y_unit = 'pol' 
    716716        else: # and if it's neither, you get punished! 
    717717            raise(TypeError,'This is neither SANS nor SESANS data, what the hell are you doing??') 
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    r1b82623 r1fac6c0  
    8484                tdx = numpy.zeros(0) 
    8585#                print "all good" 
    86                 output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam) 
     86                output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, isSesans=True ) 
    8787#                print output                 
    8888                self.filename = output.filename = basename 
     
    121121                        paramvals.append(toks[1]) 
    122122                    if len(toks)>5: 
     123                       #zvals.append(toks[0]) 
     124                        #dzvals.append(toks[1]) 
     125                        #lamvals.append(toks[2]) 
     126                        #dlamvals.append(toks[3]) 
     127                        #Pvals.append(toks[4]) 
     128                        #dPvals.append(toks[5]) 
     129 
    123130                        zvals.append(toks[0]) 
    124                         dzvals.append(toks[1]) 
    125                         lamvals.append(toks[2]) 
    126                         dlamvals.append(toks[3]) 
    127                         Pvals.append(toks[4]) 
    128                         dPvals.append(toks[5]) 
     131                        dzvals.append(toks[3]) 
     132                        lamvals.append(toks[4]) 
     133                        dlamvals.append(toks[5]) 
     134                        Pvals.append(toks[1]) 
     135                        dPvals.append(toks[2]) 
    129136                    else: 
    130137                        continue 
     
    140147                default_z_unit = "A" 
    141148                data_conv_P = None 
    142                 default_p_unit = " " 
     149                default_p_unit = " " # Adjust unit for axis (L^-3) 
    143150                lam_unit = lam_header[1].replace("[","").replace("]","") 
     151                if lam_unit == 'AA': 
     152                    lam_unit = 'A' 
    144153                varheader=[zvals[0],dzvals[0],lamvals[0],dlamvals[0],Pvals[0],dPvals[0]] 
    145154                valrange=range(1, len(zvals)) 
     
    161170                output.x, output.x_unit = self._unit_conversion(x, lam_unit, default_z_unit) 
    162171                output.y = y 
     172                output.y_unit = 'pol' # output y_unit erbij 
    163173                output.dx, output.dx_unit = self._unit_conversion(dx, lam_unit, default_z_unit) 
    164174                output.dy = dy 
     
    166176                output.dlam, output.dlam_unit = self._unit_conversion(dlam, lam_unit, default_z_unit) 
    167177 
    168                 output.xaxis("\rm{z}", output.x_unit) 
    169                 output.yaxis("\\rm{P/P0}", output.y_unit) 
     178                output.xaxis("\\rm{z}", output.x_unit) 
     179                output.yaxis("\\rm{P/P0}", output.y_unit) # Adjust label to ln P/(lam^2 t), remove lam column refs 
    170180                # Store loading process information 
    171181                output.meta_data['loader'] = self.type_name 
    172                 output.sample.thickness = float(paramvals[6]) 
     182                #output.sample.thickness = float(paramvals[6]) 
    173183                output.sample.name = paramvals[1] 
    174184                output.sample.ID = paramvals[0] 
    175185                zaccept_unit_split = paramnames[7].split("[") 
    176186                zaccept_unit = zaccept_unit_split[1].replace("]","") 
    177                 if zaccept_unit.strip() == '\AA^-1': 
     187                if zaccept_unit.strip() == '\AA^-1' or zaccept_unit.strip() == '\A^-1': 
    178188                    zaccept_unit = "1/A" 
    179189                output.sample.zacceptance=(float(paramvals[7]),zaccept_unit) 
  • src/sas/sasgui/guiframe/dataFitting.py

    r51a4d78 r1fac6c0  
    1717    """ 
    1818    """ 
    19     def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None): 
     19    def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False): 
    2020        """ 
    2121        """ 
     
    2424        if y is None: 
    2525            y = [] 
    26         PlotData1D.__init__(self, x, y, lam, dx, dy, dlam) 
    27         LoadData1D.__init__(self, x, y, lam, dx, dy, dlam) 
     26        self.isSesans = isSesans 
     27        PlotData1D.__init__(self, x, y, dx, dy, lam, dlam) 
     28        LoadData1D.__init__(self, x, y, dx, dy, lam, dlam, isSesans) 
    2829        self.id = None 
    2930        self.list_group_id = [] 
  • src/sas/sasgui/guiframe/data_manager.py

    rd85c194 r1fac6c0  
    6262        if issubclass(Data2D, data.__class__): 
    6363            new_plot = Data2D(image=None, err_image=None)  
    64         else:  
    65             new_plot = Data1D(x=[], y=[], dx=None, dy=None) 
     64        elif data.meta_data['loader'] == 'SESANS': 
     65            new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None, isSesans=True) 
     66        else: 
     67            new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None) #SESANS check??? 
    6668            
    6769        new_plot.copy_from_datainfo(data) 
  • src/sas/sasgui/plottools/plottables.py

    r7988501 r1fac6c0  
    10221022    """ 
    10231023 
    1024     def __init__(self, x, y, lam=None, dx=None, dy=None, dlam=None): 
     1024    def __init__(self, x, y, dx=None, dy=None, lam=None, dlam=None): 
    10251025        """ 
    10261026        Draw points specified by x[i],y[i] in the current color/symbol. 
Note: See TracChangeset for help on using the changeset viewer.