Changeset e4e5e29 in sasmodels


Ignore:
Timestamp:
Apr 8, 2017 10:13:19 AM (7 years ago)
Author:
jhbakker
Branches:
costrafo411
Children:
a86e249
Parents:
b2921d0
Message:

include 2D cosine transform in sesans.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sesans.py

    r94d13f1 re4e5e29  
    4545        #import logging; logging.info("creating SESANS transform") 
    4646        self.q = z 
     47        # isoriented flag determines whether data is from an oriented sample or not, should be in the data or selectable in GUI. 
     48        #if self.isoriented==False 
    4749        self._set_hankel(SElength, zaccept, Rmax) 
     50        #if self.isoriented==True 
     51        self._set_cosmat(SElength, zaccept, Rmax) 
    4852 
    4953    def apply(self, Iq): 
    50         # tye: (np.ndarray) -> np.ndarray 
    51         G0 = np.dot(self._H0, Iq) 
    52         G = np.dot(self._H.T, Iq) 
    53         P = G - G0 
     54        if len(Iq.size) == 1: # if isotropic, do Hankel transform 
     55            # type: (np.ndarray) -> np.ndarray 
     56            G0 = np.dot(self._H0, Iq) 
     57            G = np.dot(self._H.T, Iq) 
     58            P = G - G0 
     59        elif len(Iq.size) == 2: 
     60            dq=self.q_calc[0] 
     61            G0 = sum(np.dot(self._cos0, Iq)*dq) 
     62            G = sum(np.dot(self._cosmat.T, Iq)*dq) 
     63            P = G - G0 
    5464        return P 
    5565 
     
    7383        self.q_calc = q 
    7484        self._H, self._H0 = H, H0 
     85 
     86    def _set_cosmat(self, SElength, zaccept, Rmax): 
     87        # type: (np.ndarray, float, float) -> None 
     88        # Force float32 arrays, otherwise run into memory problems on some machines 
     89        SElength = np.asarray(SElength, dtype='float32') 
     90        #qymax and qzmax depend on detector shape 
     91        qzmax= 
     92        # Rmax = #value in text box somewhere in FitPage? 
     93        q_max = 2 * pi / (SElength[1] - SElength[0]) 
     94        q_min = 0.1 * 2 * pi / (np.size(SElength) * SElength[-1]) 
     95 
     96        q = np.arange(q_min, q_max, q_min, dtype='float32') 
     97        dq = q_min 
     98 
     99        cos0 = np.float32(dq / (2 * pi)) 
     100 
     101        repq = np.tile(q, (SElength.size, 1)).T 
     102        repSE = np.tile(SElength, (q.size, 1)) 
     103        cosmat = np.float32(dq / (2 * pi)) * np.cos(repSE * repq) 
     104 
     105        self.q_calc = q 
     106        self._cosmat, self._cos0 = cosmat, cos0 
Note: See TracChangeset for help on using the changeset viewer.