geometallurgy 0.4.5__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.5 → geometallurgy-0.4.7}/PKG-INFO +1 -1
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/base.py +86 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/config/mc_config.yml +1 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/pyproject.toml +1 -1
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/LICENSE +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/README.md +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/__init__.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/block_model.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/config/__init__.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/config/config_read.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/config/flowsheet_example.yaml +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/data/downloader.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/data/register.csv +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/datasets/__init__.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/datasets/datasets.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/datasets/downloader.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/datasets/register.csv +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/datasets/sample_data.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/extras.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/__init__.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/flowsheet.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/loader.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/operation.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/flowsheet/stream.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/interval_sample.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/io.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/plot.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/profile.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/sample.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/__init__.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/amenability.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/block_model_converter.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/components.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/data.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/interp.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/layout.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/moisture.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/pandas.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/parallel.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/partition.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/sampling.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/size.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/timer.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/utils/viz.py +0 -0
- {geometallurgy-0.4.5 → geometallurgy-0.4.7}/elphick/geomet/validate.py.hide +0 -0
|
@@ -235,6 +235,78 @@ class MassComposition(ABC):
|
|
|
235
235
|
|
|
236
236
|
return self
|
|
237
237
|
|
|
238
|
+
def set_moisture(self, moisture: Union[pd.Series, float, int], mass_to_adjust: Literal['wet', 'dry'] = 'wet') -> MC:
|
|
239
|
+
"""Set the moisture to the specified value
|
|
240
|
+
|
|
241
|
+
A convenience method for an mc object that modifies the concrete mass to deliver the specified moisture.
|
|
242
|
+
|
|
243
|
+
Args:
|
|
244
|
+
moisture: The moisture value to set. Can be a constant or series.
|
|
245
|
+
mass_to_adjust: The mass to adjust, either 'wet' or 'dry'.
|
|
246
|
+
|
|
247
|
+
Returns:
|
|
248
|
+
|
|
249
|
+
"""
|
|
250
|
+
|
|
251
|
+
if not self.moisture_in_scope:
|
|
252
|
+
raise AssertionError("This method is not applicable unless moisture_in_scope property is True.")
|
|
253
|
+
|
|
254
|
+
if isinstance(moisture, float) or isinstance(moisture, int):
|
|
255
|
+
# create a series with the same index as the mass data
|
|
256
|
+
moisture = pd.Series(float(moisture), index=self._mass_data.index)
|
|
257
|
+
elif not isinstance(moisture, pd.Series):
|
|
258
|
+
raise TypeError(f"moisture must be a float or a pd.Series, not {type(moisture)}")
|
|
259
|
+
|
|
260
|
+
if mass_to_adjust == 'wet':
|
|
261
|
+
self._mass_data[self.mass_wet_var] = solve_mass_moisture(mass_dry=self._mass_data[self.mass_dry_var],
|
|
262
|
+
moisture=moisture)
|
|
263
|
+
elif mass_to_adjust == 'dry':
|
|
264
|
+
self._mass_data[self.mass_dry_var] = solve_mass_moisture(mass_wet=self._mass_data[self.mass_wet_var],
|
|
265
|
+
moisture=moisture)
|
|
266
|
+
else:
|
|
267
|
+
raise ValueError(f"mass_to_adjust must be 'wet' or 'dry', not {mass_to_adjust}")
|
|
268
|
+
|
|
269
|
+
return self
|
|
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
|
+
|
|
238
310
|
def plot_parallel(self, color: Optional[str] = None,
|
|
239
311
|
vars_include: Optional[list[str]] = None,
|
|
240
312
|
vars_exclude: Optional[list[str]] = None,
|
|
@@ -771,6 +843,20 @@ class MassComposition(ABC):
|
|
|
771
843
|
|
|
772
844
|
return res
|
|
773
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
|
+
|
|
774
860
|
|
|
775
861
|
class OutOfRangeStatus:
|
|
776
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
|