From 02cd903119fa2ff39cb60aaae65d1aad2eb625d5 Mon Sep 17 00:00:00 2001 From: Shannon Osborne Date: Thu, 30 Aug 2018 09:43:18 -0400 Subject: [PATCH 1/3] Shift distorted PSFs back to correct detector position --- webbpsf/distortion.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webbpsf/distortion.py b/webbpsf/distortion.py index 6785a700..cad205c3 100644 --- a/webbpsf/distortion.py +++ b/webbpsf/distortion.py @@ -119,6 +119,10 @@ def apply_distortion(hdulist_or_filename=None, fill_value=0): xnew += xpix_center ynew += ypix_center + # 5) Shift the new indices so the center matches the sci indices + xnew += np.mean(xsci) - np.mean(xnew) + ynew += np.mean(ysci) - np.mean(ynew) + # ############################################### # Interpolate from the original indices (xsci, ysci) on to new indices (xnew, ynew) # noinspection PyTypeChecker From aa189bdf3cde8dbee63f8dbd8eea491c5964cb35 Mon Sep 17 00:00:00 2001 From: Shannon Osborne Date: Thu, 13 Sep 2018 15:28:45 -0400 Subject: [PATCH 2/3] Update fix for distorted PSFs off from detector position --- webbpsf/distortion.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webbpsf/distortion.py b/webbpsf/distortion.py index cad205c3..4a06671c 100644 --- a/webbpsf/distortion.py +++ b/webbpsf/distortion.py @@ -101,6 +101,10 @@ def apply_distortion(hdulist_or_filename=None, fill_value=0): # Going from Idl to Sci this way allows us to add in the distortion xsci, ysci = aper.idl_to_sci(xidl, yidl) + # 6) Shift the sci indices so they match the PSF's position again (moved slightly off from pysiaf calculation) + xsci += xpix_center - np.median(xsci) + ysci += ypix_center - np.median(ysci) + # ############################################### # Create an array of indices (in pixels) that the final data will be interpolated on to # 1) Set up blank indices (in pixels) @@ -119,10 +123,6 @@ def apply_distortion(hdulist_or_filename=None, fill_value=0): xnew += xpix_center ynew += ypix_center - # 5) Shift the new indices so the center matches the sci indices - xnew += np.mean(xsci) - np.mean(xnew) - ynew += np.mean(ysci) - np.mean(ynew) - # ############################################### # Interpolate from the original indices (xsci, ysci) on to new indices (xnew, ynew) # noinspection PyTypeChecker From 0c79dd300a1528d2d8f60e18fa3d37e909b1fb8e Mon Sep 17 00:00:00 2001 From: Shannon Osborne Date: Mon, 22 Oct 2018 17:21:02 -0400 Subject: [PATCH 3/3] PEP8 update --- webbpsf/distortion.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/webbpsf/distortion.py b/webbpsf/distortion.py index 75293731..89d56205 100644 --- a/webbpsf/distortion.py +++ b/webbpsf/distortion.py @@ -1,14 +1,12 @@ -import copy - import astropy.convolution import astropy.io.fits as fits +import copy import numpy as np +import poppy import pysiaf from scipy.interpolate import griddata from scipy.ndimage.interpolation import rotate -import poppy - def _get_default_siaf(instrument, aper_name): """ Store the default SIAF values for distortion and rotation """