geometallurgy 0.4.6__tar.gz → 0.4.7__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.
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/PKG-INFO +1 -1
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/base.py +53 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/config/mc_config.yml +1 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/pyproject.toml +1 -1
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/LICENSE +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/README.md +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/__init__.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/block_model.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/config/__init__.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/config/config_read.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/config/flowsheet_example.yaml +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/data/downloader.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/data/register.csv +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/datasets/__init__.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/datasets/datasets.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/datasets/downloader.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/datasets/register.csv +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/datasets/sample_data.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/extras.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/__init__.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/flowsheet.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/loader.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/operation.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/stream.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/interval_sample.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/io.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/plot.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/profile.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/sample.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/__init__.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/amenability.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/block_model_converter.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/components.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/data.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/interp.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/layout.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/moisture.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/pandas.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/parallel.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/partition.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/sampling.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/size.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/timer.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/utils/viz.py +0 -0
- {geometallurgy-0.4.6 → geometallurgy-0.4.7}/elphick/geomet/validate.py.hide +0 -0
|
@@ -268,6 +268,45 @@ class MassComposition(ABC):
|
|
|
268
268
|
|
|
269
269
|
return self
|
|
270
270
|
|
|
271
|
+
def clip_composition(self, ranges: Optional[dict[str, list[float]]] = None) -> MC:
|
|
272
|
+
"""Clip the components
|
|
273
|
+
|
|
274
|
+
Clip to the components to within the range provided or the default range for each component.
|
|
275
|
+
This method does not clip moisture - see set_moisture and solve_moisture for that.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
ranges: An optional dict defining a list of [lo, hi] floats for each component. If not provided,
|
|
279
|
+
the default range from the config file will be used.
|
|
280
|
+
|
|
281
|
+
Returns:
|
|
282
|
+
The object with clipped composition.
|
|
283
|
+
"""
|
|
284
|
+
|
|
285
|
+
# load the default ranges from the config file
|
|
286
|
+
component_ranges: dict = self._get_component_ranges(ranges)
|
|
287
|
+
|
|
288
|
+
# define a small value to ensure the clipped values lie marginally inside the specified range.
|
|
289
|
+
epsilon: float = 0.0 # 1.0e-05
|
|
290
|
+
# clip the components
|
|
291
|
+
affected_indexes = set()
|
|
292
|
+
for component, component_range in component_ranges.items():
|
|
293
|
+
before_clip = self._mass_data[component].copy()
|
|
294
|
+
# define the component mass that aligns with the lower and upper bounds
|
|
295
|
+
component_mass_limits = self._mass_data[self.mass_dry_var].values[:, np.newaxis] * np.array(
|
|
296
|
+
component_range) / self.composition_factor
|
|
297
|
+
# apply the clip to the mass data
|
|
298
|
+
self._mass_data[component] = self._mass_data[component].clip(lower=component_mass_limits[:, 0] + epsilon,
|
|
299
|
+
upper=component_mass_limits[:, 1] - epsilon)
|
|
300
|
+
affected_indexes.update(self._mass_data.index[before_clip != self._mass_data[component]])
|
|
301
|
+
|
|
302
|
+
# log the action, including the first 50 indexes affected
|
|
303
|
+
affected_indexes_list = sorted(affected_indexes)[:50]
|
|
304
|
+
self._logger.info(
|
|
305
|
+
f"{len(affected_indexes)} records where composition has been clipped to the range: {component_ranges}."
|
|
306
|
+
f" Affected indexes (first 50): {affected_indexes_list}")
|
|
307
|
+
|
|
308
|
+
return self
|
|
309
|
+
|
|
271
310
|
def plot_parallel(self, color: Optional[str] = None,
|
|
272
311
|
vars_include: Optional[list[str]] = None,
|
|
273
312
|
vars_exclude: Optional[list[str]] = None,
|
|
@@ -804,6 +843,20 @@ class MassComposition(ABC):
|
|
|
804
843
|
|
|
805
844
|
return res
|
|
806
845
|
|
|
846
|
+
def _get_component_ranges(self, ranges: dict[str, list]) -> dict[str, list]:
|
|
847
|
+
|
|
848
|
+
d_ranges: dict = get_column_config(config_dict=self.config, var_map=self.variable_map,
|
|
849
|
+
config_key='range')
|
|
850
|
+
# filter to include only components
|
|
851
|
+
d_ranges = {k: v for k, v in d_ranges.items() if k in self.composition_columns}
|
|
852
|
+
|
|
853
|
+
# modify the default dict based on any user passed constraints
|
|
854
|
+
if ranges:
|
|
855
|
+
for k, v in ranges.items():
|
|
856
|
+
d_ranges[k] = v
|
|
857
|
+
|
|
858
|
+
return d_ranges
|
|
859
|
+
|
|
807
860
|
|
|
808
861
|
class OutOfRangeStatus:
|
|
809
862
|
"""A class to check and report out-of-range records in an MC object."""
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "geometallurgy"
|
|
3
3
|
packages = [{ include = "elphick/geomet" }]
|
|
4
|
-
version = "0.4.
|
|
4
|
+
version = "0.4.7"
|
|
5
5
|
description = "Tools for the geometallurgist"
|
|
6
6
|
authors = ["Greg <11791585+elphick@users.noreply.github.com>"]
|
|
7
7
|
repository = "https://github.com/elphick/geometallurgy"
|
|
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
|
|
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
|