104104 [1 , 1 , 1 , 1 , 1 , 1 ],
105105 dtype = bool )
106106
107+ NP_INS = 7
108+ NP_DET = 6
109+ NP_GRN = 12
110+
107111# =============================================================================
108112# UTILITY METHODS
109113# =============================================================================
@@ -368,7 +372,7 @@ def param_flags(self):
368372 @param_flags .setter
369373 def param_flags (self , x ):
370374 x = np .array (x , dtype = bool ).flatten ()
371- assert len (x ) == 7 + 6 * self .num_panels , \
375+ assert len (x ) == NP_INS + NP_DET * self .num_panels , \
372376 "length of parameter list must be %d; you gave %d" \
373377 % (len (self ._param_flags ), len (x ))
374378 self ._param_flags = x
@@ -393,25 +397,21 @@ def calibration_params(self):
393397 """
394398 azim , pola = calc_angles_from_beam_vec (self .beam_vector )
395399
396- ni = 7
397- np = 6
398- ng = 12
399-
400- plist = np .zeros (ni + np * self .num_panels )
400+ plist = np .zeros (NP_INS + NP_DET * self .num_panels )
401401
402- plist [0 ] = self .beam_wavelength
402+ plist [0 ] = self .beam_energy
403403 plist [1 ] = azim
404404 plist [2 ] = pola
405405 plist [3 ] = self .chi
406406 plist [4 ], plist [5 ], plist [6 ] = self .tvec
407407
408- ii = ni
408+ ii = NP_INS
409409 for panel in self .detectors .itervalues ():
410- plist [ii :ii + np ] = np .hstack ([
410+ plist [ii :ii + NP_DET ] = np .hstack ([
411411 panel .tilt .flatten (),
412412 panel .tvec .flatten (),
413413 ])
414- ii += np
414+ ii += NP_DET
415415
416416 # FIXME: FML!!!
417417 # this assumes old style distiortion = (func, params)
@@ -423,36 +423,31 @@ def calibration_params(self):
423423
424424 return plist
425425
426-
427- def update_from_calibration_params (plist ):
426+ def update_from_calibration_params (self , plist ):
428427 """
429428 """
430- ni = 7
431- np = 6
432- ng = 12
433-
434429 # check total length
435- len_plist = ni + np * self .num_panels
430+ min_len_plist = NP_INS + NP_DET * self .num_panels
436431 for panel in self .detectors .itervalues ():
437432 if panel .distortion is not None :
438- len_plist += len (panel .distortion [1 ])
439- if len (plist ) > len_plist :
433+ min_len_plist += len (panel .distortion [1 ])
434+ if len (plist ) < min_len_plist :
440435 # ??? could have grains on here
441436 raise RuntimeError ("input plist is not the correct length" )
442437
443438 # updates
444- self .beam_wavelength = plist [0 ]
439+ self .beam_energy = plist [0 ]
445440 bvec = calc_beam_vec (plist [1 ], plist [2 ])
446441 self .beam_vector = bvec
447442 self .chi = plist [3 ]
448443 self .tvec = plist [4 :7 ]
449444
450- ii = ni
445+ ii = NP_INS
451446 for panel in self .detectors .itervalues ():
452- tilt_n_trans = plist [ii :ii + np ]
447+ tilt_n_trans = plist [ii :ii + NP_DET ]
453448 panel .tilt = tilt_n_trans [:3 ]
454449 panel .tvec = tilt_n_trans [3 :]
455- ii += np
450+ ii += NP_DET
456451
457452 # FIXME: FML!!!
458453 # this assumes old style distiortion = (func, params)
@@ -461,10 +456,9 @@ def update_from_calibration_params(plist):
461456 ldp = len (panel .distortion [1 ])
462457 panel .distortion [1 ] = plist [ii :ii + ldp ]
463458 ii += ldp
464-
459+
465460 return
466461
467-
468462 def write_config (self , filename = None , calibration_dict = {}):
469463 """ WRITE OUT YAML FILE """
470464 # initialize output dictionary
0 commit comments