Changeset 8a20be5 in sasmodels for sasmodel.py


Ignore:
Timestamp:
Jul 10, 2014 3:05:08 PM (10 years ago)
Author:
HMP1 <helen.park@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
8faffcd
Parents:
5378e40
Message:

Added a fit2 (fits two different models at different angles)
(preliminary) Added CoreshellCyl? and CapCyl? Kernels
(preliminary) Updated kernels to include functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodel.py

    r5378e40 r8a20be5  
    33 
    44import numpy as np 
     5import pyopencl as cl 
    56from bumps.names import Parameter 
    67from sans.dataloader.loader import Loader 
     
    1112    loader = Loader() 
    1213    data = loader.load(filename) 
     14    if data is None: 
     15        raise IOError("Data %r could not be loaded"%filename) 
    1316    return data 
    1417 
     
    4750 
    4851 
     52GPU_CONTEXT = None 
     53GPU_QUEUE = None 
     54def card(): 
     55    global GPU_CONTEXT, GPU_QUEUE 
     56    if GPU_CONTEXT is None: 
     57        GPU_CONTEXT = cl.create_some_context() 
     58        GPU_QUEUE = cl.CommandQueue(GPU_CONTEXT) 
     59    return GPU_CONTEXT, GPU_QUEUE 
     60 
     61 
    4962class SasModel(object): 
    50     def __init__(self, data, model, **kw): 
     63    def __init__(self, data, model, dtype='float32', **kw): 
    5164        self.index = data.mask==0 
    5265        self.iq = data.data[self.index] 
     
    5568        self.qx = data.qx_data 
    5669        self.qy = data.qy_data 
    57         self.gpu = model(self.qx, self.qy) 
     70        self.gpu = model(self.qx, self.qy, dtype=dtype) 
    5871        pd_pars = set(base+attr for base in model.PD_PARS for attr in ('_pd','_pd_n','_pd_nsigma')) 
    5972        total_pars = set(model.PARS.keys()) | pd_pars 
     
    7992    def theory(self): 
    8093        pars = dict((k,v.value) for k,v in self._parameters.items()) 
     94        print pars 
    8195        result = self.gpu.eval(pars) 
    8296        return result 
Note: See TracChangeset for help on using the changeset viewer.