porescene.worker module¶
- porescene.worker.build_structure(sc, pn, *, left=False, right=False, front=False, back=False, bottom=False, top=False)[source]¶
Constructs the cylinder and sphere meshes in the Blender scene based on the given
PoreNetworkinstance.- Parameters:
sc (
Scene) – The scene to add the objects to.pn (
PoreNetwork) – The pore network that is used to calculate cylinder and sphere positions as well as dimensionsleft (
bool) – If true, boundary pores (as well as their connections into the central network) at the start of the x-dimension are added into the scene, by default Falseright (
bool) – If true, boundary pores (as well as their connections into the central network) at the end of the x-dimension are added into the scene, by default Falsefront (
bool) – If true, boundary pores (as well as their connections into the central network) at the start of the y-dimension are added into the scene, by default Falseback (
bool) – If true, boundary pores (as well as their connections into the central network) at the end of the y-dimension are added into the scene, by default Falsebottom (
bool) – If true, boundary pores (as well as their connections into the central network) at the start of the z-dimension are added into the scene, by default Falsetop (
bool) – If true, boundary pores (as well as their connections into the central network) at the end of the z-dimension are added into the scene, by default False
- Returns:
The scene with added objects.
- Return type:
- porescene.worker.make_coordination_number(dir_img, pn, sc)[source]¶
Renders the pore network with pores, throats, and clusters colored by their coordination number and composites a matching colorbar onto the image.
A color gradient (the gradient class configured for the
coordination_numberproperty) is fitted to the coordination-number range, the sphere, cylinder, and cluster layers are colored accordingly viamake_img(), and a colorbar for the gradient is added. Each layer is only colored and shown when it is enabled in the scene configuration and the corresponding data is available.- Parameters:
dir_img (
Path) – Directory to save the rendered image and colorbar at.pn (
PoreNetwork) – The pore network providing the pore and throat coordination numbers.sc (
Scene) – The scene holding the already-built geometry and thecoordination_numberproperty configuration.
- Returns:
The file path to the rendered image with colorbar.
- Return type:
- porescene.worker.make_gradient_overlay(pth, config, mn, mx, /, ticks=(), **kwargs)[source]¶
- Return type:
- porescene.worker.make_img(dir_img, sc, show_spheres=True, show_cylinders=True, show_clusters=True, color_spheres=(), color_cylinders=(), color_clusters=(), name_spheres='', name_cylinders='', name_clusters='', no_state=None, solid=None, void=None)[source]¶
Populates the scene with the specified components, renders it, and resets the scene afterwards.
The pore spheres, throat cylinders, and pore clusters are shown (and colored) only when their respective
show_*flag is set; a solid and/or void object are added when their paths are given, and axes are shown when enabled in the scene configuration. The output file name is assembled from the enabled components (e.g.sphere-radius+cylinder-radius+axes), so each rendered combination gets a distinct, descriptive name. After rendering, all layers are hidden and the solid and void objects are removed, leaving the scene ready for the next render.- Parameters:
dir_img (
Path) – Directory to save the rendered image at.sc (
Scene) – Scene to populate and render.show_spheres (
bool) – Whether to show the pore spheres, by default True.show_cylinders (
bool) – Whether to show the throat cylinders, by default True.show_clusters (
bool) – Whether to show the pore clusters, by default True.color_spheres (
tuple[Color,...]) – Per-pore colors applied to the sphere layer (oneColorper pore); used only whenshow_spheresis set, by default [].color_cylinders (
tuple[Color,...]) – Per-throat colors applied to the cylinder layer (oneColorper throat); used only whenshow_cylindersis set, by default [].color_clusters (
tuple[Color,...]) – Per-cluster colors applied to the cluster layer; used only whenshow_clustersis set, by default [].name_spheres (
str) – Label describing the sphere coloring, embedded in the output file name with underscores replaced by hyphens (e.g."radius"), by default “”.name_cylinders (
str) – Label describing the cylinder coloring, embedded in the output file name with underscores replaced by hyphens, by default “”.name_clusters (
str) – Label describing the cluster coloring, embedded in the output file name with underscores replaced by hyphens, by default “”.no_state (
int|None) – Index of the network state being rendered; when given, appended to the file name asstate@<no_state>, by default None.solid (
Path|None) – Path to a solid-structure object to add to the scene; when given, the solid is created andsolidis added to the file name, by default None.void (
Path|None) – Path to a void-space object to add to the scene; when given, the void is created andvoidis added to the file name, by default None.
- Returns:
File path to the rendered image.
- Return type:
- porescene.worker.make_radius(dir_save, pn, sc)[source]¶
Renders the pore network with pores and throats colored by their radius and composites a matching colorbar onto the image.
A smooth color gradient is fitted to the radius range (across pore and throat radii), the sphere and cylinder layers are colored accordingly via
make_img(), the rendered image is trimmed, and a colorbar for the gradient is added. Spheres and cylinders are only colored and shown when enabled in the scene configuration and the corresponding radius data is present.- Parameters:
dir_save (
Path) – Directory to save the rendered image and colorbar at.pn (
PoreNetwork) – The pore network providing the pore and throat radii.sc (
Scene) – The scene holding the already-built geometry and theradiusproperty configuration.
- Returns:
The file path to the rendered image with colorbar.
- Return type:
- Raises:
Exception – If any boundary throats are included in the scene and matching
throat_radius_*data is missing on thePoreNetworkinstance.
- porescene.worker.make_random(dir_img, pn, sc)[source]¶
Renders the pore network with pores, throats, and clusters assigned random colors.
Each layer is drawn with colors picked at random from the scene’s palette, so that individual pores, throats, and clusters can be told apart visually. A layer is only colored and shown when it is enabled in the scene configuration and has actually been built in the scene. Unlike the property-based renders, no colorbar is added, since the random colors carry no scale.
- Parameters:
dir_img (
Path) – Directory to save the rendered image at.pn (
PoreNetwork) – The pore network providing the pore, throat, and cluster counts used to size the random color sets.sc (
Scene) – The scene holding the already-built geometry and the color palette.
- Returns:
The file path to the rendered image.
- Return type:
- porescene.worker.make_structure(dir_img, pn, sc)[source]¶
Renders the pore network with all pores, throats, and clusters in a uniform gray.
This is the plain structure view: every layer is drawn in a single neutral gray, without any property-based coloring or colorbar, giving a clean overview of the network geometry. A layer is only shown when it is enabled in the scene configuration and has actually been built in the scene.
- Parameters:
dir_img (
Path) – Directory to save the rendered image at.pn (
PoreNetwork) – The pore network providing the pore and throat counts.sc (
Scene) – The scene holding the already-built geometry.
- Returns:
The file path to the rendered image.
- Return type: