Skip to content

Commit 888daa3

Browse files
author
Joel Bernier
committed
merge of jvb master onto imageseries, with important bugfixes
2 parents 7bd2e24 + 3a3efd4 commit 888daa3

36 files changed

+2626
-1038
lines changed

conda.recipe/meta.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package:
44
version: {{ environ.get('GIT_DESCRIBE_TAG', '')[1:] }}
55

66
source:
7-
git_url: ../
7+
git_url: https://github.com/joelvbernier/hexrd.git
88
git_tag: master # edit to point to specific branch or tag
99

1010
build:
@@ -20,21 +20,21 @@ app:
2020

2121
requirements:
2222
build:
23-
- numpy ==1.9.3
23+
- numpy
2424
- python
2525
- setuptools
2626
run:
2727
- h5py
2828
- dill
2929
- matplotlib
3030
- numba
31-
- numpy ==1.9.3
31+
- numpy
3232
- progressbar >=2.3
3333
- python
3434
- python.app # [osx]
3535
- pyyaml
3636
- qtconsole
37-
- scikit-learn ==0.15.2
37+
- scikit-learn
3838
- scipy
3939
- wxpython
4040

hexrd/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ def _readenv(name, ctor, default):
7272
del _readenv
7373

7474

75-
doc_url = 'latest' if 'dev' in __version__ else 'v%s' % __version__
75+
#doc_url = 'latest' if 'dev' in __version__ else 'v%s' % __version__
76+
doc_url = 'latest'
7677
doc_url = 'http://hexrd.readthedocs.org/en/%s' % doc_url
7778

7879

hexrd/cli/findorientations.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,17 @@ def execute(args, parser):
7979
# load the configuration settings
8080
cfg = config.open(args.yml)[0]
8181

