Changeset 8a20be5 in sasmodels for sasmodel.py
- Timestamp:
- Jul 10, 2014 3:05:08 PM (10 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodel.py
r5378e40 r8a20be5 3 3 4 4 import numpy as np 5 import pyopencl as cl 5 6 from bumps.names import Parameter 6 7 from sans.dataloader.loader import Loader … … 11 12 loader = Loader() 12 13 data = loader.load(filename) 14 if data is None: 15 raise IOError("Data %r could not be loaded"%filename) 13 16 return data 14 17 … … 47 50 48 51 52 GPU_CONTEXT = None 53 GPU_QUEUE = None 54 def 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 49 62 class SasModel(object): 50 def __init__(self, data, model, **kw):63 def __init__(self, data, model, dtype='float32', **kw): 51 64 self.index = data.mask==0 52 65 self.iq = data.data[self.index] … … 55 68 self.qx = data.qx_data 56 69 self.qy = data.qy_data 57 self.gpu = model(self.qx, self.qy )70 self.gpu = model(self.qx, self.qy, dtype=dtype) 58 71 pd_pars = set(base+attr for base in model.PD_PARS for attr in ('_pd','_pd_n','_pd_nsigma')) 59 72 total_pars = set(model.PARS.keys()) | pd_pars … … 79 92 def theory(self): 80 93 pars = dict((k,v.value) for k,v in self._parameters.items()) 94 print pars 81 95 result = self.gpu.eval(pars) 82 96 return result
Note: See TracChangeset
for help on using the changeset viewer.