Commit 420e76e8 authored by Holger Niemann's avatar Holger Niemann
Browse files

Update to V3.4.1:\n downloadversionIRdata: improved documentation, adding of...

Update to V3.4.1:\n downloadversionIRdata: improved documentation, adding of request for all ports, change of request paths, files; improved warning handling with repect to issue #14\n changelog: updated to V3.4.1\n setup.py: updated requierements to w7xarchive instead of archivedb\n plot_heatflux_example: added calling of the heatflux download to agree with the code.\n IR_iamge_tools: documentation update
parent d01ae340
<<<<<<< HEAD <<<<<<< HEAD
XX.06.2020: Update to V3.5.0
- add download maximum heat flux and wetted area
16.06.2020: Update to V3.4.1
- updated and improved documentation
- include chache function and a request for all ports for heat flux and divertor load
08.02.2020: Update to V3.4.0 08.02.2020: Update to V3.4.0
- Bugfix: download_images_by_times produzierte doppelte Werte im Zeit und Bildvektor - Bugfix: download_images_by_times produzierte doppelte Werte im Zeit und Bildvektor
- - Bugfix: download divertor load gave print back that request was made, although no request was made (fixed)
- Bugfix: correction of version bug from last commit and change of default value for the profile extraction functions to None
- Readme added
Update to V3.3.3: Update to V3.3.3:
- - added function for peaking factor and strike line width calculation in tools
- bugfix: bug fix get_trigger_from_PID which caused an error in get_latest_version if it was used for non IR data
Update to V3.3.2: Update to V3.3.2:
- - extended feedback for download_heatflux
- changes of wetted area calculation
- changes of wetted area calculation
- bugfix: get_trigger_PID, get_finger and during import (see issues 6,7)
Update to V3.3.1: Update to V3.3.1:
- - bugfix: FOV for AEF50 was not working correctly
Update to V3.3.0: Update to V3.3.0:
- - IR_config_constants: added path to Test archive and use this variable in downloadversionIRdata when building an archive path
- downloadversionIRdata: consistent use of testmode parameter
- downloadversionIRdata: added testmode to all reading routines allowing reading from Test archive
- IR_image_tools: no longer sets working directory to script file location
- IR_config_constants: sets parameter_file_path as absolute path
- downloadversionIRdata: new function get_trigger_from_PID() wraps get_program_from_PID() and allows getting timestamps for lab data
- downloadversionIRdata: download_images_by_time_via_png() now uses nanosecond timestamps to call AKF_2.get_time_intervals()
- downloadversionIRdata: disable DeprecationWarning in import of archivedb (timezone issue on Windows)
- downloadversionIRdata: get_NUC_by_times() uses the reference cold frame in case no cold frame (NUC frame) was found for this time
- downloadversionIRdata: unified use of stoptime instead of endtime
- downloadversionIRdata: expanded testing sections (profile, coldframe, timestamps and scene model)
Update to V3.2.5: Update to V3.2.5:
- remove of old, not needed function and dependencies, update of download_background function
Update to V3.2.4: Update to V3.2.4:
- smaller bugfixes and setup.py got added
Update to V3.2.3: Update to V3.2.3:
- bugfix: finding right version for meta informations - bugfix: finding right version for meta informations
Update to V3.2.2: Update to V3.2.2:
...@@ -84,7 +105,8 @@ bugfixes in downloadversionIRdata: ...@@ -84,7 +105,8 @@ bugfixes in downloadversionIRdata:
- fixed: wrong time intervall for TC divertor data - fixed: wrong time intervall for TC divertor data
Versions: Versions:
V3.4.0: chaching functionality included, request for all cameras included + Bugfixes V3.5.0: download of wetted area, peak loads for different targets and
V3.4.1: chaching functionality included, request for all cameras included + Bugfixes
V3.3.0: code-cleaning, unification of variable names, new functions: get_trigger_from_PID, V3.3.0: code-cleaning, unification of variable names, new functions: get_trigger_from_PID,
V3.2.0: download of scene models possible, temperature profiles can be extracted, downsampled temperature images available V3.2.0: download of scene models possible, temperature profiles can be extracted, downsampled temperature images available
V3.1.0: add of divertor loads in the upload and the download V3.1.0: add of divertor loads in the upload and the download
......
...@@ -25,14 +25,16 @@ def get_OP_by_time(time_ns=None, shot_no=None, program_str=None): ...@@ -25,14 +25,16 @@ def get_OP_by_time(time_ns=None, shot_no=None, program_str=None):
'''Derives operation phase (OP) of W7-X based on either: '''Derives operation phase (OP) of W7-X based on either:
a nanosacond time stamp, a MDSplus style shot no. or a program ID. a nanosacond time stamp, a MDSplus style shot no. or a program ID.
IN: INPUT
time_ns - integer of nanosecond time stamp, -----
time_ns: - integer of nanosecond time stamp,
e.g. 1511972727249834301 (OPTIONAL) e.g. 1511972727249834301 (OPTIONAL)
shot_no - integer of MDSplus style shot number, shot_no - integer of MDSplus style shot number,
e.g. 171207022 (OPTIONAL) e.g. 171207022 (OPTIONAL)
program_str - string of CoDaQ ArchiveDB style prgram number or date, program_str - string of CoDaQ ArchiveDB style prgram number or date,
e.g. '20171207.022' or '20171207' (OPTIONAL) e.g. '20171207.022' or '20171207' (OPTIONAL)
RETURN: RESULT
------
conn - MDSplus connection object, to be used in e.g. 1511972727249834301 conn - MDSplus connection object, to be used in e.g. 1511972727249834301
read_MDSplus_image_simple(), read_MDSplus_metadata() read_MDSplus_image_simple(), read_MDSplus_metadata()
''' '''
...@@ -639,7 +641,13 @@ def reconstruct_coldframe (exposuretime, sT, a, bnew, coldref): ...@@ -639,7 +641,13 @@ def reconstruct_coldframe (exposuretime, sT, a, bnew, coldref):
""" """
INPUT INPUT
------ ------
exposuretime: integer
the exposure time
sT:
a:
bnew:
coldref: numpy array
the reference cold frame as the base for the reconstruction
RESULT RESULT
------ ------
...@@ -689,17 +697,27 @@ def get_work_list(pipepath,typ="q"): ...@@ -689,17 +697,27 @@ def get_work_list(pipepath,typ="q"):
""" """
INPUT INPUT
------ ------
pipepath: string
the path to the folder where the files are located
typ: string
the typ of data which is requested in the working list\n
possiblities: q, Aw, qpeak, width, load\n
or anything else for the problematic programs
RESULT RESULT
------ ------
cam_programs: list
a list containing two coloumns, cameras and programs
reasons: list, optional, only for problematic programs
a list showing the reasons, why data are not processed
NOTE NOTE
------ ------
""" """
today=datetime.datetime.now() today=datetime.datetime.now()
cam_programs=[] cam_programs=[]
if typ in ('q','load'): if typ in ('q_old','load_old'):
f=open(pipepath+str(today.year)+str(today.month)+"_"+typ+"_requests.txt") f=open(pipepath+str(today.year)+str(today.month)+"_"+typ+"_requests.txt")
elif typ in ('q','load','qpeak','Aw','width'):
f=open(pipepath+"Auto_"+typ+"_requests.txt")
else: else:
reasons=[] reasons=[]
f = open(pipepath+"problematic_programs.txt") f = open(pipepath+"problematic_programs.txt")
......
...@@ -6,3 +6,6 @@ download: ...@@ -6,3 +6,6 @@ download:
- implement download of the stored temperature data (After the upload) - implement download of the stored temperature data (After the upload)
- implement download of the stored heat flux data --> done in V3.0.0 - implement download of the stored heat flux data --> done in V3.0.0
- implement download of FLIR data --> Done in V2.8.0, in testing phase - implement download of FLIR data --> Done in V2.8.0, in testing phase
- implement caching
- implement download of wetted area, peak heat flux and average strike line width
- implement request of all ports
...@@ -4,7 +4,7 @@ Created on Wed Oct 25 15:51:46 2017 ...@@ -4,7 +4,7 @@ Created on Wed Oct 25 15:51:46 2017
updated on Tue Aug 21 10:20:00 2018 updated on Tue Aug 21 10:20:00 2018
last update on Fr Nov 23 15:37:00 2018 last update on Fr Nov 23 15:37:00 2018
Version: 3.4.0 Version: 3.4.1
(Numbering: #of big changes(OP1.2a download V1, OP1.2b download V2, heatflux V3) (Numbering: #of big changes(OP1.2a download V1, OP1.2b download V2, heatflux V3)
. .
#of updates to add functionalities #of updates to add functionalities
...@@ -12,7 +12,7 @@ Version: 3.4.0 ...@@ -12,7 +12,7 @@ Version: 3.4.0
#number of updates for bug fixes ) #number of updates for bug fixes )
@author: holn @author: holn
""" """
version="V3.4.0" version = "V3.4.1"
import numpy as np import numpy as np
import IR_image_tools as IR_tools import IR_image_tools as IR_tools
...@@ -28,7 +28,7 @@ from IR_config_constants import archivepath, testarchivepath, portcamdict, camli ...@@ -28,7 +28,7 @@ from IR_config_constants import archivepath, testarchivepath, portcamdict, camli
import datetime import datetime
import urllib.request import urllib.request
import urllib.error import urllib.error
import logging
import json import json
from PIL import Image from PIL import Image
from io import BytesIO from io import BytesIO
...@@ -36,7 +36,7 @@ from os.path import join ...@@ -36,7 +36,7 @@ from os.path import join
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
try: try:
import threading import threading
import archivedb as AKF_2 import w7xarchive as AKF_2
# disbale deprecation warnings, because of timezone warning spam # disbale deprecation warnings, because of timezone warning spam
import warnings import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning) warnings.filterwarnings("ignore", category=DeprecationWarning)
...@@ -81,12 +81,12 @@ def get_latest_version(stream, project="W7X", testmode=False, t_from=None, ...@@ -81,12 +81,12 @@ def get_latest_version(stream, project="W7X", testmode=False, t_from=None,
return int of version number of None if non-versioned or non-existing stream return int of version number of None if non-versioned or non-existing stream
author: G. Schlisio, edit by holn author: G. Schlisio, edit by holn
""" """
if testmode: if testmode:#check which archive should be used
base = testarchivepath base = testarchivepath
else: else:
base = archivepath base = archivepath
if program == None and t_from == None and t_to == None: if program == None and t_from == None and t_to == None:# check wheather any time information was given
request = urllib.request.Request(base +project+"/" + stream + "/_versions.json", headers={"Accept": "application/json"}) request = urllib.request.Request(base +project+"/" + stream + "/_versions.json", headers={"Accept": "application/json"})
else: else:
if program is not None: if program is not None:
...@@ -192,42 +192,56 @@ def download_LUT(port, time, exposure=0, emissivity=0, camera_filter=0, version= ...@@ -192,42 +192,56 @@ def download_LUT(port, time, exposure=0, emissivity=0, camera_filter=0, version=
testmode=False, verbose=0): testmode=False, verbose=0):
""" """
download_LUT(camera, port, time, exposure=0, emissivity=0, camera_filter=0, version=1): download_LUT(camera, port, time, exposure=0, emissivity=0, camera_filter=0, version=1):
time in ns download of the look up table for the infrared cameras from the database for OP1.2(a+b)
Have to swap 11, 21 until correction in the database Have to swap 11, 21 until correction in the database
INPUT INPUT
------ ------
port: port: interger
time: number of the AEF camera port
exposure: time: integer
emissivity: nanosecond timestamp for the LUT
camera_filter: exposure: integer
version: requested exposure time in microseconds
testmode: emissivity: float, string or integer
verbose: emissivity value to identify which LUT is requested
camera_filter: inter or string, only needed for port 50
filter number of the Infratec camera in port AEF50
version: integer, optional, default 0
Version of the data in the archiveDB, in case of 0 the highest version will be used
testmode: boolean, optional, default False
if True, the data will be loaded from the test archive
verbose: integer, optional, default 0
feedback level (details of print messages)
RESULT RESULT
------ ------
exist: boolean
True if Look up table was found, False if not
LUT: list
contains the calibration information: [digital level, temperature, temperature error]
NOTE NOTE
------ ------
function need to be adapted for OP2, if AEK ports come into opperation
""" """
OP = IR_tools.get_OP_by_time(time_ns=time) OP = IR_tools.get_OP_by_time(time_ns=time)#getting operation phase
if port == 21: if port == 21:# swapping both ports (21 and 11)
port = 11 port = 11
elif port == 11: elif port == 11:
port = 21 port = 21
if testmode: if testmode: #check which archive should be used
larchivepath = testarchivepath+project+"/"+portpathdict[OP]["AEF"+str(port)]+"LUT_" larchivepath = testarchivepath+project+"/"+portpathdict[OP]["AEF"+str(port)]+"LUT_"
else: else:
larchivepath = archivepath+project+"/"+portpathdict[OP]["AEF"+str(port)]+"LUT_" larchivepath = archivepath+project+"/"+portpathdict[OP]["AEF"+str(port)]+"LUT_"
#camera dependend request string generation
if port == 50 and OP == "OP1.2a":# camera=="INFRATEC" or camera=="infratec" or camera=="Infratec": if port == 50 and OP == "OP1.2a":# camera=="INFRATEC" or camera=="infratec" or camera=="Infratec":
query = "Filter_"+str(camera_filter)+"_Texp_"+str(int(exposure))+"us_e_"+str(float(emissivity)) query = "Filter_"+str(camera_filter)+"_Texp_"+str(int(exposure))+"us_e_"+str(float(emissivity))
elif port in [10, 11, 20, 21, 30, 31, 40, 41, 51] or OP == "OP1.2b":#camera=="IRCAM" or camera=="IRcam" or camera=="ircam": elif port in [10, 11, 20, 21, 30, 31, 40, 41, 51] or OP == "OP1.2b":#camera=="IRCAM" or camera=="IRcam" or camera=="ircam":
query = "Texp_"+str(int(exposure))+"us_e_"+str(float(emissivity)) query = "Texp_"+str(int(exposure))+"us_e_"+str(float(emissivity))
else: else:
print("download_LUT: Error! Camera unknown, stopping here.") # print("download_LUT: Error! Camera unknown, stopping here.")
raise Exception logging.warning("download_LUT: Error! Camera unknown, stopping here.")
if version == 0: return False, 0
# raise Exception
if version == 0:#version check, if 0
version = get_latest_version(portpathdict[OP]["AEF"+str(port)]+"LUT_DATASTREAM", t_from=time, testmode=testmode) version = get_latest_version(portpathdict[OP]["AEF"+str(port)]+"LUT_DATASTREAM", t_from=time, testmode=testmode)
if verbose > 0: if verbose > 0:
print("download_LUT: LUT V"+str(version)+" is used") print("download_LUT: LUT V"+str(version)+" is used")
...@@ -259,12 +273,27 @@ def read_LUT_from_file(port, this_time, t_exp, emissivity, cfilter, verbose=0):# ...@@ -259,12 +273,27 @@ def read_LUT_from_file(port, this_time, t_exp, emissivity, cfilter, verbose=0):#
Read LUT V3 from local files for testing new calibration. Read LUT V3 from local files for testing new calibration.
INPUT INPUT
------ ------
port: integer or string
the port number of the AEF port
this_time: integer
nanosecond timestamp for the LUT
t_exp: integer
requested exposure time in microseconds
emissivity: float, string or integer
emissivity value to identify which LUT is requested
cfilter: inter or string, only needed for port 50
filter number of the Infratec camera in port AEF50
verbose: integer, optional, default 0
feedback level (details of print messages)
RESULT RESULT
------ ------
exist: boolean
True if Look up table was found, False if not
LUT: list
contains the calibration information: [digital level, temperature, temperature error]
NOTE NOTE
------ ------
function need to be adapted for OP2, if AEK ports come into opperation
""" """
LUT_dir = '\\\\sv-e4-fs-1\\E4-Mitarbeiter\\E4 Diagnostics\\QIR\\testingLUT' LUT_dir = '\\\\sv-e4-fs-1\\E4-Mitarbeiter\\E4 Diagnostics\\QIR\\testingLUT'
OP = IR_tools.get_OP_by_time(time_ns=this_time) OP = IR_tools.get_OP_by_time(time_ns=this_time)
...@@ -284,14 +313,32 @@ def read_LUT_from_file(port, this_time, t_exp, emissivity, cfilter, verbose=0):# ...@@ -284,14 +313,32 @@ def read_LUT_from_file(port, this_time, t_exp, emissivity, cfilter, verbose=0):#
def download_NUC_by_program(port, program, exposure, version=0, testmode=False, verbose=0): def download_NUC_by_program(port, program, exposure, version=0, testmode=False, verbose=0):
''' '''
download the NUC data for a given port, program and exposure time of the camera
INPUT INPUT
------ ------
port: integer or string
port number of the AEF port of the camera
program: string
program id in the form of 'YYYYMMDD.XXX', e.g. '20181016.016'
exposure: integer
exposure time in microseconds
version: integer, optional, default 0
Version of the data in the archiveDB, in case of 0 the highest version will be used
testmode: boolean, optional, default False
if True, the data will be loaded from the test archive
verbose: integer, optional, default 0
feedback level (details of print messages)
RESULT RESULT
------ ------
exist: boolean
True if NUC data was found, False if not
NUC: list
a list vontaining images of gain, offset, cold, badpixels, gain_error and offset_error
NUC_describtion: list
a list which entry in NUC is what, looks like ['gain', 'offset', 'cold', 'badpixels', 'gain_error', 'offset_error']
NOTE NOTE
------ ------
function need to be adapted for OP2, if AEK ports come into opperation
''' '''
# prog=get_program_from_PID(program) # prog=get_program_from_PID(program)
# try: # try:
...@@ -310,14 +357,34 @@ def download_NUC_by_program(port, program, exposure, version=0, testmode=False, ...@@ -310,14 +357,34 @@ def download_NUC_by_program(port, program, exposure, version=0, testmode=False,
def download_NUC_by_times(port, starttime, stoptime, exposure, testmode=False, version=0, verbose=0): def download_NUC_by_times(port, starttime, stoptime, exposure, testmode=False, version=0, verbose=0):
''' '''
download the NUC data for a given port, start and endtime in ns and exposure time of the camera
INPUT INPUT
------ ------
port: integer or string
port number of the AEF port of the camera
starttime: integer
time in ns where the search should start
stoptime: integer
time in sn where the search should end
exposure: integer
exposure time in microseconds
version: integer, optional
Version of the data in the archiveDB, in case of 0 the highest version will be used
testmode: boolean, optional
if True, the data will be loaded from the test archive
verbose: integer, optional
feedback level (details of print messages)
RESULT RESULT
------ ------
exist: boolean
True if NUC data was found, False if not
NUC: list
a list vontaining images of gain, offset, cold, badpixels, gain_error and offset_error
NUC_describtion: list
a list which entry in NUC is what, looks like ['gain', 'offset', 'cold', 'badpixels', 'gain_error', 'offset_error']
NOTE NOTE
------ ------
function need to be adapted for OP2, if AEK ports come into opperation
''' '''
OP = IR_tools.get_OP_by_time(time_ns=starttime) OP = IR_tools.get_OP_by_time(time_ns=starttime)
if testmode: if testmode:
...@@ -370,12 +437,29 @@ def get_NUC_by_program(port, program, exposure, version=0, testmode=False, verbo ...@@ -370,12 +437,29 @@ def get_NUC_by_program(port, program, exposure, version=0, testmode=False, verbo
the cold frame and/or compute the gain, offset from the hot and cold frame. the cold frame and/or compute the gain, offset from the hot and cold frame.
INPUT INPUT
------ ------
port: integer or string
port number of the AEF port of the camera
program: string
program id in the form of 'YYYYMMDD.XXX', e.g. '20181016.016'
exposure: integer
exposure time in microseconds
version: integer, optional
Version of the data in the archiveDB, in case of 0 the highest version will be used
testmode: boolean, optional
if True, the data will be loaded from the test archive
verbose: integer, optional
feedback level (details of print messages)
RESULT RESULT
------ ------
exist: boolean
True if NUC data was found, False if not
NUC: list
a list vontaining images of gain, offset, cold, badpixels, gain_error and offset_error
NUC_describtion: list
a list which entry in NUC is what, looks like ['gain', 'offset', 'cold', 'badpixels', 'gain_error', 'offset_error']
NOTE NOTE
------ ------
function need to be adapted for OP2, if AEK ports come into opperation
''' '''
# prog=get_program_from_PID(program) # prog=get_program_from_PID(program)
# try: # try:
...@@ -399,23 +483,46 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False ...@@ -399,23 +483,46 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False
Loads NUC elements (gain, offset cold image, bad pixels) for an IR camera Loads NUC elements (gain, offset cold image, bad pixels) for an IR camera
in a given port and time interval. Depending on time and camera, reconstruct in a given port and time interval. Depending on time and camera, reconstruct
the cold frame and/or compute the gain, offset from the hot and cold frame. the cold frame and/or compute the gain, offset from the hot and cold frame.
the result is operation phase dependent, due to changes in the aquisition and saving programs
INPUT INPUT
------ ------
port: integer or string
port number of the AEF port of the camera
starttime: integer
time in ns where the search should start
stoptime: integer
time in sn where the search should end
exposure: integer
exposure time in microseconds
version: integer, optional
Version of the data in the archiveDB, in case of 0 the highest version will be used
testmode: boolean, optional
if True, the data will be loaded from the test archive
OP: string, optional, default None
name of operation phase
verbose: integer, optional
feedback level (details of print messages)
RESULT RESULT
------ ------
exist: boolean
True if NUC data was found, False if not
NUC: list
a list vontaining images of gain, offset, cold, badpixels, gain_error and offset_error
NUC_describtion: list
a list which entry in NUC is what, looks like ['gain', 'offset', 'cold', 'badpixels', 'gain_error', 'offset_error']
NOTE NOTE
------ ------
function need to be adapted for OP2, if AEK ports come into opperation
""" """
if OP is None: if OP is None: #get operation phase if not given
OP = IR_tools.get_OP_by_time(time_ns=stoptime) OP = IR_tools.get_OP_by_time(time_ns=stoptime)
if OP == "OP1.2a": if OP == "OP1.2a": # check for operation phase
t1 = stoptime t1 = stoptime
t0 = starttime t0 = starttime
prog = read_program(t1) prog = read_program(t1)
program = prog[1]['id'] program = prog[1]['id']
if (port == 31) or (port == 21 and float(program[4:]) > 1110): if (port == 31) or (port == 21 and float(program[4:]) > 1110):#camera 31 and 21 need after 20171110 new coldframes due to a open shutter during the recording of the coldframes
if verbose > 0: if verbose > 0:
print("get_NUC_by_times: rebuilding coldframe") print("get_NUC_by_times: rebuilding coldframe")
#use any way the rebuilt coldframe. #use any way the rebuilt coldframe.
...@@ -427,7 +534,9 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False ...@@ -427,7 +534,9 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False
coldref = hotcold[1] coldref = hotcold[1]
hotref = hotcold[0] hotref = hotcold[0]
else: else:
raise Exception("get_NUC_by_times: unable to download reference frames") # raise Exception("get_NUC_by_times: unable to download reference frames")
logging.warning("get_NUC_by_times: unable to download reference frames")
return False, 0, 0
filestring = 'AEF' + str(port) + '_et' + str(int(t_exp)) filestring = 'AEF' + str(port) + '_et' + str(int(t_exp))
amap = np.load(join(IRCamColdframes_fittingpath, filestring + '_a.npy')) amap = np.load(join(IRCamColdframes_fittingpath, filestring + '_a.npy'))
bmap = np.load(join(IRCamColdframes_fittingpath, filestring + '_b.npy')) bmap = np.load(join(IRCamColdframes_fittingpath, filestring + '_b.npy'))
...@@ -441,7 +550,7 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False ...@@ -441,7 +550,7 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False
gain_error = 0 gain_error = 0
offset_error = 0 offset_error = 0
return True, [gain, offset, cirebuild, badpixels, gain_error, offset_error], ['gain', 'offset', 'cold', 'badpixels', 'gain_error', 'offset_error'] return True, [gain, offset, cirebuild, badpixels, gain_error, offset_error], ['gain', 'offset', 'cold', 'badpixels', 'gain_error', 'offset_error']
elif (port == 11) or (port == 21): elif (port == 11) or (port == 21): # case of the swaped cameras
if verbose > 0: if verbose > 0:
print('get_NUC_by_times: downloading NUC') print('get_NUC_by_times: downloading NUC')
# coldref, hotref = IR_tools.load_ref_images('AEF' + str(port), t_exp) # coldref, hotref = IR_tools.load_ref_images('AEF' + str(port), t_exp)
...@@ -450,10 +559,14 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False ...@@ -450,10 +559,14 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False
coldref = hotcold[1] coldref = hotcold[1]
hotref = hotcold[0] hotref = hotcold[0]
else: else:
raise Exception("get_NUC_by_times: unable to download reference frames") # raise Exception("get_NUC_by_times: unable to download reference frames")
logging.warning("get_NUC_by_times: unable to download reference frames")
return False, 0, 0
NUC_DL = download_NUC_by_times(port, t0, t1, t_exp, version, testmode) NUC_DL = download_NUC_by_times(port, t0, t1, t_exp, version, testmode)
if NUC_DL[0] == False: if NUC_DL[0] == False:
raise Exception("get_NUC_by_times: NUC was not found") # raise Exception("get_NUC_by_times: NUC was not found")
logging.warning("get_NUC_by_times: NUC was not found")
return False, 0, 0
else: else:
ci = NUC_DL[1][2] ci = NUC_DL[1][2]
gain, offset = IR_tools.calculate_gain_offset_image(ci, None, coldref, hotref, verbose=verbose-1) gain, offset = IR_tools.calculate_gain_offset_image(ci, None, coldref, hotref, verbose=verbose-1)
...@@ -463,7 +576,7 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False ...@@ -463,7 +576,7 @@ def get_NUC_by_times(port, starttime, stoptime, t_exp, version=0, testmode=False
gain_error = 0 gain_error = 0
offset_error = 0 offset_error = 0
return True, [gain, offset, ci, badpixels, gain_error, offset_error], ['gain', 'offset', 'cold', 'badpixels', 'gain_error', 'offset_error'] return True, [gain, offset, ci, badpixels, gain_error, offset_error], ['gain', 'offset', 'cold', 'badpixels', 'gain_error', 'offset_error']
else: else: #all other cases, the "normal" case
if verbose > 0: if verbose > 0:
print('get_NUC_by_times: downloading NUC') print('get_NUC_by_times: downloading NUC')
NUC_DL = download_NUC_by_times(port,