82+
# ...make this an attribute in cfg?
83+
analysis_id = '%s_%s' %(
84+
cfg.analysis_name.strip().replace(' ', '-'),
85+
cfg.material.active.strip().replace(' ', '-'),
86+
)
87+
8288
# prepare the analysis directory
83-
quats_f = os.path.join(cfg.working_dir, 'accepted_orientations.dat')
89+
quats_f = os.path.join(
90+
cfg.working_dir,
91+
'accepted_orientations_%s.dat' %analysis_id
92+
)
8493
if os.path.exists(quats_f) and not (args.force or args.clean):
8594
logger.error(
8695
'%s already exists. Change yml file or specify "force" or "clean"', quats_f

hexrd/config/findorientations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ClusteringConfig(Config):
6969
@property
7070
def algorithm(self):
7171
key = 'find_orientations:clustering:algorithm'
72-
choices = ['dbscan', 'fclusterdata']
72+
choices = ['dbscan', 'ort-dbscan', 'sph-dbscan', 'fclusterdata']
7373
temp = self._cfg.get(key, 'dbscan').lower()
7474
if temp in choices:
7575
return temp
@@ -164,9 +164,9 @@ def hkl_seeds(self):
164164
try:
165165
temp = self._cfg.get(key)
166166
if isinstance(temp, int):
167-
temp = [temp]
167+
temp = [temp,]
168168
return temp
169-
except KeyError:
169+
except:
170170
if self._cfg.find_orientations.use_quaternion_grid is None:
171171
raise RuntimeError(
172172
'"%s" must be defined for seeded search' % key

hexrd/config/fitgrains.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ def refit(self):
9595
return temp
9696

9797

98+
"""
99+
PROBABLY JUST SCRAP THIS...s
100+
"""
101+
@property
102+
def skip_on_estimate(self):
103+
key = 'fit_grains:skip_on_estimate'
104+
temp = self._cfg.get(key, False)
105+
if temp in (True, False):
106+
return temp
107+
raise RuntimeError(
108+
'"%s" must be true or false, got "%s"' % (key, temp)
109+
)
110+
111+
98112
@property
99113
def fit_only(self):
100114
key = 'fit_grains:fit_only'

hexrd/config/tests/test_find_orientations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
mask: 10
2929
tolerance: 2
3030
clustering:
31-
algorithm: dbscan
31+
algorithm: sph-dbscan
3232
completeness: 0.35
3333
radius: 1
3434
---
@@ -128,7 +128,7 @@ def test_algorithm(self):
128128
)
129129
self.assertEqual(
130130
self.cfgs[1].find_orientations.clustering.algorithm,
131-
'dbscan'
131+
'sph-dbscan'
132132
)
133133
self.assertEqual(
134134
self.cfgs[2].find_orientations.clustering.algorithm,

hexrd/constants.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,44 @@
3030
from scipy import constants as sc
3131

3232
# pi related
33-
pi = np.pi
33+
pi = np.pi
3434
piby2 = 0.5 * pi
3535
piby3 = pi / 3.
3636
piby4 = 0.25 * pi
3737
piby6 = pi / 6.
3838

3939
# misc radicals
40-
sq2 = np.sqrt(2.)
41-
sq3 = np.sqrt(3.)
42-
sq3by2 = 0.5 * sq3
40+
sqrt2 = np.sqrt(2.)
41+
sqrt3 = np.sqrt(3.)
42+
sqrt3by2 = 0.5 * sqrt3
4343

4444
# tolerancing
45-
epsf = np.finfo(float).eps # ~2.2e-16
46-
ten_epsf = 10 * epsf # ~2.2e-15
47-
sqrt_epsf = np.sqrt(epsf) # ~1.5e-8
45+
epsf = np.finfo(float).eps # ~2.2e-16
46+
ten_epsf = 10 * epsf # ~2.2e-15
47+
sqrt_epsf = np.sqrt(epsf) # ~1.5e-8
4848

4949
# for angles
50-
periodDict = {'degrees': 360.0, 'radians': 2*pi}
51-
angularUnits = 'radians' # module-level angle units
52-
d2r = deg2rad = pi / 180.
53-
r2d = rad2deg = 180. / pi
50+
period_dict = {'degrees': 360.0, 'radians': 2*pi}
51+
angular_units = 'radians' # module-level angle units
52+
d2r = pi / 180.
53+
r2d = 180. / pi
54+
55+
# identity arrays
56+
identity_3x3 = np.eye(3) # (3, 3) identity
57+
identity_6x1 = np.r_[1., 1., 1., 0., 0., 0.]
5458

5559
# basis vectors
56-
I3 = np.eye(3) # (3, 3) identity
57-
X = np.array(I3[:, 0].reshape(3, 1), order='C') # X in the lab frame
58-
Y = np.array(I3[:, 1].reshape(3, 1), order='C') # Y in the lab frame
59-
Z = np.array(I3[:, 2].reshape(3, 1), order='C') # Z in the lab frame
60+
lab_x = np.r_[1., 0., 0.] # X in the lab frame
61+
lab_y = np.r_[0., 1., 0.] # Y in the lab frame
62+
lab_z = np.r_[0., 0., 1.] # Z in the lab frame
6063

64+
zeros_3 = np.zeros(3)
6165
zeros_3x1 = np.zeros((3, 1))
6266
zeros_6x1 = np.zeros((6, 1))
6367

6468
# reference beam direction and eta=0 ref in LAB FRAME for standard geometry
65-
bVec = -Z
66-
eVec = X
67-
68-
# for strain
69-
vInv = np.array(np.r_[1., 1., 1., 0., 0., 0.].reshape(6, 1), order='C')
69+
beam_vec = -lab_z
70+
eta_vec = lab_x
7071

7172
# for energy/wavelength conversions
72-
keVToAngstrom = lambda x: (1e7*sc.c*sc.h/sc.e) / x
73+
keVToAngstrom = lambda x: (1e7*sc.c*sc.h/sc.e) / float(x)

hexrd/coreutil.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
from hexrd.xrd import experiment as expt
1717
from hexrd.xrd.transforms import makeDetectorRotMat, unitVector, vInv_ref
1818
from hexrd.xrd import transforms_CAPI as xfcapi
19+
from hexrd.xrd import distortion as dFuncs
1920

2021
from hexrd.xrd.detector import ReadGE
2122

22-
2323
logger = logging.getLogger('hexrd')
2424

2525

@@ -195,3 +195,55 @@ def initialize_experiment(cfg):
195195
detector = None
196196

197197
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

Comments
 (0)