From 3983fe546760808654b8cc0928ed48ef3280bb59 Mon Sep 17 00:00:00 2001 From: teutoburg Date: Thu, 7 Dec 2023 19:05:25 +0100 Subject: [PATCH] Add DeprecationWarnings to all remaining fov_grid methods --- scopesim/effects/apertures.py | 8 +++++--- scopesim/effects/detector_list.py | 5 +++-- scopesim/effects/metis_lms_trace_list.py | 6 ++++++ scopesim/effects/psfs.py | 7 +++++++ scopesim/effects/shifts.py | 5 +++++ scopesim/effects/spectral_trace_list_utils.py | 3 +++ scopesim/effects/surface_list.py | 3 +++ scopesim/effects/ter_curves.py | 5 +++++ 8 files changed, 37 insertions(+), 5 deletions(-) diff --git a/scopesim/effects/apertures.py b/scopesim/effects/apertures.py index fe9309c8..261f64e2 100644 --- a/scopesim/effects/apertures.py +++ b/scopesim/effects/apertures.py @@ -1,7 +1,6 @@ """Effects related to field masks, including spectroscopic slits.""" -from pathlib import Path -import logging +import warnings import yaml import numpy as np @@ -126,7 +125,8 @@ def apply_to(self, obj, **kwargs): # Outdated. Remove when removing all old FOVManager code from effects def fov_grid(self, which="edges", **kwargs): """Return a header with the sky coordinates.""" - logging.warning("DetectorList.fov_grid will be depreciated in v1.0") + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) if which == "edges": self.meta.update(kwargs) return self.header @@ -440,6 +440,8 @@ def apply_to(self, obj, **kwargs): def fov_grid(self, which="edges", **kwargs): """See parent docstring.""" + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) return self.current_slit.fov_grid(which=which, **kwargs) def change_slit(self, slitname=None): diff --git a/scopesim/effects/detector_list.py b/scopesim/effects/detector_list.py index 2ae7b96d..c00a1539 100644 --- a/scopesim/effects/detector_list.py +++ b/scopesim/effects/detector_list.py @@ -1,6 +1,6 @@ """TBA.""" -import logging +import warnings import numpy as np from astropy import units as u @@ -158,7 +158,8 @@ def apply_to(self, obj, **kwargs): def fov_grid(self, which="edges", **kwargs): """Return an ApertureMask object. kwargs are "pixel_scale" [arcsec].""" - logging.warning("DetectorList.fov_grid will be depreciated in v1.0") + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) aperture_mask = None if which == "edges": self.meta.update(kwargs) diff --git a/scopesim/effects/metis_lms_trace_list.py b/scopesim/effects/metis_lms_trace_list.py index 7a4422b9..b54f7e19 100644 --- a/scopesim/effects/metis_lms_trace_list.py +++ b/scopesim/effects/metis_lms_trace_list.py @@ -1,6 +1,7 @@ """SpectralTraceList and SpectralTrace for the METIS LM spectrograph.""" from copy import deepcopy +import warnings import numpy as np from scipy.interpolate import RectBivariateSpline @@ -205,6 +206,11 @@ def fov_grid(self): `x_max`, `y_max`. Spatial limits refer to the sky and are given in arcsec. """ + # TODO: Specify in the warning where the functionality should go! + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release. The functionality should be moved" + " somewhere else.", DeprecationWarning, stacklevel=2) + aperture = self._file["Aperture list"].data[self.meta["slice"]] x_min = aperture["left"] x_max = aperture["right"] diff --git a/scopesim/effects/psfs.py b/scopesim/effects/psfs.py index 4b121ffd..7e033b8b 100644 --- a/scopesim/effects/psfs.py +++ b/scopesim/effects/psfs.py @@ -1,3 +1,4 @@ +import warnings import numpy as np from scipy.signal import convolve from scipy.interpolate import RectBivariateSpline @@ -118,6 +119,8 @@ def apply_to(self, obj, **kwargs): def fov_grid(self, which="waveset", **kwargs): """See parent docstring.""" + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) waveset = [] if which == "waveset": if self._waveset is not None: @@ -210,6 +213,8 @@ def __init__(self, **kwargs): def fov_grid(self, which="waveset", **kwargs): """See parent docstring.""" + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) if which == "waveset": self.meta.update(kwargs) self.meta = utils.from_currsys(self.meta) @@ -312,6 +317,8 @@ def __init__(self, diameter, **kwargs): def fov_grid(self, which="waveset", **kwargs): """See parent docstring.""" + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) wavelengths = [] if which == "waveset" and \ "waverange" in kwargs and \ diff --git a/scopesim/effects/shifts.py b/scopesim/effects/shifts.py index b99d3336..997f5240 100644 --- a/scopesim/effects/shifts.py +++ b/scopesim/effects/shifts.py @@ -1,3 +1,4 @@ +import warnings import numpy as np from astropy import units as u from astropy.table import Table @@ -24,6 +25,8 @@ def apply_to(self, obj, **kwargs): def fov_grid(self, which="shifts", **kwargs): """See parent docstring.""" + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) if which == "shifts": col_names = ["wavelength", "dx", "dy"] waves, dx, dy = [self.get_table(**kwargs)[col] @@ -222,6 +225,8 @@ def apply_to(self, fov, **kwargs): def fov_grid(self, which="shifts", **kwargs): """See parent docstring.""" + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) kwargs.update(self.meta) if "quick_adc" in self.meta: ad = AtmosphericDispersion(**self.meta) diff --git a/scopesim/effects/spectral_trace_list_utils.py b/scopesim/effects/spectral_trace_list_utils.py index 275e6f36..fb69a40a 100644 --- a/scopesim/effects/spectral_trace_list_utils.py +++ b/scopesim/effects/spectral_trace_list_utils.py @@ -10,6 +10,7 @@ """ import logging +import warnings import numpy as np @@ -94,6 +95,8 @@ def fov_grid(self): Spatial limits are determined by the `ApertureMask` effect and are not returned here. """ + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) aperture_id = self.meta["aperture_id"] lam_arr = self.table[self.meta["wave_colname"]] diff --git a/scopesim/effects/surface_list.py b/scopesim/effects/surface_list.py index deadcdc7..95dfd042 100644 --- a/scopesim/effects/surface_list.py +++ b/scopesim/effects/surface_list.py @@ -1,5 +1,6 @@ """TBA.""" +import warnings import numpy as np from astropy import units as u @@ -26,6 +27,8 @@ def __init__(self, **kwargs): self._emission = None def fov_grid(self, which="waveset", **kwargs): + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) wave_edges = [] if which == "waveset": self.meta.update(kwargs) diff --git a/scopesim/effects/ter_curves.py b/scopesim/effects/ter_curves.py index 9b9a5dc3..538f2b22 100644 --- a/scopesim/effects/ter_curves.py +++ b/scopesim/effects/ter_curves.py @@ -1,5 +1,6 @@ """Transmission, emissivity, reflection curves.""" +import warnings import logging from collections.abc import Collection @@ -407,6 +408,8 @@ def __init__(self, **kwargs): self.table["transmission"][mask] = 0 def fov_grid(self, which="waveset", **kwargs): + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) if which == "waveset": self.meta.update(kwargs) self.meta = from_currsys(self.meta) @@ -580,6 +583,8 @@ def apply_to(self, obj, **kwargs): return self.current_filter.apply_to(obj, **kwargs) def fov_grid(self, which="waveset", **kwargs): + warnings.warn("The fov_grid method is deprecated and will be removed " + "in a future release.", DeprecationWarning, stacklevel=2) return self.current_filter.fov_grid(which=which, **kwargs) def change_filter(self, filtername=None):