Improvements to surface RoC initialisation
There are some aspects of the initialisation of the Surface Rcx
and Rcy
parameters I'd like to change as currently it's not so intuitive in my opinion. Right now we have a single Rc
value in Surface.__init__
(and correspondingly in Mirror
, Beamsplitter
); if a sequence of length 2 is passed to this then Rcx
, Rcy
will be set accordingly; otherwise they both get set to the same value. This is a little cumbersome, especially from the kat syntax side and even more especially when trying to initialise a surface such that Rcx
and Rcy
remain equal, so I propose some changes below.
I think the arguments should instead be (ignoring all the other args):
class Surface:
def __init__(self, Rc=None, Rcx=None, Rcy=None):
# (First thing would be sanity checks on combinations of None / not None of course)
# Default case is just make a flat surface
if Rc is None and Rcx is None and Rcy is None:
self.Rcx = np.inf
self.Rcy = np.inf
# If only Rc is specified then make a non-astigmatic surface where
# self.Rcy is automatically set to reference of Rcx
if Rc is not None:
self.Rcx = Rc
self.Rcy = self.Rcx.ref
# Or if Rcx and Rcy given then set both accordingly --- note that this could
# be used to also make a non-astigmatic surface but where Rcy is not auto set
# to reference of Rcx
else:
self.Rcx = Rcx
self.Rcy = Rcy
This is motivated by the fact that when someone makes a surface with equal Rcx and Rcy, they typically want both
to be set simultaneously when scanning one. But if not then they can just use Rcx
and Rcy
during construction
instead of Rc
.
If people don't like this hidden reference setting (or if it's not possible at component construction time due to
some other limitation) then the same as above could be used but the second if
block would be changed to:
if Rc is not None:
self.Rcx = Rc
self.Rcy = Rc
i.e. not automatically setting Rcy
to reference of Rcx
.
Either way, I think splitting the arguments up in this way makes it clearer as to how non-astigmatic vs. astigmatic
surfaces are initialised; and removes ugliness in kat-files where Rc
values would be set to tuples for astigmatic surfaces. The only issue I can
think of with this splitting up of arguments may be some headaches when generating kat script from the model as it
might end up dumping values into all of Rc
, Rcx
and Rcy
(which would then cause errors when parsing the file
again) --- but maybe there's an easy way around this issue, @sean-leavey is the best person to comment on this really.
Please let me know if anyone has thoughts on any of this.