Commit 82ea1796 authored by whooie's avatar whooie
Browse files

mode accounting for OD array into AbsorptionData, as it should be

parent 97f18ec7
......@@ -20,11 +20,11 @@ DEF_DX = 3.45 # pixel size for Flir Grasshopper [um]
class ImagingData:
def __init__(self, outdir: pathlib.Path, arrays: dict[str, np.ndarray],
config: dict[str, ...], comments: str=None,
config: dict[str, ...]=None, comments: str=None,
results: dict[str, ...]=None):
self.outdir = outdir
self.arrays = arrays
self.config = config
self.config = dict() if config is None else config
self.comments = str() if comments is None else comments
self.results = results
......@@ -90,39 +90,20 @@ class ImagingData:
#if printflag: print(" Done.")
return ImagingData(outdir, arrays, config, comments, results)
def render_arrays(self, target: pathlib.Path=None, dx=None,
printflag: bool=True):
def render_arrays(self, target: pathlib.Path=None, printflag: bool=True):
T = self.outdir if target is None else target
T = T.joinpath("images")
_dx = self.config.get("bin_size", 1) * (DEF_DX if dx is None else dx)
if printflag: print(f"[imaging] Render images to {T}:")
if not T.is_dir():
if printflag: print(f"[imaging] mkdir {T}")
T.mkdir(parents=True, exist_ok=True)
for label, array in self.arrays.items():
if printflag: print(f"[imaging] render '{label}'")
if label == "od":
warnings.filterwarnings("ignore")
H, W = array.shape
(pd.Plotter()
.imshow(array,
cmap=pd.colormaps["vibrant"], vmin=-0.1, vmax=0.15,
extent=[0, W * _dx, H * _dx, 0]
)
.colorbar()
#.set_clim(0, array.max())
.set_xlabel("[$\\mu$m]")
.set_ylabel("[$\\mu$m]")
.savefig(T.joinpath(label + ".png"))
.close()
)
warnings.resetwarnings()
else:
PIL.Image.fromarray(array).save(T.joinpath(label + ".png"))
PIL.Image.fromarray(array).save(T.joinpath(label + ".png"))
#if printflag: print(" Done.")
return self
def compute_results(self, dA=(2*3.45)**2, printflag: bool=True):
def compute_results(self, printflag: bool=True):
raise NotImplementedError
class AbsorptionData(ImagingData):
......@@ -145,6 +126,38 @@ class AbsorptionData(ImagingData):
self.results.update({"sx": sx, "sy": sy})
return self
def render_arrays(self, target: pathlib.Path=None, dx=None,
printflag: bool=True):
T = self.outdir if target is None else target
T = T.joinpath("images")
_dx = self.config.get("bin_size", 1) * (DEF_DX if dx is None else dx)
if printflag: print(f"[imaging] Render images to {T}:")
if not T.is_dir():
if printflag: print(f"[imaging] mkdir {T}")
T.mkdir(parents=True, exist_ok=True)
for label, array in self.arrays.items():
if printflag: print(f"[imaging] render '{label}'")
if label == "od":
warnings.filterwarnings("ignore")
H, W = array.shape
(pd.Plotter()
.imshow(array,
cmap=pd.colormaps["vibrant"], vmin=-0.1, vmax=0.15,
extent=[0, W * _dx, H * _dx, 0]
)
.colorbar()
#.set_clim(0, array.max())
.set_xlabel("[$\\mu$m]")
.set_ylabel("[$\\mu$m]")
.savefig(T.joinpath(label + ".png"))
.close()
)
warnings.resetwarnings()
else:
PIL.Image.fromarray(array).save(T.joinpath(label + ".png"))
#if printflag: print(" Done.")
return self
def compute_od(shadow: np.ndarray, bright: np.ndarray, dark: np.ndarray):
with np.errstate(divide="ignore", invalid="ignore"):
T = (shadow - dark) / (bright - dark)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment