Skip to content
Snippets Groups Projects
Commit b1fe1ac5 authored by rfetick's avatar rfetick
Browse files

use super() for subclasses, use __str__

parent ce8b303e
No related branches found
No related tags found
No related merge requests found
......@@ -78,7 +78,7 @@ class Instrument:
self.phasemask_shift = (0.0,0.0)
self._phasemask = None
def __repr__(self):
def __str__(self):
s = "---------------------------------\n"
s += self.fullname+"\n"
s += "---------------------------------\n"
......
......@@ -226,20 +226,27 @@ class ParametricPSF:
Not to be instantiated, only serves as a referent for subclasses
"""
def __init__(self,npix):
def __init__(self, nparam, npix):
"""
Parameters
----------
npix : tuple of two elements
Model X and Y pixel size when called
"""
if type(npix)!=tuple:
if not isinstance(nparam, int):
raise TypeError("Argument `nparam` must be an integer")
if not isinstance(npix, tuple):
raise TypeError("Argument `npix` must be a tuple")
self.npix = npix
self.bounds = ()
self._nparam = nparam
self.bounds = ((-np.inf,)*nparam, (np.inf,)*nparam)
def __repr__(self):
return "ParametricPSF of size (%u,%u)"%self.npix
def __str__(self):
s = "ParametricPSF\n"
s += "-------------\n"
s += "pixels : (%u,%u)\n"%self.npix
s += "nb param: %u"%self._nparam
return s
def __call__(self,*args,**kwargs):
raise ValueError("ParametricPSF is not made to be instantiated. Better use its subclasses")
......@@ -287,9 +294,8 @@ class ConstantPSF(ParametricPSF):
With such a formalism, a constant PSF is just a particular case of a parametric PSF
"""
def __init__(self,image_psf):
super().__init__(np.shape(image_psf))
super().__init__(0, np.shape(image_psf))
self.image_psf = image_psf
self.bounds = ()
def __call__(self,*args,**kwargs):
return self.image_psf
......@@ -297,8 +303,8 @@ class ConstantPSF(ParametricPSF):
class Moffat(ParametricPSF):
"""Moffat PSF model"""
def __init__(self,npix,norm=np.inf):
self.npix = npix
def __init__(self, npix, norm=np.inf):
super().__init__(4, npix)
self.norm = norm
bounds_down = [_EPSILON,_EPSILON,-np.inf,1+_EPSILON]
bounds_up = [np.inf for i in range(4)]
......@@ -329,8 +335,8 @@ class Moffat(ParametricPSF):
class Gaussian(ParametricPSF):
"""Gaussian PSF model"""
def __init__(self,npix):
self.npix = npix
def __init__(self, npix):
super().__init__(3, npix)
bounds_down = [_EPSILON,_EPSILON,-np.inf]
bounds_up = [np.inf for i in range(3)]
self.bounds = (bounds_down,bounds_up)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment