fakecbed 0.5.1__py3-none-any.whl → 0.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fakecbed/discretized.py CHANGED
@@ -635,14 +635,17 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
635
635
 
636
636
  Let :math:`u_{x}` and :math:`u_{y}` be the fractional horizontal and
637
637
  vertical coordinates, respectively, of a point in an undistorted image,
638
- where :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)` is the bottom left
639
- corner of the image. Secondly, let :math:`q_{x}` and :math:`q_{y}` be the
638
+ where :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
639
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
640
+ left [upper right] corner of the lower left [upper right] pixel of the
641
+ undistorted image. Secondly, let :math:`q_{x}` and :math:`q_{y}` be the
640
642
  fractional horizontal and vertical coordinates, respectively, of a point in
641
643
  a distorted image, where :math:`\left(q_{x},q_{y}\right)=\left(0,0\right)`
642
- is the bottom left corner of the image. When users specify the distortion
643
- model, represented by an instance of the class
644
- :class:`distoptica.DistortionModel`, they also specify a coordinate
645
- transformation, :math:`\left(T_{⌑;x}\left(u_{x},u_{y}\right),
644
+ :math:`\left[\left(q_{x},q_{y}\right)=\left(1,1\right)\right]` is the lower
645
+ left [upper right] corner of the lower left [upper right] pixel of the
646
+ distorted image.. When users specify the distortion model, represented by an
647
+ instance of the class :class:`distoptica.DistortionModel`, they also specify
648
+ a coordinate transformation, :math:`\left(T_{⌑;x}\left(u_{x},u_{y}\right),
646
649
  T_{⌑;y}\left(u_{x},u_{y}\right)\right)`, which maps a given coordinate pair
647
650
  :math:`\left(u_{x},u_{y}\right)` to a corresponding coordinate pair
648
651
  :math:`\left(q_{x},q_{y}\right)`, and implicitly a right-inverse to said
@@ -867,7 +870,18 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
867
870
  \end{cases}
868
871
  :label: LD_I_MF__1
869
872
 
870
- 4. For :math:`0\le k<N_{\text{D}}`, calculate
873
+ 4. Calculate
874
+
875
+ .. math ::
876
+ \mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}\leftarrow
877
+ \mathcal{I}_{\text{TDS}}\left(T_{\square;x}\left(
878
+ q_{\mathring{\mathcal{I}};x;j},
879
+ q_{\mathring{\mathcal{I}};y;i}\right),
880
+ T_{\square;y}\left(q_{\mathring{\mathcal{I}};x;j},
881
+ q_{\mathring{\mathcal{I}};y;i}\right)\right),
882
+ :label: HD_I_CBED__1
883
+
884
+ 5. For :math:`0\le k<N_{\text{D}}`, calculate
871
885
 
872
886
  .. math ::
873
887
  \mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}&
@@ -876,7 +890,7 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
876
890
  q_{\mathring{\mathcal{I}};x;j},q_{\mathring{\mathcal{I}};y;i}\right),
877
891
  T_{\square;y}\left(q_{\mathring{\mathcal{I}};x;j},
878
892
  q_{\mathring{\mathcal{I}};y;i}\right)\right),
879
- :label: HD_I_CBED__1
893
+ :label: HD_I_CBED__2
880
894
 
881
895
  .. math ::
882
896
  \mathring{\mathcal{I}}_{k;\text{DS};⌑;i,j}\leftarrow
@@ -905,7 +919,7 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
905
919
  \mathcal{I}_{\text{DOM};⌑;n,m}+\mathcal{I}_{k;\text{DS};⌑;n,m}.
906
920
  :label: LD_I_DOM__2
907
921
 
908
- 5. Calculate
922
+ 6. Calculate
909
923
 
910
924
  .. math ::
911
925
  \mathcal{I}_{\text{DOM};⌑;n,m}\leftarrow
@@ -914,7 +928,7 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
914
928
  \mathcal{I}_{\text{DOM};⌑;n,m}.
915
929
  :label: LD_I_DOM__3
916
930
 
917
- 6. For :math:`0\le k<N_{\text{M}}`, calculate
931
+ 7. For :math:`0\le k<N_{\text{M}}`, calculate
918
932
 
919
933
  .. math ::
920
934
  \mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}&
@@ -923,9 +937,9 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
923
937
  q_{\mathring{\mathcal{I}};x;j},q_{\mathring{\mathcal{I}};y;i}\right),
924
938
  T_{\square;y}\left(q_{\mathring{\mathcal{I}};x;j},
925
939
  q_{\mathring{\mathcal{I}};y;i}\right)\right).
926
- :label: HD_I_CBED__2
940
+ :label: HD_I_CBED__3
927
941
 
928
- 7. Calculate
942
+ 8. Calculate
929
943
 
930
944
  .. math ::
931
945
  \mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}\leftarrow
@@ -933,21 +947,21 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
933
947
  q_{\mathring{\mathcal{I}};x;j},
934
948
  q_{\mathring{\mathcal{I}};y;i}\right)\right)
935
949
  \left|\mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}\right|.
936
- :label: HD_I_CBED__3
950
+ :label: HD_I_CBED__4
937
951
 
938
- 8. Apply average pooling to
952
+ 9. Apply average pooling to
939
953
  :math:`\mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}` with a kernel of
940
954
  dimensions :math:`\left(N_{\mathring{\mathcal{I}};y}/N_{\mathcal{I};y},
941
955
  N_{\mathring{\mathcal{I}};x}/N_{\mathcal{I};x}\right)`, and store the result
942
956
  in :math:`\mathcal{I}_{\text{CBED};⌑;n,m}`.
943
957
 
944
- 9. Apply a Gaussian filter to :math:`\mathcal{I}_{\text{CBED};⌑;n,m}` that
958
+ 10. Apply a Gaussian filter to :math:`\mathcal{I}_{\text{CBED};⌑;n,m}` that
945
959
  is identical in outcome to that implemented by the function
946
960
  :func:`scipy.ndimage.gaussian_filter`, with ``sigma`` set to
947
961
  ``gaussian_filter_std_dev`` and ``truncate`` set to ``4``, and store the
948
962
  result in :math:`\mathcal{I}_{\text{CBED};⌑;n,m}`.
949
963
 
950
- 10. Calculate
964
+ 11. Calculate
951
965
 
952
966
  .. math ::
953
967
  k_{\text{I};1}\leftarrow
@@ -961,18 +975,18 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
961
975
  k_{\text{I};2}\leftarrow k_{\text{I};1}+N_{\text{DPW}}-1.
962
976
  :label: k_I_2__1
963
977
 
964
- 11. If ``apply_shot_noise`` is set to ``True``, then apply shot/Poisson
978
+ 12. If ``apply_shot_noise`` is set to ``True``, then apply shot/Poisson
965
979
  noise to :math:`\mathcal{I}_{\text{CBED};⌑;n,m}`, and store the result in
966
980
  :math:`\mathcal{I}_{\text{CBED};⌑;n,m}`.
967
981
 
968
- 12. If :math:`N_{\text{DPW}}>0`, then inpaint the pixels in the rows indexed
982
+ 13. If :math:`N_{\text{DPW}}>0`, then inpaint the pixels in the rows indexed
969
983
  from :math:`k_{\text{I};1}` to :math:`k_{\text{I};2}` and the columns
970
984
  indexed from :math:`k_{\text{I};1}` to :math:`k_{\text{I};2}` of the image
971
985
  :math:`\mathcal{I}_{\text{CBED};⌑;n,m}` using the function
972
986
  :func:`skimage.restoration.inpaint_biharmonic`, and store the result in
973
987
  :math:`\mathcal{I}_{\text{CBED};⌑;n,m}`.
974
988
 
975
- 13. Calculate
989
+ 14. Calculate
976
990
 
977
991
  .. math ::
978
992
  \mathcal{I}_{\text{CBED};⌑;n,m}\leftarrow
@@ -981,25 +995,25 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
981
995
  \mathcal{I}_{\text{CBED};⌑;n,m}.
982
996
  :label: LD_I_CBED__1
983
997
 
984
- 14. Update pixels of :math:`\mathcal{I}_{\text{CBED};⌑;n,m}` at pixel
998
+ 15. Update pixels of :math:`\mathcal{I}_{\text{CBED};⌑;n,m}` at pixel
985
999
  locations specified by ``cold_pixels`` to the value of zero.
986
1000
 
987
- 15. Apply min-max normalization of :math:`\mathcal{I}_{\text{CBED};⌑;n,m}`,
1001
+ 16. Apply min-max normalization of :math:`\mathcal{I}_{\text{CBED};⌑;n,m}`,
988
1002
  and store result in :math:`\mathcal{I}_{\text{CBED};⌑;n,m}`.
989
1003
 
990
- 16. Calculate
1004
+ 17. Calculate
991
1005
 
992
1006
  .. math ::
993
1007
  \mathcal{I}_{\text{CS};⌑;n,m}\leftarrow1
994
1008
  -\mathcal{I}_{\text{MF};⌑;n,m}\mathcal{I}_{\text{OI};⌑;n,m}.
995
1009
  :label: LD_I_CS__1
996
1010
 
997
- 17. Convolve a :math:`3 \times 3` filter of ones over a symmetrically unity-padded
1011
+ 18. Convolve a :math:`3 \times 3` filter of ones over a symmetrically unity-padded
998
1012
  :math:`\mathcal{I}_{\text{CS};⌑;n,m}` to yield an output matrix with the
999
1013
  same dimensions of :math:`\mathcal{I}_{\text{CBED};⌑;n,m}`, and store said
1000
1014
  output matrix in :math:`\mathcal{I}_{\text{CS};⌑;n,m}`.
1001
1015
 
1002
- 18. For :math:`0\le k<N_{\text{D}}`, calculate
1016
+ 19. For :math:`0\le k<N_{\text{D}}`, calculate
1003
1017
 
1004
1018
  .. math ::
1005
1019
  \mathcal{I}_{k;\text{DCM};⌑;n,m}\leftarrow
@@ -1008,8 +1022,8 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1008
1022
 
1009
1023
  .. math ::
1010
1024
  \Omega_{k;\text{DCR};⌑}\leftarrow\begin{cases}
1011
- \text{True}, & \text{if }
1012
- \left(\sum_{n,m}\mathcal{I}_{k;\text{DCM};⌑;n,m}\neq0\right)\bigparallel
1025
+ \text{True}, & \text{if }\left.\left(\sum_{n,m}
1026
+ \mathcal{I}_{k;\text{DCM};⌑;n,m}\neq0\right)\right\Vert
1013
1027
  \left(\sum_{n,m}\mathcal{I}_{k;\text{DS};⌑;n,m}=0\right),\\
1014
1028
  \text{False}, & \text{otherwise},
1015
1029
  \end{cases}
@@ -3493,8 +3507,8 @@ class CroppedCBEDPattern(fancytypes.PreSerializableAndUpdatable):
3493
3507
  N_{\mathcal{I};x}=N_{\mathcal{I};y},
3494
3508
  :label: N_I_x_eq_N_I_y__2
3495
3509
 
3496
- Furthermore, let :math:`N_{\text{max-iter}}=30, and let N_{\text{SS}}`
3497
- be ``disk_boundary_sample_size``.
3510
+ Furthermore, let :math:`N_{\text{max-iter}}=30`, and let
3511
+ :math:`N_{\text{SS}}` be ``disk_boundary_sample_size``.
3498
3512
 
3499
3513
  Next, let :math:`\partial S_{\text{PDS};x;l}` and :math:`\partial
3500
3514
  S_{\text{PDS};y;l}` denote
fakecbed/shapes.py CHANGED
@@ -36,12 +36,16 @@ nonnegative.
36
36
 
37
37
  Let :math:`u_{x}` and :math:`u_{y}` be the fractional horizontal and vertical
38
38
  coordinates, respectively, of a point in an undistorted image, where
39
- :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)` is the bottom left corner of
40
- the image. Secondly, let :math:`q_{x}` and :math:`q_{y}` be the fractional
39
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
40
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower left
41
+ [upper right] corner of the lower left [upper right] pixel of the undistorted
42
+ image. Secondly, let :math:`q_{x}` and :math:`q_{y}` be the fractional
41
43
  horizontal and vertical coordinates, respectively, of a point in a distorted
42
- image, where :math:`\left(q_{x},q_{y}\right)=\left(0,0\right)` is the bottom
43
- left corner of the image. When users specify a distortion model, represented by
44
- an :obj:`distoptica.DistortionModel` object, they also specify a coordinate
44
+ image, where :math:`\left(q_{x},q_{y}\right)=\left(0,0\right)`
45
+ :math:`\left[\left(q_{x},q_{y}\right)=\left(1,1\right)\right]` is the lower left
46
+ [upper right] corner of the lower left [upper right] pixel of the distorted
47
+ image. When users specify a distortion model, represented by an
48
+ :obj:`distoptica.DistortionModel` object, they also specify a coordinate
45
49
  transformation which maps a given coordinate pair
46
50
  :math:`\left(u_{x},u_{y}\right)` to a corresponding coordinate pair
47
51
  :math:`\left(q_{x},q_{y}\right)`, and implicitly a right-inverse to said
@@ -277,10 +281,11 @@ class BaseShape(fancytypes.PreSerializableAndUpdatable):
277
281
  r"""Evaluate the intensity pattern of the undistorted shape.
278
282
 
279
283
  Let :math:`u_{x}` and :math:`u_{y}` be the fractional horizontal and
280
- vertical coordinates, respectively, of a point in an undistorted image.
281
- We adopt the convention where the fractional coordinate pair
282
- :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)` is the bottom left
283
- corner of an image.
284
+ vertical coordinates, respectively, of a point in an undistorted image,
285
+ where :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
286
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the
287
+ lower left [upper right] corner of the lower left [upper right] pixel of
288
+ the undistorted image.
284
289
 
285
290
  Parameters
286
291
  ----------
@@ -452,14 +457,23 @@ class Circle(BaseShape):
452
457
 
453
458
  .. math ::
454
459
  \mathcal{I}_{\text{C}}\left(u_{x},u_{y}\right)=
455
- A_{\text{C}}\Theta\left(R_{\text{C}}
456
- -\sqrt{\left(u_{x}-u_{x;c;\text{C}}\right)^{2}
457
- +\left(u_{y}-u_{y;c;\text{C}}\right)^{2}}\right),
460
+ A_{\text{C}}\Theta\left(R_{\text{C}}-u_{r;\text{C}}\right),
458
461
  :label: intensity_pattern_of_circle__1
459
462
 
460
463
  where :math:`u_{x}` and :math:`u_{y}` are fractional horizontal and vertical
461
- coordinates of the undistorted intensity pattern of the circle respectively,
462
- and :math:`\Theta\left(\cdots\right)` is the Heaviside step function.
464
+ coordinates of the undistorted intensity pattern of the circle respectively;
465
+ :math:`\Theta\left(\cdots\right)` is the Heaviside step function; and
466
+
467
+ .. math ::
468
+ u_{r;\text{C}}=\sqrt{\left(u_{x}-u_{x;c;\text{C}}\right)^{2}
469
+ +\left(u_{y}-u_{y;c;\text{C}}\right)^{2}};
470
+ :label: u_r_C__1
471
+
472
+ By fractional coordinates, we mean that
473
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
474
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
475
+ left [upper right] corner of the lower left [upper right] pixel of an image
476
+ of the undistorted intensity pattern.
463
477
 
464
478
  Parameters
465
479
  ----------
@@ -567,8 +581,10 @@ class Circle(BaseShape):
567
581
  delta_u_y = u_y-u_y_c
568
582
 
569
583
  u_r = torch.sqrt(delta_u_x*delta_u_x + delta_u_y*delta_u_y)
584
+
585
+ one = torch.tensor(1.0, device=u_r.device)
570
586
 
571
- result = A * (u_r <= R)
587
+ result = A * torch.heaviside(R-u_r, one)
572
588
 
573
589
  return result
574
590
 
@@ -670,27 +686,47 @@ class Ellipse(BaseShape):
670
686
 
671
687
  .. math ::
672
688
  \mathcal{I}_{\text{E}}\left(u_{x},u_{y}\right)=
673
- A_{\text{E}}\Theta\left(\Theta_{\arg;\text{E}}\left(u_{x},
674
- u_{y}\right)\right),
689
+ A_{\text{E}}\Theta\left(
690
+ R_{\text{E}}\left(u_{\theta;\text{E}}\right)-u_{r;\text{E}}\right),
675
691
  :label: intensity_pattern_of_ellipse__1
676
692
 
677
693
  where :math:`u_{x}` and :math:`u_{y}` are fractional horizontal and vertical
678
694
  coordinates of the undistorted intensity pattern of the ellipse
679
- respectively, :math:`\Theta\left(\cdots\right)` is the Heaviside step
680
- function, and
695
+ respectively; :math:`\Theta\left(\cdots\right)` is the Heaviside step
696
+ function;
681
697
 
682
698
  .. math ::
683
- &\Theta_{\arg;\text{E}}\left(u_{x},u_{y}\right)\\&\quad=
684
- \left\{ 1-e_{\text{E}}^{2}\right\} a_{\text{E}}^{2}\\
685
- &\quad\quad-\left\{ 1-e_{\text{E}}^{2}\right\}
686
- \left\{ \left[u_{x}-u_{x;c;\text{E}}\right]
687
- \cos\left(\theta_{\text{E}}\right)
688
- -\left[u_{y}-u_{y;c;\text{E}}\right]
689
- \sin\left(\theta_{\text{E}}\right)\right\} ^{2}\\
690
- &\quad\quad-\left\{ \left[u_{x}-
691
- u_{x;c;\text{E}}\right]\sin\left(\theta_{\text{E}}\right)+\left[u_{y}-
692
- u_{y;c;\text{E}}\right]\cos\left(\theta_{\text{E}}\right)\right\}^{2}.
693
- :label: ellipse_support_arg__1
699
+ u_{r;\text{E}}=\sqrt{\left(u_{x}-u_{x;c;\text{E}}\right)^{2}
700
+ +\left(u_{y}-u_{y;c;\text{E}}\right)^{2}};
701
+ :label: u_r_E__1
702
+
703
+ .. math ::
704
+ u_{\theta;\text{E}}=
705
+ \tan^{-1}\left(\frac{u_{y}
706
+ -u_{y;c;\text{E}}}{u_{x}-u_{x;c;\text{E}}}\right);
707
+ :label: u_theta_E__1
708
+
709
+ and
710
+
711
+ .. math ::
712
+ R_{\text{E}}\left(u_{\theta;\text{E}}\right)=a_{\text{E}}
713
+ \sqrt{\frac{1-e_{\text{E}}^{2}}{1
714
+ -\left\{ e_{\text{E}}\cos\left(u_{\theta;\text{E}}
715
+ +\theta_{\text{E}}\right)\right\} ^{2}}}.
716
+ :label: R_E__1
717
+
718
+ By fractional coordinates, we mean that
719
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
720
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
721
+ left [upper right] corner of the lower left [upper right] pixel of an image
722
+ of the undistorted intensity pattern.
723
+
724
+ Note that if :math:`\theta_{\text{E}}=0`, then the longest chord of the
725
+ ellipse is horizontal. Let us refer to this ellipse with
726
+ :math:`\theta_{\text{E}}=0` as the "reference shape". If
727
+ :math:`\theta_{\text{E}} \neq 0`, then the ellipse is equal to the reference
728
+ shape after rotating the latter shape clockwise by :math:`\theta_{\text{E}}`
729
+ about its center.
694
730
 
695
731
  Parameters
696
732
  ----------
@@ -802,42 +838,33 @@ class Ellipse(BaseShape):
802
838
 
803
839
 
804
840
  def _eval(self, u_x, u_y):
805
- A = self._intra_shape_val
806
- support_arg = self._calc_support_arg(u_x, u_y)
807
- one = torch.tensor(1.0, device=support_arg.device)
808
- result = A * torch.heaviside(support_arg, one)
809
-
810
- return result
811
-
812
-
813
-
814
- def _calc_support_arg(self, u_x, u_y):
815
841
  u_x_c, u_y_c = self._center
816
842
  a = self._semi_major_axis
817
843
  e = self._eccentricity
818
- theta = torch.tensor(self._rotation_angle, dtype=u_x.dtype)
844
+ rotation_angle = self._rotation_angle
845
+ A = self._intra_shape_val
819
846
 
820
847
  delta_u_x = u_x-u_x_c
821
848
  delta_u_y = u_y-u_y_c
822
849
 
823
- e_sq = e*e
824
- a_sq = a*a
825
- b_sq = (1-e_sq)*a_sq
850
+ u_r = torch.sqrt(delta_u_x*delta_u_x + delta_u_y*delta_u_y)
851
+ u_theta = torch.atan2(delta_u_y, delta_u_x) % (2*np.pi)
852
+
853
+ theta = torch.tensor(rotation_angle, dtype=u_r.dtype)
854
+
855
+ u_theta_shifted = u_theta + theta
856
+ cos_u_theta_shifted = torch.cos(u_theta_shifted)
826
857
 
827
- cos_theta = torch.cos(theta)
828
- sin_theta = torch.sin(theta)
858
+ e_sq = e*e
829
859
 
830
- delta_u_x_prime = delta_u_x*cos_theta - delta_u_y*sin_theta
831
- delta_u_x_prime_sq = delta_u_x_prime*delta_u_x_prime
860
+ R = a * torch.sqrt((1 - e_sq)
861
+ / (1 - e_sq*cos_u_theta_shifted*cos_u_theta_shifted))
832
862
 
833
- delta_u_y_prime = delta_u_x*sin_theta + delta_u_y*cos_theta
834
- delta_u_y_prime_sq = delta_u_y_prime*delta_u_y_prime
863
+ one = torch.tensor(1.0, device=u_theta.device)
835
864
 
836
- support_arg = (b_sq
837
- - (b_sq/a_sq)*delta_u_x_prime_sq
838
- - delta_u_y_prime_sq)
865
+ result = A * torch.heaviside(R-u_r, one)
839
866
 
840
- return support_arg
867
+ return result
841
868
 
842
869
 
843
870
 
@@ -945,7 +972,7 @@ class Peak(BaseShape):
945
972
  :label: intensity_pattern_of_peak__1
946
973
 
947
974
  where :math:`u_{x}` and :math:`u_{y}` are fractional horizontal and vertical
948
- coordinates of the undistorted intensity pattern of the peak respectively,
975
+ coordinates of the undistorted intensity pattern of the peak respectively;
949
976
 
950
977
  .. math ::
951
978
  F_{\beta;\text{P}}\left(\omega\right)=\begin{cases}
@@ -987,6 +1014,12 @@ class Peak(BaseShape):
987
1014
 
988
1015
  with :math:`\Theta\left(\cdots\right)` being the Heaviside step function.
989
1016
 
1017
+ By fractional coordinates, we mean that
1018
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
1019
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
1020
+ left [upper right] corner of the lower left [upper right] pixel of an image
1021
+ of the undistorted intensity pattern.
1022
+
990
1023
  Parameters
991
1024
  ----------
992
1025
  center : `array_like` (`float`, shape=(``2``,)), optional
@@ -1298,7 +1331,7 @@ class Band(BaseShape):
1298
1331
  :label: intensity_pattern_of_band__1
1299
1332
 
1300
1333
  where :math:`u_{x}` and :math:`u_{y}` are fractional horizontal and vertical
1301
- coordinates of the undistorted intensity pattern of the band respectively,
1334
+ coordinates of the undistorted intensity pattern of the band respectively;
1302
1335
 
1303
1336
  .. math ::
1304
1337
  \Theta\left(\omega\right)=\begin{cases}
@@ -1316,7 +1349,7 @@ class Band(BaseShape):
1316
1349
  .. math ::
1317
1350
  d_{\text{B};1}\left(u_{x},u_{y}\right)=
1318
1351
  \frac{a_{\text{B};1}u_{x}+b_{\text{B};1}u_{y}
1319
- +c_{\text{B};1}}{\sqrt{a_{\text{B};1}^{2}+b_{\text{B};1}^{2}}};
1352
+ +c_{\text{B};1}}{\sqrt{a_{\text{B};1}^{2}+b_{\text{B};1}^{2}}},
1320
1353
  :label: d_1_of_band__1
