diff --git a/downloadversionIRdata.py b/downloadversionIRdata.py
index f0e9d9f7cbeca1e56fbd4e9f4e6dfe22a468a596..729c6e527e3ee6d84d2abe93ac354d9ae3e5dcf8 100644
--- a/downloadversionIRdata.py
+++ b/downloadversionIRdata.py
@@ -1797,6 +1797,8 @@ def get_temp_from_raw_by_program(portnr,program,time_window=0,emi=0.8,T_version=
                             
                             for i in range(len(frames)):
                                 frames[i]=(frames[i]*FOV).astype(np.float32)
+                            
+#                            if portnr!=50:
                             if verbose>0:
                                 print(datetime.datetime.now(),"get_temp_from_raw_by_program: correcting bad pixels")
                             frames=IR_tools.correct_images(frames,badpixels)
@@ -2108,7 +2110,7 @@ def apply_calib_on_raw(images,background,LUT,refT=28.5,gain=0,offset=0,gain_erro
 #        if fullbackground:
         #sbackground=np.zeros(np.shape(images[0]),dtype=np.float32)+background
         for i in range(len(images)):
-            images[i]=np.clip((images[i]-background),a_min=0,a_max=None).astype(np.uint16)
+            images[i]=np.clip((images[i].astype(np.int32)-background),a_min=0,a_max=None).astype(np.uint16)
 #        else:
 #            for i in range(len(images)):
 #                images[i]=images[i]-background
@@ -2638,7 +2640,7 @@ def download_heatflux_by_times(port,tstart,tend,time_window=0,threads=1,testmode
                 if verbose>0:
                     print(now,"download_heatflux_by_times: heat flux data is not available, creating request")          
                 if request:
-                    f=open(heatflux_requestlist_path+str(now.year)+str(now.month)+"_q_requests.txt",'a')
+                    f=open(heatflux_requestlist_path+str(now.year)+str(now.month-1)+"_q_requests.txt",'a')
                     try:
                         programid=AKF_2.get_program_id(tstart)
                     except Exception as E:
@@ -3333,24 +3335,30 @@ if __name__=='__main__':
     print("local function calling") 
     
 #%% temperature download and plotting example                  
-#    port=50#"AEF50"#"AEF51"
-#    prog="20180920.042"#"20171109.021"#"20181010.036"
-#    status,time,images,valid=get_temp_from_raw_by_program(port,prog,time_window=[0,2],emi=0.82,T_version=2,version=0,threads=1,give_ERROR=False,use_firstframe_as_background=False,verbose=50,framerate=1)
+    port=50#"AEF50"#"AEF51"
+    prog='20170927.020'#"20181011.036"#"20181016.037"#"20180920.042"#"20171109.021"#"20181010.036"
+    status,time,images,valid=get_temp_from_raw_by_program(port,prog,time_window=[0,4],emi=0.80,T_version=2,version=0,threads=4,give_ERROR=False,use_firstframe_as_background=False,verbose=5)
+#    status2,time2,images2=download_raw_images_by_program(port,prog,time_window=0.02,verbose=5)
+#    bla=get_calib_data(50,program=prog,verbose=5)
 #    success,t,s,profile=extract_temperature_profile_from_DL(port,np.asarray(time-time[0])/1e9,images,profile="TM3h_5_5",verbose=10,reference_time=time[0])
-#    if status:
-#        plt.figure()
-#        plt.imshow(images[0],vmin=330,vmax=1000,cmap=exJet)
-#        cb=plt.colorbar()
-#        cb.set_label("temperature in K",rotation=270,labelpad=20,fontsize=20)
-#        cb.ax.tick_params(labelsize=20)
+    if status:
+        plt.figure()
+        plt.imshow(images[0],vmin=330,vmax=1000,cmap=exJet)
+        cb=plt.colorbar()
+        cb.set_label("temperature in K",rotation=270,labelpad=20,fontsize=20)
+        cb.ax.tick_params(labelsize=20)
 #%% heatflux test
 #    port=10
-#    prog="20171114.039"    
-#    status,time,images=download_heatflux_by_program(port,prog,timewindow=0.5,threads=1,version=1,verbose=3,givealpha=False,request=True)
-#    if status:
-#        print(prog,port,"OK")
-#    else:
-#        print(prog,port,"missing")
+#    prog="20180904.015" 
+#    
+#    for prog in ["20180823.016","20180918.045","20181016.037","20181009.024","20181016.016"]:#"20171207.024","20180814.024","20181016.016","20181010.036"]:
+#        for port in [10,11,20,21,30,31,40,41,50,51]:
+#            status,time,images=download_heatflux_by_program(port,prog,time_window=4,threads=4,version=2,verbose=3,givealpha=False,request=True)            
+##            status,time,load,error=download_divertor_load(port,targetmodule=['all','tm1h'],program=prog,verbose=5,version=3)
+#            if status:
+#                print(prog,port,"OK")
+#            else:
+#                print(prog,port,"missing")
 #        plt.figure(),plt.imshow(images[0],vmin=0)
 #        plt.figure(),plt.imshow(images[50],vmin=0)
 #    status,mapping=download_heatflux_mapping_reference(verbose=4)
diff --git a/plot_IR_data.py b/plot_IR_data.py
index 6c34d00124d2b71bcdbf03dcf5dd455aa58d2fe7..29a58e57133eebac5461baa33c45068c192f8f68 100644
--- a/plot_IR_data.py
+++ b/plot_IR_data.py
@@ -15,7 +15,7 @@ if __name__=='__main__':
     
     #%% loading data
     print(datetime.datetime.now(),"start")
-    status,time,images,valid=downIR.get_temp_from_raw_by_program(10,"20180801.017",time_s=2.5,emi=0.8,T_version=2,version=0,threads=1,give_ERROR=False,verbose=5)
+    status,time,images,valid=downIR.get_temp_from_raw_by_program(10,"20180801.017",time_window=2.5,emi=0.8,T_version=2,version=0,threads=1,give_ERROR=False,verbose=5)
     print('fertig')
     
     #%% plotting data
diff --git a/plot_heatflux_example.py b/plot_heatflux_example.py
index db6091d7c91a9f58e0ef591a6b88ac560fcdae16..67e41e6c4734f611650469457eb11d7cf559b94c 100644
--- a/plot_heatflux_example.py
+++ b/plot_heatflux_example.py
@@ -16,12 +16,12 @@ if __name__=='__main__':
     
     #%% loading data
     print(datetime.datetime.now(),"start")
-    status,times,images=IR.download_heatflux_by_program(port,program,time_window=0.9,version=1,threads=1,verbose=5,testmode=False)
+    status,times,images=IR.download_heatflux_by_program(port,program,time_window=6.5,version=2,threads=1,verbose=5,testmode=False)
     print('done')
     
     #%% plotting data
     if status:
-        status2,time,s,q=IR.extract_heatflux_profile_from_DL((np.asarray(times)-times[0])/1e9,images,profile="TM3h_5_5",time_window=0.5,verbose=5,testmode=False)        
+        status2,time,s,q=IR.extract_heatflux_profile_from_DL((np.asarray(times)-times[0])/1e9,images,profile="TM3h_5_5",time_window=None,verbose=5,testmode=False)        
         plt.figure()
         plt.imshow(images[-1]/1e6)
         plt.clim([0,4])