|
16 | 16 | from hexrd.xrd import experiment as expt |
17 | 17 | from hexrd.xrd.transforms import makeDetectorRotMat, unitVector, vInv_ref |
18 | 18 | from hexrd.xrd import transforms_CAPI as xfcapi |
| 19 | +from hexrd.xrd import distortion as dFuncs |
19 | 20 |
|
20 | 21 | from hexrd.xrd.detector import ReadGE |
21 | 22 |
|
22 | | - |
23 | 23 | logger = logging.getLogger('hexrd') |
24 | 24 |
|
25 | 25 |
|
@@ -195,3 +195,55 @@ def initialize_experiment(cfg): |
195 | 195 | detector = None |
196 | 196 |
|
197 | 197 | return pd, reader, detector |
| 198 | + |
| 199 | +def get_instrument_parameters(cfg): |
| 200 | + # TODO: this needs to be |
| 201 | + det_p = cfg.instrument.parameters |
| 202 | + if not os.path.exists(det_p): |
| 203 | + migrate_detector_to_instrument_config( |
| 204 | + np.loadtxt(cfg.instrument.detector.parameters_old), |
| 205 | + cfg.instrument.detector.pixels.rows, |
| 206 | + cfg.instrument.detector.pixels.columns, |
| 207 | + cfg.instrument.detector.pixels.size, |
| 208 | + detID='GE', |
| 209 | + chi=0., |
| 210 | + tVec_s=np.zeros(3), |
| 211 | + filename=cfg.instrument.parameters |
| 212 | + ) |
| 213 | + with open(cfg.instrument.parameters, 'r') as f: |
| 214 | + # only one panel for now |
| 215 | + # TODO: configurize this |
| 216 | + return [cfg for cfg in yaml.load_all(f)][0] |
| 217 | + |
| 218 | + |
| 219 | +def get_detector_parameters(instr_cfg): |
| 220 | + return np.hstack([ |
| 221 | + instr_cfg['detector']['transform']['tilt_angles'], |
| 222 | + instr_cfg['detector']['transform']['t_vec_d'], |
| 223 | + instr_cfg['oscillation_stage']['chi'], |
| 224 | + instr_cfg['oscillation_stage']['t_vec_s'], |
| 225 | + ]) |
| 226 | + |
| 227 | + |
| 228 | +def get_distortion_correction(instrument_cfg): |
| 229 | + # ***FIX*** |
| 230 | + # at this point we know we have a GE and hardwire the distortion func; |
| 231 | + # need to pull name from yml file in general case |
| 232 | + return ( |
| 233 | + dFuncs.GE_41RT, |
| 234 | + instrument_cfg['detector']['distortion']['parameters'] |
| 235 | + ) |
| 236 | + |
| 237 | + |
| 238 | +def get_saturation_level(instr_cfg): |
| 239 | + return instr_cfg['detector']['saturation_level'] |
| 240 | + |
| 241 | + |
| 242 | +def set_planedata_exclusions(cfg, detector, pd): |
| 243 | + tth_max = cfg.fit_grains.tth_max |
| 244 | + if tth_max is True: |
| 245 | + pd.exclusions = np.zeros_like(pd.exclusions, dtype=bool) |
| 246 | + pd.exclusions = pd.getTTh() > detector.getTThMax() |
| 247 | + elif tth_max > 0: |
| 248 | + pd.exclusions = np.zeros_like(pd.exclusions, dtype=bool) |
| 249 | + pd.exclusions = pd.getTTh() >= np.radians(tth_max) |
0 commit comments