Skip to content

Commit

Permalink
freeze WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
andykee committed Jul 9, 2024
1 parent 4c5b842 commit 55c2417
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lentil/plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def __init__(self, amplitude=1, opd=0, mask=None, pixelscale=None, diameter=None

def __repr__(self):
return f'{self.__class__.__name__}()'

def __freeze__(self):
return Plane(amplitude=self.amplitude,
opd=self.opd,
mask=self.mask,
pixelscale=self.pixelscale,
diameter=self.diameter,
ptype=self.ptype)

@property
def ptype(self):
Expand Down Expand Up @@ -261,6 +269,22 @@ def copy(self):
:class:`~lentil.Plane`
"""
return copy.deepcopy(self)

def freeze(self):
"""
Return a static copy of this object.
Returns
-------
:class:`~lentil.Plane`
Notes
-----
The behavior of this function can be changed (for example, to freeze
additional custom attributes in a subclass) by modifying the
``Plane.__freeze__()`` method.
"""
return self.__freeze__()

def fit_tilt(self, inplace=False):
"""
Expand Down Expand Up @@ -608,6 +632,14 @@ def __init__(self, amplitude=1, opd=0, mask=None, pixelscale=None,

self.focal_length = focal_length

def __freeze__(self):
return Pupil(amplitude=self.amplitude,
opd=self.opd,
mask=self.mask,
pixelscale=self.pixelscale,
diameter=self.diameter,
focal_length=self.focal_length)

def multiply(self, wavefront):

wavefront = super().multiply(wavefront)
Expand Down Expand Up @@ -656,6 +688,14 @@ def __init__(self, amplitude=1, opd=0, mask=None, pixelscale=None,
pixelscale=pixelscale, ptype=lentil.image,
**kwargs)

def __freeze__(self):
return Image(amplitude=self.amplitude,
opd=self.opd,
mask=self.mask,
pixelscale=self.pixelscale,
diameter=self.diameter,
ptype=self.ptype)

def fit_tilt(self, *args, **kwargs):
return self

Expand Down

0 comments on commit 55c2417

Please sign in to comment.