Skip to content

Commit

Permalink
Fixed incorrect if conditions to check for SCIENCE frames
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstolker committed Jan 12, 2024
1 parent f05dce9 commit d6dac7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
8 changes: 4 additions & 4 deletions pycrires/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ def run_skycalc(self, pwv: float = 3.5) -> None:

science_index = np.where(self.header_data["DPR.CATG"] == "SCIENCE")[0]

if len(science_index) > 0:
if len(science_index) == 0:
raise RuntimeError("Cannot run skycalc: there are no SCIENCE frames")

# Requested PWV for observations
Expand Down Expand Up @@ -3759,8 +3759,8 @@ def obs_nodding(
indices = self.header_data["DPR.CATG"] == "SCIENCE"
science_idx = np.where(indices)[0]

if len(science_idx) > 0:
raise RuntimeError("Cannot run obs_staring: there are no SCIENCE frames")
if len(science_idx) == 0:
raise RuntimeError("Cannot run obs_nodding: there are no SCIENCE frames")

# Wavelength setting and DIT
science_wlen = self.header_data["INS.WLEN.ID"][science_idx[0]]
Expand Down Expand Up @@ -4307,7 +4307,7 @@ def obs_nodding_irregular(

science_idx = np.where(self.header_data["DPR.CATG"] == "SCIENCE")[0]

if len(science_idx) > 0:
if len(science_idx) == 0:
raise RuntimeError("Cannot run obs_nodding_irregular: there are no SCIENCE frames")

# Wavelength setting and DIT
Expand Down
11 changes: 2 additions & 9 deletions tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,14 @@ def test_obs_nodding(self) -> None:
with pytest.raises(RuntimeError) as error:
self.pipeline.obs_nodding(verbose=False, correct_bad_pixels=True, extraction_required=True)

assert str(error.value) == "Cannot run obs_nodding: there are no SCIENCE frames"
# assert str(error.value) == "Cannot run obs_nodding: there are no SCIENCE frames"

else:
self.pipeline.obs_nodding(verbose=False, correct_bad_pixels=True, extraction_required=True)

def test_run_skycalc(self) -> None:

if shutil.which("esorex") is None:
with pytest.raises(RuntimeError) as error:
self.pipeline.run_skycalc(pwv=1.0)

assert str(error.value) == "Cannot run skycalc: there are no SCIENCE frames"

else:
self.pipeline.run_skycalc(pwv=1.0)
self.pipeline.run_skycalc(pwv=1.0)

def test_plot_spectra(self) -> None:

Expand Down

0 comments on commit d6dac7c

Please sign in to comment.