From ab1a68174debdf1307de85a12c6abb9bc59dbb7a Mon Sep 17 00:00:00 2001 From: Alan Loh Date: Tue, 10 Oct 2023 17:56:08 +0200 Subject: [PATCH] Gain interpolation shape correction --- nenupy/__init__.py | 2 +- nenupy/astro/astro_tools.py | 5 +++-- nenupy/instru/nenufar.py | 11 +++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/nenupy/__init__.py b/nenupy/__init__.py index 47d5c1f..7a17693 100644 --- a/nenupy/__init__.py +++ b/nenupy/__init__.py @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2023, nenupy" __credits__ = ["Alan Loh"] __license__ = "MIT" -__version__ = "2.3.13" +__version__ = "2.3.14" __maintainer__ = "Alan Loh" __email__ = "alan.loh@obspm.fr" diff --git a/nenupy/astro/astro_tools.py b/nenupy/astro/astro_tools.py index c0f460d..7f67c14 100644 --- a/nenupy/astro/astro_tools.py +++ b/nenupy/astro/astro_tools.py @@ -1181,8 +1181,9 @@ def hour_angle(self, fast_compute: bool = True) -> Longitude: # ============================================================= # # ----------------------- faraday_angle ----------------------- # # ============================================================= # -@u.quantity_input -def faraday_angle(frequency: u.Quantity[u.MHz], rotation_measure: u.Quantity[u.rad/u.m**2], inverse: bool = False): +# @u.quantity_input +# def faraday_angle(frequency: u.Quantity[u.MHz], rotation_measure: u.Quantity[u.rad/u.m**2], inverse: bool = False): +def faraday_angle(frequency: u.Quantity, rotation_measure: u.Quantity, inverse: bool = False): """ Computes the Faraday rotation angle. :param frequency: diff --git a/nenupy/instru/nenufar.py b/nenupy/instru/nenufar.py index 1760ea6..3e71ed5 100644 --- a/nenupy/instru/nenufar.py +++ b/nenupy/instru/nenufar.py @@ -130,9 +130,9 @@ def __getitem__(self, sky: Sky) -> np.ndarray: # Find the interpolated gain at the desired frequency #gain = self.interpolated_gain(self.healpix_coords, freqs) #gain = self.interpolated_gain((freqs, self.healpix_coords)) - gain = self.interpolated_gain(freqs) - if gain.ndim == 1: - gain = gain.reshape((1, gain.size)) + gain = self.interpolated_gain(freqs) # shape: (freq, pix_coord) + # if gain.ndim == 1: + # gain = gain.reshape((1, gain.size)) # Find the interpolated gain at the desired coordinates for each frequency gain = np.array([ @@ -145,8 +145,11 @@ def __getitem__(self, sky: Sky) -> np.ndarray: ) for gain_i in gain ]) + if gain.ndim == 2: + # The time dimension is not yet included + gain = gain.reshape((1,) + gain.shape) # Return something shaped as (time, freq, coord) - return gain#np.moveaxis(gain, 0, 1) + return np.moveaxis(gain, 0, 1) # keep that! #return gain.reshape((1,) + gain.shape) # use with RegularGridInterpolator