1321
1354
 
1322
1355
  with
@@ -1400,6 +1433,12 @@ class Band(BaseShape):
1400
1433
  \end{cases}
1401
1434
  :label: c_2_of_band__1
1402
1435
 
1436
+ By fractional coordinates, we mean that
1437
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
1438
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
1439
+ left [upper right] corner of the lower left [upper right] pixel of an image
1440
+ of the undistorted intensity pattern.
1441
+
1403
1442
  Parameters
1404
1443
  ----------
1405
1444
  end_pt_1 : `array_like` (`float`, shape=(``2``,)), optional
@@ -1697,11 +1736,11 @@ class PlaneWave(BaseShape):
1697
1736
 
1698
1737
  where :math:`u_{x}` and :math:`u_{y}` are fractional horizontal and vertical
1699
1738
  coordinates of the undistorted intensity pattern of the plane wave
1700
- respectively,
1739
+ respectively;
1701
1740
 
1702
1741
  .. math ::
1703
1742
  k_{x;\text{PW}}=\frac{2\pi}{\lambda_{\text{PW}}}
1704
- \cos\left(\theta_{\text{PW}}\right),
1743
+ \cos\left(\theta_{\text{PW}}\right);
1705
1744
  :label: k_x_of_plane_wave__1
1706
1745
 
1707
1746
  and
@@ -1711,6 +1750,12 @@ class PlaneWave(BaseShape):
1711
1750
  \sin\left(\theta_{\text{PW}}\right).
1712
1751
  :label: k_y_of_plane_wave__1
1713
1752
 
1753
+ By fractional coordinates, we mean that
1754
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
1755
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
1756
+ left [upper right] corner of the lower left [upper right] pixel of an image
1757
+ of the undistorted intensity pattern.
1758
+
1714
1759
  Parameters
1715
1760
  ----------
1716
1761
  amplitude : `float`, optional
@@ -1944,12 +1989,12 @@ class Arc(BaseShape):
1944
1989
 
1945
1990
  where :math:`u_{x}` and :math:`u_{y}` are fractional horizontal and vertical
1946
1991
  coordinates of the undistorted intensity pattern of the circular arc
1947
- respectively, :math:`\Theta\left(\cdots\right)` is the Heaviside step
1948
- function,
1992
+ respectively; :math:`\Theta\left(\cdots\right)` is the Heaviside step
1993
+ function;
1949
1994
 
1950
1995
  .. math ::
1951
1996
  u_{r;\text{A}}=\sqrt{\left(u_{x}-u_{x;c;\text{A}}\right)^{2}
1952
- +\left(u_{y}-u_{y;c;\text{A}}\right)^{2}},
1997
+ +\left(u_{y}-u_{y;c;\text{A}}\right)^{2}};
1953
1998
  :label: u_r_UA__1
1954
1999
 
1955
2000
  and
@@ -1960,6 +2005,12 @@ class Arc(BaseShape):
1960
2005
  -\theta_{\text{A}}\right\} \mod 2\pi.
1961
2006
  :label: u_theta_UA__1
1962
2007
 
2008
+ By fractional coordinates, we mean that
2009
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
2010
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
2011
+ left [upper right] corner of the lower left [upper right] pixel of an image
2012
+ of the undistorted intensity pattern.
2013
+
1963
2014
  Parameters
1964
2015
  ----------
1965
2016
  center : `array_like` (`float`, shape=(``2``,)), optional
@@ -2218,24 +2269,24 @@ class GenericBlob(BaseShape):
2218
2269
  .. math ::
2219
2270
  \mathcal{I}_{\text{GB}}\left(u_{x},u_{y}\right)=
2220
2271
  A_{\text{GB}}\Theta\left(
2221
- R_{\text{GB}}\left(u_{\theta;\text{UA}}\right)-u_{r;\text{GB}}\right),
2272
+ R_{\text{GB}}\left(u_{\theta;\text{GB}}\right)-u_{r;\text{GB}}\right),
2222
2273
  :label: intensity_pattern_of_generic_blob__1
2223
2274
 
2224
2275
  where :math:`u_{x}` and :math:`u_{y}` are fractional horizontal and vertical
2225
2276
  coordinates of the undistorted intensity pattern of the generic blob
2226
- respectively, :math:`\Theta\left(\cdots\right)` is the Heaviside step
2227
- function,
2277
+ respectively; :math:`\Theta\left(\cdots\right)` is the Heaviside step
2278
+ function;
2228
2279
 
2229
2280
  .. math ::
2230
2281
  u_{r;\text{GB}}=\sqrt{\left(u_{x}-u_{x;c;\text{GB}}\right)^{2}
2231
2282
  +\left(u_{y}-u_{y;c;\text{GB}}\right)^{2}};
