From 6ef3c5a328f021cfc734fad6eccce301055e35c9 Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Wed, 3 Jul 2024 11:40:10 -0700 Subject: [PATCH 1/6] Revert "FIXME: override datamodels.open" This reverts commit 701a431a0ed01e138776ab4098ed29cb513c353f. --- .../dark_current/dark_current_step.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/liger_iris_pipeline/dark_current/dark_current_step.py b/liger_iris_pipeline/dark_current/dark_current_step.py index ebca3fd..d7d13f1 100644 --- a/liger_iris_pipeline/dark_current/dark_current_step.py +++ b/liger_iris_pipeline/dark_current/dark_current_step.py @@ -22,19 +22,6 @@ class DarkCurrentStep(Step): reference_file_types = ["dark"] - #FIXME - This will need to be ported to a new LigerIrisStep class - # I do not understand why this is necessary, in JWST it seems like - # this is not needed and works out of the box. - # Without this, the pipeline tries to call `datamodes.open` on a - # file that is already open, which gives the error: - # expected str, bytes or os.PathLike object, not LigerIrisDataModel - @classmethod - def _datamodels_open(cls, init, **kwargs): - if issubclass(init.__class__, stdatamodels.model_base.DataModel): - return init - else: - return datamodels.open(init, **kwargs) - def process(self, input): # Open the input data model From 0eb968dd23ed8c065d0cad8094f5aab511d982ea Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Sun, 21 Jul 2024 20:41:36 -0500 Subject: [PATCH 2/6] Revert "Revert "FIXME: override datamodels.open"" This reverts commit 6ef3c5a328f021cfc734fad6eccce301055e35c9. --- .../dark_current/dark_current_step.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/liger_iris_pipeline/dark_current/dark_current_step.py b/liger_iris_pipeline/dark_current/dark_current_step.py index d7d13f1..ebca3fd 100644 --- a/liger_iris_pipeline/dark_current/dark_current_step.py +++ b/liger_iris_pipeline/dark_current/dark_current_step.py @@ -22,6 +22,19 @@ class DarkCurrentStep(Step): reference_file_types = ["dark"] + #FIXME - This will need to be ported to a new LigerIrisStep class + # I do not understand why this is necessary, in JWST it seems like + # this is not needed and works out of the box. + # Without this, the pipeline tries to call `datamodes.open` on a + # file that is already open, which gives the error: + # expected str, bytes or os.PathLike object, not LigerIrisDataModel + @classmethod + def _datamodels_open(cls, init, **kwargs): + if issubclass(init.__class__, stdatamodels.model_base.DataModel): + return init + else: + return datamodels.open(init, **kwargs) + def process(self, input): # Open the input data model From 5f38de034d24c9b3d6bb5574d832c2a413417683 Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Sun, 21 Jul 2024 20:45:14 -0500 Subject: [PATCH 3/6] new base class LigerIrisStep --- .../dark_current/dark_current_step.py | 15 +-------------- liger_iris_pipeline/stpipe/__init__.py | 1 + liger_iris_pipeline/stpipe/step.py | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 liger_iris_pipeline/stpipe/__init__.py create mode 100644 liger_iris_pipeline/stpipe/step.py diff --git a/liger_iris_pipeline/dark_current/dark_current_step.py b/liger_iris_pipeline/dark_current/dark_current_step.py index ebca3fd..ca60634 100644 --- a/liger_iris_pipeline/dark_current/dark_current_step.py +++ b/liger_iris_pipeline/dark_current/dark_current_step.py @@ -1,4 +1,4 @@ -from jwst.stpipe import Step +from ..stpipe import Step from .. import datamodels from ..datamodels import DarkModel from . import dark_sub @@ -22,19 +22,6 @@ class DarkCurrentStep(Step): reference_file_types = ["dark"] - #FIXME - This will need to be ported to a new LigerIrisStep class - # I do not understand why this is necessary, in JWST it seems like - # this is not needed and works out of the box. - # Without this, the pipeline tries to call `datamodes.open` on a - # file that is already open, which gives the error: - # expected str, bytes or os.PathLike object, not LigerIrisDataModel - @classmethod - def _datamodels_open(cls, init, **kwargs): - if issubclass(init.__class__, stdatamodels.model_base.DataModel): - return init - else: - return datamodels.open(init, **kwargs) - def process(self, input): # Open the input data model diff --git a/liger_iris_pipeline/stpipe/__init__.py b/liger_iris_pipeline/stpipe/__init__.py new file mode 100644 index 0000000..128b8f7 --- /dev/null +++ b/liger_iris_pipeline/stpipe/__init__.py @@ -0,0 +1 @@ +from .step import LigerIrisStep as Step diff --git a/liger_iris_pipeline/stpipe/step.py b/liger_iris_pipeline/stpipe/step.py new file mode 100644 index 0000000..4c492e0 --- /dev/null +++ b/liger_iris_pipeline/stpipe/step.py @@ -0,0 +1,19 @@ +from jwst.stpipe import Step +from jwst import datamodels +import stdatamodels + + +class LigerIrisStep(Step): + + # FIXME - This will need to be ported to a new LigerIrisStep class + # I do not understand why this is necessary, in JWST it seems like + # this is not needed and works out of the box. + # Without this, the pipeline tries to call `datamodes.open` on a + # file that is already open, which gives the error: + # expected str, bytes or os.PathLike object, not LigerIrisDataModel + @classmethod + def _datamodels_open(cls, init, **kwargs): + if issubclass(init.__class__, stdatamodels.model_base.DataModel): + return init + else: + return datamodels.open(init, **kwargs) From e94d602b756b4f16fca04a7d2c7a5888f21750e7 Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Mon, 22 Jul 2024 23:45:45 -0500 Subject: [PATCH 4/6] Revert "new base class LigerIrisStep" This reverts commit 5f38de034d24c9b3d6bb5574d832c2a413417683. --- .../dark_current/dark_current_step.py | 15 ++++++++++++++- liger_iris_pipeline/stpipe/__init__.py | 1 - liger_iris_pipeline/stpipe/step.py | 19 ------------------- 3 files changed, 14 insertions(+), 21 deletions(-) delete mode 100644 liger_iris_pipeline/stpipe/__init__.py delete mode 100644 liger_iris_pipeline/stpipe/step.py diff --git a/liger_iris_pipeline/dark_current/dark_current_step.py b/liger_iris_pipeline/dark_current/dark_current_step.py index ca60634..ebca3fd 100644 --- a/liger_iris_pipeline/dark_current/dark_current_step.py +++ b/liger_iris_pipeline/dark_current/dark_current_step.py @@ -1,4 +1,4 @@ -from ..stpipe import Step +from jwst.stpipe import Step from .. import datamodels from ..datamodels import DarkModel from . import dark_sub @@ -22,6 +22,19 @@ class DarkCurrentStep(Step): reference_file_types = ["dark"] + #FIXME - This will need to be ported to a new LigerIrisStep class + # I do not understand why this is necessary, in JWST it seems like + # this is not needed and works out of the box. + # Without this, the pipeline tries to call `datamodes.open` on a + # file that is already open, which gives the error: + # expected str, bytes or os.PathLike object, not LigerIrisDataModel + @classmethod + def _datamodels_open(cls, init, **kwargs): + if issubclass(init.__class__, stdatamodels.model_base.DataModel): + return init + else: + return datamodels.open(init, **kwargs) + def process(self, input): # Open the input data model diff --git a/liger_iris_pipeline/stpipe/__init__.py b/liger_iris_pipeline/stpipe/__init__.py deleted file mode 100644 index 128b8f7..0000000 --- a/liger_iris_pipeline/stpipe/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .step import LigerIrisStep as Step diff --git a/liger_iris_pipeline/stpipe/step.py b/liger_iris_pipeline/stpipe/step.py deleted file mode 100644 index 4c492e0..0000000 --- a/liger_iris_pipeline/stpipe/step.py +++ /dev/null @@ -1,19 +0,0 @@ -from jwst.stpipe import Step -from jwst import datamodels -import stdatamodels - - -class LigerIrisStep(Step): - - # FIXME - This will need to be ported to a new LigerIrisStep class - # I do not understand why this is necessary, in JWST it seems like - # this is not needed and works out of the box. - # Without this, the pipeline tries to call `datamodes.open` on a - # file that is already open, which gives the error: - # expected str, bytes or os.PathLike object, not LigerIrisDataModel - @classmethod - def _datamodels_open(cls, init, **kwargs): - if issubclass(init.__class__, stdatamodels.model_base.DataModel): - return init - else: - return datamodels.open(init, **kwargs) From c2c4453931c38647bd1b6f9830fad8d5c0b70574 Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Mon, 22 Jul 2024 23:48:10 -0500 Subject: [PATCH 5/6] Revert "Revert "Revert "FIXME: override datamodels.open""" This reverts commit 0eb968dd23ed8c065d0cad8094f5aab511d982ea. --- .../dark_current/dark_current_step.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/liger_iris_pipeline/dark_current/dark_current_step.py b/liger_iris_pipeline/dark_current/dark_current_step.py index ebca3fd..d7d13f1 100644 --- a/liger_iris_pipeline/dark_current/dark_current_step.py +++ b/liger_iris_pipeline/dark_current/dark_current_step.py @@ -22,19 +22,6 @@ class DarkCurrentStep(Step): reference_file_types = ["dark"] - #FIXME - This will need to be ported to a new LigerIrisStep class - # I do not understand why this is necessary, in JWST it seems like - # this is not needed and works out of the box. - # Without this, the pipeline tries to call `datamodes.open` on a - # file that is already open, which gives the error: - # expected str, bytes or os.PathLike object, not LigerIrisDataModel - @classmethod - def _datamodels_open(cls, init, **kwargs): - if issubclass(init.__class__, stdatamodels.model_base.DataModel): - return init - else: - return datamodels.open(init, **kwargs) - def process(self, input): # Open the input data model From 8ac4ef988530361f8fc964d63f1ab33d5ecce1d4 Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Mon, 22 Jul 2024 23:58:52 -0500 Subject: [PATCH 6/6] fix: inherit from JwstDataModel Fixes #60 --- liger_iris_pipeline/datamodels/model_base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/liger_iris_pipeline/datamodels/model_base.py b/liger_iris_pipeline/datamodels/model_base.py index 2593cf8..ad13468 100644 --- a/liger_iris_pipeline/datamodels/model_base.py +++ b/liger_iris_pipeline/datamodels/model_base.py @@ -1,6 +1,6 @@ from astropy.time import Time -from stdatamodels import DataModel as _DataModel +from stdatamodels.jwst.datamodels import JwstDataModel as _DataModel __all__ = ["LigerIrisDataModel"] @@ -30,7 +30,8 @@ def get_crds_parameters(self): dict """ return { - key: val for key, val in self.to_flat_dict(include_arrays=False).items() + key: val + for key, val in self.to_flat_dict(include_arrays=False).items() if isinstance(val, (str, int, float, complex, bool)) } @@ -51,4 +52,4 @@ def on_save(self, init): """ super().on_save(init) - self.meta.date = Time.now().isot \ No newline at end of file + self.meta.date = Time.now().isot