Commit 9467269b authored by Peter Drewelow's avatar Peter Drewelow
Browse files

downloadversionIRdata: catch more fail cases for get_NUCed_coldframe_by_program()

parent 69d01578
...@@ -585,16 +585,25 @@ def get_NUCed_coldframe_by_program(port, program, exposure=None, version=0, plot ...@@ -585,16 +585,25 @@ def get_NUCed_coldframe_by_program(port, program, exposure=None, version=0, plot
NUCed cold frame NUCed cold frame
""" """
if exposure is None: if exposure is None:
exist, t, exposure = get_exposure_by_program(port, program, version=version) try:
exist, t, exposure = get_exposure_by_program(port, program, version=version)
except:
print('get_NUCed_coldframe_by_program: ERROR! no exposure time found!')
return False, []
t_exp = exposure[0] t_exp = exposure[0]
else: else:
if verbose>0: if verbose>0:
print('get_NUCed_coldframe_by_program: using exposure time {0}'.format(exposure)) print('get_NUCed_coldframe_by_program: using exposure time {0}'.format(exposure))
t_exp = exposure t_exp = exposure
exist, data, desc = get_NUC_by_program(port, program, t_exp, version=version, verbose=verbose-1) try:
exist, data, desc = get_NUC_by_program(port, program, t_exp, version=version, verbose=verbose-1)
except:
print('get_NUCed_coldframe_by_program: ERROR! no cold frame found!')
return False, []
if exist: if exist:
cold_raw = data[2] cold_raw = data[2]
porg_nr = int(program.split('.')[1]) porg_nr = int(program.split('.')[1])
ref_program = '{0}.{1:03d}'.format(program.split('.')[0], porg_nr-1) ref_program = '{0}.{1:03d}'.format(program.split('.')[0], porg_nr-1)
...@@ -606,7 +615,7 @@ def get_NUCed_coldframe_by_program(port, program, exposure=None, version=0, plot ...@@ -606,7 +615,7 @@ def get_NUCed_coldframe_by_program(port, program, exposure=None, version=0, plot
else: else:
ref_program = '{0}.{1:03d}'.format(program.split('.')[0], porg_nr+1) ref_program = '{0}.{1:03d}'.format(program.split('.')[0], porg_nr+1)
if verbose>0: if verbose>0:
print('get_NUCed_coldframe_by_program: program {0} is first of day.\n --> using NUC of {1}'.format(program, ref_program)) print('get_NUCed_coldframe_by_program: program {0} has no predecessor.\n --> using NUC of {1}'.format(program, ref_program))
exist2, data, desc = get_NUC_by_program(port, ref_program, t_exp, version=version, verbose=verbose-1) exist2, data, desc = get_NUC_by_program(port, ref_program, t_exp, version=version, verbose=verbose-1)
if exist2: if exist2:
coldframe = apply_NUC([cold_raw],data[0],data[1])[0] coldframe = apply_NUC([cold_raw],data[0],data[1])[0]
...@@ -3588,7 +3597,7 @@ if __name__=='__main__': ...@@ -3588,7 +3597,7 @@ if __name__=='__main__':
#%% get hot cold image test #%% get hot cold image test
port=10 port=10
program="20180904.015" program="20180904.002"
exist, coldframe = get_NUCed_coldframe_by_program(port, program, exposure=None, version=0, plot_it=True, verbose=3) exist, coldframe = get_NUCed_coldframe_by_program(port, program, exposure=None, version=0, plot_it=True, verbose=3)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment