def sum_score_detail(self,reciprocal_space_vectors): """Evaluates the probability that the trial value of ( S0_vector | origin_offset ) is correct, given the current estimate and the observations. The trial value comes through the reciprocal space vectors, and the current estimate comes through the short list of DPS solutions. Actual return value is a sum of NH terms, one for each DPS solution, each ranging from -1.0 to 1.0""" nh = min ( self.getSolutions().size(), 20) # extended API solutions = self.getSolutions() #extended API sum_score = 0.0 for t in xrange(nh): #if t!=unique:continue dfft = Directional_FFT(angle = solutions[t], xyzdata = reciprocal_space_vectors, granularity = self.granularity, amax = self.amax, # extended API F0_cutoff = 11) kval = dfft.kval(); kmax = dfft.kmax(); kval_cutoff = self.raw_spot_input.size()/4.0; # deprecate record if ( kval > kval_cutoff ): ff=dfft.fft_result; kbeam = ((-dfft.pmin)/dfft.delta_p) + 0.5; Tkmax = cmath.phase(ff[kmax]); backmax = math.cos(Tkmax+(2*math.pi*kmax*kbeam/(2*ff.size()-1)) ); ### Here it should be possible to calculate a gradient. ### Then minimize with respect to two coordinates. Use lbfgs? Have second derivatives? ### can I do something local to model the cosine wave? ### direction of wave travel. Period. phase. sum_score += backmax; #if t == unique: # print t, kmax, dfft.pmin, dfft.delta_p, Tkmax,(2*math.pi*kmax*kbeam/(2*ff.size()-1)) return sum_score
def sum_score_detail(self,reciprocal_space_vectors): """Evaluates the probability that the trial value of ( S0_vector | origin_offset ) is correct, given the current estimate and the observations. The trial value comes through the reciprocal space vectors, and the current estimate comes through the short list of DPS solutions. Actual return value is a sum of NH terms, one for each DPS solution, each ranging from -1.0 to 1.0""" nh = min ( self.getSolutions().size(), 20) # extended API solutions = self.getSolutions() #extended API sum_score = 0.0 for t in range(nh): #if t!=unique:continue dfft = Directional_FFT(angle = solutions[t], xyzdata = reciprocal_space_vectors, granularity = self.granularity, amax = self.amax, # extended API F0_cutoff = 11) kval = dfft.kval(); kmax = dfft.kmax(); kval_cutoff = self.raw_spot_input.size()/4.0; # deprecate record if ( kval > kval_cutoff ): ff=dfft.fft_result; kbeam = ((-dfft.pmin)/dfft.delta_p) + 0.5; Tkmax = cmath.phase(ff[kmax]); backmax = math.cos(Tkmax+(2*math.pi*kmax*kbeam/(2*ff.size()-1)) ); ### Here it should be possible to calculate a gradient. ### Then minimize with respect to two coordinates. Use lbfgs? Have second derivatives? ### can I do something local to model the cosine wave? ### direction of wave travel. Period. phase. sum_score += backmax; #if t == unique: # print t, kmax, dfft.pmin, dfft.delta_p, Tkmax,(2*math.pi*kmax*kbeam/(2*ff.size()-1)) return sum_score
def _sum_score_detail(reciprocal_space_vectors, solutions, granularity=None, amax=None): """Evaluates the probability that the trial value of (S0_vector | origin_offset) is correct, given the current estimate and the observations. The trial value comes through the reciprocal space vectors, and the current estimate comes through the short list of DPS solutions. Actual return value is a sum of NH terms, one for each DPS solution, each ranging from -1.0 to 1.0""" nh = min(solutions.size(), 20) # extended API sum_score = 0.0 for t in range(nh): dfft = Directional_FFT( angle=Direction(solutions[t]), xyzdata=reciprocal_space_vectors, granularity=5.0, amax=amax, # extended API XXX These values have to come from somewhere! F0_cutoff=11, ) kval = dfft.kval() kmax = dfft.kmax() kval_cutoff = reciprocal_space_vectors.size() / 4.0 if kval > kval_cutoff: ff = dfft.fft_result kbeam = ((-dfft.pmin) / dfft.delta_p) + 0.5 Tkmax = cmath.phase(ff[kmax]) backmax = math.cos( Tkmax + (2 * math.pi * kmax * kbeam / (2 * ff.size() - 1)) ) ### Here it should be possible to calculate a gradient. ### Then minimize with respect to two coordinates. Use lbfgs? Have second derivatives? ### can I do something local to model the cosine wave? ### direction of wave travel. Period. phase. sum_score += backmax return sum_score