Changes in / [dd4f5ed:ca04add] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sasview_model.py

    r9644b5a rbcdd6c9  
    169169    return make_model_from_info(model_info) 
    170170 
    171  
     171     
    172172def _register_old_models(): 
    173173    # type: () -> None 
     
    597597                            % type(qdist)) 
    598598 
    599     def calc_composition_models(self, qx): 
    600         """ 
    601         returns parts of the composition model or None if not a composition 
    602         model. 
    603         """ 
    604         # TODO: have calculate_Iq return the intermediates. 
    605         # 
    606         # The current interface causes calculate_Iq() to be called twice, 
    607         # once to get the combined result and again to get the intermediate 
    608         # results.  This is necessary for now. 
    609         # Long term, the solution is to change the interface to calculate_Iq 
    610         # so that it returns a results object containing all the bits: 
    611         #     the A, B, C, ... of the composition model (and any subcomponents?) 
    612         #     the P and S of the product model, 
    613         #     the combined model before resolution smearing, 
    614         #     the sasmodel before sesans conversion, 
    615         #     the oriented 2D model used to fit oriented usans data, 
    616         #     the final I(q), 
    617         #     ... 
    618         # 
    619         # Have the model calculator add all of these blindly to the data 
    620         # tree, and update the graphs which contain them.  The fitter 
    621         # needs to be updated to use the I(q) value only, ignoring the rest. 
    622         # 
    623         # The simple fix of returning the existing intermediate results 
    624         # will not work for a couple of reasons: (1) another thread may 
    625         # sneak in to compute its own results before calc_composition_models 
    626         # is called, and (2) calculate_Iq is currently called three times: 
    627         # once with q, once with q values before qmin and once with q values 
    628         # after q max.  Both of these should be addressed before 
    629         # replacing this code. 
    630         composition = self._model_info.composition 
    631         if composition and composition[0] == 'product': # only P*S for now 
    632             with calculation_lock: 
    633                 self._calculate_Iq(qx) 
    634                 return self._intermediate_results 
    635         else: 
    636             return None 
     599    def get_composition_models(self): 
     600        """ 
     601            Returns usable models that compose this model 
     602        """ 
     603        s_model = None 
     604        p_model = None 
     605        if hasattr(self._model_info, "composition") \ 
     606           and self._model_info.composition is not None: 
     607            p_model = make_model_from_info(self._model_info.composition[1][0])() 
     608            s_model = make_model_from_info(self._model_info.composition[1][1])() 
     609        return p_model, s_model 
    637610 
    638611    def calculate_Iq(self, qx, qy=None): 
     
    675648        result = calculator(call_details, values, cutoff=self.cutoff, 
    676649                            magnetic=is_magnetic) 
    677         self._intermediate_results = getattr(calculator, 'results', None) 
    678650        calculator.release() 
    679651        self._model.release() 
Note: See TracChangeset for help on using the changeset viewer.