upxo.repqual.grain_network_repr_assesser_3D module
Created on Fri Sep 6 11:11:45 2024
@author: Dr. Sunil Anandatheertha
- class upxo.repqual.grain_network_repr_assesser_3D.KREPR(**kwargs)[source]
Bases:
objectDocstring.
Usage
from upxo.repqual.grain_network_repr_assesser import KREPR
- param upxogs_tgt:
- type upxogs_tgt:
UPXO grain structure data
- param upxogs_smp:
- type upxogs_smp:
UPXO grain structure data
- param tgset:
Set of target grain structures. keys: int. grain strucyure IDs. values: must be any of the UPXO grain structure type. note: keys are usually tslice values, but can be user defined. Example: {0: <upxo.pxtal.mcgs2_temporal_slice.mcgs2_grain_structure at 0x2d37fcb54f0>,
1: <upxo.pxtal.mcgs2_temporal_slice.mcgs2_grain_structure at 0x2d37fcb5680>, 2: <upxo.pxtal.mcgs2_temporal_slice.mcgs2_grain_structure at 0x2d37fcb5810>, …}
- type tgset:
dict
- param sgset:
Set of sample grain structures. keys: int. grain strucyure IDs. values: must be any of the UPXO grain structure type. note: keys are usually tslice values, but can be user defined. Example: {0: <upxo.pxtal.mcgs2_temporal_slice.mcgs2_grain_structure at 0x2d37fcb54f0>,
1: <upxo.pxtal.mcgs2_temporal_slice.mcgs2_grain_structure at 0x2d37fcb5680>, 2: <upxo.pxtal.mcgs2_temporal_slice.mcgs2_grain_structure at 0x2d37fcb5810>, …}
- type sgset:
dict
- param tkset:
Set of networkx graphs of target grain structure neighbour networks. keys: int/float. Neighbour order, ordern value. values: dict
keys: int. grain (node) IDs. values: list. contains neighbouring grain ids (gids), ie. node ids. note: keys are usually tslice values, but can be user defined.
- type tkset:
dict
- param skset:
Set of networkx graphs of sample grain structure neighbour networks. keys: int/float. Neighbour order, ordern value. values: dict
keys: int. grain (node) IDs. values: list. contains neighbouring grain ids (gids), ie. node ids. note: keys are usually tslice values, but can be user defined.
- type skset:
dict
- param tnset:
Set of UPXO returned target grain structure neighbour mapping. keys: int/float. Neighbour order, ordern value. values: dict
keys: int. grain IDs. values: list. contains neighbouring grain ids (gids). note: keys are usually tslice values, but can be user defined.
- type tnset:
dict
- param snset:
Set of UPXO returned sample grain structure neighbour mapping. keys: int/float. Neighbour order, ordern value. values: dict
keys: int. grain IDs. values: list. contains neighbouring grain ids (gids). note: keys are usually tslice values, but can be user defined.
- type snset:
dict
- param tmpset:
Target morphological property set. keys: names of morphological properties. values: dict
keys: O(n) values: dict
keys: int. gid: grain id values values: list: neighbour gids.
- type tmpset:
dict
- param smpset:
Sample morphological property set. keys: names of morphological properties. values: dict
keys: O(n) values: dict
keys: int. gid: grain id values values: list: neighbour gids.
- type smpset:
dict
- param tid:
Contains usable values of target grain ids. MUST belong to tgset.keys() and/or tkset.keys() depending on study path. Note: if not set by the user, all tkset.keys() will be assigned !!
- type tid:
list
- param sid:
Contains usable values of target grain ids. MUST belong to tgset.keys() and/or tkset.keys() depending on study path. Note: if not set by the user, all skset.keys() will be assigned !!
- type sid:
list
- param ordern:
Contains values of the ordern. If not set by the user, ordern=1 will be assigned.
- type ordern:
list
- param mprop3d_flags:
- type mprop3d_flags:
all dict types
- param sprop3d_flags:
- type sprop3d_flags:
all dict types
- param mprop3d:
- type mprop3d:
all dict types
- param sprop2d:
- type sprop2d:
all dict types
- param sprop3d:
- type sprop3d:
all dict types
- param rkf:
Contains network (k) based R-Field (i.e. rkf) data. Thi smust be set before representativeness assessment is done.
- type rkf:
dict
- param _cim_:
Class initiation method, not intended for user use.
- type _cim_:
str
- param Author:
- type Author:
Dr. Sunil Anandatheertha
- param om jayanti man’gaLA kALi bhadrakALi kapAlini |:
- param durgA kshamA shivA dhAtri svAhA svadhA namOstute ||:
- mp_gspn_map = {'arbbox': 'arbbox', 'arellfit': 'arellfit', 'com': 'com', 'ecc': 'ecc', 'eqdia': 'eqdia', 'fdim': 'fdim', 'feqdia': 'feqdia', 'fn': 'fn', 'ksr': 'ksr', 'kx': 'kx', 'ky': 'ky', 'kz': 'kz', 'mi': 'mi', 'pergl': 'pergl', 'pernv': 'pernv', 'pervl': 'pervl', 'psa': 'psa', 'rat_sanv_volnv': 'rat_sanv_volnv', 'rnd': 'rnd', 'sanv': 'sanv', 'sasr': 'sasr', 'savi': 'savi', 'sol': 'sol', 'sph': 'sph', 'volch': 'volch', 'volnv': 'volnv', 'volsr': 'volsr'}
- dim
- gstype
- tid
- sid
- upxogs_tgt
- upxogs_smp
- tgset
- sgset
- tkset
- skset
- tnset
- snset
- classmethod from_gs(*, upxogs_tgt=None, upxogs_smp=None, tgset=None, sgset=None, ordern=[1], tsid_source='from_gs', ssid_source='from_gs', tid=None, sid=None, _cim_='from_gs')[source]
Intiantiate network based repr class using UPXO grain structure.
- Parameters:
upxogs_tgt
upxogs_smp
tgset (dict) – Target grain structures. Defaults to None.
sgset (dict) – Sample grain structures. Defaults to None.
ordern (list) – Neighbour order-n to be used. Defaults to [1].
_cim_ (str) – Class initiation method. Defaults to ‘from_gs’. Not intended for user. Leave it alone.
mcgs (from upxo.ggrowth.mcgs import)
mcgs(study='independent' (tgt =)
input_dashboard='input_dashboard.xls')
tgt.simulate()
tgt.detect_grains()
{i (tgset =)
KREPR (from upxo.repqual.grain_network_repr_assesser import)
KREPR.from_gs(tgset=tgset (kr =)
sgset=tgset)
kr.creation_method
- classmethod from_neigh(*, tnset=None, snset=None, ordern=[1], tsid_source='from_neigh', ssid_source='from_neigh', tid=None, sid=None, _cim_='from_neigh')[source]
# Assuming 20 tslices being available witrh increments of tslice=1, # we will go through the folloing example.
ordern = [1, 3]
from upxo.ggrowth.mcgs import mcgs tgt = mcgs(study=’independent’, input_dashboard=’input_dashboard.xls’) tgt.simulate() tgt.detect_grains() tslices = np.array(list(tgt.gs.keys()))[1::10] tnset = {no: {tslice: None for tslice in tslices} for no in ordern} for no in ordern:
- for tslice in tslices:
_ = tgt.gs[tslice].get_upto_nth_order_neighbors_all_grains tnn = _(no, include_parent=True, output_type=’nparray’) tnset[no][tslice] = tnn
smp = mcgs(study=’independent’, input_dashboard=’input_dashboard.xls’) smp.simulate() smp.detect_grains() tslices = np.array(list(smp.gs.keys()))[1::10] snset = {no: {tslice: None for tslice in tslices} for no in ordern} for no in ordern:
- for tslice in tslices:
_ = smp.gs[tslice].get_upto_nth_order_neighbors_all_grains snn = _(no, include_parent=True, output_type=’nparray’) snset[no][tslice] = snn
from upxo.repqual.grain_network_repr_assesser import KREPR kr = KREPR.from_neigh(tnset=tnset, snset=tnset,
tid=list(tnset.keys()), sid=list(snset.keys()), _cim_=’from_neigh’)
kr.snset.keys() kr.snset[3].keys() kr.snset[3][11] kr.snset[3][11][40] # <– O(3) Neigh gids of gid=40 of tslice = 11 kr.ordern kr.tid
- classmethod from_k(*, tkset=None, skset=None, ordern=[1], tsid_source='from_k', ssid_source='from_k', tid=None, sid=None, _cim_='from_k')[source]
# Assuming 20 tslices being available witrh increments of tslice=1, # we will go through the folloing example.
ordern = [1, 3]
from upxo.ggrowth.mcgs import mcgs tgt = mcgs(study=’independent’, input_dashboard=’input_dashboard.xls’) tgt.simulate() tgt.detect_grains() tslices = np.array(list(tgt.gs.keys()))[1::10] tkset = {no: {tslice: None for tslice in tslices} for no in ordern} for no in ordern:
- for tslice in tslices:
_ = tgt.gs[tslice].get_upto_nth_order_neighbors_all_grains tnn = _(no, include_parent=True, output_type=’nparray’) tnn_k = kmake.create_grain_network_nx(tnn) tkset[no][tslice] = tnn_k
smp = mcgs(study=’independent’, input_dashboard=’input_dashboard.xls’) smp.simulate() smp.detect_grains() tslices = np.array(list(smp.gs.keys()))[1::10] skset = {no: {tslice: None for tslice in tslices} for no in ordern} for no in ordern:
- for tslice in tslices:
_ = smp.gs[tslice].get_upto_nth_order_neighbors_all_grains snn = _(no, include_parent=True, output_type=’nparray’) snn_k = kmake.create_grain_network_nx(snn) skset[no][tslice] = snn_k
from upxo.repqual.grain_network_repr_assesser import KREPR kr = KREPR.from_k(tkset=tkset, skset=tkset,
tid=list(tkset.keys()), sid=list(skset.keys()), _cim_=’from_k’)
kr.tkset kr.ordern kr.tid
- classmethod from_gsgen(gstype_tgt='mcgs2d', gstype_smp='mcgs3d', is_smp_same_as_tgt=False, char_tgt=True, char_smp=True, set_mprops_tgt=False, set_mprops_smp=False, tgt_dashboard='input_dashboard_krepr1.xls', smp_dashboard='input_dashboard_krepr2.xls', ordern=[1], tsid_source='from_neigh', ssid_source='from_neigh', tid=None, sid=None, _cim_='from_gsgen', label_str_order=1, mpflags={'arbbox': True, 'arellfit': False, 'com': False, 'ecc': False, 'eqdia': False, 'fdim': False, 'feqdia': False, 'fn': False, 'ksr': False, 'kx': False, 'ky': False, 'kz': False, 'mi': False, 'pergl': False, 'pernv': False, 'pervl': False, 'psa': False, 'rat_sanv_volnv': True, 'rnd': False, 'sanv': True, 'sasr': False, 'savi': False, 'sol': False, 'sph': False, 'volch': False, 'volnv': True, 'volsr': False})[source]
Initiate KREPR by generating target and sample grain structure sets.
- Parameters:
gstype (str) – Type of grain structure needed. Could be deprecated later on. Defaults to ‘mcgs’.
is_smp_same_as_tgt (bool) – Defaults to False.
tgt_dashboard (str) – Defaults to ‘input_dashboard.xls’.
smp_dashboard (str) – Defaults to ‘input_dashboard.xls’.
_cim_ (str) – Defaults to ‘from_gsgen’.
Explanations
------------
Example
import numpy as np from upxo.repqual.grain_network_repr_assesser_3D import KREPR import matplotlib.pyplot as plt
neigh_orders=[3]
- kr = KREPR.from_gsgen(gstype_tgt=’mcgs3d’, gstype_smp=’mcgs3d’,
is_smp_same_as_tgt = False, characterize_tgt=True, characterize_smp=True, set_mprops_tgt=False, set_mprops_smp=False,
tgt_dashboard=’input_dashboard.xls’, smp_dashboard=’input_dashboard.xls’, ordern=neigh_orders,
- tsid_source=’user’, ssid_source=’user’,
tid=np.arange(10, 20, 1),
sid=np.arange(10, 20, 1), _cim_=’from_gsgen’)
kr.set_mprop3d_flags(volnv=True, sanv=True, rat_sanv_volnv=True)
- kr.calculate_mprop3d(print_msg_tors=True, print_msg_prnm=True,
print_msg_no=True, print_msg_gsid=False, print_msg_gid=False)
- kr.set_rkf(js=True, wd=True, ksp=True, ed=True, nlsd=True,
degcen=False, btwcen=False, clscen=False, egnvcen=False)
kr.calculate_rkf()
- property creation_method
Creation method.
- set_ordern(ordern)[source]
Set the n values in O(n).
Parametyers
- ordern: list
O(n) values
- rtype:
None
- set_mprop3d_flags(volnv=True, volsr=False, volch=False, sanv=True, savi=False, sasr=False, psa=False, pernv=False, pervl=False, pergl=False, eqdia=False, feqdia=False, kx=False, ky=False, kz=False, ksr=False, arbbox=True, arellfit=False, sol=False, ecc=False, com=False, sph=False, fn=False, rnd=False, mi=False, fdim=False, rat_sanv_volnv=True, iputs='flags', mpnames=('volnv',))[source]
Set flags for operational 3D morpholohgical properties.
- Parameters:
volnv (bool, optional) – Volume by number of voxels, default True
volsr (bool, optional) – Volume after gb surf reconstruction, default False
volch (bool, optional) – Volume of convex hull, default False
sanv (bool, optional) – Surface area by number of voxels, default True
savi (bool, optional) – Surface area by voxel interfaces, default False
sasr (bool, optional) – Surface area after gb surf reconstruction, default False
psa (bool, optional) – Projected surface area, default False
pernv (bool, optional) – Perimeter by number of voxels, default False
pervl (bool, optional) – Perimeter by voxel edge lines, default False
pergl (bool, optional) – Perimeter by geom. gb line segments, default False
eqdia (bool, optional) – Equivalent diameter, default False
feqdia (bool, optional) – Feret equivalent diameter, default False
kx (bool, optional) – gb voxel local curvature in yz plane, default False
ky (bool, optional) – gb voxel local curvature in xz plane, default False
kz (bool, optional) – gb voxel local curvature in xy plane, default False
ksr (bool, optional) – k computed from surf reconstruction, default False
arbbox (bool, optional) – Aspect ratio by bounding box, default True
arellfit (bool, optional) – Aspect ratio by ellipsoidal fit, default False
sol (bool, optional) – Solidity of the grains, default False
ecc (bool, optional) – Eccentricity of the grains, default False
com (bool, optional) – Compactness of the grains, default False
sph (bool, optional) – Sphericity of the grains, default False
fn (bool, optional) – Flatness of the grains, default False
rnd (bool, optional) – Roundness of the grains, default False
mi (bool, optional) – Moment of inertia tensor, default False
fdim (bool, optional) – Fractal dimension, default False
rat_sanv_volnv (bool, optional) – Ratio of sanv to volnv, default True
- Return type:
None
- Raises:
ValueError – Invalid mpnames if type(mpnames) not in dth.dt.ITERABLES or if len(mpnames) > 0. Only under iputs being input as ‘mp_names’.
- calculate_mprop3d(print_msg_tors=True, print_msg_prnm=True, print_msg_no=True, print_msg_gsid=False, print_msg_gid=False)[source]
Data structure
- kr.mprop3d: dict
- kr.mprop3d[tors]: dict
- kr.mprop3d[tors][prnm]: dict
- kr.mprop3d[tors][prnm][no]: dict
- kr.mprop3d[tors][prnm][no][gsid]: dict
- kr.mprop3d[tors][prnm][no][gsid][gid]: np.array
kr.mprop3d[tors][prnm][no][gsid][gid][i]: float
- Where,
mprop3d: 3d morphology properties tors: either ‘tgt’ or ‘smp’ prnm: property name no: neighbour order gsid: grain structure ID gid: grain ID i: prnm Property value of ith neighbour of gid grain of tors gid
for O(n) = on.
Data access
- kr.mprop3d[‘tgt’][‘area_pix’][O(n)][gsid][GID]. This contains a
list of gids which are O(n) neighbours of GID grain.
Example
gid = 2 kr.mprop3d[‘tgt’][‘area_pix’][1.25][8][gid] The correspionding neighbour data is: kr.tnset[1.25][8][gid]
Note
len(kr.tnset[1.25][8][gid]) = kr.mprop3d[‘tgt’][‘area_pix’][1.25][8][gid].size
mpflags: local copy of morpho prop flag. reqprop: keys in mpflags with True values. tors: target or sample: self.mprop3d keys. prnm: property name in the list of values in reqprop. no: neighbour order in list kr.ordern. gsid: Grain structue ID in self.tid gid: Grain IDs in local neighbour network.
Author: Dr. Sunil Anandatheertha
- estimate_upper_ordern_bycount(tors='tgt', gsid=1, on_start=1.0, on_max=10.0, on_incr=0.5, neigh_count_vf_max=0.8, include_parent=True, kdeplot=True, kdeplot_kwargs={'cmap': 'cividis', 'dpi': 120, 'figsize': (5, 5), 'fill': True, 'fs_legend': 10, 'fs_xlabel': 12, 'fs_xticks': 10, 'fs_ylabel': 12, 'fs_yticks': 10, 'legend_loc': 'best', 'legend_ncols': 2}, statplot=True, statplot_kwargs={'dpi': 120, 'figsize': (5, 5), 'stat': 'mean'}, gsplot=True, gsplot_kwargs={'dpi': 120, 'figsize': (5, 5)})[source]
Estimate O(n) needed to reach neigh_count_vf_max.
- Parameters:
tors (str) – Specify ‘tgt’ for Target and ‘smp’ for Sample. Defaults to ‘tgt’.
gsid (int) – Grain Structure ID. Defaults to 1.
on_start (float) – Minimum O(n) value to start iterations from. on_start >= 1. Defaults to 1.0.
on_max (float) – Maximum O(n) value to end iterating. on_max >= on_start. Defaults to 10.0.
on_incr (float) – del(O(n)) increments to o(n) search space. on_incr >= 0.1. Defaults to 0.5.
neigh_count_vf_max (float) – neigh_count_vf value to stop iterating. 0.11 < neigh_count_vf_max < 0.99, generally, although value may change depending on grain structure. Note: these bounds are not accurate. Defaults to 0.8.
include_parent (bool) – Include gid in the neigh list of gid if True, else exclude. Defaults to True.
plot_kde (bool) – Plot kdes of a list containing total number of neighbours of every gid in the grain structure for each O(n). Defaults to True.
- Returns:
LON (float) – Limiting Order-n
neighn_stats (dict) – keys: on of every iteration. value: dict
- (key, value):
’mean’ neighn.min() ‘min’: neighn.min() ‘max’: neighn.max() ‘std’: neighn.std() ‘var’: neighn.var() ‘iqr’: stats.iqr(neighn): Inter-quartile range ‘sem’: stats.sem(neighn): Standard Error of the Mean
- Where,
neighn = np.array([len(neighs) for neighs in ngh.values()]) ngh: dict: {gid: gid neighbours list}
Ng (int) – Number of grains in the provided grain structure.
Explanations
————
As O(n) increases the number of order-n neighbours (N) for a gid
increases. But, it cannot increase for ever. Its maximum value is
the total number of grains in the grain structure. The ratio of N to
total number of grains (i.e. neigh_count_vf) is then unity. However,
for o(n) < O(n), neigh_count_vf < 1. This function helps determine
o(n) for which neigh_count_vf < neigh_count_vf_max.
The kde if plotted, will show the following trends –
Shift right as o(n) increases during iterations.
Peak drops initially as o(n) increases and as width increases.
Peak increase again as o(n) increases further and width decreases.
- create_gid_network(dataid='tgt', neigh_order=1, gsid=1)[source]
Create the network nx graph from the neighbours dictionary.
- Parameters:
dataid (str. Options: 'tgt' (default), 'smp'.)
neigh_order (int. Order of the raw neighbours data-structure. Defaults) – to 1.
gsid (int. ID of the grain structure. Defaults to 1.)
- Returns:
nxg
- Return type:
network nx graph.
- create_tgt_networks(saa=True, throw=False)[source]
Create networkx graphs for all target gs neighbours database.
- Parameters:
saa (bool.) – Save as attrbute of True. Defults to True.
throw (bool.) – Return value if True. Defaults to False.
structure (Data)
--------------
dict(no1 (dict(gsid1: dict(gid1: [12, 1, 16,..]))),) – no2: dict(gsid2: dict(gid2: [16, 15, 8,..]))),… noi: dict(gsidj: dict(gidk: [2, 86, 95,..]))),… noN: dict(gsidM: dict(gidG: [20, 15, 196,..]))),… )
Where –
noi: an element of ordern list of size N. gsidj: jth grain structure’s ID of a toytal of M grain structes. gidk: kth grain ID of all G grains. noi-gsidj-gidk: kth grain ID in the jth grain structure’s
neighbour network dictionary of the ith O(n) database.
- :paramnoi: an element of ordern list of size N.
gsidj: jth grain structure’s ID of a toytal of M grain structes. gidk: kth grain ID of all G grains. noi-gsidj-gidk: kth grain ID in the jth grain structure’s
neighbour network dictionary of the ith O(n) database.
- create_smp_networks(saa=True, throw=False)[source]
Create networkx graphs for all sample gs neighbours database.
- Parameters:
saa (bool.) – Save as attrbute of True. Defults to True.
throw (bool.) – Return value if True. Defaults to False.
structure (Data)
--------------
dict(no1 (dict(gsid1: dict(gid1: [12, 1, 16,..]))),) – no2: dict(gsid2: dict(gid2: [16, 15, 8,..]))),… noi: dict(gsidj: dict(gidk: [2, 86, 95,..]))),… noN: dict(gsidM: dict(gidG: [20, 15, 196,..]))),… )
Where –
noi: an element of ordern list of size N. gsidj: jth grain structure’s ID of a toytal of M grain structes. gidk: kth grain ID of all G grains. noi-gsidj-gidk: kth grain ID in the jth grain structure’s
neighbour network dictionary of the ith O(n) database.
- :paramnoi: an element of ordern list of size N.
gsidj: jth grain structure’s ID of a toytal of M grain structes. gidk: kth grain ID of all G grains. noi-gsidj-gidk: kth grain ID in the jth grain structure’s
neighbour network dictionary of the ith O(n) database.
- create_tgt_smp_networks(saa=True, throw=False)[source]
Create networkx graphs for all tgt and smp gs neighbours database.
- Parameters:
saa (bool.) – Save as attrbute of True. Defults to True.
throw (bool.) – Return value if True. Defaults to False.
structure (Data)
--------------
dict(no1 (dict(gsid1: dict(gid1: [12, 1, 16,..]))),) – no2: dict(gsid2: dict(gid2: [16, 15, 8,..]))),… noi: dict(gsidj: dict(gidk: [2, 86, 95,..]))),… noN: dict(gsidM: dict(gidG: [20, 15, 196,..]))),… )
Where –
noi: an element of ordern list of size N. gsidj: jth grain structure’s ID of a toytal of M grain structes. gidk: kth grain ID of all G grains. noi-gsidj-gidk: kth grain ID in the jth grain structure’s
neighbour network dictionary of the ith O(n) database.
- :paramnoi: an element of ordern list of size N.
gsidj: jth grain structure’s ID of a toytal of M grain structes. gidk: kth grain ID of all G grains. noi-gsidj-gidk: kth grain ID in the jth grain structure’s
neighbour network dictionary of the ith O(n) database.
- set_rkf(js=False, wd=False, ksp=False, ed=False, nlsd=False, degcen=False, btwcen=False, clscen=False, egnvcen=False)[source]
Set rkf field calculation flags and initiate rkf dict accordingly.
- Parameters:
js (bool) – Jaccard similarity measure of representativeness. Defaults to True
wd (bool) – Wasserstein distance measure of representativeness. Defaults to True
ksp (bool) – K-S test P-value measure of representativeness. Defaults to False
ed (bool) – Energy distance measure of representativeness. Defaults to True
nlsd (bool) – NetLSD similarity measure of representativeness. Defaults to False
degcen (bool) – Betweenness Centrality. How connected each grain is. Defaults to False.
btwcen (bool) – Betweenness Centrality. How important a grain is in connecting others. Defaults to False.
clscen (bool) – Closeness Centrality. How close a grain is to all other grains. Defaults to False.
egnvcen (bool) – Eigenvector Centrality. How influential a grain is within the network. Defaults to False.
structures (Data)
---------------
{n (kr.rkf[RMNAME] =)
Where – MNAME = Repr metric name in (‘js’, ‘wd’, ‘ksp’, ‘ed’, ‘nlsd’) ZEROS = np.zeros((len(kr.sid), len(kr.tid)))
- :paramMNAME = Repr metric name in (‘js’, ‘wd’, ‘ksp’, ‘ed’, ‘nlsd’)
ZEROS = np.zeros((len(kr.sid), len(kr.tid)))
- initiate_rk_dict(js=False, wd=False, ksp=False, ed=False, nlsd=False, degcen=False, btwcen=False, clscen=False, egnvcen=False)[source]
Initiate dictionaries to store representativeness measures.
- Parameters:
js (bool) – Jaccard similarity measure of representativeness. Defaults to True
wd (bool) – Wasserstein distance measure of representativeness. Defaults to True
ksp (bool) – K-S test P-value measure of representativeness. Defaults to False
ed (bool) – Energy distance measure of representativeness. Defaults to True
nlsd (bool) – NetLSD similarity measure of representativeness. Defaults to False
structures (Data)
---------------
{n (kr.rkf[RMNAME] =)
Where – MNAME = Repr metric name in (‘js’, ‘wd’, ‘ksp’, ‘ed’, ‘nlsd’) ZEROS = np.zeros((len(kr.sid), len(kr.tid)))
- :paramMNAME = Repr metric name in (‘js’, ‘wd’, ‘ksp’, ‘ed’, ‘nlsd’)
ZEROS = np.zeros((len(kr.sid), len(kr.tid)))
- calculate_kdeg(ktgt, ksmp)[source]
Calculate the node degrees of target and sample gs O(n) networks.
Paramerters
ktgt: target grain structure O(n) neighbour network graph. ksmp: sample grain structure O(n) neighbour network graph.
- returns:
kd_tgt (node degrees of target gs O(n) neigh network graph.)
kd_smp (node degrees of sample gs O(n) neigh network graph.)
Data structures
—————
ktgt (networkx graph for target gs’s O(n) neighbour netwprk dict data.)
ksmp (networkx graph for sample gs’s O(n) neighbour netwprk dict data.)
kd_tgt (list: nodal degres of ktgt)
kd_smp (list: nodal degres of ksmp)
Exzplanations
————-
This def calls for calculate_kdegrees. Please refer to
upxo.netops.kchar.calculate_kdegrees for complete documentaion.
- calculate_kdeg_equal_binning(ktgt, ksmp)[source]
Calculate the node degrees of T and S gs O(n) k’s and equally bin them.
Paramerters
ktgt: target grain structure O(n) neighbour network graph. ksmp: sample grain structure O(n) neighbour network graph.
- returns:
kd_tgt (node degrees of target gs O(n) neigh network graph.)
kd_smp (node degrees of sample gs O(n) neigh network graph.)
Data structures
—————
ktgt (networkx graph for target gs’s O(n) neighbour netwprk dict data.)
ksmp (networkx graph for sample gs’s O(n) neighbour netwprk dict data.)
kd_tgt (list: nodal degres of ktgt)
kd_smp (list: nodal degres of ksmp)
Exzplanations
————-
This def calls for calculate_kdegrees_equalbinning. Please refer to
upxo.netops.kchar.calculate_kdegrees_equalbinning for complete
documentaion.
Data is binned as per global min and max in degree and the distribtuion
is re-computed using histogram.
- calculate_rkf_js_pairwise(ktgt, ksmp)[source]
Calculate Jaccard similarity between ktgt and ksmp.
- Parameters:
- Returns:
r (representativeness level.)
Explanations
————
Refer to calculate_rkfield_js for complete documentation.
Location (upxo.netops.kcmp.calculate_rkfield_js)
Data structures
—————
ktgt (networkx graph for target gs’s O(n) neighbour netwprk dict data.)
ksmp (networkx graph for sample gs’s O(n) neighbour netwprk dict data.)
r (int between 0 and 1. Higher the value, greater is) – the representativeness.
- tmpset
- smpset
- ntid
- nsid
- ordern
- rkf_flags
- rkf
- mprop3d_flags
- mprop3d
- calculate_rkf_wd_pairwise(ktgt, ksmp, equal_bins=False)[source]
Calculate Jaccard similarity between ktgt and ksmp.
- Parameters:
- Returns:
r (representativeness level.)
Explanations
————
Refer to calculate_rkfield_wd for complete documentation.
Location (upxo.netops.kcmp.calculate_rkfield_wd)
Data structures
—————
ktgt (networkx graph for target gs’s O(n) neighbour netwprk dict data.)
ksmp (networkx graph for sample gs’s O(n) neighbour netwprk dict data.)
r (int between 0 and 1. Higher the value, greater is) – the representativeness.
- calculate_rkf_ksp_pairwise(ktgt, ksmp, equal_bins=False)[source]
Calculate Jaccard similarity between ktgt and ksmp.
- Parameters:
- Returns:
r (representativeness level.)
Explanations
————
Refer to calculate_rkfield_ksp for complete documentation.
Location (upxo.netops.kcmp.calculate_rkfield_ksp)
Data structures
—————
ktgt (networkx graph for target gs’s O(n) neighbour netwprk dict data.)
ksmp (networkx graph for sample gs’s O(n) neighbour netwprk dict data.)
r (int between 0 and 1. Higher the value, greater is) – the representativeness.
- calculate_rkf_ed_pairwise(ktgt, ksmp, equal_bins=False)[source]
Calculate Jaccard similarity between ktgt and ksmp.
- Parameters:
- Returns:
r (representativeness level.)
Explanations
————
Refer to calculate_rkfield_ed for complete documentation.
Location (upxo.netops.kcmp.calculate_rkfield_ed)
Data structures
—————
ktgt (networkx graph for target gs’s O(n) neighbour netwprk dict data.)
ksmp (networkx graph for sample gs’s O(n) neighbour netwprk dict data.)
r (int between 0 and 1. Higher the value, greater is) – the representativeness.
- calculate_rkf_nlsd_pairwise(ktgt, ksmp, timescales=numpy.logspace, equal_bins=False)[source]
Calculate Jaccard similarity between ktgt and ksmp.
- Parameters:
- Returns:
r (representativeness level.)
Explanations
————
Refer to calculate_rkfield_nlsd for complete documentation.
Location (upxo.netops.kcmp.calculate_rkfield_nlsd)
Data structures
—————
ktgt (networkx graph for target gs’s O(n) neighbour netwprk dict data.)
ksmp (networkx graph for sample gs’s O(n) neighbour netwprk dict data.)
r (int between 0 and 1. Higher the value, greater is) – the representativeness.
- calculate_rkf_js_on(neigh_order=1)[source]
- Parameters:
notgt (neighbour order of interest for target)
nosmp (neighbour order of interest for sample)
- calculate_rkf_wd_on_generalized(neigh_order_tgt=1, neigh_order_smp=1, equal_bins=False)[source]
Calculate rkf wd on generalized.
- calculate_rkf_ksp_on_generalized(neigh_order_tgt=1, neigh_order_smp=1, equal_bins=False)[source]
Calculate rkf ksp on generalized.
- calculate_rkf_ed_on_generalized(neigh_order_tgt=1, neigh_order_smp=1, equal_bins=False)[source]
Calculate rkf ed on generalized.
- calculate_rkf_nlsd_on(neigh_order=1, timescales=numpy.logspace, equal_bins=False)[source]
Calculate rkf nlsd on.
- calculate_rkf_ed_nlsd_generalized(neigh_order_tgt=1, neigh_order_smp=1, equal_bins=False)[source]
Calculate rkf ed nlsd generalized.
- calculate_rkf_pairwise(neigh_order, idtgt, idsmp, prop='kdegree', printmsg=False)[source]
Calculate rkf pairwise.
- calculate_rkf_pairwise_generalized(neigh_order_tgt, neigh_order_smp, idtgt, idsmp, prop='kdegree', printmsg=False)[source]
Calculate rkf pairwise generalized.
- calculate_rkf(prop='kdegree')[source]
Calculate the network R-Field values for entire tgt and smp database.
Parmeters
- prop: str
- property name. Defaults to ‘kdegree’. Options include:
‘kdegree’
‘area_pixel’
‘volume_voxel’
‘gblength_pixel’
‘gblength_geom2’
‘gblength_voxel’
‘gblength_geom3’
‘gbarea_voxels’
‘gbarea_geom’
‘gbrough_r’
‘ntjp’
Explanations
User specified boolean flags in rkf_flags dictate which R-field metrics would be calculated.
- calculate_uncertainty_angdist(rkf_measure='js', neigh_orders=[1], n_bins=30, data_title='Jaccard sim. measure', throw=False, plot_ad=True)[source]
Calculate uncertainty angdist.
- plot_ang_dist(ANG_DISTANCE, n_bins, neigh_orders=[1], figsize=(5, 5), dpi=150, data_title='DATA TITLE', cmap='nipy_spectral', throw_axis=True)[source]
Visualise ang dist using Matplotlib or PyVista.
- plot_rkf(neigh_orders=[1], power=1, figsize=(7, 5), dpi=120, xtick_incr=2, ytick_incr=2, lfs=7, tfs=8, cmap='nipy_spectral', cbarticks=numpy.arange, cbfs=10, cbtitle='Measure of representativeness R(S|T)', cbfraction=0.046, cbpad=0.04, cbaspect=30, shrink=0.5, cborientation='vertical', flags={'rkf_btwcen': False, 'rkf_clscen': False, 'rkf_degcen': False, 'rkf_ed': False, 'rkf_egnvcen': False, 'rkf_js': False, 'rkf_ksp': False, 'rkf_nlsd': False, 'rkf_wd': False})[source]
Example
import numpy as np from upxo.repqual.grain_network_repr_assesser import KREPR import matplotlib.pyplot as plt kr = KREPR.from_gsgen(gstype=’mcgs’,
is_smp_same_as_tgt = False, tgt_dashboard=’input_dashboard.xls’, smp_dashboard=’input_dashboard.xls’, ordern=[1, 3, 5],
tsid_source=’from_gs’, ssid_source=’from_gs’,
tid=None, sid=None, _cim_=’from_gsgen’)
kr.set_rkf(js=True, wd=True, ksp=False, ed=True, nlsd=False) kr.calculate_rkf()
- kr.plot_rkf(neigh_orders=[1, 3, 5], figsize=(7, 5), dpi=50,
xtick_incr=2, ytick_incr=2, lfs=7, tfs=8, cmap=’nipy_spectral’, cbarticks=np.arange(0, 1.1, 0.1), cbfs=10, cbtitle=’Measure of representativeness R(S|T)’, cbfraction=0.046, cbpad=0.04, cbaspect=15, shrink=0.4, cborientation=’vertical’, plot_rkf_js=False)