parq_blockmodel.reblocking.downsample.downsample_attributes#
- parq_blockmodel.reblocking.downsample.downsample_attributes(attributes, fx, fy, fz, aggregation_config)[source]#
Downsample a 3D block model to a coarser grid with multiple attributes using specified aggregation methods.
Parameters: - attributes: dict of 3D numpy arrays, e.g., {‘grade’: …, ‘density’: …, ‘rock_type’: …} - fx, fy, fz: downsampling factors along x, y, z axes - aggregation_config: dict specifying aggregation method and optional basis for each attribute
The fill_ratio key in aggregation_config indicates that the aggregation should be normalized by the fill ratio attribute specified. This is useful when some blocks may be partially filled after reblocking.
The replace key is used where users want to map specific aggregated values (for example 0) to another missing value indicator such as NaN.
Example
- attributes = {
‘grade’: grade, ‘density’: density, ‘dry_mass’: dry_mass, ‘volume’: volume, ‘rock_type’: rock_types ‘mass_with_missing’: mass_with_missing
}
- aggregation_config = {
‘grade’: {‘method’: ‘weighted_mean’, ‘basis’: ‘dry_mass’}, ‘density’: {‘method’: ‘weighted_mean’, ‘basis’: ‘volume’, fill_ratio: fill_ratio}, ‘dry_mass’: {‘method’: ‘sum’, fill_ratio: fill_ratio}, ‘volume’: {‘method’: ‘sum’}, ‘rock_type’: {‘method’: ‘mode’} ‘mass_with_missing’: {‘method’: ‘sum’, ‘replace’: { 0: nan }}
}
downsampled = downsample_attributes(attributes, fx=2, fy=2, fz=2, aggregation_config=aggregation_config)
NOTE: for regular models only the averaging f density can be simplified: From: ‘density’: {‘method’: ‘weighted_mean’, ‘basis’: ‘volume’, fill_ratio: fill_ratio}, To: ‘density’: {‘method’: ‘mean’},
Returns: - dict of downsampled 3D arrays