Commit ede2e2e9 authored by FETICK Romain's avatar FETICK Romain
Browse files

Merge branch 'alexis_develop' into 'master'

Adding an optional argument for calculating oversampling factor "k"

See merge request !1
parents 31dc34f4 af845360
...@@ -2,7 +2,7 @@ d: 8.0 ...@@ -2,7 +2,7 @@ d: 8.0
filters: {} filters: {}
fullname: VLT MUSE (NFM) fullname: VLT MUSE (NFM)
gain: 5.0 gain: 5.0
nact: 39 nact: 34
name: MUSE_NFM name: MUSE_NFM
occ: 0.14 occ: 0.14
phasemask_path: null phasemask_path: null
......
...@@ -19,9 +19,21 @@ from maoppy.utils import binning as _binning ...@@ -19,9 +19,21 @@ from maoppy.utils import binning as _binning
_EPSILON = _np.sqrt(_sys.float_info.epsilon) _EPSILON = _np.sqrt(_sys.float_info.epsilon)
#%% FUNCTIONS #%% FUNCTIONS
def oversample(samp): def oversample(samp, fixed_k = None):
"""Find the minimal integer that allows oversampling""" """
Find the minimal integer that allows oversampling
Args:
samp (float): input sampling
fixed_k (int, optional): Oversampling factor to be fixed. Defaults to None.
Returns:
(k*samp, k): the oversampling (>=2) and the corresponding oversampling factor
"""
if fixed_k == None:
k = int(_np.ceil(2.0/samp)) k = int(_np.ceil(2.0/samp))
else:
k = fixed_k
return (k*samp,k) return (k*samp,k)
#%% FITTING #%% FITTING
...@@ -399,17 +411,20 @@ class Gaussian(ParametricPSF): ...@@ -399,17 +411,20 @@ class Gaussian(ParametricPSF):
#%% MASTER CLASS #%% MASTER CLASS
class ParametricPSFfromPSD(ParametricPSF): class ParametricPSFfromPSD(ParametricPSF):
"""This class is NOT to be instantiated""" """This class is NOT to be instantiated"""
def __init__(self,nparam,npix,system=None,samp=None): def __init__(self,nparam,npix,system=None,samp=None, fixed_k = None):
if not (type(npix) in [tuple,list,_np.ndarray]): raise ValueError("npix must be a tuple, list or numpy.ndarray") if not (type(npix) in [tuple,list,_np.ndarray]): raise ValueError("npix must be a tuple, list or numpy.ndarray")
if len(npix)!=2: raise ValueError("npix must be of length = 2") if len(npix)!=2: raise ValueError("npix must be of length = 2")
if (npix[0]%2) or (npix[1]%2): raise ValueError("Each npix component must be even") if (npix[0]%2) or (npix[1]%2): raise ValueError("Each npix component must be even")
if system is None: raise ValueError("Keyword `system` must be defined") if system is None: raise ValueError("Keyword `system` must be defined")
if samp is None: raise ValueError("Keyword `samp` must be defined") if samp is None: raise ValueError("Keyword `samp` must be defined")
self.fixed_k = fixed_k
self._npix = npix # "_" to bypass the _xyarray update, that will be made with samp setter self._npix = npix # "_" to bypass the _xyarray update, that will be made with samp setter
self.samp = samp # also init _xyarray self.samp = samp # also init _xyarray
self.system = system self.system = system
self._nparam = nparam self._nparam = nparam
@property @property
def npix(self): def npix(self):
return self._npix return self._npix
...@@ -424,9 +439,9 @@ class ParametricPSFfromPSD(ParametricPSF): ...@@ -424,9 +439,9 @@ class ParametricPSFfromPSD(ParametricPSF):
return self._samp_over/self._k return self._samp_over/self._k
@samp.setter @samp.setter
def samp(self,value): def samp(self, value):
# Manage cases of undersampling # Manage cases of undersampling
self._samp_over, self._k = oversample(value) self._samp_over, self._k = oversample(value, fixed_k = self.fixed_k)
self._computeXYarray() self._computeXYarray()
def _computeXYarray(self): def _computeXYarray(self):
...@@ -637,7 +652,7 @@ class Psfao(ParametricPSFfromPSD): ...@@ -637,7 +652,7 @@ class Psfao(ParametricPSFfromPSD):
--------- ---------
Fétick et al., August 2019, A&A, Vol.628 Fétick et al., August 2019, A&A, Vol.628
""" """
def __init__(self,npix,system=None,Lext=10.,samp=None): def __init__(self,npix,system=None,Lext=10.,samp=None, fixed_k = None):
""" """
Parameters Parameters
---------- ----------
...@@ -651,7 +666,7 @@ class Psfao(ParametricPSFfromPSD): ...@@ -651,7 +666,7 @@ class Psfao(ParametricPSFfromPSD):
Von-Karman external scale (default = 10 m) Von-Karman external scale (default = 10 m)
Useless if Fao >> 1/Lext Useless if Fao >> 1/Lext
""" """
super().__init__(7,npix,system=system,samp=samp) super().__init__(7,npix,system=system,samp=samp,fixed_k=fixed_k)
self.Lext = Lext self.Lext = Lext
# r0,C,A,alpha,ratio,theta,beta # r0,C,A,alpha,ratio,theta,beta
...@@ -694,6 +709,7 @@ class Psfao(ParametricPSFfromPSD): ...@@ -694,6 +709,7 @@ class Psfao(ParametricPSFfromPSD):
removeInside = (1+_np.sqrt(2))/2 * self._pix2freq/2 # remove central pixel in energy computation removeInside = (1+_np.sqrt(2))/2 * self._pix2freq/2 # remove central pixel in energy computation
moff = moffat(f2D,param,norm=Fao,removeInside=removeInside) * (F2 < Fao**2.) moff = moffat(f2D,param,norm=Fao,removeInside=removeInside) * (F2 < Fao**2.)
moff[nx0,ny0] = 0.0 # Set Moffat PSD = 0 at null frequency moff[nx0,ny0] = 0.0 # Set Moffat PSD = 0 at null frequency
# Newly added for the PSFAO19 model
moff = moff / (_np.sum(moff)*self._pix2freq**2) # normalize moffat numerically to get correct A=sigma² in the AO zone moff = moff / (_np.sum(moff)*self._pix2freq**2) # normalize moffat numerically to get correct A=sigma² in the AO zone
# Warning: Moffat numerical normalization generates strehlOTF jump when "_k" is changed # Warning: Moffat numerical normalization generates strehlOTF jump when "_k" is changed
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment