fakecbed 0.0.2__tar.gz → 0.1.0__tar.gz

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.
Files changed (41) hide show
  1. {fakecbed-0.0.2 → fakecbed-0.1.0}/PKG-INFO +1 -1
  2. {fakecbed-0.0.2 → fakecbed-0.1.0}/examples/basic_usage.ipynb +43 -1
  3. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed/discretized.py +147 -35
  4. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed/version.py +2 -2
  5. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed.egg-info/PKG-INFO +1 -1
  6. {fakecbed-0.0.2 → fakecbed-0.1.0}/tests/test_discretized.py +9 -14
  7. {fakecbed-0.0.2 → fakecbed-0.1.0}/.coveragerc +0 -0
  8. {fakecbed-0.0.2 → fakecbed-0.1.0}/.github/workflows/measure_code_coverage.yml +0 -0
  9. {fakecbed-0.0.2 → fakecbed-0.1.0}/.github/workflows/publish_documentation_website.yml +0 -0
  10. {fakecbed-0.0.2 → fakecbed-0.1.0}/.github/workflows/publish_release_to_pypi.yml +0 -0
  11. {fakecbed-0.0.2 → fakecbed-0.1.0}/.github/workflows/test_library.yml +0 -0
  12. {fakecbed-0.0.2 → fakecbed-0.1.0}/.gitignore +0 -0
  13. {fakecbed-0.0.2 → fakecbed-0.1.0}/LICENSE +0 -0
  14. {fakecbed-0.0.2 → fakecbed-0.1.0}/README.md +0 -0
  15. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/INSTALL.rst +0 -0
  16. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/Makefile +0 -0
  17. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/_static/readthedocs_custom.css +0 -0
  18. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/_templates/custom_class_template.rst +0 -0
  19. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/_templates/custom_module_template.rst +0 -0
  20. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/_templates/versions.html +0 -0
  21. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/api.rst +0 -0
  22. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/build_docs.py +0 -0
  23. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/conf.py +0 -0
  24. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/examples.rst +0 -0
  25. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/index.rst +0 -0
  26. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/license.rst +0 -0
  27. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/literature.rst +0 -0
  28. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/make.bat +0 -0
  29. {fakecbed-0.0.2 → fakecbed-0.1.0}/docs/private_members_to_publish_to_docs.rst +0 -0
  30. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed/__init__.py +0 -0
  31. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed/shapes.py +0 -0
  32. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed/tds.py +0 -0
  33. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed.egg-info/SOURCES.txt +0 -0
  34. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed.egg-info/dependency_links.txt +0 -0
  35. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed.egg-info/requires.txt +0 -0
  36. {fakecbed-0.0.2 → fakecbed-0.1.0}/fakecbed.egg-info/top_level.txt +0 -0
  37. {fakecbed-0.0.2 → fakecbed-0.1.0}/pyproject.toml +0 -0
  38. {fakecbed-0.0.2 → fakecbed-0.1.0}/setup.cfg +0 -0
  39. {fakecbed-0.0.2 → fakecbed-0.1.0}/setup.py +0 -0
  40. {fakecbed-0.0.2 → fakecbed-0.1.0}/tests/test_shapes.py +0 -0
  41. {fakecbed-0.0.2 → fakecbed-0.1.0}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fakecbed
3
- Version: 0.0.2
3
+ Version: 0.1.0
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
@@ -783,6 +783,48 @@
783
783
  "cbed_pattern.signal.plot(**kwargs)"
784
784
  ]
785
785
  },
786
+ {
787
+ "cell_type": "markdown",
788
+ "id": "2d3c761e-3f6d-48e9-9072-c013491476af",
789
+ "metadata": {},
790
+ "source": [
791
+ "Next, let's add a mask frame."
792
+ ]
793
+ },
794
+ {
795
+ "cell_type": "code",
796
+ "execution_count": null,
797
+ "id": "d0a54fa9-3f3c-48b9-a898-f3aa0a97f0f1",
798
+ "metadata": {},
799
+ "outputs": [],
800
+ "source": [
801
+ "new_core_attr_subset_candidate = {\"mask_frame\": (40, 20, 0, 60)}\n",
802
+ "cbed_pattern.update(new_core_attr_subset_candidate)"
803
+ ]
804
+ },
805
+ {
806
+ "cell_type": "markdown",
807
+ "id": "e9031b4b-bcf4-43be-9cb7-d45ef97e84d7",
808
+ "metadata": {},
809
+ "source": [
810
+ "Let's visualize the updated fake CBED pattern."
811
+ ]
812
+ },
813
+ {
814
+ "cell_type": "code",
815
+ "execution_count": null,
816
+ "id": "cdddf688-522a-4f22-a801-8e0a53495af0",
817
+ "metadata": {},
818
+ "outputs": [],
819
+ "source": [
820
+ "kwargs = {\"axes_off\": False, \n",
821
+ " \"scalebar\": False, \n",
822
+ " \"colorbar\": False, \n",
823
+ " \"gamma\": 0.3,\n",
824
+ " \"cmap\": \"jet\"}\n",
825
+ "cbed_pattern.signal.plot(**kwargs)"
826
+ ]
827
+ },
786
828
  {
787
829
  "cell_type": "markdown",
788
830
  "id": "8a8f4eb6-b9d9-4e20-93e9-45327b620c83",
@@ -1042,7 +1084,7 @@
1042
1084
  "id": "f7bb052c-92d0-4fc1-8c11-72fbdfb05972",
1043
1085
  "metadata": {},
1044
1086
  "source": [
1045
- "We can visualize the illumination support as follows:"
1087
+ "We can visualize the illumination support masked by the mask frame as follows:"
1046
1088
  ]
1047
1089
  },
1048
1090
  {
@@ -490,6 +490,31 @@ def _de_pre_serialize_cold_pixels(serializable_rep):
490
490
 
491
491
 
492
492
 
493
+ def _check_and_convert_mask_frame(params):
494
+ current_func_name = inspect.stack()[0][3]
495
+ obj_name = current_func_name[19:]
496
+ kwargs = {"obj": params[obj_name], "obj_name": obj_name}
497
+ mask_frame = czekitout.convert.to_quadruplet_of_nonnegative_ints(**kwargs)
498
+
499
+ return mask_frame
500
+
501
+
502
+
503
+ def _pre_serialize_mask_frame(mask_frame):
504
+ obj_to_pre_serialize = random.choice(list(locals().values()))
505
+ serializable_rep = obj_to_pre_serialize
506
+
507
+ return serializable_rep
508
+
509
+
510
+
511
+ def _de_pre_serialize_mask_frame(serializable_rep):
512
+ mask_frame = serializable_rep
513
+
514
+ return mask_frame
515
+
516
+
517
+
493
518
  def _check_and_convert_deep_copy(params):
494
519
  current_func_name = inspect.stack()[0][3]
495
520
  obj_name = current_func_name[19:]
@@ -561,6 +586,8 @@ _default_skip_validation_and_conversion = \
561
586
  fakecbed.shapes._default_skip_validation_and_conversion
562
587
  _default_deep_copy = \
563
588
  True
589
+ _default_mask_frame = \
590
+ 4*(0,)
564
591
 
565
592
 
566
593
 
@@ -708,6 +735,15 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
708
735
  :math:`n_{k;\text{CP}}` and :math:`m_{k;\text{CP}}` respectively, with the
709
736
  integer :math:`k` being equal to the value of ``k``.
710
737
 
738
+ The mask frame of the image of the target fake CBED pattern is specified by
739
+ the parameter ``mask_frame``, which is expected to be a 4-element tuple,
740
+ :math:`\left(L, R, B, T\right)`, of nonnegative integers. ``mask_frame[0]``,
741
+ ``mask_frame[1]``, ``mask_frame[2]``, and ``mask_frame[3]`` are the widths,
742
+ in units of pixels, of the left, right, bottom, and top sides of the mask
743
+ frame respectively. If all elements of ``mask_frame`` are zero, then no
744
+ pixels in the image of the target fake CBED pattern are masked by the mask
745
+ frame.
746
+
711
747
  Below we describe in more detail how various attributes of the current class
712
748
  are effectively calculated. Before doing so, we need to introduce a few more
713
749
  quantities:
@@ -800,14 +836,12 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
800
836
  3. Calculate
801
837
 
802
838
  .. math ::
803
- \mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}&
804
- \leftarrow\mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}\\&
805
- \quad\quad\mathop{+}\mathcal{I}_{k;\text{D}}\left(
806
- T_{\square;x}\left(q_{\mathring{\mathcal{I}};x;j},
807
- q_{\mathring{\mathcal{I}};y;i}\right),T_{\square;y}\left(
808
- q_{\mathring{\mathcal{I}};x;j},
809
- q_{\mathring{\mathcal{I}};y;i}\right)\right),
810
- :label: HD_I_CBED__1
839
+ \mathcal{I}_{\text{MF};⌑;n,m}\leftarrow\begin{cases}
840
+ \text{True}, & \text{if }L\le m<N_{\mathcal{I};x}-R
841
+ \text{ and }T\le n<N_{\mathcal{I};y}-B,\\
842
+ \text{False}, & \text{otherwise}.
843
+ \end{cases}
844
+ :label: LD_I_MF__1
811
845
 
