Commit b57ce29e authored by rfetick's avatar rfetick
Browse files

syntax improvement

parent 853b5eac
......@@ -30,3 +30,4 @@ pip-delete-this-directory.txt
.cache
nosetests.xml
coverage.xml
.pylint.d/
......@@ -58,7 +58,7 @@ class ParametricPSF:
def list2dict(self, lst):
"""Transform a list of parameters into a dictionary"""
return {k:v for (k,v) in zip(self.param_name,lst)}
return dict(zip(self.param_name,lst))
def __call__(self, *args, **kwargs):
raise NotImplementedError("ParametricPSF is not made to be instantiated. Better use its subclasses")
......@@ -225,7 +225,10 @@ class ParametricPSFfromPSD(ParametricPSF):
@property
def npixOver(self):
"""Return the number of pixels for the correctly sampled array (at least at Shannon-Nyquist)"""
"""
Return the number of pixels for the correctly sampled array
(at least at Shannon-Nyquist)
"""
return self.npix[0]*self._k, self.npix[1]*self._k
......@@ -507,8 +510,8 @@ class Turbulent(ParametricPSFfromPSD):
self.check_parameters(parampsd)
nx0,ny0 = self._nullFreqIndex
r0,Lext = parampsd
psd = 0.0229* r0**(-5./3.) * ((1./Lext**2.) + self._f2)**(-11./6.)
r0,lext = parampsd
psd = 0.0229* r0**(-5./3.) * ((1./lext**2.) + self._f2)**(-11./6.)
# Set PSD = 0 at null frequency
psd[nx0,ny0] = 0.0
......@@ -522,7 +525,7 @@ class Turbulent(ParametricPSFfromPSD):
if grad:
gg = np.zeros((len(parampsd),)+self._f2.shape)
gg[0,...] = psd*(-5./3)/r0
gg[1,...] = psd*(-11./6)/((1./Lext**2.) + self._f2)*(-2/Lext**3)
gg[1,...] = psd*(-11./6)/((1./lext**2.) + self._f2)*(-2/lext**3)
# compute integral gradient
integral_g = [0,0]
......@@ -559,7 +562,7 @@ class Psfao(ParametricPSFfromPSD):
Fétick et al., August 2019, A&A, Vol.628
"""
def __init__(self, npix, system=None, Lext=10., samp=None, fixed_k=None):
def __init__(self, npix, system=None, lext=10., samp=None, fixed_k=None):
"""
Parameters
----------
......@@ -572,13 +575,13 @@ class Psfao(ParametricPSFfromPSD):
Optical system for this PSF
samp : float
Sampling at the observation wavelength
Lext : float
lext : float
Von-Karman external scale (default = 10 m)
Useless if Fao >> 1/Lext
Useless if Fao >> 1/lext
fixed_k : int
Define a fixed oversampling factor
"""
self.Lext = Lext
self.lext = lext
self._maskin = None
self._vk = None
super().__init__(7,npix,system=system,samp=samp,fixed_k=fixed_k)
......@@ -602,7 +605,7 @@ class Psfao(ParametricPSFfromPSD):
def _computeXYarray(self):
super()._computeXYarray()
self._maskin = (self._f2 < self.cutoffAOfreq**2.)
self._vk = (1-self._maskin) * 0.0229 * ((1. / self.Lext**2.) + self._f2)**(-11./6.)
self._vk = (1-self._maskin) * 0.0229 * ((1. / self.lext**2.) + self._f2)**(-11./6.)
@property
......@@ -650,11 +653,11 @@ class Psfao(ParametricPSFfromPSD):
remove_inside = (1+np.sqrt(2))/2 * pix/2 # remove central pixel in energy computation
if grad:
moff,dm = moffat_center(self._fx2, self._fxy, self._fy2,
param, norm=self.cutoffAOfreq, removeInside=remove_inside, grad=True)
moff,dm = moffat_center(self._fx2, self._fxy, self._fy2, param,
norm=self.cutoffAOfreq, removeInside=remove_inside, grad=True)
else:
moff = moffat_center(self._fx2, self._fxy, self._fy2,
param, norm=self.cutoffAOfreq, removeInside=remove_inside, grad=False)
moff = moffat_center(self._fx2, self._fxy, self._fy2, param,
norm=self.cutoffAOfreq, removeInside=remove_inside, grad=False)
moff *= self._maskin
numerical_norm = False # set to true in order to activate code below
......@@ -728,7 +731,7 @@ class Psfao(ParametricPSFfromPSD):
hdr["HIERARCH SYSTEM D"] = (self.system.D,"Primary mirror diameter")
hdr["HIERARCH SYSTEM NACT"] = (self.system.Nact,"Linear number of AO actuators")
hdr["HIERARCH SAMP"] = (self.samp,"Sampling (eg. 2 for Shannon)")
hdr["HIERARCH LEXT"] = (self.Lext,"Von-Karman outer scale")
hdr["HIERARCH lext"] = (self.lext,"Von-Karman outer scale")
hdu = fits.PrimaryHDU(psf, hdr)
hdu.writeto(filename)
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