@@ -633,7 +633,11 @@ def batoidModelName(self, value: str | None) -> None:
633633 @property
634634 def batoidOffsetOptic (self ) -> str | None :
635635 """The optic that is offset in the Batoid model."""
636- return self ._batoidOffsetOptic
636+ # Default to the detector if value not explicitly set
637+ if self ._batoidOffsetOptic is None and self .batoidModelName is not None :
638+ return "Detector"
639+ else :
640+ return self ._batoidOffsetOptic
637641
638642 @batoidOffsetOptic .setter
639643 def batoidOffsetOptic (self , value : str | None ) -> None :
@@ -734,6 +738,7 @@ def _getIntrinsicZernikesCached(
734738 self ,
735739 xAngle : float ,
736740 yAngle : float ,
741+ defocalType : DefocalType | None ,
737742 band : BandLabel | str ,
738743 jmax : int ,
739744 ) -> np .ndarray :
@@ -747,6 +752,9 @@ def _getIntrinsicZernikesCached(
747752 The x-component of the field angle in degrees.
748753 yAngle : float
749754 The y-component of the field angle in degrees.
755+ defocalType : DefocalType or str or None
756+ The DefocalType Enum or corresponding string, specifying which side
757+ of focus to model. If None, the model is not defocused.
750758 band : BandLabel or str, optional
751759 The BandLabel Enum or corresponding string, specifying which batoid
752760 model to load. Only relevant if self.batoidModelName contains
@@ -769,6 +777,13 @@ def _getIntrinsicZernikesCached(
769777 if batoidModel is None :
770778 return np .zeros (jmax + 1 )
771779
780+ # Offset the focal plane
781+ if defocalType is not None :
782+ defocalType = DefocalType (defocalType )
783+ defocalSign = + 1 if defocalType == DefocalType .Extra else - 1
784+ offset = [0 , 0 , defocalSign * self .defocalOffset ]
785+ batoidModel = batoidModel .withLocallyShiftedOptic (self .batoidOffsetOptic , offset )
786+
772787 # Get the wavelength
773788 if len (self .wavelength ) > 1 :
774789 wavelength = self .wavelength [band ]
@@ -794,6 +809,7 @@ def getIntrinsicZernikes(
794809 self ,
795810 xAngle : float ,
796811 yAngle : float ,
812+ defocalType : DefocalType | None = None ,
797813 band : BandLabel | str = BandLabel .REF ,
798814 nollIndices : Sequence [int ] = tuple (np .arange (4 , 79 )),
799815 ) -> np .ndarray :
@@ -805,6 +821,9 @@ def getIntrinsicZernikes(
805821 The x-component of the field angle in degrees.
806822 yAngle : float
807823 The y-component of the field angle in degrees.
824+ defocalType : DefocalType or str or None
825+ The DefocalType Enum or corresponding string, specifying which side
826+ of focus to model. If None, the model is not defocused.
808827 band : BandLabel or str, optional
809828 The BandLabel Enum or corresponding string, specifying which batoid
810829 model to load. Only relevant if self.batoidModelName contains
@@ -822,7 +841,13 @@ def getIntrinsicZernikes(
822841 nollIndices = np .array (nollIndices )
823842
824843 # Retrieve cached Zernikes
825- zk = self ._getIntrinsicZernikesCached (xAngle , yAngle , band , max (nollIndices ))
844+ zk = self ._getIntrinsicZernikesCached (
845+ xAngle = xAngle ,
846+ yAngle = yAngle ,
847+ defocalType = defocalType ,
848+ band = band ,
849+ jmax = max (nollIndices ),
850+ )
826851
827852 return zk [nollIndices ]
828853
@@ -831,7 +856,7 @@ def _getIntrinsicZernikesTACached(
831856 self ,
832857 xAngle : float ,
833858 yAngle : float ,
834- defocalType : DefocalType ,
859+ defocalType : DefocalType | None ,
835860 band : BandLabel | str ,
836861 jmax : int ,
837862 ) -> np .ndarray :
@@ -843,9 +868,9 @@ def _getIntrinsicZernikesTACached(
843868 The x-component of the field angle in degrees.
844869 yAngle : float
845870 The y-component of the field angle in degrees.
846- defocalType : DefocalType or str
871+ defocalType : DefocalType or str or None
847872 The DefocalType Enum or corresponding string, specifying which side
848- of focus to model.
873+ of focus to model. If None, the model is not defocused.
849874 band : BandLabel or str
850875 The BandLabel Enum or corresponding string, specifying which
851876 batoid model to load. Only relevant if self.batoidModelName
@@ -877,10 +902,11 @@ def _getIntrinsicZernikesTACached(
877902 return np .zeros (jmax + 1 )
878903
879904 # Offset the focal plane
880- defocalType = DefocalType (defocalType )
881- defocalSign = + 1 if defocalType == DefocalType .Extra else - 1
882- offset = [0 , 0 , defocalSign * self .defocalOffset ]
883- batoidModel = batoidModel .withLocallyShiftedOptic ("Detector" , offset )
905+ if defocalType is not None :
906+ defocalType = DefocalType (defocalType )
907+ defocalSign = + 1 if defocalType == DefocalType .Extra else - 1
908+ offset = [0 , 0 , defocalSign * self .defocalOffset ]
909+ batoidModel = batoidModel .withLocallyShiftedOptic (self .batoidOffsetOptic , offset )
884910
885911 # Get the wavelength
886912 if len (self .wavelength ) > 1 :
@@ -909,7 +935,7 @@ def getOffAxisCoeff(
909935 self ,
910936 xAngle : float ,
911937 yAngle : float ,
912- defocalType : DefocalType ,
938+ defocalType : DefocalType | None ,
913939 band : BandLabel | str = BandLabel .REF ,
914940 nollIndicesModel : Sequence = tuple (np .arange (4 , 79 )),
915941 nollIndicesIntr : Sequence = tuple (np .arange (4 , 79 )),
@@ -922,9 +948,9 @@ def getOffAxisCoeff(
922948 The x-component of the field angle in degrees.
923949 yAngle : float
924950 The y-component of the field angle in degrees.
925- defocalType : DefocalType or str
951+ defocalType : DefocalType or str or None
926952 The DefocalType Enum or corresponding string, specifying which side
927- of focus to model.
953+ of focus to model. If None, the model is not defocused.
928954 band : BandLabel or str, optional
929955 The BandLabel Enum or corresponding string, specifying which
930956 batoid model to load. Only relevant if self.batoidModelName
@@ -952,19 +978,20 @@ def getOffAxisCoeff(
952978
953979 # Get zernikeTA
954980 zkTA = self ._getIntrinsicZernikesTACached (
955- xAngle ,
956- yAngle ,
957- defocalType ,
958- band ,
959- max (nollIndicesModel ),
981+ xAngle = xAngle ,
982+ yAngle = yAngle ,
983+ defocalType = defocalType ,
984+ band = band ,
985+ jmax = max (nollIndicesModel ),
960986 )
961987
962988 # Get regular intrinsic zernikes
963989 zk = self ._getIntrinsicZernikesCached (
964- xAngle ,
965- yAngle ,
966- band ,
967- max (nollIndicesIntr ),
990+ xAngle = xAngle ,
991+ yAngle = yAngle ,
992+ defocalType = None ,
993+ band = band ,
994+ jmax = max (nollIndicesIntr ),
968995 )
969996
970997 # Subtract intrinsics from zernikeTA
0 commit comments