fakecbed 0.2.1__py3-none-any.whl → 0.3.0__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 +52 -1
- fakecbed/version.py +2 -2
- {fakecbed-0.2.1.dist-info → fakecbed-0.3.0.dist-info}/METADATA +1 -1
- fakecbed-0.3.0.dist-info/RECORD +10 -0
- fakecbed-0.2.1.dist-info/RECORD +0 -10
- {fakecbed-0.2.1.dist-info → fakecbed-0.3.0.dist-info}/LICENSE +0 -0
- {fakecbed-0.2.1.dist-info → fakecbed-0.3.0.dist-info}/WHEEL +0 -0
- {fakecbed-0.2.1.dist-info → fakecbed-0.3.0.dist-info}/top_level.txt +0 -0
fakecbed/discretized.py
CHANGED
|
@@ -412,6 +412,41 @@ def _de_pre_serialize_apply_shot_noise(serializable_rep):
|
|
|
412
412
|
|
|
413
413
|
|
|
414
414
|
|
|
415
|
+
def _check_and_convert_rng_seed(params):
|
|
416
|
+
obj_name = "rng_seed"
|
|
417
|
+
obj = params[obj_name]
|
|
418
|
+
|
|
419
|
+
current_func_name = "_check_and_convert_rng_seed"
|
|
420
|
+
|
|
421
|
+
if obj is not None:
|
|
422
|
+
kwargs = {"obj": obj, "obj_name": obj_name}
|
|
423
|
+
try:
|
|
424
|
+
rng_seed = czekitout.convert.to_nonnegative_int(**kwargs)
|
|
425
|
+
except:
|
|
426
|
+
err_msg = globals()[current_func_name+"_err_msg_1"]
|
|
427
|
+
raise TypeError(err_msg)
|
|
428
|
+
else:
|
|
429
|
+
rng_seed = obj
|
|
430
|
+
|
|
431
|
+
return rng_seed
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def _pre_serialize_rng_seed(rng_seed):
|
|
436
|
+
obj_to_pre_serialize = rng_seed
|
|
437
|
+
serializable_rep = obj_to_pre_serialize
|
|
438
|
+
|
|
439
|
+
return serializable_rep
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
def _de_pre_serialize_rng_seed(serializable_rep):
|
|
444
|
+
rng_seed = serializable_rep
|
|
445
|
+
|
|
446
|
+
return rng_seed
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
415
450
|
def _check_and_convert_detector_partition_width_in_pixels(params):
|
|
416
451
|
obj_name = "detector_partition_width_in_pixels"
|
|
417
452
|
func_alias = czekitout.convert.to_nonnegative_int
|
|
@@ -562,6 +597,8 @@ _default_num_pixels_across_pattern = \
|
|
|
562
597
|
512
|
|
563
598
|
_default_apply_shot_noise = \
|
|
564
599
|
False
|
|
600
|
+
_default_rng_seed = \
|
|
601
|
+
None
|
|
565
602
|
_default_detector_partition_width_in_pixels = \
|
|
566
603
|
0
|
|
567
604
|
_default_cold_pixels = \
|
|
@@ -1035,6 +1072,9 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
|
|
|
1035
1072
|
If ``apply_shot_noise`` is set to ``True``, then shot noise is applied
|
|
1036
1073
|
to the image of the fake CBED pattern. Otherwise, no shot noise is
|
|
1037
1074
|
applied.
|
|
1075
|
+
rng_seed : `int` | `None`, optional
|
|
1076
|
+
``rng_seed`` specifies the seed used in the random number generator used
|
|
1077
|
+
to apply shot noise.
|
|
1038
1078
|
detector_partition_width_in_pixels : `int`, optional
|
|
1039
1079
|
The detector partition width in units of pixels,
|
|
1040
1080
|
:math:`N_{\text{DPW}}`. Must be nonnegative.
|
|
@@ -1057,6 +1097,7 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
|
|
|
1057
1097
|
"num_pixels_across_pattern",
|
|
1058
1098
|
"distortion_model",
|
|
1059
1099
|
"apply_shot_noise",
|
|
1100
|
+
"rng_seed",
|
|
1060
1101
|
"detector_partition_width_in_pixels",
|
|
1061
1102
|
"cold_pixels",
|
|
1062
1103
|
"mask_frame")
|
|
@@ -1091,6 +1132,8 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
|
|
|
1091
1132
|
_default_distortion_model,
|
|
1092
1133
|
apply_shot_noise=\
|
|
1093
1134
|
_default_apply_shot_noise,
|
|
1135
|
+
rng_seed=\
|
|
1136
|
+
_default_rng_seed,
|
|
1094
1137
|
detector_partition_width_in_pixels=\
|
|
1095
1138
|
_default_detector_partition_width_in_pixels,
|
|
1096
1139
|
cold_pixels=\
|
|
@@ -1657,7 +1700,11 @@ class CBEDPattern(fancytypes.PreSerializableAndUpdatable):
|
|
|
1657
1700
|
image = method_alias(u_x, u_y)
|
|
1658
1701
|
|
|
1659
1702
|
apply_shot_noise = self._apply_shot_noise
|
|
1660
|
-
|
|
1703
|
+
if apply_shot_noise == True:
|
|
1704
|
+
np_rng = np.random.default_rng(self._rng_seed)
|
|
1705
|
+
torch_rng_seed = np_rng.integers(low=0, high=2**32-1).item()
|
|
1706
|
+
torch_rng = torch.Generator().manual_seed(torch_rng_seed)
|
|
1707
|
+
image = torch.poisson(image, torch_rng)
|
|
1661
1708
|
|
|
1662
1709
|
image = self._apply_detector_partition_inpainting(input_image=image)
|
|
1663
1710
|
|
|
@@ -2522,6 +2569,10 @@ _check_and_convert_distortion_model_err_msg_1 = \
|
|
|
2522
2569
|
"grid, specified by the object ``distortion_model``, must be divisible "
|
|
2523
2570
|
"by the object ``num_pixels_across_pattern``.")
|
|
2524
2571
|
|
|
2572
|
+
_check_and_convert_rng_seed_err_msg_1 = \
|
|
2573
|
+
("The object ``rng_seed`` must be either a nonnegative integer or of the "
|
|
2574
|
+
"type `NoneType`.")
|
|
2575
|
+
|
|
2525
2576
|
_check_and_convert_cold_pixels_err_msg_1 = \
|
|
2526
2577
|
("The object ``cold_pixels`` must be a sequence of integer pairs, where "
|
|
2527
2578
|
"each integer pair specifies valid pixel coordinates (i.e. row and column "
|
fakecbed/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: fakecbed
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.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
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
fakecbed/__init__.py,sha256=iP73WNV_HZgxiVUVdesbJqlrhDGESooh1hlBs8kox9M,1342
|
|
2
|
+
fakecbed/discretized.py,sha256=vDV1kU2Q-JYDMp_WEAYCCLGXLN7urBCTfej-ggYC19M,99328
|
|
3
|
+
fakecbed/shapes.py,sha256=TiqJBZI4JZib0Q6zfO0e-dh7ACjYhvAYUvEtIedoo74,116471
|
|
4
|
+
fakecbed/tds.py,sha256=mk5359ErIhdpCoTdHq9r1-foKb8t3qCOHqNoabx3bQw,8066
|
|
5
|
+
fakecbed/version.py,sha256=Jk2iAU7m-7Vx9XV1TtdD9ZoJraIncDq_4_Wd-qtUotg,411
|
|
6
|
+
fakecbed-0.3.0.dist-info/LICENSE,sha256=N0P3pKtRMvfb64jmgJdlerg3TnS0a2QC776AzPsbZIg,35128
|
|
7
|
+
fakecbed-0.3.0.dist-info/METADATA,sha256=Yh3j9fCD-N_AXT5nUkdRHDdOGsQquCLbxJbW9fLsLng,3006
|
|
8
|
+
fakecbed-0.3.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
+
fakecbed-0.3.0.dist-info/top_level.txt,sha256=l0jL8P0CjRiCSznYLnq7riaAnOmYaV3zjjjIJx9vjSQ,9
|
|
10
|
+
fakecbed-0.3.0.dist-info/RECORD,,
|
fakecbed-0.2.1.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
fakecbed/__init__.py,sha256=iP73WNV_HZgxiVUVdesbJqlrhDGESooh1hlBs8kox9M,1342
|
|
2
|
-
fakecbed/discretized.py,sha256=bM_K0VJtSTxlIUdbsbPl2eiC6jJjoLn2y2iYy1XvBZE,97939
|
|
3
|
-
fakecbed/shapes.py,sha256=TiqJBZI4JZib0Q6zfO0e-dh7ACjYhvAYUvEtIedoo74,116471
|
|
4
|
-
fakecbed/tds.py,sha256=mk5359ErIhdpCoTdHq9r1-foKb8t3qCOHqNoabx3bQw,8066
|
|
5
|
-
fakecbed/version.py,sha256=MxUhzLJIZQfEpDTTcKSxciTGrMLd5v2VmMlHa2HGeo0,411
|
|
6
|
-
fakecbed-0.2.1.dist-info/LICENSE,sha256=N0P3pKtRMvfb64jmgJdlerg3TnS0a2QC776AzPsbZIg,35128
|
|
7
|
-
fakecbed-0.2.1.dist-info/METADATA,sha256=Oee7NOEdAU8tX0G00o0EiVf-ldtnubLkivCBYCq_2RY,3006
|
|
8
|
-
fakecbed-0.2.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
-
fakecbed-0.2.1.dist-info/top_level.txt,sha256=l0jL8P0CjRiCSznYLnq7riaAnOmYaV3zjjjIJx9vjSQ,9
|
|
10
|
-
fakecbed-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|