Input and Output¶
PtyLab.io
¶
getExampleDataFolder()
¶
generateSimulationData
¶
Generate synthetic CPM simulation data and save as simu.hdf5.
This module contains the simulation logic from example_scripts/simulateData.py as a callable function with no side effects (no plotting, no os.chdir).
generate_simu_hdf5(output_path)
¶
Generate a synthetic CPM ptychography dataset and save it as an HDF5 file.
The simulation produces a focused Gaussian probe and a complex spiral object, computes diffraction patterns using Fraunhofer propagation, adds Poisson noise, and writes the result to output_path.
Parameters¶
output_path : Path
Destination file path (e.g. example_data/simu.hdf5).
The parent directory must already exist.
Source code in PtyLab/io/generateSimulationData.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
readExample
¶
examplePath(key)
¶
Return the full path to a particular example file. If the key is not found, the key is returned as path. :param key: which dataset to look for. :return:
Source code in PtyLab/io/readExample.py
loadExample(key, *args, **kwargs)
¶
Load an example from the example_data folder. To check which datasets are available, either run listExamples() or look in the folder example_data.
:param key: Key to look for. Will try to look up the filename in readExample.exampleFiles, otherwise it will attempt to find the file in example_data. :param args: will be passed to loadInputData :param kwargs: idem :return:
Source code in PtyLab/io/readExample.py
readHdf5
¶
scalify(l)
¶
hdf5 file storing (especially when using matlab) can store integers as Numpy arrays of size [1,1]. Convert to scalar if that's the case
loadInputData(filename, requiredFields, optionalFields)
¶
Load all values from an hdf5 file into a dictionary, but only with the required fields :param filename: the .hdf5 file that has to be loaded. If it's a .mat file it will attempt to load it :param python_order: Weather to read in the files in a way that is common in python, aka for a list of images the first index is the image and not the pixel. :return:
Source code in PtyLab/io/readHdf5.py
getOrientation(filename)
¶
If orientation is given, return it. Otherwise, return None
Source code in PtyLab/io/readHdf5.py
checkDataFields(filename, requiredFields)
¶
Make sure that all the fields in a given .hdf5 file are supported and do some sanity checks.
This is run before loading the file just to make sure that the file is correctly formatted. :param filename: '.hdf5' file with all the necessary attributes. :return: None if correct :raise: KeyError if one of the attributes is missing.