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
Holger Niemann
IR_data_access
Commits
08307ab1
Commit
08307ab1
authored
Jul 02, 2018
by
Holger Niemann
Browse files
some changes back to old get program
parent
782d0a01
Changes
11
Hide whitespace changes
Inline
Side-by-side
IR_image_tools.py
View file @
08307ab1
...
...
@@ -217,7 +217,7 @@ def correct_images(images,badpixels):
if
type
(
badpixels
)
!=
int
:
if
type
(
images
)
==
list
:
# return corrected images also as list of 2D arrays
images
=
restore_bad_pixels
(
images
,
np
.
invert
(
badpixels
==
1
)).
astype
(
np
.
float32
)
images
=
restore_bad_pixels
(
images
,
np
.
invert
(
badpixels
==
1
))
#
.astype(np.float32)
images
=
list
(
images
)
else
:
# keep shape
...
...
AEF10_coldframes_background_fails_real.txt
→
data/
AEF10_coldframes_background_fails_real.txt
View file @
08307ab1
File moved
AEF11_coldframes_background_fails_real.txt
→
data/
AEF11_coldframes_background_fails_real.txt
View file @
08307ab1
File moved
AEF20_coldframes_background_fails_real.txt
→
data/
AEF20_coldframes_background_fails_real.txt
View file @
08307ab1
File moved
AEF21_coldframes_background_fails_real.txt
→
data/
AEF21_coldframes_background_fails_real.txt
View file @
08307ab1
File moved
AEF30_coldframes_background_fails_real.txt
→
data/
AEF30_coldframes_background_fails_real.txt
View file @
08307ab1
File moved
AEF31_coldframes_background_fails_real.txt
→
data/
AEF31_coldframes_background_fails_real.txt
View file @
08307ab1
File moved
AEF40_coldframes_background_fails_real.txt
→
data/
AEF40_coldframes_background_fails_real.txt
View file @
08307ab1
File moved
AEF41_coldframes_background_fails_real.txt
→
data/
AEF41_coldframes_background_fails_real.txt
View file @
08307ab1
File moved
AEF51_coldframes_background_fails_real.txt
→
data/
AEF51_coldframes_background_fails_real.txt
View file @
08307ab1
File moved
downloadversionIRdata.py
View file @
08307ab1
...
...
@@ -375,13 +375,13 @@ def download_raw_images_by_times(port,starttime,stoptime,version=0,intervalSize=
if
fastDL
:
def
download_raw_images_by_program_via_png
(
port
,
program
,
time_s
=
0
,
version
=
0
,
threads
=
1
,
verbose
=
0
):
#
prog=AKF_1.get_program_from_PID(program)
try
:
t_program
=
AKF_2
.
get_program_from_to
(
program
)
prog
=
AKF_2
.
get_program_list
(
t_program
[
0
],
t_program
[
1
])
#
if prog[0]:
starttime
=
prog
[
0
][
'trigger'
][
'1'
][
0
]
stoptime
=
prog
[
0
][
'trigger'
][
'6'
][
0
]
prog
=
AKF_1
.
get_program_from_PID
(
program
)
#
try:
#
t_program = AKF_2.get_program_from_to(program)
#
prog =AKF_2.get_program_list(t_program[0], t_program[1])
if
prog
[
0
]:
starttime
=
prog
[
1
][
'trigger'
][
'1'
][
0
]
stoptime
=
prog
[
1
][
'trigger'
][
'6'
][
0
]
success
=
True
OP
=
get_OP_by_time
(
starttime
)
Cam
=
portcamdict
[
OP
][
'AEF'
+
str
(
port
)]
...
...
@@ -465,8 +465,8 @@ if fastDL:
times
=
times
+
resultdict
[
order
.
index
(
i
)][
2
]
del
resultdict
return
success
,
np
.
array
(
times
),
images
except
Exception
as
E
:
raise
Exception
(
E
)
#
except Exception as E:
#
raise Exception(E)
def
download_raw_images_png_by_times_thread
(
port
,
times
,
out_q
,
threadnumber
,
version
=
0
):
...
...
@@ -593,15 +593,15 @@ def download_raw_parlog_by_times(port,starttime,stoptime,version=0):
def
get_INFRATEC_filter_by_program
(
program
,
version
=
0
):
#
prog=AKF_1.get_program_from_PID(program)
try
:
t_program
=
AKF_2
.
get_program_from_to
(
program
)
prog
=
AKF_2
.
get_program_list
(
t_program
[
0
],
t_program
[
1
])
#
if prog[0]:
starttime
=
prog
[
0
][
'trigger'
][
'1'
][
0
]
stoptime
=
prog
[
0
][
'trigger'
][
'6'
][
0
]
prog
=
AKF_1
.
get_program_from_PID
(
program
)
#
try:
#
t_program = AKF_2.get_program_from_to(program)
#
prog =AKF_2.get_program_list(t_program[0], t_program[1])
if
prog
[
0
]:
starttime
=
prog
[
1
][
'trigger'
][
'1'
][
0
]
stoptime
=
prog
[
1
][
'trigger'
][
'6'
][
0
]
return
get_INFRATEC_filter_by_times
(
starttime
,
stoptime
,
50
,
version
)
except
:
else
:
#
except:
print
(
"cannot find the program"
)
return
False
,
0
,
0
...
...
@@ -679,15 +679,15 @@ def get_camera_temp_by_times(port,starttime,stoptime,version=0):
return
AKF_1
.
read_restdb
(
larchivepath
+
"DATASTREAM/V"
+
str
(
version
)
+
"/1/cameratempetarure/_signal.json?from="
+
str
(
starttime
)
+
"&upto="
+
str
(
stoptime
))
def
get_sensor_temp_by_program
(
port
,
program
,
version
=
0
):
#
prog=AKF_1.get_program_from_PID(program)
try
:
t_program
=
AKF_2
.
get_program_from_to
(
program
)
prog
=
AKF_2
.
get_program_list
(
t_program
[
0
],
t_program
[
1
])
#
if prog[0]:
starttime
=
prog
[
0
][
'trigger'
][
'1'
][
0
]
stoptime
=
prog
[
0
][
'trigger'
][
'6'
][
0
]
prog
=
AKF_1
.
get_program_from_PID
(
program
)
#
try:
#
t_program = AKF_2.get_program_from_to(program)
#
prog =AKF_2.get_program_list(t_program[0], t_program[1])
if
prog
[
0
]:
starttime
=
prog
[
1
][
'trigger'
][
'1'
][
0
]
stoptime
=
prog
[
1
][
'trigger'
][
'6'
][
0
]
return
get_sensor_temp_by_times
(
port
,
starttime
,
stoptime
,
version
)
except
:
else
:
#
except:
print
(
"cannot find the program"
)
return
False
,
0
,
0
...
...
@@ -1332,145 +1332,148 @@ def apply_NUC(images,gain,offset,gain_error=0,offset_error=0,give_error=False):
return
0
def
get_calib_data
(
port
,
program
,
emissivity
=
0.8
,
Temp_V
=
2
,
version
=
0
,
back_emissivity
=
0.8
,
verbose
=
0
):
#
prog=AKF_1.get_program_from_PID(program)
try
:
t_program
=
AKF_2
.
get_program_from_to
(
program
)
prog
=
AKF_2
.
get_program_list
(
t_program
[
0
],
t_program
[
1
])
#
if prog[0]:
t0
=
prog
[
0
][
'trigger'
][
'0'
][
0
]
t1
=
prog
[
0
][
'trigger'
][
'1'
][
0
]
t6
=
prog
[
0
][
'trigger'
][
'6'
][
0
]
OP
=
get_OP_by_program
(
program
)
Camera
=
portcamdict
[
OP
][
'AEF'
+
str
(
port
)]
if
Camera
.
split
(
"_"
)[
0
]
==
"Infratec"
:
cf
=
get_INFRATEC_filter
_by_program
(
program
,
version
)
if
cf
[
0
]:
cfilter
=
cf
[
2
]
else
:
cfilter
=-
1
raise
Exception
(
"Filter not found for INFRATEC Camera"
)
prog
=
AKF_1
.
get_program_from_PID
(
program
)
#
try:
#
t_program = AKF_2.get_program_from_to(program)
#
prog =AKF_2.get_program_list(t_program[0], t_program[1])
if
prog
[
0
]:
t0
=
prog
[
1
][
'trigger'
][
'0'
][
0
]
t1
=
prog
[
1
][
'trigger'
][
'1'
][
0
]
t6
=
prog
[
1
][
'trigger'
][
'6'
][
0
]
# except Exception as E:
#
print("Warning: Program was not found: ",E)
#
return 0,0,0,0,0,0,0,0,0,0
OP
=
get_OP
_by_program
(
program
)
Camera
=
portcamdict
[
OP
][
'AEF'
+
str
(
port
)]
if
Camera
.
split
(
"_"
)[
0
]
==
"Infratec"
:
cf
=
get_INFRATEC_filter_by_program
(
program
,
version
)
if
cf
[
0
]:
cfilter
=
cf
[
2
]
else
:
cfilter
=
0
expo_DL
=
get_exposure_by_times
(
port
,
t1
,
t6
,
version
)
if
expo_DL
[
0
]:
t_exp
=
int
(
expo_DL
[
2
][
0
])
del
expo_DL
time
=
int
(
TimeToNs
([
2017
,
9
,
26
],[
8
,
0
,
0
,
0
]))
LUT_DL
=
download_LUT
(
port
,
time
,
t_exp
,
emissivity
,
cfilter
,
version
,
verbose
=
verbose
-
1
)
if
LUT_DL
[
0
]:
LUT
=
LUT_DL
[
1
]
del
LUT_DL
back_DL
=
download_background_by_times
(
port
,
t0
,
t1
,
t_exp
,
cfilter
,
version
)
if
back_DL
[
0
]:
background
=
back_DL
[
2
]
if
Temp_V
==
1
:
if
verbose
>
0
:
print
(
'use temperature calibration version 1'
)
backtime
=
back_DL
[
1
]
backtime
=
backtime
.
tolist
()
divertorpart
=
"all"
TCT_dl
=
get_average_divertor_TC_for_camtemp
(
port
,
int
(
backtime
-
2e9
),
int
(
backtime
+
2e9
),
divertorpart
)
cfilter
=-
1
raise
Exception
(
"Filter not found for INFRATEC Camera"
)
else
:
cfilter
=
0
expo_DL
=
get_exposure_by_times
(
port
,
t1
,
t6
,
version
)
if
expo_DL
[
0
]:
t_exp
=
int
(
expo_DL
[
2
][
0
])
del
expo_DL
time
=
int
(
TimeToNs
([
2017
,
9
,
26
],[
8
,
0
,
0
,
0
]))
LUT_DL
=
download_LUT
(
port
,
time
,
t_exp
,
emissivity
,
cfilter
,
version
,
verbose
=
verbose
-
1
)
if
LUT_DL
[
0
]:
LUT
=
LUT_DL
[
1
]
del
LUT_DL
back_DL
=
download_background_by_times
(
port
,
t0
,
t1
,
t_exp
,
cfilter
,
version
)
if
back_DL
[
0
]:
background
=
back_DL
[
2
]
if
Temp_V
==
1
:
if
verbose
>
0
:
print
(
'use temperature calibration version 1'
)
backtime
=
back_DL
[
1
]
backtime
=
backtime
.
tolist
()
divertorpart
=
"all"
TCT_dl
=
get_average_divertor_TC_for_camtemp
(
port
,
int
(
backtime
-
2e9
),
int
(
backtime
+
2e9
),
divertorpart
)
if
TCT_dl
[
0
]:
refT
=
np
.
average
(
TCT_dl
[
2
])
else
:
TCT_dl
=
get_average_divertor_TC_for_camtemp
(
port
,
int
(
backtime
-
6e9
),
int
(
backtime
+
6e9
),
divertorpart
)
if
TCT_dl
[
0
]:
refT
=
np
.
average
(
TCT_dl
[
2
])
else
:
TCT_dl
=
get_average_divertor_TC_for_camtemp
(
port
,
int
(
backtime
-
6e9
),
int
(
backtime
+
6e9
),
divertorpart
)
if
TCT_dl
[
0
]:
refT
=
np
.
average
(
TCT_dl
[
2
])
else
:
raise
Exception
(
"Unable to find thermocouple data"
)
elif
Temp_V
==
2
:
if
verbose
>
0
:
print
(
'use temperature calibration version 2'
)
frame
=
background
.
copy
()
background
=
get_average_background_recangle
(
port
,
background
)
refT
=
28.5
elif
Temp_V
==
3
:
if
verbose
>
0
:
print
(
'use temperature calibration version 3'
)
frame
=
background
.
copy
()
background
=
get_average_background_recangle
(
port
,
background
)
refT
=
28.5
raise
Exception
(
"Unable to find thermocouple data"
)
elif
Temp_V
==
2
:
if
verbose
>
0
:
print
(
'use temperature calibration version 2'
)
frame
=
background
.
copy
()
background
=
get_average_background_recangle
(
port
,
background
)
refT
=
28.5
elif
Temp_V
==
3
:
if
verbose
>
0
:
print
(
'use temperature calibration version 3'
)
frame
=
background
.
copy
()
background
=
get_average_background_recangle
(
port
,
background
)
refT
=
28.5
# back_off=estimate_offset(port,program)
# background=(background-back_off)/(back_emissivity)+back_off
else
:
raise
Exception
(
"Unknown temperature calibration method"
)
if
cfilter
==
0
and
not
Camera
.
split
(
"_"
)[
0
]
==
"Infratec"
:
if
(
port
==
31
)
or
(
port
==
21
and
float
(
program
[
4
:])
>
1110
):
print
(
"rebuilding coldframe"
)
#use any way the rebuilt coldframe.
sT
=
get_sensor_temp_by_program
(
port
,
program
)[
2
][
0
]
coldref
,
hotref
=
IR_tools
.
load_ref_images
(
'AEF'
+
str
(
port
),
t_exp
)
filestring
=
'AEF'
+
str
(
port
)
+
'_et'
+
str
(
t_exp
)
amap
=
np
.
load
(
join
(
IRCamColdframes_fittingpath
,
filestring
+
'_a.npy'
))
bmap
=
np
.
load
(
join
(
IRCamColdframes_fittingpath
,
filestring
+
'_b.npy'
))
cirebuild
=
IR_tools
.
reconstruct_coldframe
(
t_exp
,
sT
,
amap
,
bmap
,
coldref
)
gain
,
offset
=
IR_tools
.
calculate_gain_offset_image
(
cirebuild
,
None
,
coldref
,
hotref
)
gain
[
gain
==
np
.
inf
]
=
0
offset
[
offset
==
np
.
inf
]
=
0
badpixels
=
find_badpixels
(
port
,
gain
,
offset
,
niterations
=
10
,
tolerance
=
10
)
gain_error
=
0
offset_error
=
0
exist
,
time
,
frames
=
download_raw_images_by_times
(
port
,
t1
,
int
(
t1
+
0.02
*
1e9
),
version
)
if
exist
:
frames
=
[
im
.
swapaxes
(
0
,
1
)
for
im
in
frames
]
bim
=
apply_NUC
([
frames
[
0
]],
gain
,
offset
)
background
=
get_average_background_recangle
(
port
,
bim
[
0
])
else
:
raise
Exception
(
"cannot find the first frame of the discharge, reconstruction failed"
)
elif
(
port
==
11
)
or
(
port
==
21
):
coldref
,
hotref
=
IR_tools
.
load_ref_images
(
'AEF'
+
str
(
port
),
t_exp
)
NUC_DL
=
download_NUC_by_times
(
port
,
t0
,
t1
,
t_exp
,
version
)
if
NUC_DL
[
0
]
==
False
:
raise
Exception
(
"NUC was not found"
)
else
:
ci
=
NUC_DL
[
1
][
2
]
gain
,
offset
=
IR_tools
.
calculate_gain_offset_image
(
ci
,
None
,
coldref
,
hotref
)
gain
[
gain
==
np
.
inf
]
=
0
offset
[
offset
==
np
.
inf
]
=
0
badpixels
=
find_badpixels
(
port
,
gain
,
offset
,
niterations
=
10
,
tolerance
=
10
)
gain_error
=
0
offset_error
=
0
exist
,
time
,
frames
=
download_raw_images_by_times
(
port
,
t1
,
int
(
t1
+
0.02
*
1e9
),
version
)
if
exist
:
frames
=
[
im
.
swapaxes
(
0
,
1
)
for
im
in
frames
]
bim
=
apply_NUC
([
frames
[
0
]],
gain
,
offset
)
background
=
get_average_background_recangle
(
port
,
bim
[
0
])
else
:
raise
Exception
(
"background wrong due to wrong NUC, firstframe not found, reconstruction failed"
)
else
:
raise
Exception
(
"Unknown temperature calibration method"
)
if
cfilter
==
0
and
not
Camera
.
split
(
"_"
)[
0
]
==
"Infratec"
:
if
(
port
==
31
)
or
(
port
==
21
and
float
(
program
[
4
:])
>
1110
):
print
(
"rebuilding coldframe"
)
#use any way the rebuilt coldframe.
sT
=
get_sensor_temp_by_program
(
port
,
program
)[
2
][
0
]
coldref
,
hotref
=
IR_tools
.
load_ref_images
(
'AEF'
+
str
(
port
),
t_exp
)
filestring
=
'AEF'
+
str
(
port
)
+
'_et'
+
str
(
t_exp
)
amap
=
np
.
load
(
join
(
IRCamColdframes_fittingpath
,
filestring
+
'_a.npy'
))
bmap
=
np
.
load
(
join
(
IRCamColdframes_fittingpath
,
filestring
+
'_b.npy'
))
cirebuild
=
IR_tools
.
reconstruct_coldframe
(
t_exp
,
sT
,
amap
,
bmap
,
coldref
)
gain
,
offset
=
IR_tools
.
calculate_gain_offset_image
(
cirebuild
,
None
,
coldref
,
hotref
)
gain
[
gain
==
np
.
inf
]
=
0
offset
[
offset
==
np
.
inf
]
=
0
badpixels
=
find_badpixels
(
port
,
gain
,
offset
,
niterations
=
10
,
tolerance
=
10
)
gain_error
=
0
offset_error
=
0
exist
,
time
,
frames
=
download_raw_images_by_times
(
port
,
t1
,
int
(
t1
+
0.02
*
1e9
),
version
)
if
exist
:
frames
=
[
im
.
swapaxes
(
0
,
1
)
for
im
in
frames
]
bim
=
apply_NUC
([
frames
[
0
]],
gain
,
offset
)
background
=
get_average_background_recangle
(
port
,
bim
[
0
])
else
:
NUC_DL
=
download_NUC_by_times
(
port
,
t0
,
t1
,
t_exp
,
version
)
if
NUC_DL
[
0
]
==
False
:
raise
Exception
(
"NUC was not found"
)
else
:
gain
=
np
.
array
(
NUC_DL
[
1
][
0
])
offset
=
np
.
array
(
NUC_DL
[
1
][
1
])
offset
[
offset
<-
1e300
]
=
0
gain_error
=
np
.
array
(
NUC_DL
[
1
][
4
])
offset_error
=
np
.
array
(
NUC_DL
[
1
][
5
])
badpixels
=
np
.
array
(
NUC_DL
[
1
][
3
],
dtype
=
np
.
ubyte
)
if
np
.
max
(
badpixels
)
==
0
:
if
verbose
>
0
:
print
(
datetime
.
datetime
.
now
(),
"Scanning for bad pixel"
)
# initial list from config files
init_bp_list
=
IR_tools
.
read_bad_pixels_from_file
(
port
,
program
=
program
)
# find more bad pixel
badpixels
=
find_badpixels
(
port
,
gain
,
offset
,
init_bp_list
=
init_bp_list
,
niterations
=
10
,
tolerance
=
10
,
verbose
=
verbose
-
1
)
else
:
gain
=
0
offset
=
0
badpixels
=
find_badpixels
(
port
,
frame
-
background
,
offset
,
niterations
=
10
,
tolerance
=
10
,
plot_it
=
False
)
#find_badpixels(port,gain,offset)
raise
Exception
(
"cannot find the first frame of the discharge, reconstruction failed"
)
elif
(
port
==
11
)
or
(
port
==
21
):
coldref
,
hotref
=
IR_tools
.
load_ref_images
(
'AEF'
+
str
(
port
),
t_exp
)
NUC_DL
=
download_NUC_by_times
(
port
,
t0
,
t1
,
t_exp
,
version
)
if
NUC_DL
[
0
]
==
False
:
raise
Exception
(
"NUC was not found"
)
else
:
ci
=
NUC_DL
[
1
][
2
]
gain
,
offset
=
IR_tools
.
calculate_gain_offset_image
(
ci
,
None
,
coldref
,
hotref
)
gain
[
gain
==
np
.
inf
]
=
0
offset
[
offset
==
np
.
inf
]
=
0
badpixels
=
find_badpixels
(
port
,
gain
,
offset
,
niterations
=
10
,
tolerance
=
10
)
gain_error
=
0
offset_error
=
0
exist
,
time
,
frames
=
download_raw_images_by_times
(
port
,
t1
,
int
(
t1
+
0.02
*
1e9
),
version
)
if
exist
:
frames
=
[
im
.
swapaxes
(
0
,
1
)
for
im
in
frames
]
bim
=
apply_NUC
([
frames
[
0
]],
gain
,
offset
)
background
=
get_average_background_recangle
(
port
,
bim
[
0
])
else
:
raise
Exception
(
"background wrong due to wrong NUC, firstframe not found, reconstruction failed"
)
else
:
NUC_DL
=
download_NUC_by_times
(
port
,
t0
,
t1
,
t_exp
,
version
)
if
NUC_DL
[
0
]
==
False
:
raise
Exception
(
"NUC was not found"
)
else
:
gain
=
np
.
array
(
NUC_DL
[
1
][
0
])
offset
=
np
.
array
(
NUC_DL
[
1
][
1
])
offset
[
offset
<-
1e300
]
=
0
gain_error
=
np
.
array
(
NUC_DL
[
1
][
4
])
offset_error
=
np
.
array
(
NUC_DL
[
1
][
5
])
badpixels
=
np
.
array
(
NUC_DL
[
1
][
3
],
dtype
=
np
.
ubyte
)
if
np
.
max
(
badpixels
)
==
0
:
if
verbose
>
0
:
print
(
datetime
.
datetime
.
now
(),
"Scanning for bad pixel"
)
# initial list from config files
init_bp_list
=
IR_tools
.
read_bad_pixels_from_file
(
port
,
program
=
program
)
# find more bad pixel
badpixels
=
find_badpixels
(
port
,
gain
,
offset
,
init_bp_list
=
init_bp_list
,
niterations
=
10
,
tolerance
=
10
,
verbose
=
verbose
-
1
)
else
:
raise
Exception
(
"no background image found"
)
gain
=
0
offset
=
0
badpixels
=
find_badpixels
(
port
,
frame
-
background
,
offset
,
niterations
=
10
,
tolerance
=
10
,
plot_it
=
False
)
#find_badpixels(port,gain,offset)
gain_error
=
0
offset_error
=
0
else
:
raise
Exception
(
"no
LUT
found"
)
raise
Exception
(
"no
background image
found"
)
else
:
raise
Exception
(
"no exposure time found"
)
return
background
,
LUT
,
refT
,
gain
,
offset
,
badpixels
,
t_exp
,
cfilter
,
gain_error
,
offset_error
except
:
print
(
"Warning: Program was not found"
)
return
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
raise
Exception
(
"no LUT found"
)
else
:
raise
Exception
(
"no exposure time found"
)
return
background
,
LUT
,
refT
,
gain
,
offset
,
badpixels
,
t_exp
,
cfilter
,
gain_error
,
offset_error
# except Exception as E:
# print("Warning: Program was not found: ",E)
# return 0,0,0,0,0,0,0,0,0,0
def
find_badpixels
(
port
,
gain
,
offset
,
init_bp_list
=
None
,
niterations
=
3
,
tolerance
=
10
,
plot_it
=
False
,
verbose
=
0
):
...
...
@@ -1607,122 +1610,56 @@ if __name__=='__main__':
print
(
"local function calling"
)
#
# #status,time,images,valid=get_temp_from_raw_by_program_V1(51,"20171018.019",time_s=0,emi=0.8,divertorpart="all",version=1)
## status1,time1,images1,valid1=get_temp_from_raw_by_program_V1(41,"20171024.016",time_s=[0.75,0.99],emi=0.8,version=1)
## exist,time1,frames=download_raw_images_by_program_via_png(41,"20171024.016",time_s=[0.75,0.99],version=1,threads=1)
# import h5py as h5
#
# for prog in ["20171108.015"]:#"20171109.010","20170926.009","20171207.009"]:
# for port in [20,21]:
# try:
# texp=get_exposure_by_program(port,prog)
# except:
# texp=[False]
# if texp[0]:
# texp=texp[2][0]
# background=download_background_by_program(port,prog,texp)
#
# if background[0]:
#
## btest=check_backgroundframe(background[2])
## if not btest[0]:
# plt.figure()
# plt.imshow(background[2],vmin=np.mean(background[2])-200,vmax=np.mean(background[2])+200)
## plt.colorbar()
# plt.title(prog+" "+str(port))
# cold=download_NUC_by_program(port,prog,texp)
# if cold[0]:
# if port==11:
# portnr=21
# elif port==21:
# portnr=11
# else:
# portnr=port
# camera=portcamdict['OP1.2a']['AEF'+str(portnr)]
# path="\\\\sv-e4-fs-1\\E4-Mitarbeiter\\E4 Diagnostics\\QIR\\Calibrations\\IRCamReferenceImages\\"
## path="\\\\sv-e4-fs-1\\E4-Mitarbeiter\\E4 Diagnostics\\QIR\\Software\\QI-RealTime\\v1.0.1\\QIR-IrAnalysis\\release\\Config\\Thermal calibration\\"
# file=h5.File(path+"IRCAM_"+camera.split("_")[2]+"\\"+camera+"_nuc_reference_cold_"+str(int(texp))+"us.h5",'r')
## file=h5.File(path+camera+"\\"+camera+"_nuc_reference_cold_"+str(int(texp))+"us.h5",'r')
# refframe=np.array(file[camera+"_nuc_reference_cold_"+str(int(texp))+"us.h5"])
## ctest=check_coldframe_by_refframe(cold[1][2],refframe,plot_it=False)
# references=[]
# shapi=np.shape(refframe)
# for i in [int(shapi[1]//4),int(shapi[1]//2),int(shapi[1]//4*3)]:
# dataline=refframe[0:shapi[0],i]
# references.append(dataline-np.mean(dataline))
# ctest=IR_tools.check_coldframe(cold[1][2],references,plot_it=True)
# print(ctest,port,prog)
# if not ctest[0]:
# bla=np.array(cold[1][2])-np.array(refframe)
# print(np.mean(bla),np.max(bla),np.min(bla),np.std(bla),(np.max(bla)-np.min(bla))/np.mean(bla),port)
# dataset=[]
# threshold=100
# shapi=np.shape(bla)
# plt.figure()
# for i in [int(shapi[1]//4),int(shapi[1]//2),int(shapi[1]//4*3)]:
# referenceline=bla[0:shapi[0],i]
# meanref=referenceline-np.mean(referenceline)
# dataset.append(meanref)#np.max(meanref[100:-99])-np.min(meanref[100:-99]))
## plt.plot(meanref,label=str(i))
# for j in range(len(dataset)):
# if j==0:
# plt.plot(dataset[j]-dataset[-1],label=str(j))
# else:
# plt.plot(dataset[j]-dataset[j-1],label=str(j))
# plt.title(prog+"_AEF"+str(port))
# if np.mean(dataset)>threshold:
# valid=False
# else:
# valid=True
# print(valid,np.mean(dataset))#,np.mean(dataset[0]-dataset[-1]),np.mean(dataset[1]-dataset[0]),np.mean(dataset[2]-dataset[1]))
# plt.figure()
# plt.imshow(cold[1][2],vmin=np.mean(cold[1][2])-500,vmax=np.mean(cold[1][2])+500)
# plt.colorbar()
# plt.title(prog+" "+str(port))
# plt.figure()
# plt.imshow(bla,vmin=np.mean(bla)-100,vmax=np.mean(bla)+100)
# plt.colorbar()
# plt.figure()
# plt.imshow(refframe,vmin=np.mean(refframe)-100,vmax=np.mean(refframe)+100)
# plt.colorbar()
# plt.title("referenceframe "+str(port))
port
=
20
prog
=
"20171108.015"
# status,time,images,valid=get_temp_from_raw_by_program(port,prog,time_s=[0,0.2],emi=0.82,T_version=2,version=0,threads=1,give_ERROR=False,use_firstframe_as_background=True)
bla
=
get_exposure_by_program
(
port
,
prog
)
status2
,
time2
,
images2
=
download_raw_images_by_program_via_png
(
port
,
prog
,
time_s
=
[
0
,
0.2
],
threads
=
1
)
# plt.figure()
# plt.imshow(images[0],vmin=300,vmax=400)
# plt.colorbar()
# status1,time1,images1,valid1=get_temp_from_raw_by_program_V1(41,"20171024.016",time_s=[0.75,0.99],emi=0.8,version=1)
## exist,time1,frames=download_raw_images_by_program_via_png(41,"20171024.016",time_s=[0.75,0.99],version=1,threads=1)
port
=
51
# prog="20171108.015"
# prog="20171025.030"
prog
=
"20171012.035"
status
,
time
,
images
,
valid
=
get_temp_from_raw_by_program
(
port
,
prog
,
time_s
=
[
0
,
1
],
emi
=
0.82
,
T_version
=
2
,
version
=
0
,
threads
=
1
,
give_ERROR
=
False
,
use_firstframe_as_background
=
True
)
# bla=get_exposure_by_program(port,prog)
# status2,time2,images2=download_raw_images_by_program_via_png(port,prog,time_s=[0,0.2],threads=1)
import
holn.functions
as
fu
import
h5py
as
h5
szene
=
h5
.
File
(
"X:
\\
E4 Diagnostics
\\
QIR\Calibrations
\\
scene_models
\\
AEF"
+
str
(
port
)
+
"
\\
AEF"
+
str
(
port
)
+
"_scene_model.h5"
)
Xloc
=
np
.
asarray
(
szene
[
'x'
])
Yloc
=
np
.
asarray
(
szene
[
'y'
])
Zloc
=
np
.
asarray
(
szene
[
'z'
])
CAD
=
np
.
asarray
(
szene
[
'CAD'
])
plt
.
figure
()
#
plt
.
imshow
(
CAD
,
cmap
=
'gray'
)
plt
.
imshow
(
images
[
-
1
],
vmin
=
300
,
vmax
=
750
,
cmap
=
fu
.
exJet_trans
)
cb
=
plt
.
colorbar
()
cb
.
set_label
(
"temperature K"
,
rotation
=
270
,
labelpad
=
26
,
fontsize
=
26
)
cb
.
ax
.
tick_params
(
labelsize
=
26
)
# tmax=[]
# port=20
NUCblock
=
download_NUC_by_program
(
port
,
prog
,
bla
[
2
][
0
])
background
,
LUT
,
refT
,
gain
,
offset
,
badpixels
,
t_exp
,
cfilter
,
gain_error
,
offset_error
=
get_calib_data
(
port
,
prog
)
refcoldhot
=
IR_tools
.
load_ref_images
(
"AEF"
+
str
(
port
),
bla
[
2
][
0
])
recal_gain_offset
=
IR_tools
.
calculate_gain_offset_image_pix
(
NUCblock
[
1
][
2
].
copy
(),
None
,
refcoldhot
[
0
].
copy
(),
refcoldhot
[
1
].
copy
())
plt
.
figure
()
plt
.
imshow
(
NUCblock
[
1
][
0
]
-
recal_gain_offset
[
0
])
plt
.
title
(
"gain"
)
plt
.
figure
()
plt
.
imshow
(
NUCblock
[
1
][
1
]
-
recal_gain_offset
[
1
])
plt
.
title
(
"offset"
)
#
NUCblock=download_NUC_by_program(port,prog,bla[2][0])
#
background,LUT,refT,gain,offset,badpixels,t_exp,cfilter,gain_error,offset_error=get_calib_data(port,prog)
#
refcoldhot=IR_tools.load_ref_images("AEF"+str(port),bla[2][0])
#
recal_gain_offset=IR_tools.calculate_gain_offset_image_pix(NUCblock[1][2].copy(),None,refcoldhot[0].copy(),refcoldhot[1].copy())
#
plt.figure()
#
plt.imshow(NUCblock[1][0]-recal_gain_offset[0])
#
plt.title("gain")
#
plt.figure()
#
plt.imshow(NUCblock[1][1]-recal_gain_offset[1])
#
plt.title("offset")
# ima1=apply_NUC(images2.copy(),NUCblock[1][0],NUCblock[1][1])
# ima2=apply_NUC(images2.copy(),recal_gain_offset[0],recal_gain_offset[1])
ima1
=
apply_calib_on_raw
(
images2
.
copy
(),
background
,
LUT
,
gain
=
NUCblock
[
1
][
0
],
offset
=
NUCblock
[
1
][
1
])
ima2
=
apply_calib_on_raw
(
images2
.
copy
(),
background
,
LUT
,
gain
=
recal_gain_offset
[
0
],
offset
=
recal_gain_offset
[
1
])
plt
.
figure
()
plt
.
imshow
(
ima1
[
0
],
vmin
=
300
,
vmax
=
400
)
plt
.
colorbar
()
plt
.
title
(
"aleix nuc"
)
plt
.
figure
()
plt
.
imshow
(
ima2
[
0
],
vmin
=
300
,
vmax
=
400
)
plt
.
colorbar
()
plt
.
title
(
"adnan nuc"
)
#
ima1=apply_calib_on_raw(images2.copy(),background,LUT,gain=NUCblock[1][0],offset=NUCblock[1][1])
#
ima2=apply_calib_on_raw(images2.copy(),background,LUT,gain=recal_gain_offset[0],offset=recal_gain_offset[1])
#
#
plt.figure()
#
plt.imshow(ima1[0],vmin=300,vmax=400)
#
plt.colorbar()
#
plt.title("aleix nuc")
#
#
plt.figure()
#
plt.imshow(ima2[0],vmin=300,vmax=400)
#
plt.colorbar()
#
plt.title("adnan nuc")
# for i in range(len(images)):
# tmax.append(np.max(images[i]))
# plt.figure()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment