Opaque RuntimeWarnings in S3
For reasons that I do not understand, when running Stage 3 I sometimes get many RuntimeWarnings of the type:

> 2022-03-10 14:37:21,622 - stpipe - WARNING - /Users/tjbell1/miniconda3/envs/eureka/lib/python3.9/site-packages/numpy/core/fromnumeric.py:3474: RuntimeWarning: Mean of empty slice.
>   return _methods._mean(a, axis=axis, dtype=dtype,
> 
> 2022-03-10 14:37:21,622 - stpipe - WARNING - /Users/tjbell1/miniconda3/envs/eureka/lib/python3.9/site-packages/numpy/core/_methods.py:189: RuntimeWarning: invalid value encountered in true_divide
>   ret = ret.dtype.type(ret / rcount)
diff --git a/eureka/S3_data_reduction/s3_reduce.py b/eureka/S3_data_reduction/s3_reduce.py
index 25664391..ca07fb9d 100644
--- a/eureka/S3_data_reduction/s3_reduce.py
+++ b/eureka/S3_data_reduction/s3_reduce.py
@@ -158,7 +158,7 @@ def reduceJWST(eventlabel, ecf_path='./', s2_meta=None):
 
     #check for range of background apertures
     if isinstance(meta.bg_hw, list):
-        meta.bg_hw_range = range(meta.bg_hw[0], meta.bg_hw[1]+meta.spec_hw[2], meta.bg_hw[2])
+        meta.bg_hw_range = range(meta.bg_hw[0], meta.bg_hw[1]+meta.bg_hw[2], meta.bg_hw[2])
     else:
         meta.bg_hw_range = [meta.bg_hw]
 
@@ -239,7 +239,7 @@ def reduceJWST(eventlabel, ecf_path='./', s2_meta=None):
                 istart = 0
             for m in range(istart, meta.num_data_files):
                 # Keep track if this is the first file - otherwise MIRI will keep swapping x and y windows
-                if m==istart:
+                if m==istart and meta.spec_hw==meta.spec_hw_range[0] and meta.bg_hw==meta.bg_hw_range[0]:
                     meta.firstFile = True
                 else:
                     meta.firstFile = False
['eureka/S3_data_reduction/s3_reduce.py']