812
846
  4. For :math:`0\le k<N_{\text{D}}`, calculate
813
847
 
@@ -818,7 +852,7 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
818
852
  q_{\mathring{\mathcal{I}};x;j},q_{\mathring{\mathcal{I}};y;i}\right),
819
853
  T_{\square;y}\left(q_{\mathring{\mathcal{I}};x;j},
820
854
  q_{\mathring{\mathcal{I}};y;i}\right)\right),
821
- :label: HD_I_CBED__2
855
+ :label: HD_I_CBED__1
822
856
 
823
857
  .. math ::
824
858
  \mathring{\mathcal{I}}_{k;\text{DS};⌑;i,j}\leftarrow
@@ -851,7 +885,9 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
851
885
 
852
886
  .. math ::
853
887
  \mathcal{I}_{\text{DOM};⌑;n,m}\leftarrow
854
- \mathcal{I}_{\text{OI};⌑;n,m}\mathcal{I}_{\text{DOM};⌑;n,m}.
888
+ \mathcal{I}_{\text{MF};⌑;n,m}
889
+ \mathcal{I}_{\text{OI};⌑;n,m}
890
+ \mathcal{I}_{\text{DOM};⌑;n,m}.
855
891
  :label: LD_I_DOM__3
856
892
 
857
893
  6. For :math:`0\le k<N_{\text{M}}`, calculate
@@ -863,7 +899,7 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
863
899
  q_{\mathring{\mathcal{I}};x;j},q_{\mathring{\mathcal{I}};y;i}\right),
864
900
  T_{\square;y}\left(q_{\mathring{\mathcal{I}};x;j},
865
901
  q_{\mathring{\mathcal{I}};y;i}\right)\right).
866
- :label: HD_I_CBED__3
902
+ :label: HD_I_CBED__2
867
903
 
868
904
  7. Calculate
869
905
 
@@ -873,7 +909,7 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
873
909
  q_{\mathring{\mathcal{I}};x;j},
874
910
  q_{\mathring{\mathcal{I}};y;i}\right)\right)
875
911
  \mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}.
876
- :label: HD_I_CBED__4
912
+ :label: HD_I_CBED__3
877
913
 
878
914
  8. Apply average pooling to
879
915
  :math:`\mathring{\mathcal{I}}_{\text{CBED};⌑;i,j}` with a kernel of
@@ -916,7 +952,9 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
916
952
 
917
953
  .. math ::
918
954
  \mathcal{I}_{\text{CBED};⌑;n,m}\leftarrow
919
- \mathcal{I}_{\text{OI};⌑;n,m}\mathcal{I}_{\text{CBED};⌑;n,m}.
955
+ \mathcal{I}_{\text{MF};⌑;n,m}
956
+ \mathcal{I}_{\text{OI};⌑;n,m}
957
+ \mathcal{I}_{\text{CBED};⌑;n,m}.
920
958
  :label: LD_I_CBED__1
921
959
 
922
960
  14. Update pixels of :math:`\mathcal{I}_{\text{CBED};⌑;n,m}` at pixel
@@ -928,7 +966,8 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
928
966
  16. Calculate
929
967
 
930
968
  .. math ::
931
- \mathcal{I}_{\text{CS};⌑;n,m}\leftarrow1-\mathcal{I}_{\text{OI};⌑;n,m}.
969
+ \mathcal{I}_{\text{CS};⌑;n,m}\leftarrow1
970
+ -\mathcal{I}_{\text{MF};⌑;n,m}\mathcal{I}_{\text{OI};⌑;n,m}.
932
971
  :label: LD_I_CS__1
933
972
 
934
973
  17. Convolve a :math:`3 \times 3` filter of ones over a symmetrically unity-padded
@@ -1017,6 +1056,13 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1017
1056
  :math:`N_{\text{DPW}}`. Must be nonnegative.
