Changeset d03228e in sasview for src/sas/sascalc


Ignore:
Timestamp:
Jul 12, 2016 6:13:24 AM (8 years ago)
Author:
lewis
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:
8bdc103
Parents:
41345d7e
Message:

Add backbone for Hilbert transform

Location:
src/sas/sascalc/corfunc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/corfunc/corfunc_calculator.py

    reb320682 rd03228e  
    1010from numpy.linalg import lstsq 
    1111from sas.sascalc.dataloader.data_info import Data1D 
    12 from sas.sascalc.corfunc.transform_thread import TransformThread 
     12from sas.sascalc.corfunc.transform_thread import FourierThread 
     13from sas.sascalc.corfunc.transform_thread import HilbertThread 
    1314 
    1415class CorfuncCalculator(object): 
     
    122123        return extrapolation 
    123124 
    124     def compute_transform(self, extrapolation, background=None, 
     125    def compute_transform(self, extrapolation, trans_type, background=None, 
    125126        completefn=None, updatefn=None): 
    126127        """ 
     
    141142        if background is None: background = self.background 
    142143 
    143         self._transform_thread = TransformThread(self._data, extrapolation, 
    144         background, completefn=completefn, updatefn=updatefn) 
     144        if trans_type == 'fourier': 
     145            self._transform_thread = FourierThread(self._data, extrapolation, 
     146            background, completefn=completefn, updatefn=updatefn) 
     147        elif trans_type == 'hilbert': 
     148            self._transform_thread = HilbertThread(self._data, extrapolation, 
     149            background, completefn=completefn, updatefn=updatefn) 
     150        else: 
     151            err = ("Incorrect transform type supplied, must be 'fourier'", 
     152                " or 'hilbert'") 
     153            raise ValueError, err 
     154 
    145155        self._transform_thread.queue() 
    146156 
  • src/sas/sascalc/corfunc/transform_thread.py

    ra2db1ab rd03228e  
    55from time import sleep 
    66 
    7 class TransformThread(CalcThread): 
     7class FourierThread(CalcThread): 
    88    def __init__(self, raw_data, extrapolated_data, bg, updatefn=None, 
    99        completefn=None): 
     
    3939 
    4040        self.complete(transform=transform) 
     41 
     42class HilbertThread(CalcThread): 
     43    def __init__(self, raw_data, extrapolated_data, bg, updatefn=None, 
     44        completefn=None): 
     45        CalcThread.__init__(self, updatefn=updatefn, completefn=completefn) 
     46        self.data = raw_data 
     47        self.background = bg 
     48        self.extrapolation = extrapolated_data 
     49 
     50    def compute(self): 
     51        qs = self.extrapolation.x 
     52        iqs = self.extrapolation.y 
     53        q = self.data.x 
     54        background = self.background 
     55 
     56        self.ready(delay=0.0) 
     57        self.update(msg="Starting Hilbert transform.") 
     58        self.ready(delay=0.0) 
     59        if self.isquit(): 
     60            return 
     61 
     62        # TODO: Implement hilbert transform 
     63 
     64        self.update(msg="Hilbert transform completed.") 
     65 
     66        self.complete(transform=None) 
Note: See TracChangeset for help on using the changeset viewer.