2232
- :label: u_r_UGB__1
2283
+ :label: u_r_GB__1
2233
2284
 
2234
2285
  .. math ::
2235
2286
  u_{\theta;\text{GB}}=
2236
2287
  \tan^{-1}\left(\frac{u_{y}
2237
2288
  -u_{y;c;\text{GB}}}{u_{x}-u_{x;c;\text{GB}}}\right);
2238
- :label: u_theta_UGB__1
2289
+ :label: u_theta_GB__1
2239
2290
 
2240
2291
  and
2241
2292
 
@@ -2244,20 +2295,26 @@ class GenericBlob(BaseShape):
2244
2295
  D_{\text{GB};0}\\&\quad\mathop{+}\min\left(1,N_{\text{GB}}\right)
2245
2296
  \sum_{n=1}^{N_{\text{GB}}}D_{\text{GB};n}
2246
2297
  \cos\left(nu_{\theta;\text{GB}}-\phi_{\text{GB};n-1}\right),
2247
- :label: R_UGB__1
2298
+ :label: R_GB__1
2248
2299
 
2249
2300
  with
2250
2301
 
2251
2302
  .. math ::
2252
2303
  D_{\text{GB};n} \ge 0,
2253
2304
  \quad\forall n\in\left\{ 1,\ldots,N_{\text{GB}}\right\},
2254
- :label: D_UGB_n__1
2305
+ :label: D_GB_n__1
2255
2306
 
2256
2307
  and
2257
2308
 
2258
2309
  .. math ::
2259
2310
  D_{\text{GB};0}>\sum_{n=1}^{N_{\text{GB}}}D_{\text{GB};n}.
2260
- :label: D_UGB_n__2
2311
+ :label: D_GB_n__2
2312
+
2313
+ By fractional coordinates, we mean that
2314
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
2315
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
2316
+ left [upper right] corner of the lower left [upper right] pixel of an image
2317
+ of the undistorted intensity pattern.
2261
2318
 
2262
2319
  Parameters
2263
2320
  ----------
@@ -2377,12 +2434,12 @@ class GenericBlob(BaseShape):
2377
2434
 
2378
2435
  N = len(phi)
2379
2436
 
2380
- one = torch.tensor(1.0, device=u_x.device)
2381
-
2382
2437
  R = D[0]*torch.ones_like(u_theta)
2383
2438
  for n in range(1, N+1):
2384
2439
  R += D[n]*torch.cos(n*u_theta - phi[n-1])
2385
2440
 
2441
+ one = torch.tensor(1.0, device=u_r.device)
2442
+
2386
2443
  result = A * torch.heaviside(R-u_r, one)
2387
2444
 
2388
2445
  return result
@@ -2555,11 +2612,11 @@ class Orbital(BaseShape):
2555
2612
 
2556
2613
  where :math:`u_{x}` and :math:`u_{y}` are fractional horizontal and vertical
2557
2614
  coordinates of the undistorted intensity pattern of the orbital
2558
- respectively,
2615
+ respectively;
2559
2616
 
2560
2617
  .. math ::
2561
2618
  u_{r;\text{O}}=\sqrt{\left(u_{x}-u_{x;c;\text{O}}\right)^{2}
2562
- +\left(u_{y}-u_{y;c;\text{O}}\right)^{2}},
2619
+ +\left(u_{y}-u_{y;c;\text{O}}\right)^{2}};
2563
2620
  :label: u_r_O__1
2564
2621
 
2565
2622
  .. math ::
@@ -2594,6 +2651,12 @@ class Orbital(BaseShape):
2594
2651
  u_{\phi;\text{O}}\right)` is the spherical harmonic function of degree
2595
2652
  :math:`l_{\text{O}}` and order :math:`m_{\text{O}}`.
2596
2653
 
2654
+ By fractional coordinates, we mean that
2655
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
2656
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
2657
+ left [upper right] corner of the lower left [upper right] pixel of an image
2658
+ of the undistorted intensity pattern.
2659
+
2597
2660
  Parameters
2598
2661
  ----------
2599
2662
  center : `array_like` (`float`, shape=(``2``,)), optional
@@ -3037,6 +3100,12 @@ class Lune(BaseShape):
3037
3100
  where :math:`u_{x}` and :math:`u_{y}` are fractional horizontal and vertical
3038
3101
  coordinates of the undistorted intensity pattern of the lune respectively.
3039
3102
 
3103
+ By fractional coordinates, we mean that
3104
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
3105
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
3106
+ left [upper right] corner of the lower left [upper right] pixel of an image
3107
+ of the undistorted intensity pattern.
3108
+
3040
3109
  Parameters
3041
3110
  ----------
3042
3111
  bg_ellipse : :class:`fakecbed.shapes.Circle` | :class:`fakecbed.shapes.Ellipse` | `None`, optional
@@ -3293,6 +3362,12 @@ class NonuniformBoundedShape(BaseShape):
3293
3362
  coordinates of the undistorted intensity pattern of the nonuniform bounded
3294
3363
  shape respectively.
3295
3364
 
3365
+ By fractional coordinates, we mean that
3366
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
3367
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
3368
+ left [upper right] corner of the lower left [upper right] pixel of an image
3369
+ of the undistorted intensity pattern.
3370
+
3296
3371
  Parameters
3297
3372
  ----------
3298
3373
  support : :class:`fakecbed.shapes.Circle` | :class:`fakecbed.shapes.Ellipse` | :class:`fakecbed.shapes.Band` | :class:`fakecbed.shapes.Arc` | :class:`fakecbed.shapes.GenericBlob` | :class:`fakecbed.shapes.Lune` | `None`, optional
fakecbed/tds.py CHANGED
@@ -142,6 +142,12 @@ class Model(fakecbed.shapes.BaseShape):
142
142
  coordinates of the undistorted intensity pattern of the TDS model
143
143
  respectively.
144
144
 
145
+ By fractional coordinates, we mean that
146
+ :math:`\left(u_{x},u_{y}\right)=\left(0,0\right)`
147
+ :math:`\left[\left(u_{x},u_{y}\right)=\left(1,1\right)\right]` is the lower
148
+ left [upper right] corner of the lower left [upper right] pixel of an image
149
+ of the undistorted intensity pattern.
150
+
145
151
  Parameters
146
152
  ----------
147
153
  peaks : `array_like` (`fakecbed.shapes.Peak`, ndim=1), optional
fakecbed/version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.5.1'
32
- __version_tuple__ = version_tuple = (0, 5, 1)
31
+ __version__ = version = '0.5.2'
32
+ __version_tuple__ = version_tuple = (0, 5, 2)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fakecbed
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: A Python library for generating quickly images that imitate convergent beam electron diffraction patterns.
5
5
  Author-email: Matthew Fitzpatrick <matthew.rc.fitzpatrick@gmail.com>
6
6
  Project-URL: Homepage, https://mrfitzpa.github.io/fakecbed
@@ -0,0 +1,10 @@
1
+ fakecbed/__init__.py,sha256=iP73WNV_HZgxiVUVdesbJqlrhDGESooh1hlBs8kox9M,1342
2
+ fakecbed/discretized.py,sha256=Vp2EJF1peMnQLYxSIdFKZpiFZ4ROp9HRUxeU1oGCIf0,205672
3
+ fakecbed/shapes.py,sha256=lo4bySMojS4hdWnVkeTZYyHlETKvczFWPhuf6a2csR0,120050
4
+ fakecbed/tds.py,sha256=M0w0GfUfDqJiGiqB5f6PUb3oCRQA9sY2aAbJLS3IA-k,8367
5
+ fakecbed/version.py,sha256=LGYtjQ6cyPZC_N0AovMIeSYYDK21050nm3HYgDanQBM,704
6
+ fakecbed-0.5.2.dist-info/licenses/LICENSE,sha256=N0P3pKtRMvfb64jmgJdlerg3TnS0a2QC776AzPsbZIg,35128
7
+ fakecbed-0.5.2.dist-info/METADATA,sha256=sR0VEVs9vH0NDPJgcdeWY1aJQGd5Q5dbSdH3NHuN8uk,7023
8
+ fakecbed-0.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ fakecbed-0.5.2.dist-info/top_level.txt,sha256=l0jL8P0CjRiCSznYLnq7riaAnOmYaV3zjjjIJx9vjSQ,9
10
+ fakecbed-0.5.2.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- fakecbed/__init__.py,sha256=iP73WNV_HZgxiVUVdesbJqlrhDGESooh1hlBs8kox9M,1342
2
- fakecbed/discretized.py,sha256=uV9tc8CC0K6GG1rGp2Nvq8p9qf6zLmp4lWTbKicmULE,205011
3
- fakecbed/shapes.py,sha256=Lo4pg46lpBwGiUJB6Q3X6gxoaa1d9eRwwjG49gkZ2zY,116472
4
- fakecbed/tds.py,sha256=mk5359ErIhdpCoTdHq9r1-foKb8t3qCOHqNoabx3bQw,8066
5
- fakecbed/version.py,sha256=cYMOhuaBHd0MIZmumuccsEQ-AxM8LIJy9dsBAWgOpqE,704
6
- fakecbed-0.5.1.dist-info/licenses/LICENSE,sha256=N0P3pKtRMvfb64jmgJdlerg3TnS0a2QC776AzPsbZIg,35128
7
- fakecbed-0.5.1.dist-info/METADATA,sha256=NGCr4SUFD2W5hKMPPe1mv3YAHRvMQ4TlKUITz_hjVgQ,7023
8
- fakecbed-0.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- fakecbed-0.5.1.dist-info/top_level.txt,sha256=l0jL8P0CjRiCSznYLnq7riaAnOmYaV3zjjjIJx9vjSQ,9
10
- fakecbed-0.5.1.dist-info/RECORD,,