1018
1057
  cold_pixels : `array_like` (`int`, ndim=2), optional
1019
1058
  The pixel coordinates of the cold pixels.
1059
+ mask_frame : `array_like` (`int`, shape=(4,)), optional
1060
+ ``mask_frame`` specifies the mask frame of the image of the target fake
1061
+ CBED pattern. ``mask_frame[0]``, ``mask_frame[1]``, ``mask_frame[2]``,
1062
+ and ``mask_frame[3]`` are the widths, in units of pixels, of the left,
1063
+ right, bottom, and top sides of the mask frame respectively. If all
1064
+ elements of ``mask_frame`` are zero, then no pixels in the image of the
1065
+ target fake CBED pattern are masked by the mask frame.
1020
1066
 
1021
1067
  """
1022
1068
  ctor_param_names = ("undistorted_tds_model",
@@ -1028,7 +1074,8 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1028
1074
  "distortion_model",
1029
1075
  "apply_shot_noise",
1030
1076
  "detector_partition_width_in_pixels",
1031
- "cold_pixels")
1077
+ "cold_pixels",
1078
+ "mask_frame")
1032
1079
  kwargs = {"namespace_as_dict": globals(),
1033
1080
  "ctor_param_names": ctor_param_names}
1034
1081
 
@@ -1064,6 +1111,8 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1064
1111
  _default_detector_partition_width_in_pixels,
1065
1112
  cold_pixels=\
1066
1113
  _default_cold_pixels,
1114
+ mask_frame=\
1115
+ _default_mask_frame,
1067
1116
  skip_validation_and_conversion=\
1068
1117
  _default_skip_validation_and_conversion):
1069
1118
  ctor_params = {key: val
@@ -1194,8 +1243,15 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1194
1243
  .. code-block:: python
1195
1244
 
1196
1245
  coords_of_cold_pixels = core_attrs["cold_pixels"]
1246
+ L, R, B, T = core_attrs["mask_frame"]
1247
+ N_I_x = core_attrs["num_pixels_across_pattern"]
1248
+ N_I_y = N_I_x
1197
1249
 
1198
1250
  image = (overriding_image * illumination_support).clip(min=0)
1251
+ image[:T, :] = 0
1252
+ image[max(N_I_y-B, 0):, :] = 0
1253
+ image[:, :L] = 0
1254
+ image[:, max(N_I_x-R, 0):] = 0
1199
1255
  for coords_of_cold_pixel in coords_of_cold_pixels:
1200
1256
  image[coords_of_cold_pixel] = 0
1201
1257
 
@@ -1244,8 +1300,15 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1244
1300
  illumination_support = self._illumination_support
1245
1301
 
1246
1302
  coords_of_cold_pixels = self._cold_pixels
1303
+ L, R, B, T = self._mask_frame
1304
+ N_I_x = self._num_pixels_across_pattern
1305
+ N_I_y = N_I_x
1247
1306
 
1248
1307
  image = overriding_image*illumination_support
1308
+ image[:T, :] = 0
1309
+ image[max(N_I_y-B, 0):, :] = 0
1310
+ image[:, :L] = 0
1311
+ image[:, max(N_I_x-R, 0):] = 0
1249
1312
  for coords_of_cold_pixel in coords_of_cold_pixels:
1250
1313
  image[coords_of_cold_pixel] = 0
1251
1314
 
@@ -1391,12 +1454,19 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1391
1454
  disk_supports = self._disk_supports.numpy(force=True)
1392
1455
 
1393
1456
  num_disks = self._num_disks
1457
+ L, R, B, T = self._mask_frame
1458
+ N_I_x = self._num_pixels_across_pattern
1459
+ N_I_y = N_I_x
1394
1460
 
1395
1461
  signal_data_shape = (num_disks+3,) + image.shape
1396
1462
 
1397
1463
  signal_data = np.zeros(signal_data_shape, dtype=image.dtype)
1398
1464
  signal_data[0] = image
1399
1465
  signal_data[1] = illumination_support
1466
+ signal_data[1, :T, :] = 0
1467
+ signal_data[1, max(N_I_y-B, 0):, :] = 0
1468
+ signal_data[1, :, :L] = 0
1469
+ signal_data[1, :, max(N_I_x-R, 0):] = 0
1400
1470
  signal_data[2] = disk_overlap_map
1401
1471
  signal_data[3:] = disk_supports
1402
1472
 
@@ -1474,25 +1544,7 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1474
1544
  self._disk_supports = method_alias(u_x, u_y)
1475
1545
  disk_supports = self._disk_supports
1476
1546
 
1477
- clip_support = ~illumination_support
1478
- for _ in range(2):
1479
- clip_support = torch.unsqueeze(clip_support, dim=0)
1480
- clip_support = clip_support.to(dtype=torch.float)
1481
-
1482
- conv_weights = torch.ones((1, 1, 5, 5),
1483
- device=illumination_support.device)
1484
-
1485
- kwargs = {"input": clip_support,
1486
- "weight": conv_weights,
1487
- "padding": "same"}
1488
- clip_support = (torch.nn.functional.conv2d(**kwargs) != 0)
1489
- clip_support = clip_support.to(dtype=torch.bool)
1490
-
1491
- clip_support[0, 0, :2, :] = True
1492
- clip_support[0, 0, -2:, :] = True
1493
- clip_support[0, 0, :, :2] = True
1494
- clip_support[0, 0, :, -2:] = True
1495
- clip_support = clip_support[0, 0]
1547
+ clip_support = self._calc_clip_support(illumination_support)
1496
1548
 
1497
1549
  disk_clipping_map = disk_supports*clip_support[None, :, :]
1498
1550
 
@@ -1512,6 +1564,10 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1512
1564
  num_disks = len(undistorted_disks)
1513
1565
 
1514
1566
  if num_disks > 0:
1567
+ L, R, B, T = self._mask_frame
1568
+ N_I_x = self._num_pixels_across_pattern
1569
+ N_I_y = N_I_x
1570
+
1515
1571
  if self._illumination_support is None:
1516
1572
  method_name = "_calc_illumination_support"
1517
1573
  method_alias = getattr(self, method_name)
@@ -1534,6 +1590,10 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1534
1590
  disk_supports = pooler(disk_supports)[0]
1535
1591
  disk_supports = disk_supports.to(dtype=torch.bool)
1536
1592
  disk_supports[:, :, :] *= illumination_support[None, :, :]
1593
+ disk_supports[:, :T, :] = 0
1594
+ disk_supports[:, max(N_I_y-B, 0):, :] = 0
1595
+ disk_supports[:, :, :L] = 0
1596
+ disk_supports[:, :, max(N_I_x-R, 0):] = 0
1537
1597
  else:
1538
1598
  num_pixels_across_pattern = self._num_pixels_across_pattern
1539
1599
 
@@ -1549,6 +1609,35 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1549
1609
 
1550
1610
 
1551
1611
 
1612
+ def _calc_clip_support(self, illumination_support):
1613
+ L, R, B, T = self._mask_frame
1614
+ N_I_x = self._num_pixels_across_pattern
1615
+ N_I_y = N_I_x
1616
+
1617
+ clip_support = ~illumination_support
1618
+ for _ in range(2):
1619
+ clip_support = torch.unsqueeze(clip_support, dim=0)
1620
+ clip_support = clip_support.to(dtype=torch.float)
1621
+
1622
+ conv_weights = torch.ones((1, 1, 5, 5),
1623
+ device=illumination_support.device)
1624
+
1625
+ kwargs = {"input": clip_support,
1626
+ "weight": conv_weights,
1627
+ "padding": "same"}
1628
+ clip_support = (torch.nn.functional.conv2d(**kwargs) != 0)
1629
+
1630
+ clip_support = clip_support.to(dtype=torch.bool)
1631
+ clip_support[0, 0, :T+2, :] = True
1632
+ clip_support[0, 0, max(N_I_y-B-2, 0):, :] = True
1633
+ clip_support[0, 0, :, :L+2] = True
1634
+ clip_support[0, 0, :, max(N_I_x-R-2, 0):] = True
1635
+ clip_support = clip_support[0, 0]
1636
+
1637
+ return clip_support
1638
+
1639
+
1640
+
1552
1641
  def _calc_disk_absence_registry_and_cache_select_intermediates(self,
1553
1642
  u_x,
1554
1643
  u_y):
@@ -1594,7 +1683,14 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1594
1683
  else noiseless_image)
1595
1684
 
1596
1685
  coords_of_cold_pixels = self._cold_pixels
1597
-
1686
+ L, R, B, T = self._mask_frame
1687
+ N_I_x = self._num_pixels_across_pattern
1688
+ N_I_y = N_I_x
1689
+
1690
+ image[:T, :] = 0
1691
+ image[max(N_I_y-B, 0):, :] = 0
1692
+ image[:, :L] = 0
1693
+ image[:, max(N_I_x-R, 0):] = 0
1598
1694
  for coords_of_cold_pixel in coords_of_cold_pixels:
1599
1695
  image[coords_of_cold_pixel] = 0
1600
1696
 
@@ -1796,8 +1892,16 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1796
1892
  self._disk_supports = method_alias(u_x, u_y)
1797
1893
  disk_supports = self._disk_supports
1798
1894
 
1895
+ L, R, B, T = self._mask_frame
1896
+ N_I_x = self._num_pixels_across_pattern
1897
+ N_I_y = N_I_x
1898
+
1799
1899
  disk_overlap_map = (illumination_support
1800
1900
  * torch.sum(disk_supports, dim=0))
1901
+ disk_overlap_map[:T, :] = 0
1902
+ disk_overlap_map[max(N_I_y-B, 0):, :] = 0
1903
+ disk_overlap_map[:, :L] = 0
1904
+ disk_overlap_map[:, max(N_I_x-R, 0):] = 0
1801
1905
  else:
1802
1906
  num_pixels_across_pattern = self._num_pixels_across_pattern
1803
1907
 
@@ -1872,8 +1976,16 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
1872
1976
 
1873
1977
  .. code-block:: python
1874
1978
 
1979
+ L, R, B, T = core_attrs["mask_frame"]
1980
+ N_I_x = core_attrs["num_pixels_across_pattern"]
1981
+ N_I_y = N_I_x
1982
+
1875
1983
  signal.data[0] = image.numpy(force=True)
1876
1984
  signal.data[1] = illumination_support.numpy(force=True)
1985
+ signal.data[1, :T, :] = 0
1986
+ signal.data[1, max(N_I_y-B, 0):, :] = 0
1987
+ signal.data[1, :, :L] = 0
1988
+ signal.data[1, :, max(N_I_x-R, 0):] = 0
1877
1989
  signal.data[2] = disk_overlap_map.numpy(force=True)
1878
1990
  signal.data[3:] = disk_supports.numpy(force=True)
1879
1991
 
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.0.2'
16
- __version_tuple__ = version_tuple = (0, 0, 2)
15
+ __version__ = version = '0.1.0'
16
+ __version_tuple__ = version_tuple = (0, 1, 0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fakecbed
3
- Version: 0.0.2
3
+ Version: 0.1.0
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
@@ -54,27 +54,20 @@ def generate_cbed_pattern():
54
54
  def generate_cbed_pattern_ctor_params():
55
55
  num_pixels_across_pattern = 128
56
56
 
57
- undistorted_tds_model = \
58
- generate_undistorted_tds_model()
57
+ undistorted_tds_model = generate_undistorted_tds_model()
59
58
 
60
- undistorted_disks = \
61
- generate_undistorted_disks()
59
+ undistorted_disks = generate_undistorted_disks()
62
60
 
63
- kwargs = \
64
- {"undistorted_disks": undistorted_disks}
65
- undistorted_misc_shapes = \
66
- generate_undistorted_misc_shapes(**kwargs)
61
+ kwargs = {"undistorted_disks": undistorted_disks}
62
+ undistorted_misc_shapes = generate_undistorted_misc_shapes(**kwargs)
67
63
 
68
64
  undistorted_outer_illumination_shape = \
69
65
  generate_undistorted_outer_illumination_shape(**kwargs)
70
66
 
71
- kwargs = \
72
- {"num_pixels_across_pattern": num_pixels_across_pattern}
73
- distortion_model = \
74
- generate_distortion_model(**kwargs)
67
+ kwargs = {"num_pixels_across_pattern": num_pixels_across_pattern}
68
+ distortion_model = generate_distortion_model(**kwargs)
75
69
 
76
- cold_pixels = \
77
- generate_cold_pixels(num_pixels_across_pattern)
70
+ cold_pixels = generate_cold_pixels(num_pixels_across_pattern)
78
71
 
79
72
  cbed_pattern_ctor_params = {"undistorted_tds_model": \
80
73
  undistorted_tds_model,
@@ -96,6 +89,8 @@ def generate_cbed_pattern_ctor_params():
96
89
  4,
97
90
  "cold_pixels": \
98
91
  cold_pixels,
92
+ "mask_frame": \
93
+ (2, 5, 0, 7),
99
94
  "skip_validation_and_conversion": \
100
95
  False}
101
96
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes