geometallurgy 0.4.11__py3-none-any.whl → 0.4.13__py3-none-any.whl

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.
Files changed (49) hide show
  1. elphick/geomet/__init__.py +11 -11
  2. elphick/geomet/base.py +1133 -1133
  3. elphick/geomet/block_model.py +319 -358
  4. elphick/geomet/config/__init__.py +1 -1
  5. elphick/geomet/config/config_read.py +39 -39
  6. elphick/geomet/config/flowsheet_example_partition.yaml +31 -31
  7. elphick/geomet/config/flowsheet_example_simple.yaml +25 -25
  8. elphick/geomet/config/mc_config.yml +35 -35
  9. elphick/geomet/data/downloader.py +39 -39
  10. elphick/geomet/data/register.csv +12 -12
  11. elphick/geomet/datasets/__init__.py +2 -2
  12. elphick/geomet/datasets/datasets.py +47 -47
  13. elphick/geomet/datasets/downloader.py +40 -40
  14. elphick/geomet/datasets/register.csv +12 -12
  15. elphick/geomet/datasets/sample_data.py +196 -196
  16. elphick/geomet/extras.py +35 -35
  17. elphick/geomet/flowsheet/__init__.py +1 -1
  18. elphick/geomet/flowsheet/flowsheet.py +1216 -1193
  19. elphick/geomet/flowsheet/loader.py +99 -99
  20. elphick/geomet/flowsheet/operation.py +256 -256
  21. elphick/geomet/flowsheet/stream.py +39 -38
  22. elphick/geomet/interval_sample.py +641 -641
  23. elphick/geomet/io.py +379 -379
  24. elphick/geomet/plot.py +147 -147
  25. elphick/geomet/sample.py +28 -28
  26. elphick/geomet/utils/amenability.py +49 -49
  27. elphick/geomet/utils/block_model_converter.py +93 -93
  28. elphick/geomet/utils/components.py +136 -136
  29. elphick/geomet/utils/data.py +49 -49
  30. elphick/geomet/utils/estimates.py +108 -108
  31. elphick/geomet/utils/interp.py +193 -193
  32. elphick/geomet/utils/interp2.py +134 -134
  33. elphick/geomet/utils/layout.py +72 -72
  34. elphick/geomet/utils/moisture.py +61 -61
  35. elphick/geomet/utils/output.html +617 -0
  36. elphick/geomet/utils/pandas.py +378 -378
  37. elphick/geomet/utils/parallel.py +29 -29
  38. elphick/geomet/utils/partition.py +63 -63
  39. elphick/geomet/utils/size.py +51 -51
  40. elphick/geomet/utils/timer.py +80 -80
  41. elphick/geomet/utils/viz.py +56 -56
  42. elphick/geomet/validate.py.hide +176 -176
  43. {geometallurgy-0.4.11.dist-info → geometallurgy-0.4.13.dist-info}/LICENSE +21 -21
  44. {geometallurgy-0.4.11.dist-info → geometallurgy-0.4.13.dist-info}/METADATA +7 -5
  45. geometallurgy-0.4.13.dist-info/RECORD +49 -0
  46. {geometallurgy-0.4.11.dist-info → geometallurgy-0.4.13.dist-info}/WHEEL +1 -1
  47. elphick/geomet/utils/sampling.py +0 -5
  48. geometallurgy-0.4.11.dist-info/RECORD +0 -49
  49. {geometallurgy-0.4.11.dist-info → geometallurgy-0.4.13.dist-info}/entry_points.txt +0 -0
@@ -1 +1 @@
1
- from .config_read import read_yaml
1
+ from .config_read import read_yaml
@@ -1,39 +1,39 @@
1
- import logging
2
- from typing import Dict
3
-
4
- import yaml
5
-
6
-
7
- def read_yaml(file_path):
8
- with open(file_path, "r") as f:
9
- d_config: Dict = yaml.safe_load(f)
10
- if 'MC' != list(d_config.keys())[0]:
11
- msg: str = f'config file {file_path} is not a MassComposition config file - no MC key'
12
- logging.error(msg)
13
- raise KeyError(msg)
14
- return d_config['MC']
15
-
16
-
17
- def read_flowsheet_yaml(file_path):
18
- with open(file_path, "r") as f:
19
- d_config: Dict = yaml.safe_load(f)
20
- if 'FLOWSHEET' != list(d_config.keys())[0]:
21
- msg: str = f'config file {file_path} is not a Flowsheet config file - no FLOWSHEET key'
22
- logging.error(msg)
23
- raise KeyError(msg)
24
- return d_config['FLOWSHEET']
25
-
26
-
27
- def get_column_config(config_dict: dict, var_map: dict, config_key: str = 'range') -> dict:
28
- res: dict = {}
29
- # populate from the config
30
- # var_map only includes mass-composition columns, no supplementary. vars are keys, cols are values
31
- composition_cols = [v for k, v in var_map.items() if k not in ['mass_wet', 'mass_dry', 'moisture']]
32
-
33
- for k, v in config_dict['vars'].items():
34
- if k == 'composition':
35
- for col in composition_cols:
36
- res[col] = v[config_key]
37
- elif k in list(var_map.keys()) and v.get(config_key):
38
- res[var_map[k]] = v[config_key]
39
- return res
1
+ import logging
2
+ from typing import Dict
3
+
4
+ import yaml
5
+
6
+
7
+ def read_yaml(file_path):
8
+ with open(file_path, "r") as f:
9
+ d_config: Dict = yaml.safe_load(f)
10
+ if 'MC' != list(d_config.keys())[0]:
11
+ msg: str = f'config file {file_path} is not a MassComposition config file - no MC key'
12
+ logging.error(msg)
13
+ raise KeyError(msg)
14
+ return d_config['MC']
15
+
16
+
17
+ def read_flowsheet_yaml(file_path):
18
+ with open(file_path, "r") as f:
19
+ d_config: Dict = yaml.safe_load(f)
20
+ if 'FLOWSHEET' != list(d_config.keys())[0]:
21
+ msg: str = f'config file {file_path} is not a Flowsheet config file - no FLOWSHEET key'
22
+ logging.error(msg)
23
+ raise KeyError(msg)
24
+ return d_config['FLOWSHEET']
25
+
26
+
27
+ def get_column_config(config_dict: dict, var_map: dict, config_key: str = 'range') -> dict:
28
+ res: dict = {}
29
+ # populate from the config
30
+ # var_map only includes mass-composition columns, no supplementary. vars are keys, cols are values
31
+ composition_cols = [v for k, v in var_map.items() if k not in ['mass_wet', 'mass_dry', 'moisture']]
32
+
33
+ for k, v in config_dict['vars'].items():
34
+ if k == 'composition':
35
+ for col in composition_cols:
36
+ res[col] = v[config_key]
37
+ elif k in list(var_map.keys()) and v.get(config_key):
38
+ res[var_map[k]] = v[config_key]
39
+ return res
@@ -1,31 +1,31 @@
1
- FLOWSHEET:
2
- flowsheet:
3
- name: Flowsheet
4
- streams: # graph edges
5
- Feed:
6
- name: Feed
7
- node_in: feed
8
- node_out: screen
9
- Coarse:
10
- name: Coarse
11
- node_in: screen
12
- node_out: lump
13
- Fine:
14
- name: Fine
15
- node_in: screen
16
- node_out: fines
17
- operations: # graph nodes
18
- feed:
19
- name: feed
20
- screen:
21
- name: screen
22
- type: PartitionOperation
23
- partition:
24
- module: elphick.geomet.utils.partition
25
- function: napier_munn_size_1mm
26
- partition_stream: Lump # the stream that the partition model defines
27
- args: null # e.g. d50, ep if not defined in the (partial) function
28
- lump:
29
- name: lump
30
- fines:
31
- name: fines
1
+ FLOWSHEET:
2
+ flowsheet:
3
+ name: Flowsheet
4
+ streams: # graph edges
5
+ Feed:
6
+ name: Feed
7
+ node_in: feed
8
+ node_out: screen
9
+ Coarse:
10
+ name: Coarse
11
+ node_in: screen
12
+ node_out: lump
13
+ Fine:
14
+ name: Fine
15
+ node_in: screen
16
+ node_out: fines
17
+ operations: # graph nodes
18
+ feed:
19
+ name: feed
20
+ screen:
21
+ name: screen
22
+ type: PartitionOperation
23
+ partition:
24
+ module: elphick.geomet.utils.partition
25
+ function: napier_munn_size_1mm
26
+ partition_stream: Lump # the stream that the partition model defines
27
+ args: null # e.g. d50, ep if not defined in the (partial) function
28
+ lump:
29
+ name: lump
30
+ fines:
31
+ name: fines
@@ -1,25 +1,25 @@
1
- FLOWSHEET:
2
- flowsheet:
3
- name: Flowsheet
4
- streams: # graph edges
5
- Feed:
6
- name: Feed
7
- node_in: feed
8
- node_out: screen
9
- Coarse:
10
- name: Coarse
11
- node_in: screen
12
- node_out: lump
13
- Fine:
14
- name: Fine
15
- node_in: screen
16
- node_out: fines
17
- operations: # graph nodes
18
- feed:
19
- name: feed
20
- screen:
21
- name: screen
22
- lump:
23
- name: lump
24
- fines:
25
- name: fines
1
+ FLOWSHEET:
2
+ flowsheet:
3
+ name: Flowsheet
4
+ streams: # graph edges
5
+ Feed:
6
+ name: Feed
7
+ node_in: feed
8
+ node_out: screen
9
+ Coarse:
10
+ name: Coarse
11
+ node_in: screen
12
+ node_out: lump
13
+ Fine:
14
+ name: Fine
15
+ node_in: screen
16
+ node_out: fines
17
+ operations: # graph nodes
18
+ feed:
19
+ name: feed
20
+ screen:
21
+ name: screen
22
+ lump:
23
+ name: lump
24
+ fines:
25
+ name: fines
@@ -1,35 +1,35 @@
1
- MC:
2
- vars:
3
- mass_wet:
4
- default_name: 'mass_wet'
5
- search_regex: '(mass_wet)|(wet_mass)|(wmt)' # case in-sensitive regex
6
- format: '%.0f' # cannot use %d, use %.
7
- range: [0.0, .inf] # the range of valid values
8
- mass_dry:
9
- default_name: 'mass_dry'
10
- search_regex: '(mass_dry)|(dry_mass)|(dmt)'
11
- format: '%.0f'
12
- range: [ 0.0, .inf]
13
- moisture:
14
- default_name: 'h2o'
15
- search_regex: '(h2o)|(moisture)|(moist)'
16
- format: '%.1f'
17
- range: [0.0, 100.0]
18
- composition:
19
- ignore: ['Y'] # ignore anything in this list when detecting chemistry components
20
- format: '%.2f'
21
- range: [0.0, 100.0]
22
- fe:
23
- range: [0.0, 69.97] # hematite
24
- intervals:
25
- closed: left
26
- suffixes:
27
- - [from, to]
28
- - [retained, passing]
29
- - [sink, float]
30
- - [lo, hi]
31
- comparisons:
32
- recovery: 'rec'
33
- difference: 'diff'
34
- divide: 'ur'
35
-
1
+ MC:
2
+ vars:
3
+ mass_wet:
4
+ default_name: 'mass_wet'
5
+ search_regex: '(mass_wet)|(wet_mass)|(wmt)' # case in-sensitive regex
6
+ format: '%.0f' # cannot use %d, use %.
7
+ range: [0.0, .inf] # the range of valid values
8
+ mass_dry:
9
+ default_name: 'mass_dry'
10
+ search_regex: '(mass_dry)|(dry_mass)|(dmt)'
11
+ format: '%.0f'
12
+ range: [ 0.0, .inf]
13
+ moisture:
14
+ default_name: 'h2o'
15
+ search_regex: '(h2o)|(moisture)|(moist)'
16
+ format: '%.1f'
17
+ range: [0.0, 100.0]
18
+ composition:
19
+ ignore: ['Y'] # ignore anything in this list when detecting chemistry components
20
+ format: '%.2f'
21
+ range: [0.0, 100.0]
22
+ fe:
23
+ range: [0.0, 69.97] # hematite
24
+ intervals:
25
+ closed: left
26
+ suffixes:
27
+ - [from, to]
28
+ - [retained, passing]
29
+ - [sink, float]
30
+ - [lo, hi]
31
+ comparisons:
32
+ recovery: 'rec'
33
+ difference: 'diff'
34
+ divide: 'ur'
35
+
@@ -1,39 +1,39 @@
1
- import webbrowser
2
- from pathlib import Path
3
- from typing import Dict
4
-
5
- import pandas as pd
6
- import platformdirs
7
- import pooch
8
- from pooch import Unzip, Pooch
9
-
10
-
11
- class Downloader:
12
- def __init__(self):
13
- """Instantiate a Downloader
14
- """
15
-
16
- self.register: pd.DataFrame = pd.read_csv(Path(__file__).parent / 'register.csv', index_col=False)
17
-
18
- self.dataset_hashes: Dict = self.register[['target', 'target_sha256']].set_index('target').to_dict()[
19
- 'target_sha256']
20
-
21
- self.downloader: Pooch = pooch.create(path=Path(platformdirs.user_cache_dir('mass_composition', 'elphick')),
22
- base_url="https://github.com/elphick/mass-composition/raw/main/docs"
23
- "/source/_static/",
24
- version=None,
25
- version_dev=None,
26
- registry={**self.dataset_hashes})
27
-
28
- def load_data(self, datafile: str = 'size_by_assay.zip', show_report: bool = False) -> pd.DataFrame:
29
- """
30
- Load the 231575341_size_by_assay data as a pandas.DataFrame.
31
- """
32
- if datafile not in self.dataset_hashes.keys():
33
- raise KeyError(f"The file {datafile} is not in the registry containing: {self.dataset_hashes.keys()}")
34
-
35
- fnames = self.downloader.fetch(datafile, processor=Unzip())
36
- if show_report:
37
- webbrowser.open(str(Path(fnames[0]).with_suffix('.html')))
38
- data = pd.read_csv(Path(fnames[0]).with_suffix('.csv'))
39
- return data
1
+ import webbrowser
2
+ from pathlib import Path
3
+ from typing import Dict
4
+
5
+ import pandas as pd
6
+ import platformdirs
7
+ import pooch
8
+ from pooch import Unzip, Pooch
9
+
10
+
11
+ class Downloader:
12
+ def __init__(self):
13
+ """Instantiate a Downloader
14
+ """
15
+
16
+ self.register: pd.DataFrame = pd.read_csv(Path(__file__).parent / 'register.csv', index_col=False)
17
+
18
+ self.dataset_hashes: Dict = self.register[['target', 'target_sha256']].set_index('target').to_dict()[
19
+ 'target_sha256']
20
+
21
+ self.downloader: Pooch = pooch.create(path=Path(platformdirs.user_cache_dir('mass_composition', 'elphick')),
22
+ base_url="https://github.com/elphick/mass-composition/raw/main/docs"
23
+ "/source/_static/",
24
+ version=None,
25
+ version_dev=None,
26
+ registry={**self.dataset_hashes})
27
+
28
+ def load_data(self, datafile: str = 'size_by_assay.zip', show_report: bool = False) -> pd.DataFrame:
29
+ """
30
+ Load the 231575341_size_by_assay data as a pandas.DataFrame.
31
+ """
32
+ if datafile not in self.dataset_hashes.keys():
33
+ raise KeyError(f"The file {datafile} is not in the registry containing: {self.dataset_hashes.keys()}")
34
+
35
+ fnames = self.downloader.fetch(datafile, processor=Unzip())
36
+ if show_report:
37
+ webbrowser.open(str(Path(fnames[0]).with_suffix('.html')))
38
+ data = pd.read_csv(Path(fnames[0]).with_suffix('.csv'))
39
+ return data
@@ -1,12 +1,12 @@
1
- ,dataset,datafile,bytes,metadata,report,archive,datafile_md5,target_filepath,target,target_sha256
2
- 0,A072391_assay,..\..\datasets\A072391_assay\A072391_assay.csv,32891149,True,True,True,957309836cb748525974aa690c5f919a,..\..\datasets\A072391_assay\A072391_assay.zip,A072391_assay.zip,b669840cc90aaa2d615986cdcf4ef5f97ec7352032597adc93440b154159d41f
3
- 1,A072391_collars,..\..\datasets\A072391_collars\A072391_collars.csv,765470,True,True,True,597f5fe444270fe4409814b002b6e5cd,..\..\datasets\A072391_collars\A072391_collars.zip,A072391_collars.zip,9c01345766dc39462327c26604bddbd02db38f76118fe092bc90407e15bb5d09
4
- 2,A072391_geo,..\..\datasets\A072391_geo\A072391_geo.csv,23544608,True,True,True,cdd8aed2841c73f3c203b995e099b590,..\..\datasets\A072391_geo\A072391_geo.zip,A072391_geo.zip,cf687584cc891fa084a45432e82747b7ef581eb21fe54f885f0b4c4f342c1641
5
- 3,A072391_met,..\..\datasets\A072391_met\A072391_met.csv,412184,True,True,True,d2ac41f41ab7ba56f8239d63dba8a906,..\..\datasets\A072391_met\A072391_met.zip,A072391_met.zip,f4f84eeb4826755410d9979771a7e4f96afa2333586be85b775f179ece9c7bdf
6
- 4,A072391_wireline,..\..\datasets\A072391_wireline\A072391_wireline.csv,4904606,True,True,True,6c810d264e83fe9c25576a53ebe8ff07,..\..\datasets\A072391_wireline\A072391_wireline.zip,A072391_wireline.zip,d3a566ec8806277a6c4e7a594d8e39f9e71c634947f9001766a03d32683e4baf
7
- 5,demo_data,..\..\datasets\demo_data\demo_data.csv,284,True,True,True,746da032cebd545d165bdc5f3c9fb625,..\..\datasets\demo_data\demo_data.zip,demo_data.zip,0e294393e3980da04ba18f56a3a0a8f9fac2fa8f066f773846e23a6a9de89d8e
8
- 6,iron_ore_sample_A072391,..\..\datasets\iron_ore_sample_A072391\iron_ore_sample_A072391.csv,10923,True,True,True,8403fb2acbc37e98738486ba5f49fa7d,..\..\datasets\iron_ore_sample_A072391\iron_ore_sample_A072391.zip,iron_ore_sample_A072391.zip,698b6ae7dacded385fcddf39070d8dfead0b769cc0127363ad9fec03f38d61b0
9
- 7,iron_ore_sample_xyz_A072391,..\..\datasets\iron_ore_sample_xyz_A072391\iron_ore_sample_xyz_A072391.csv,14496,True,True,True,4ea605c41b073a304514a8c5e1d9cca3,..\..\datasets\iron_ore_sample_xyz_A072391\iron_ore_sample_xyz_A072391.zip,iron_ore_sample_xyz_A072391.zip,37dd3872d4da12b0a145f7f52b43c2541da44b1ef21826757dc3616aa372766d
10
- 8,nordic_iron_ore_sink_float,..\..\datasets\nordic_iron_ore_sink_float\nordic_iron_ore_sink_float.csv,698,True,True,True,9ff12a4195620133a93ddc34c026745e,..\..\datasets\nordic_iron_ore_sink_float\nordic_iron_ore_sink_float.zip,nordic_iron_ore_sink_float.zip,f796f2b07b55466e2392cfe4b10d50f12de8ed9c39e231f216773a41d925faa1
11
- 9,size_by_assay,..\..\datasets\size_by_assay\size_by_assay.csv,249,True,True,True,3ea813789ad8efb1b9d4cbb7d47f00a4,..\..\datasets\size_by_assay\size_by_assay.zip,size_by_assay.zip,28010532f3da6d76fa32aa2ae8c4521c83f9864f8f0972949c931a49ad982d7c
12
- 10,size_distribution,..\..\datasets\size_distribution\size_distribution.csv,565,True,True,True,bd183c8240cceda4c9690746a69ce729,..\..\datasets\size_distribution\size_distribution.zip,size_distribution.zip,cd996c940010e859a16dbf508a9928fdbd04c9278c5eb1131873444db7382766
1
+ ,dataset,datafile,bytes,metadata,report,archive,datafile_md5,target_filepath,target,target_sha256
2
+ 0,A072391_assay,..\..\datasets\A072391_assay\A072391_assay.csv,32891149,True,True,True,957309836cb748525974aa690c5f919a,..\..\datasets\A072391_assay\A072391_assay.zip,A072391_assay.zip,b669840cc90aaa2d615986cdcf4ef5f97ec7352032597adc93440b154159d41f
3
+ 1,A072391_collars,..\..\datasets\A072391_collars\A072391_collars.csv,765470,True,True,True,597f5fe444270fe4409814b002b6e5cd,..\..\datasets\A072391_collars\A072391_collars.zip,A072391_collars.zip,9c01345766dc39462327c26604bddbd02db38f76118fe092bc90407e15bb5d09
4
+ 2,A072391_geo,..\..\datasets\A072391_geo\A072391_geo.csv,23544608,True,True,True,cdd8aed2841c73f3c203b995e099b590,..\..\datasets\A072391_geo\A072391_geo.zip,A072391_geo.zip,cf687584cc891fa084a45432e82747b7ef581eb21fe54f885f0b4c4f342c1641
5
+ 3,A072391_met,..\..\datasets\A072391_met\A072391_met.csv,412184,True,True,True,d2ac41f41ab7ba56f8239d63dba8a906,..\..\datasets\A072391_met\A072391_met.zip,A072391_met.zip,f4f84eeb4826755410d9979771a7e4f96afa2333586be85b775f179ece9c7bdf
6
+ 4,A072391_wireline,..\..\datasets\A072391_wireline\A072391_wireline.csv,4904606,True,True,True,6c810d264e83fe9c25576a53ebe8ff07,..\..\datasets\A072391_wireline\A072391_wireline.zip,A072391_wireline.zip,d3a566ec8806277a6c4e7a594d8e39f9e71c634947f9001766a03d32683e4baf
7
+ 5,demo_data,..\..\datasets\demo_data\demo_data.csv,284,True,True,True,746da032cebd545d165bdc5f3c9fb625,..\..\datasets\demo_data\demo_data.zip,demo_data.zip,0e294393e3980da04ba18f56a3a0a8f9fac2fa8f066f773846e23a6a9de89d8e
8
+ 6,iron_ore_sample_A072391,..\..\datasets\iron_ore_sample_A072391\iron_ore_sample_A072391.csv,10923,True,True,True,8403fb2acbc37e98738486ba5f49fa7d,..\..\datasets\iron_ore_sample_A072391\iron_ore_sample_A072391.zip,iron_ore_sample_A072391.zip,698b6ae7dacded385fcddf39070d8dfead0b769cc0127363ad9fec03f38d61b0
9
+ 7,iron_ore_sample_xyz_A072391,..\..\datasets\iron_ore_sample_xyz_A072391\iron_ore_sample_xyz_A072391.csv,14496,True,True,True,4ea605c41b073a304514a8c5e1d9cca3,..\..\datasets\iron_ore_sample_xyz_A072391\iron_ore_sample_xyz_A072391.zip,iron_ore_sample_xyz_A072391.zip,37dd3872d4da12b0a145f7f52b43c2541da44b1ef21826757dc3616aa372766d
10
+ 8,nordic_iron_ore_sink_float,..\..\datasets\nordic_iron_ore_sink_float\nordic_iron_ore_sink_float.csv,698,True,True,True,9ff12a4195620133a93ddc34c026745e,..\..\datasets\nordic_iron_ore_sink_float\nordic_iron_ore_sink_float.zip,nordic_iron_ore_sink_float.zip,f796f2b07b55466e2392cfe4b10d50f12de8ed9c39e231f216773a41d925faa1
11
+ 9,size_by_assay,..\..\datasets\size_by_assay\size_by_assay.csv,249,True,True,True,3ea813789ad8efb1b9d4cbb7d47f00a4,..\..\datasets\size_by_assay\size_by_assay.zip,size_by_assay.zip,28010532f3da6d76fa32aa2ae8c4521c83f9864f8f0972949c931a49ad982d7c
12
+ 10,size_distribution,..\..\datasets\size_distribution\size_distribution.csv,565,True,True,True,bd183c8240cceda4c9690746a69ce729,..\..\datasets\size_distribution\size_distribution.zip,size_distribution.zip,cd996c940010e859a16dbf508a9928fdbd04c9278c5eb1131873444db7382766
@@ -1,2 +1,2 @@
1
- from .downloader import Downloader
2
- from .datasets import *
1
+ from .downloader import Downloader
2
+ from .datasets import *
@@ -1,47 +1,47 @@
1
- from elphick.geomet.datasets import Downloader
2
- import pandas as pd
3
-
4
-
5
- def load_a072391_assay(show_report: bool = False) -> pd.DataFrame:
6
- return Downloader().load_data(datafile='A072391_assay.zip', show_report=show_report)
7
-
8
-
9
- def load_a072391_collars(show_report: bool = False) -> pd.DataFrame:
10
- return Downloader().load_data(datafile='A072391_collars.zip', show_report=show_report)
11
-
12
-
13
- def load_a072391_geo(show_report: bool = False) -> pd.DataFrame:
14
- return Downloader().load_data(datafile='A072391_geo.zip', show_report=show_report)
15
-
16
-
17
- def load_a072391_met(show_report: bool = False) -> pd.DataFrame:
18
- return Downloader().load_data(datafile='A072391_met.zip', show_report=show_report)
19
-
20
-
21
- def load_a072391_wireline(show_report: bool = False) -> pd.DataFrame:
22
- return Downloader().load_data(datafile='A072391_wireline.zip', show_report=show_report)
23
-
24
-
25
- def load_demo_data(show_report: bool = False) -> pd.DataFrame:
26
- return Downloader().load_data(datafile='demo_data.zip', show_report=show_report)
27
-
28
-
29
- def load_iron_ore_sample_a072391(show_report: bool = False) -> pd.DataFrame:
30
- return Downloader().load_data(datafile='iron_ore_sample_A072391.zip', show_report=show_report)
31
-
32
-
33
- def load_iron_ore_sample_xyz_a072391(show_report: bool = False) -> pd.DataFrame:
34
- return Downloader().load_data(datafile='iron_ore_sample_xyz_A072391.zip', show_report=show_report)
35
-
36
-
37
- def load_nordic_iron_ore_sink_float(show_report: bool = False) -> pd.DataFrame:
38
- return Downloader().load_data(datafile='nordic_iron_ore_sink_float.zip', show_report=show_report)
39
-
40
-
41
- def load_size_by_assay(show_report: bool = False) -> pd.DataFrame:
42
- return Downloader().load_data(datafile='size_by_assay.zip', show_report=show_report)
43
-
44
-
45
- def load_size_distribution(show_report: bool = False) -> pd.DataFrame:
46
- return Downloader().load_data(datafile='size_distribution.zip', show_report=show_report)
47
-
1
+ from elphick.geomet.datasets import Downloader
2
+ import pandas as pd
3
+
4
+
5
+ def load_a072391_assay(show_report: bool = False) -> pd.DataFrame:
6
+ return Downloader().load_data(datafile='A072391_assay.zip', show_report=show_report)
7
+
8
+
9
+ def load_a072391_collars(show_report: bool = False) -> pd.DataFrame:
10
+ return Downloader().load_data(datafile='A072391_collars.zip', show_report=show_report)
11
+
12
+
13
+ def load_a072391_geo(show_report: bool = False) -> pd.DataFrame:
14
+ return Downloader().load_data(datafile='A072391_geo.zip', show_report=show_report)
15
+
16
+
17
+ def load_a072391_met(show_report: bool = False) -> pd.DataFrame:
18
+ return Downloader().load_data(datafile='A072391_met.zip', show_report=show_report)
19
+
20
+
21
+ def load_a072391_wireline(show_report: bool = False) -> pd.DataFrame:
22
+ return Downloader().load_data(datafile='A072391_wireline.zip', show_report=show_report)
23
+
24
+
25
+ def load_demo_data(show_report: bool = False) -> pd.DataFrame:
26
+ return Downloader().load_data(datafile='demo_data.zip', show_report=show_report)
27
+
28
+
29
+ def load_iron_ore_sample_a072391(show_report: bool = False) -> pd.DataFrame:
30
+ return Downloader().load_data(datafile='iron_ore_sample_A072391.zip', show_report=show_report)
31
+
32
+
33
+ def load_iron_ore_sample_xyz_a072391(show_report: bool = False) -> pd.DataFrame:
34
+ return Downloader().load_data(datafile='iron_ore_sample_xyz_A072391.zip', show_report=show_report)
35
+
36
+
37
+ def load_nordic_iron_ore_sink_float(show_report: bool = False) -> pd.DataFrame:
38
+ return Downloader().load_data(datafile='nordic_iron_ore_sink_float.zip', show_report=show_report)
39
+
40
+
41
+ def load_size_by_assay(show_report: bool = False) -> pd.DataFrame:
42
+ return Downloader().load_data(datafile='size_by_assay.zip', show_report=show_report)
43
+
44
+
45
+ def load_size_distribution(show_report: bool = False) -> pd.DataFrame:
46
+ return Downloader().load_data(datafile='size_distribution.zip', show_report=show_report)
47
+
@@ -1,40 +1,40 @@
1
- import webbrowser
2
- from pathlib import Path
3
- from typing import Dict
4
-
5
- import pandas as pd
6
- import platformdirs
7
- import pooch
8
- from pooch import Unzip, Pooch
9
-
10
-
11
- class Downloader:
12
- def __init__(self):
13
- """Instantiate a Downloader
14
- """
15
-
16
- self.register: pd.DataFrame = pd.read_csv(Path(__file__).parent / 'register.csv', index_col=False)
17
-
18
- self.dataset_hashes: Dict = self.register[['target', 'target_sha256']].set_index('target').to_dict()[
19
- 'target_sha256']
20
-
21
- self.downloader: Pooch = pooch.create(path=Path(platformdirs.user_cache_dir('mass_composition', 'elphick')),
22
- base_url="https://github.com/elphick/mass-composition/raw/main/docs"
23
- "/source/_static/",
24
- version=None,
25
- version_dev=None,
26
- registry={**self.dataset_hashes})
27
-
28
- def load_data(self, datafile: str = 'size_by_assay.zip', show_report: bool = False) -> pd.DataFrame:
29
- """
30
- Load the 231575341_size_by_assay data as a pandas.DataFrame.
31
- """
32
- if datafile not in self.dataset_hashes.keys():
33
- raise KeyError(f"The file {datafile} is not in the registry containing: {self.dataset_hashes.keys()}")
34
-
35
- fnames = self.downloader.fetch(datafile, processor=Unzip())
36
- if show_report:
37
- webbrowser.open(str(Path(fnames[0]).with_suffix('.html')))
38
- data = pd.read_csv(Path(fnames[0]).with_suffix('.csv'))
39
- return data
40
-
1
+ import webbrowser
2
+ from pathlib import Path
3
+ from typing import Dict
4
+
5
+ import pandas as pd
6
+ import platformdirs
7
+ import pooch
8
+ from pooch import Unzip, Pooch
9
+
10
+
11
+ class Downloader:
12
+ def __init__(self):
13
+ """Instantiate a Downloader
14
+ """
15
+
16
+ self.register: pd.DataFrame = pd.read_csv(Path(__file__).parent / 'register.csv', index_col=False)
17
+
18
+ self.dataset_hashes: Dict = self.register[['target', 'target_sha256']].set_index('target').to_dict()[
19
+ 'target_sha256']
20
+
21
+ self.downloader: Pooch = pooch.create(path=Path(platformdirs.user_cache_dir('mass_composition', 'elphick')),
22
+ base_url="https://github.com/elphick/mass-composition/raw/main/docs"
23
+ "/source/_static/",
24
+ version=None,
25
+ version_dev=None,
26
+ registry={**self.dataset_hashes})
27
+
28
+ def load_data(self, datafile: str = 'size_by_assay.zip', show_report: bool = False) -> pd.DataFrame:
29
+ """
30
+ Load the 231575341_size_by_assay data as a pandas.DataFrame.
31
+ """
32
+ if datafile not in self.dataset_hashes.keys():
33
+ raise KeyError(f"The file {datafile} is not in the registry containing: {self.dataset_hashes.keys()}")
34
+
35
+ fnames = self.downloader.fetch(datafile, processor=Unzip())
36
+ if show_report:
37
+ webbrowser.open(str(Path(fnames[0]).with_suffix('.html')))
38
+ data = pd.read_csv(Path(fnames[0]).with_suffix('.csv'))
39
+ return data
40
+
@@ -1,12 +1,12 @@
1
- ,dataset,datafile,bytes,metadata,report,archive,datafile_md5,target_filepath,target,target_sha256
2
- 0,A072391_assay,..\..\datasets\A072391_assay\A072391_assay.csv,32891149,True,True,True,957309836cb748525974aa690c5f919a,..\..\datasets\A072391_assay\A072391_assay.zip,A072391_assay.zip,b669840cc90aaa2d615986cdcf4ef5f97ec7352032597adc93440b154159d41f
3
- 1,A072391_collars,..\..\datasets\A072391_collars\A072391_collars.csv,765470,True,True,True,597f5fe444270fe4409814b002b6e5cd,..\..\datasets\A072391_collars\A072391_collars.zip,A072391_collars.zip,9c01345766dc39462327c26604bddbd02db38f76118fe092bc90407e15bb5d09
4
- 2,A072391_geo,..\..\datasets\A072391_geo\A072391_geo.csv,23544608,True,True,True,cdd8aed2841c73f3c203b995e099b590,..\..\datasets\A072391_geo\A072391_geo.zip,A072391_geo.zip,cf687584cc891fa084a45432e82747b7ef581eb21fe54f885f0b4c4f342c1641
5
- 3,A072391_met,..\..\datasets\A072391_met\A072391_met.csv,412184,True,True,True,d2ac41f41ab7ba56f8239d63dba8a906,..\..\datasets\A072391_met\A072391_met.zip,A072391_met.zip,f4f84eeb4826755410d9979771a7e4f96afa2333586be85b775f179ece9c7bdf
6
- 4,A072391_wireline,..\..\datasets\A072391_wireline\A072391_wireline.csv,4904606,True,True,True,6c810d264e83fe9c25576a53ebe8ff07,..\..\datasets\A072391_wireline\A072391_wireline.zip,A072391_wireline.zip,d3a566ec8806277a6c4e7a594d8e39f9e71c634947f9001766a03d32683e4baf
7
- 5,demo_data,..\..\datasets\demo_data\demo_data.csv,284,True,True,True,746da032cebd545d165bdc5f3c9fb625,..\..\datasets\demo_data\demo_data.zip,demo_data.zip,0e294393e3980da04ba18f56a3a0a8f9fac2fa8f066f773846e23a6a9de89d8e
8
- 6,iron_ore_sample_A072391,..\..\datasets\iron_ore_sample_A072391\iron_ore_sample_A072391.csv,10923,True,True,True,8403fb2acbc37e98738486ba5f49fa7d,..\..\datasets\iron_ore_sample_A072391\iron_ore_sample_A072391.zip,iron_ore_sample_A072391.zip,698b6ae7dacded385fcddf39070d8dfead0b769cc0127363ad9fec03f38d61b0
9
- 7,iron_ore_sample_xyz_A072391,..\..\datasets\iron_ore_sample_xyz_A072391\iron_ore_sample_xyz_A072391.csv,14496,True,True,True,4ea605c41b073a304514a8c5e1d9cca3,..\..\datasets\iron_ore_sample_xyz_A072391\iron_ore_sample_xyz_A072391.zip,iron_ore_sample_xyz_A072391.zip,37dd3872d4da12b0a145f7f52b43c2541da44b1ef21826757dc3616aa372766d
10
- 8,nordic_iron_ore_sink_float,..\..\datasets\nordic_iron_ore_sink_float\nordic_iron_ore_sink_float.csv,698,True,True,True,9ff12a4195620133a93ddc34c026745e,..\..\datasets\nordic_iron_ore_sink_float\nordic_iron_ore_sink_float.zip,nordic_iron_ore_sink_float.zip,f796f2b07b55466e2392cfe4b10d50f12de8ed9c39e231f216773a41d925faa1
11
- 9,size_by_assay,..\..\datasets\size_by_assay\size_by_assay.csv,249,True,True,True,3ea813789ad8efb1b9d4cbb7d47f00a4,..\..\datasets\size_by_assay\size_by_assay.zip,size_by_assay.zip,28010532f3da6d76fa32aa2ae8c4521c83f9864f8f0972949c931a49ad982d7c
12
- 10,size_distribution,..\..\datasets\size_distribution\size_distribution.csv,565,True,True,True,bd183c8240cceda4c9690746a69ce729,..\..\datasets\size_distribution\size_distribution.zip,size_distribution.zip,cd996c940010e859a16dbf508a9928fdbd04c9278c5eb1131873444db7382766
1
+ ,dataset,datafile,bytes,metadata,report,archive,datafile_md5,target_filepath,target,target_sha256
2
+ 0,A072391_assay,..\..\datasets\A072391_assay\A072391_assay.csv,32891149,True,True,True,957309836cb748525974aa690c5f919a,..\..\datasets\A072391_assay\A072391_assay.zip,A072391_assay.zip,b669840cc90aaa2d615986cdcf4ef5f97ec7352032597adc93440b154159d41f
3
+ 1,A072391_collars,..\..\datasets\A072391_collars\A072391_collars.csv,765470,True,True,True,597f5fe444270fe4409814b002b6e5cd,..\..\datasets\A072391_collars\A072391_collars.zip,A072391_collars.zip,9c01345766dc39462327c26604bddbd02db38f76118fe092bc90407e15bb5d09
4
+ 2,A072391_geo,..\..\datasets\A072391_geo\A072391_geo.csv,23544608,True,True,True,cdd8aed2841c73f3c203b995e099b590,..\..\datasets\A072391_geo\A072391_geo.zip,A072391_geo.zip,cf687584cc891fa084a45432e82747b7ef581eb21fe54f885f0b4c4f342c1641
5
+ 3,A072391_met,..\..\datasets\A072391_met\A072391_met.csv,412184,True,True,True,d2ac41f41ab7ba56f8239d63dba8a906,..\..\datasets\A072391_met\A072391_met.zip,A072391_met.zip,f4f84eeb4826755410d9979771a7e4f96afa2333586be85b775f179ece9c7bdf
6
+ 4,A072391_wireline,..\..\datasets\A072391_wireline\A072391_wireline.csv,4904606,True,True,True,6c810d264e83fe9c25576a53ebe8ff07,..\..\datasets\A072391_wireline\A072391_wireline.zip,A072391_wireline.zip,d3a566ec8806277a6c4e7a594d8e39f9e71c634947f9001766a03d32683e4baf
7
+ 5,demo_data,..\..\datasets\demo_data\demo_data.csv,284,True,True,True,746da032cebd545d165bdc5f3c9fb625,..\..\datasets\demo_data\demo_data.zip,demo_data.zip,0e294393e3980da04ba18f56a3a0a8f9fac2fa8f066f773846e23a6a9de89d8e
8
+ 6,iron_ore_sample_A072391,..\..\datasets\iron_ore_sample_A072391\iron_ore_sample_A072391.csv,10923,True,True,True,8403fb2acbc37e98738486ba5f49fa7d,..\..\datasets\iron_ore_sample_A072391\iron_ore_sample_A072391.zip,iron_ore_sample_A072391.zip,698b6ae7dacded385fcddf39070d8dfead0b769cc0127363ad9fec03f38d61b0
9
+ 7,iron_ore_sample_xyz_A072391,..\..\datasets\iron_ore_sample_xyz_A072391\iron_ore_sample_xyz_A072391.csv,14496,True,True,True,4ea605c41b073a304514a8c5e1d9cca3,..\..\datasets\iron_ore_sample_xyz_A072391\iron_ore_sample_xyz_A072391.zip,iron_ore_sample_xyz_A072391.zip,37dd3872d4da12b0a145f7f52b43c2541da44b1ef21826757dc3616aa372766d
10
+ 8,nordic_iron_ore_sink_float,..\..\datasets\nordic_iron_ore_sink_float\nordic_iron_ore_sink_float.csv,698,True,True,True,9ff12a4195620133a93ddc34c026745e,..\..\datasets\nordic_iron_ore_sink_float\nordic_iron_ore_sink_float.zip,nordic_iron_ore_sink_float.zip,f796f2b07b55466e2392cfe4b10d50f12de8ed9c39e231f216773a41d925faa1
11
+ 9,size_by_assay,..\..\datasets\size_by_assay\size_by_assay.csv,249,True,True,True,3ea813789ad8efb1b9d4cbb7d47f00a4,..\..\datasets\size_by_assay\size_by_assay.zip,size_by_assay.zip,28010532f3da6d76fa32aa2ae8c4521c83f9864f8f0972949c931a49ad982d7c
12
+ 10,size_distribution,..\..\datasets\size_distribution\size_distribution.csv,565,True,True,True,bd183c8240cceda4c9690746a69ce729,..\..\datasets\size_distribution\size_distribution.zip,size_distribution.zip,cd996c940010e859a16dbf508a9928fdbd04c9278c5eb1131873444db7382766