Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ixstools
xrstools
Commits
a01cf976
Commit
a01cf976
authored
Dec 01, 2020
by
myron
Browse files
Merge branch 'alessandro_develop' into cdi
parents
522702f5
00233a02
Changes
44
Expand all
Show whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
a01cf976
...
...
@@ -6,7 +6,8 @@ variables:
PROJECT_NAME
:
"
xrstools"
LOCAL_REPO
:
"
/dev/shm/gitlab_ci/xrstools"
VENV_DIR
:
/dev/shm/gitlab_ci/xrstools/venv
USE_CLEAN_VENV
:
"
true"
USE_CLEAN_VENV
:
"
false"
CLEAN_RESULTS
:
"
true"
test
:
stage
:
test
...
...
@@ -32,11 +33,13 @@ test:
script
:
-
pwd
-
cd nonregressions/xes
-
-
/usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python xes_analysis.py > output
-
/usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python xes_analysis.py >
|
output
-
cd ../xrs_raman
-
/usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python non_reg_testing_XRS.py > output1
-
/usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python non_reg_testing_XRS_small.py > output2
-
/usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python non_reg_testing_XRS_raman_extraction.py > output3
-
/usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python non_reg_testing_XRS.py >| output1
-
/usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python non_reg_testing_XRS_small.py >| output2
-
/usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python non_reg_testing_XRS_raman_extraction.py >| output3
-
cd ../volumes/test1
-
/usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a python test.py >| output
-
deactivate
after_script
:
-
pwd
...
...
XRStools/XRS_swissknife.py
View file @
a01cf976
This diff is collapsed.
Click to expand it.
XRStools/reponse_percussionelle.py
View file @
a01cf976
...
...
@@ -1433,7 +1433,9 @@ def DOROIS(filename = "../nonregressions/demo_imaging.hdf5" , groupname = "ROI_B
for
i
in
range
(
len
(
newspots
)):
newspots
[
i
]
=
newspots
[
i
]
/
newspots
[
i
].
sum
()
spot_sum
=
newspots
[
i
].
sum
()
if
spot_sum
:
newspots
[
i
]
=
newspots
[
i
]
/
spot_sum
h5
[
"matrix"
]
=
newspots
...
...
XRStools/roifinder_and_gui.py
View file @
a01cf976
This diff is collapsed.
Click to expand it.
XRStools/xrs_calctools.py
View file @
a01cf976
...
...
@@ -567,6 +567,24 @@ class xyzAtom:
norm
=
np
.
trapz
(
self
.
spectrum
[
inds
,
1
],
self
.
spectrum
[
inds
,
0
])
self
.
spectrum
[:,
1
]
/=
norm
def
getDist
(
self
,
atom
):
return
np
.
linalg
.
norm
(
self
.
coordinates
-
atom
.
coordinates
)
def
getDistPBCarb
(
self
,
atom
,
lattice
,
lattice_inv
):
return
getDistancePBC_arb
(
self
,
atom
,
lattice
,
lattice_inv
)
def
getAnglePBCarb
(
self
,
atom2
,
atom3
,
lattice
,
lattice_inv
,
degrees
=
True
):
""" **get_angle**
Return angle between the three given atoms (as seen from atom2).
"""
vec1
=
getDistVectorPBC_arb
(
atom2
,
self
,
lattice
,
lattice_inv
)
vec2
=
getDistVectorPBC_arb
(
atom3
,
self
,
lattice
,
lattice_inv
)
dotp
=
np
.
dot
(
vec1
/
np
.
linalg
.
norm
(
vec1
),
vec2
/
np
.
linalg
.
norm
(
vec2
))
if
degrees
:
return
np
.
degrees
(
np
.
arccos
(
np
.
clip
(
dotp
,
-
1.0
,
1.0
)
)
)
else
:
return
np
.
arccos
(
np
.
clip
(
dotp
,
-
1.0
,
1.0
)
)
class
xyzMolecule
:
""" **xyzMolecule**
...
...
XRStools/xrs_read.py
View file @
a01cf976
...
...
@@ -434,7 +434,7 @@ class Hydra:
print
(
"Integrating pixelwise "
+
scan
)
self
.
scans
[
scan
].
apply_rois_pw
(
self
.
roi_obj
)
def
SumDirect
(
self
,
scan_numbers
):
def
SumDirect
(
self
,
scan_numbers
,
index
=
None
):
""" **SumDirect**
Creates a summed 2D image of a given scan or list of scans.
...
...
@@ -463,9 +463,18 @@ class Hydra:
en_column
=
en_column
,
moni_column
=
self
.
moni_column
)
if
im_sum
is
None
:
im_sum
=
np
.
zeros
(
scan
.
edfmats
[
0
].
shape
,
"f"
)
im_sum
[:]
+=
scan
.
edfmats
.
sum
(
axis
=
0
)
return
im_sum
im_sum1
=
np
.
zeros
(
scan
.
edfmats
[
0
].
shape
,
"f"
)
im_sum2
=
np
.
zeros
(
scan
.
edfmats
[
0
].
shape
,
"f"
)
if
not
index
:
im_sum1
[:]
+=
scan
.
edfmats
.
sum
(
axis
=
0
)
else
:
im_sum1
[:]
+=
scan
.
edfmats
[
0
:
index
,:,:].
sum
(
axis
=
0
)
im_sum2
[:]
+=
scan
.
edfmats
[
index
:,:,:].
sum
(
axis
=
0
)
if
not
index
:
return
im_sum1
else
:
return
im_sum2
-
im_sum1
def
get_eloss_new
(
self
,
method
=
'sum'
):
""" **get_eloss_new**
...
...
@@ -528,8 +537,8 @@ class Hydra:
# master eloss scale in eV is the one of central pixel in first ROI
self
.
signals
=
np
.
zeros
((
len
(
self
.
energy
),
len
(
self
.
cenom_dict
)))
self
.
errors
=
np
.
zeros
((
len
(
self
.
energy
),
len
(
self
.
cenom_dict
)))
master_eloss
=
(
self
.
energy
-
np
.
median
([
np
.
median
(
self
.
cenom_dict
[
key
])
for
key
in
self
.
cenom_dict
])
)
*
1.0e3
self
.
E0
=
np
.
mean
(
self
.
cenom_dict
[
first_key
][
self
.
cenom_dict
[
first_key
]
>
0.0
])
master_eloss
=
(
self
.
energy
-
np
.
median
(
self
.
cenom_dict
[
first_key
][
self
.
cenom_dict
[
first_key
]
>
0.0
])
)
*
1.0e3
self
.
E0
=
np
.
me
di
an
(
self
.
cenom_dict
[
first_key
][
self
.
cenom_dict
[
first_key
]
>
0.0
])
for
key
,
ii
in
zip
(
sorted
(
self
.
cenom_dict
),
range
(
len
(
self
.
cenom_dict
))):
print
(
'Pixel-by-pixel compensation for '
+
key
+
'.'
)
signal
=
np
.
zeros
(
len
(
master_eloss
))
...
...
@@ -539,6 +548,7 @@ class Hydra:
x
=
(
self
.
energy
-
self
.
cenom_dict
[
key
][
dim1
,
dim2
]
)
*
1.0e3
# signals
y
=
self
.
raw_signals
[
key
][:,
dim1
,
dim2
]
if
np
.
any
(
y
)
>
0.0
:
#print "Y AMAX", signal.max()
#rbfi = Rbf( x, y, function='linear' )
rbfi
=
interp1d
(
x
,
y
,
bounds_error
=
False
,
fill_value
=
0.0
)
...
...
@@ -2154,7 +2164,7 @@ class read_id20:
self
.
scans
=
{}
# was a dictionary before
if
absfilename
is
not
None
:
if
not
os
.
path
.
isfile
(
absfilename
):
raise
Exception
(
'IOError! No such file, please check filename.'
)
raise
Exception
(
'IOError! No such file
%s
, please check filename.'
%
absfilename
)
self
.
path
=
os
.
path
.
split
(
absfilename
)[
0
]
+
'/'
self
.
filename
=
os
.
path
.
split
(
absfilename
)[
1
]
if
not
edfName
:
...
...
XRStools/xrs_rois.py
View file @
a01cf976
...
...
@@ -44,6 +44,7 @@ import copy
import
h5py
import
os
import
matplotlib.pyplot
as
plt
from
collections
import
Iterable
# commented the *import because otherwise sphinx documents all the symbol of other packages
# from xrs_utilities import *
...
...
@@ -168,32 +169,82 @@ class roi_object:
"""
Container class to hold all relevant information about given ROIs.
"""
def
__init__
(
self
):
self
.
roi_matrix
=
np
.
array
([])
# single matrix of zeros, ones, twos, ... , n's (where n is the number of ROIs defined)
self
.
red_rois
=
{}
# dictionary, one entry for each ROI, each ROI has an origin and a rectangular box of ones and zeros defining the ROI
self
.
indices
=
[]
# list of list of tuples (one list of tuples for each ROI)
def
__init__
(
self
):
self
.
roi_matrix
=
np
.
array
([])
# single matrix of zeros, ones, twos, ... ,
# n's (where n is the number of ROIs defined)
self
.
red_rois
=
{}
# dictionary, one entry for each ROI, each ROI
# has an origin and a rectangular box of ones
# and zeros defining the ROI
self
.
indices
=
[]
# list of list of tuples (one list of tuples
# for each ROI)
self
.
number_of_rois
=
0
# number of ROIs defined
self
.
kind
=
[]
# keyword (e.g. 'zoom', 'line', 'auto', etc.), certain features (esp. in imaging) are only available for certain kinds of ROIs
self
.
kind
=
[]
# keyword (e.g. 'zoom', 'line', 'auto', etc.),
# certain features (esp. in imaging) are only
# available for certain kinds of ROIs
self
.
x_indices
=
[]
# list of numpy arrays of x-indices (for each ROI)
self
.
y_indices
=
[]
# list of numpy arrays of y-indices (for each ROI)
self
.
masks
=
[]
# 3D numpy array with slices of zeros and ones (same size as detector image) for each roi
self
.
masks
=
[]
# 3D numpy array with slices of zeros and ones (same
# size as detector image) for each roi
self
.
input_image
=
[]
# 2D imput image that was used to define the ROIs
def
load_rois_fromMasksDict
(
self
,
masksDict
,
newshape
=
None
,
kind
=
"zoom"
):
def
__add__
(
self
,
roi_obj
):
""" **__add__**
Allows appending two ROI objects by using the + operator.
"""
assert
(
type
(
roi_obj
)
==
type
(
self
)
)
# create a new instance
new_obj
=
roi_object
()
# copy the ROIs
new_obj
.
red_rois
=
copy
.
deepcopy
(
self
.
red_rois
)
# append the other ROIs
self_len
=
len
(
new_obj
.
red_rois
)
for
ii
,
key
in
enumerate
(
sorted
(
roi_obj
.
red_rois
)
):
new_key
=
'ROI%02d'
%
(
ii
+
self_len
)
if
not
new_key
in
list
(
new_obj
.
red_rois
.
keys
()
):
new_obj
.
red_rois
[
new_key
]
=
roi_obj
.
red_rois
[
key
]
new_obj
.
red_rois
[
new_key
][
1
][
new_obj
.
red_rois
[
new_key
][
1
]
>
0
]
+=
self_len
else
:
'something fishy happened, skipping %s.'
%
(
key
)
return
self
# add the input images
new_obj
.
input_image
=
self
.
input_image
+
roi_obj
.
input_image
# convert summed ROIs to other ROI formats
new_obj
.
roi_matrix
=
convert_redmatrix_to_matrix
(
new_obj
.
red_rois
,
np
.
zeros_like
(
new_obj
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
new_obj
.
masks
=
convert_roi_matrix_to_masks
(
new_obj
.
roi_matrix
)
new_obj
.
indices
=
convert_matrix_rois_to_inds
(
new_obj
.
roi_matrix
)
new_obj
.
number_of_rois
=
int
(
np
.
amax
(
new_obj
.
roi_matrix
)
)
new_obj
.
x_indices
=
convert_inds_to_xinds
(
new_obj
.
indices
)
new_obj
.
y_indices
=
convert_inds_to_yinds
(
new_obj
.
indices
)
return
new_obj
def
load_rois_fromMasksDict
(
self
,
masksDict
,
newshape
=
None
,
kind
=
"zoom"
):
""" **load_rois_fromMasksDict**
"""
self
.
kind
=
kind
self
.
red_rois
=
masksDict
if
newshape
is
not
None
:
self
.
roi_matrix
=
np
.
zeros
(
newshape
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
masksDict
,
self
.
roi_matrix
,
offsetX
=
0
,
offsetY
=
0
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
masksDict
,
self
.
roi_matrix
,
offsetX
=
0
,
offsetY
=
0
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
))
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
def
writeH5
(
self
,
fname
):
def
writeH5
(
self
,
fname
):
""" **writeH5**
Creates an HDF5 file and writes the ROIs into it.
Args:
...
...
@@ -215,6 +266,7 @@ class roi_object:
def
loadH5
(
self
,
fname
):
""" **loadH5**
Loads ROIs from an HDF5 file written by the self.writeH5() method.
Args:
...
...
@@ -237,42 +289,65 @@ class roi_object:
self
.
load_rois_fromMasksDict
(
self
.
red_rois
,
newshape
=
shape
,
kind
=
"zoom"
)
else
:
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
))
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
def
load_shadok_h5
(
self
,
fname
,
group_name1
,
group_name2
=
'ROI_AS_SELECTED'
):
def
load_shadok_h5
(
self
,
fname
,
group_name1
,
group_name2
=
'ROI_AS_SELECTED'
):
""" **load_shadok_h5**
Load ROIs from a HDF5-file created by the Shadok/XRS_Swissknife.
"""
f
=
h5py
.
File
(
fname
,
"r"
)
self
.
input_image
=
f
[
group_name1
][
group_name2
][
"rois_definition"
][
"image"
][:]
self
.
red_rois
=
{}
load_rois_fromh5
(
f
[
group_name1
][
group_name2
],
self
.
red_rois
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
))
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
def
append
(
self
,
roi_object
):
orig_length
=
len
(
self
.
red_rois
)
self
.
indices
.
extend
(
roi_object
.
indices
)
# list of list of tuples (one list of tuples for each ROI)
self
.
number_of_rois
=+
roi_object
.
number_of_rois
# number of ROIs defined
self
.
x_indices
.
extend
(
roi_object
.
x_indices
)
# list of numpy arrays of x-indices (for each ROI)
self
.
y_indices
.
extend
(
roi_object
.
y_indices
)
# list of numpy arrays of y-indices (for each ROI)
#self.masks = [] # 3D numpy array with slices of zeros and ones (same size as detector image) for each roi
#self.input_image += [] # 2D imput image that was used to define the ROIs
roi_object
.
roi_matrix
[
roi_object
.
roi_matrix
>
0
]
+=
orig_length
self
.
roi_matrix
+=
roi_object
.
roi_matrix
# single matrix of zeros, ones, twos, ... , n's (where n is the number of ROIs defined)
def
append
(
self
,
roi_object
):
""" **append**
Append other ROI definitions.
Args:
* roi_object (roi_obj) : Instance of the roi_object class.
"""
assert
(
type
(
roi_object
)
==
type
(
self
)
)
orig_length
=
len
(
self
.
red_rois
)
for
ii
,
key
in
enumerate
(
sorted
(
roi_object
.
red_rois
)):
new_key
=
'ROI%02d'
%
(
ii
+
orig_length
)
self
.
red_rois
[
new_key
]
=
roi_object
.
red_rois
[
key
]
self
.
red_rois
[
new_key
][
1
][
self
.
red_rois
[
new_key
][
1
]
>
0
]
+=
orig_length
def
get_number_of_rois
(
self
):
# convert summed ROIs to other ROI formats
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
)
)
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
def
get_number_of_rois
(
self
):
""" **get_number_of_rois**
Returns the number of currently defined ROIs.
"""
return
self
.
number_of_rois
def
get_indices
(
self
):
...
...
@@ -297,62 +372,112 @@ class roi_object:
"""
return
copy
.
deepcopy
(
self
)
def
strip
_rois
(
self
):
""" **strip
_rois
**
Strips extra zeros
out of
ROIs.
def
strip
(
self
):
""" **strip**
Strips extra zeros
from border of the
ROIs.
"""
pass
for
key
in
self
.
red_rois
:
num
=
int
(
""
.
join
([
c
for
c
in
key
if
c
.
isdigit
()]))
origin
=
self
.
red_rois
[
key
][
0
]
data
=
self
.
red_rois
[
key
][
1
]
inds1
,
inds2
=
np
.
where
(
data
>
0
)
new_data
=
np
.
zeros
((
inds1
.
max
()
-
inds1
.
min
()
+
1
,
inds2
.
max
()
-
inds2
.
min
()
+
1
))
new_data
=
data
[
inds1
,
inds2
].
reshape
(
new_data
)
new_origin
=
(
origin
[
0
]
+
inds1
.
min
(),
origin
[
1
]
+
inds2
.
min
())
self
.
red_rois
[
key
][
0
]
=
new_origin
self
.
red_rois
[
key
][
1
]
=
new_data
def
delete_empty_rois
(
self
):
def
delete_empty_rois
(
self
):
""" **delete_empty_rois**
"""
pass
def
shift_rois
(
self
,
shiftVal
,
direction
=
'horiz'
,
whichroi
=
None
):
Deletes ROI entries that are completely empty.
"""
**shift_rois**
for
key
in
self
.
red_rois
:
if
not
np
.
any
(
self
.
red_rois
[
key
][
1
])
>
0
:
self
.
pop
(
key
)
def
shift
(
self
,
shiftVal
,
direction
=
'horiz'
,
roi_inds
=
None
):
""" **shift**
Displaces the defined ROIs by the provided value.
Args
* shiftVal : int
Value by which the ROIs should be shifted.
* direction : string
Description of which direction to shit by.
* whichroi : sequence
Sequence (iterable) for which ROIs should be shifted.
* shiftVal (int) : Value by which the ROIs should be shifted.
* direction (str) : Description of which direction to shift
by (can be 'horiz' or 'vert'), default
is 'horiz'.
* roi_inds (int) or (sequence) : Index or Sequence (iterable)
for which ROIs should be shifted.
If None, all ROIs defined are
shifted (default.)
"""
the_indices
=
[]
if
not
whichroi
:
inds
=
list
(
range
(
len
(
self
.
indices
)))
if
not
roi_inds
:
inds
=
list
(
range
(
len
(
self
.
red_rois
)))
else
:
inds
=
whichroi
inds
=
roi_inds
if
direction
==
'vert'
:
for
roi
in
self
.
indices
:
oneroi
=
[]
for
pixel
in
roi
:
oneroi
.
append
(
(
pixel
[
0
]
+
shiftVal
,
pixel
[
1
])
)
the_indices
.
append
(
oneroi
)
if
not
isinstance
(
inds
,
Iterable
):
inds
=
list
([
inds
])
for
ind
in
inds
:
key
=
'ROI%02d'
%
ind
if
direction
==
'horiz'
:
for
roi
in
self
.
indices
:
oneroi
=
[]
for
pixel
in
roi
:
oneroi
.
append
(
(
pixel
[
0
],
pixel
[
1
]
+
shiftVal
)
)
the_indices
.
append
(
oneroi
)
self
.
red_rois
[
key
][
0
][
1
]
+=
shiftVal
self
.
indices
=
the_indices
elif
direction
==
'vert'
:
self
.
red_rois
[
key
][
0
][
0
]
+=
shiftVal
# convert summed ROIs to other ROI formats
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
)
)
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
def
pop
(
self
,
roi_key
=
None
):
""" **pop**
Discards a ROI.
Args
* roi_key (str) : Dict key for ROI to delete. If None, the ROI with
highest index (defined last) will be discarded (defalt).
"""
# delete last ROI if no key is specified
if
not
roi_key
:
roi_key
=
sorted
(
list
(
self
.
red_rois
.
keys
()))[
-
1
]
# make sure the ROI exists
assert
(
roi_key
in
list
(
self
.
red_rois
.
keys
())
)
# delete the ROI from the maskDict
self
.
red_rois
.
pop
(
roi_key
)
# convert summed ROIs to other ROI formats
self
.
roi_matrix
=
convert_redmatrix_to_matrix
(
self
.
red_rois
,
np
.
zeros_like
(
self
.
input_image
),
offsetX
=
0
,
offsetY
=
0
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
self
.
indices
=
convert_matrix_rois_to_inds
(
self
.
roi_matrix
)
self
.
number_of_rois
=
int
(
np
.
amax
(
self
.
roi_matrix
)
)
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
self
.
roi_matrix
=
convert_inds_to_matrix
(
self
.
indices
,
self
.
input_image
.
shape
)
self
.
red_rois
=
convert_matrix_to_redmatrix
(
self
.
roi_matrix
)
self
.
x_indices
=
convert_inds_to_xinds
(
self
.
indices
)
self
.
y_indices
=
convert_inds_to_yinds
(
self
.
indices
)
self
.
masks
=
convert_roi_matrix_to_masks
(
self
.
roi_matrix
)
def
show
_rois
(
self
,
cmap
=
'Blues'
,
interpolation
=
'nearest'
,
logscaling
=
True
):
""" **show
_rois
**
def
show
(
self
,
cmap
=
'Blues'
,
interpolation
=
'nearest'
,
logscaling
=
True
):
""" **show**
Creates a figure showing the existing ROIs.
...
...
@@ -413,7 +538,7 @@ class roi_object:
plt
.
show
()
def
convert_redmatrix_to_matrix
(
masksDict
,
mask
,
offsetX
=
0
,
offsetY
=
0
):
def
convert_redmatrix_to_matrix
(
masksDict
,
mask
,
offsetX
=
0
,
offsetY
=
0
):
for
key
,
(
pos
,
M
)
in
six
.
iteritems
(
masksDict
):
num
=
int
(
""
.
join
([
c
for
c
in
key
if
c
.
isdigit
()]))
S
=
M
.
shape
...
...
fitcc/CMakeLists.txt
0 → 100644
View file @
a01cf976
cmake_minimum_required
(
VERSION 3.8
)
option
(
USE_STATIC_LIBRARIES
"Link with static libraries if available"
OFF
)
option
(
TRY_CUDA
"compile Cuda files"
OFF
)
# c++ as a basis
project
(
FRSV LANGUAGES CXX C
)
# optionally we can use cuda
# to compile conditionally
include
(
CheckLanguage
)
find_package
(
HighFive REQUIRED
)
find_package
(
MPI
)
if
(
MPI_C_FOUND
)
message
(
STATUS
"YES : MPI support: configured variable MPI_C_COMPILER =
${
MPI_C_COMPILER
}
"
)
message
(
STATUS
" MPI_C_COMPILE_FLAGS =
${
MPI_C_COMPILEFLAGS
}
"
)
message
(
STATUS
" MPI_C_INCLUDE_PATH =
${
MPI_C_INCLUDE_PATH
}
"
)
message
(
STATUS
" MPI_C_LINK_FLAGS =
${
MPI_C_LINK_FLAGS
}
"
)
message
(
STATUS
" MPI_C_ LIBRARIES =
${
MPI_C_LIBRARIES
}
"
)
message
(
STATUS
" MPI_CXX_COMPILER =
${
MPI_CXX_COMPILER
}
"
)
message
(
STATUS
" MPI_CXX_COMPILE_FLAGS =
${
MPI_CXX_COMPILEFLAGS
}
"
)
message
(
STATUS
" MPI_CXX_INCLUDE_PATH =
${
MPI_CXX_INCLUDE_PATH
}
"
)
message
(
STATUS
" MPI_CXX_LINK_FLAGS =
${
MPI_CXX_LINK_FLAGS
}
"
)
message
(
STATUS
" MPI_CXX_ LIBRARIES =
${
MPI_CXX_LIBRARIES
}
"
)
endif
()
find_package
(
Boost 1.50 REQUIRED COMPONENTS filesystem system
)
message
(
STATUS
"Boost version:
${
Boost_VERSION
}
"
)
if
(
Boost_FOUND
)
message
(
" FOUND Boost"
)
message
(
Boost_INCLUDEDIR
"
${
BOOST_INCLUDE_DIR
}
"
)
message
(
Boost_LIBRARY_DIR_RELEASE
"
${
BOOST_LIBRARY_DIR_RELEASE
}
"
)
message
(
"
${}
"
)
message
(
"
${}
"
)
endif
()
find_package
(
Yaml-cpp
)
if
(
Yaml-cpp_FOUND
)
message
(
" FOUND YAML-CPP"
)
message
(
STATUS
"YAML_CPP_INCLUDE_DIR
${
YAML_CPP_INCLUDE_DIR
}
"
)
message
(
STATUS
"YAML_CPP_LIBRARIES
${
YAML_CPP_LIBRARIES
}
"
)
message
(
STATUS
" YAML_CPP_VERSION =
${
YAML_CPP_VERSION
}
"
)
message
(
STATUS
" YAML_CPP_LIBRARY_DIR =
${
YAML_CPP_LIBRARY_DIR
}
"
)
endif
()
include
(
CheckCXXCompilerFlag
)
# The version number.
set
(
FRSV_VERSION_MAJOR 1
)
set
(
FRSV_VERSION_MINOR 0
)
# Set minimum C++ to 2011 standards
set
(
CMAKE_CXX_STANDARD 11
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
# configure a header file to pass some of the CMake settings
# to the source code
configure_file
(
"
${
PROJECT_SOURCE_DIR
}
/FRSVConfig.h.in"
"
${
PROJECT_BINARY_DIR
}
/FRSVConfig.h"
)
# add the binary tree to the search path for include files
# so that we will find FRSVConfig.h
include_directories
(
"
${
PROJECT_BINARY_DIR
}
"
)
set
(
CMAKE_BUILD_TYPE RELEASE
)
if
(
NOT CMAKE_BUILD_TYPE
)
set
(
CMAKE_BUILD_TYPE DEBUG
)
endif
()
## set(CMAKE_CXX_FLAGS "-Wextra -Wall -mfpmath=sse -Ofast -flto -mcpu=native ${CMAKE_CXX_FLAGS} " )
set
(
CMAKE_CXX_FLAGS_DEBUG
"-g -Wextra -Wall -fopenmp
${
CMAKE_CXX_FLAGS
}
"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
" -g -Wextra -Wall -fopenmp -Ofast -mtune=native
${
CMAKE_CXX_FLAGS
}
"
)
## set(CMAKE_CXX_FLAGS_PIPPO "-g -Wextra -Wall -Ofast -flto -mtune=native ${CMAKE_CXX_FLAGS}" )
set
(
CMAKE_CXX_FLAGS_PIPPO
"-g -Wextra -Wall
${
CMAKE_CXX_FLAGS
}
"
)
# set(CMAKE_CXX_FLAGS "-g -Wextra -Wall -mfpmath=sse -Ofast -mtune=native ${CMAKE_CXX_FLAGS}" )
add_executable
(
frsv frsv.cc
)
target_link_libraries
(
frsv PRIVATE yaml-cpp Boost::filesystem Boost::system HighFive
)
target_include_directories
(
frsv PRIVATE
"
${
PROJECT_SOURCE_DIR
}
"
)
fitcc/FRSVConfig.h.in
0 → 100644
View file @
a01cf976
// the configured options and settings for Tutorial
#define FRSV_VERSION_MAJOR @FRSV_VERSION_MAJOR@
#define FRSV_VERSION_MINOR @FRSV_VERSION_MINOR@
/* #define HASCUDA @HASCUDA@ */
/* #define HASAF @HASAF@ */
/* #cmakedefine USE_MYMATH */
fitcc/batch_extraction.py
0 → 100644
View file @
a01cf976
import
numpy
as
np
import
h5py
import
glob
import
json
BATCH_PARALLELISM
=
4
cenom
=
np
.
array
(
[
0
,
12.91684471961497
,
1
,
12.91601322225362
,
2
,
12.915539860755496
,
3
,
12.916480273530496
,