PGD Subtools
These are subtools for the PresolarGrains class.
All of them must be invoked from the PresolarGrains class!
Sub tool to retrieve data from the filtered database.
Data
Data retrieving class.
By default, the length of any the returned data is not necessarily the same as the
length of the parent class database. This is because empty values are filtered out.
For certain methods you can specify dropnan=False in order to avoid this
behavior. Properties that automatically drop empty values generally have a
NAME_all in addition that do not drop empty values.
See the documentation of individual routines to see how data are filtered.
Source code in pgdtools/sub_tools/data.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
notes
property
Retrieve the notes from the filtered database.
Note: Values with empty notes will be dropped. To avoid this, use
the notes_all property.
Returns:
| Type | Description |
|---|---|
|
Series with notes. Index is the PGD ID. |
notes_all
property
Retrieve the notes from the filtered database.
Note: This routine does not drop any values, even if no notes are present.
Returns:
| Type | Description |
|---|---|
Series
|
Series with notes. Index is the PGD ID. |
size
property
Retrieve the size data from the filtered database.
This retrieves the grain sizes in µm from the presolar grain database. Two columns are returned, "Size a" and "Size b".
Note: This routine will drop the rows that have no size information.
Note that Size a (µm) is always the longer or average reported dimesnions.
Size b (µm) is either the shorter dimension or - if not available in the
database, set equal here to Size a.
Returns:
| Type | Description |
|---|---|
DataFrame
|
Two columns of size information. |
size_all
property
Retrieve the size data from the filtered database.
This retrieves the grain sizes in µm from the presolar grain database. Two columns are returned, "Size a" and "Size b".
Note: This routine does not drop any values, even if no size information is
present.
Note that Size a (µm) is always the longer or average reported dimensions.
Size b (µm) is either the shorter dimension or - if not available in the
database, set equal here to Size a.
Returns:
| Type | Description |
|---|---|
DataFrame
|
Two columns of size information. |
__init__(parent)
Initialize the Data class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
PresolarGrains
|
Parent class, must be of type |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Parent class is not of type |
Source code in pgdtools/sub_tools/data.py
ratio(rat, dropnan=True)
Retrieve a given isotope ratio from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rat
|
Tuple[str, str]
|
Isotope ratio to retrieve. Tuple of two strings. Each string represents an isotope. Example: ("29Si", "28Si"). |
required |
dropnan
|
bool
|
Drop rows with NaN values for the given isotope ratio.
Defaults to |
True
|
Returns:
| Type | Description |
|---|---|
Tuple[Series, Series, Series]
|
Series with the isotope ratio. |
Source code in pgdtools/sub_tools/data.py
ratio_xy(rat_x, rat_y, simplify_unc=False)
Retrieve two isotope ratios and their respective uncertainties.
This function is similar to the ratio function. It drops all NaNs, i.e.,
all rows that do not contain values for the wanted x and y ratio. This makes
this function, as the name implies, very useful for plotting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rat_x
|
Tuple[str, str]
|
Isotope ratio to get for x-axis of plot. Tuple of two strings. Each string represents an isotope. Example: ("29Si", "28Si"). |
required |
rat_y
|
Tuple[str, str]
|
Isotope ratio to get for y-axis of plot. Tuple of two strings. Each string represents an isotope. Example: ("29Si", "28Si"). |
required |
simplify_unc
|
By default, uncertainties are returned as asymmetric
errors. This would return a dataframe with two columns.
However, if |
False
|
Returns:
| Type | Description |
|---|---|
Tuple[Series, Union[Series, DataFrame], Series, Union[Series, DataFrame], Union[None, Series]]
|
This function returns a tuple with various Series or Dataframes.
1. The values for |
Source code in pgdtools/sub_tools/data.py
Sub tool to add filtering capabilities.
Filters
Filtering class to filter the data set.
Note that this class will filter the dataset in the parent class!
Source code in pgdtools/sub_tools/filters.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
__init__(parent)
Initialize the Filters class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
PresolarGrains
|
Parent class, must be of type |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Parent class is not of type |
Source code in pgdtools/sub_tools/filters.py
db(dbs, exclude=False)
Filter out a specific database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dbs
|
Union[DataBase, List[DataBase]]
|
Database or databases to filter the data set on. |
required |
exclude
|
bool
|
Exclude the given databases from the data set. |
False
|
Raises:
| Type | Description |
|---|---|
TypeError
|
Database is not of type PresolarGrains.DataBase. |
Source code in pgdtools/sub_tools/filters.py
pgd_id(ids, exclude=False)
Filter the data set based on PGD IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
Union[str, List[str]]
|
PGD ID (single or multiple) to filter the data set on. |
required |
exclude
|
bool
|
Exclude the given IDs from the data set. |
False
|
Source code in pgdtools/sub_tools/filters.py
pgd_subtype(st, exclude=False)
Filter for a given PGD subtype or subtypes.
Note: Empty values are not dropped if exclude is set to True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
st
|
Union[str, List[str]]
|
PGD subtype or subtypes to filter the data set on. |
required |
exclude
|
bool
|
Exclude the given subtypes from the data set. |
False
|
Source code in pgdtools/sub_tools/filters.py
pgd_type(tp, exclude=False)
Filter for a given PGD type or types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
Union[str, List[str]]
|
PGD type or types to filter the data set on. |
required |
exclude
|
bool
|
Exclude the given types from the |
False
|
Source code in pgdtools/sub_tools/filters.py
ratio(rat, cmp, value, exclude=False)
Filter the data set based on a given isotope ratio.
Here, a given isotope ratio is filtered based on a comparator and a value. Some error checking is done on the comparator to ensure that it is valid.
Note: rows with NaN values for the given comparator will be dropped
from the dataset before filtering. This behavior is independent of the value
of exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rat
|
Tuple[str, str]
|
Isotope ratio to filter the data set on. Tuple of two strings. Each string represents an isotope. Example: ("29Si", "28Si"). |
required |
cmp
|
str
|
Comparison operator to use. Available operators are: "<", "<=", ">", ">=", "==", "!=". |
required |
value
|
float
|
Value to compare the isotope ratio against. |
required |
exclude
|
bool
|
Exclude the given isotope ratio value range from the data set. |
False
|
Source code in pgdtools/sub_tools/filters.py
reference(refs, exclude=False)
Filter the data set based on (a) given reference(s).
Note that the references must be exactly what is written in the database.
If you want to search for references, check out the routine:
pgd.reference.search("search string").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refs
|
Union[str, List[str]]
|
Reference or references to filter the data set on. |
required |
exclude
|
Exclude the given references from the data set. |
False
|
Source code in pgdtools/sub_tools/filters.py
reset()
Reset all the filters and re-instate the original database.
Alternatively, this can also be done directly from the parent class by using
the reset method.
uncertainty(rat, cmp, value, exclude=False)
Filter the data set based on a given uncertainty of an isotope ratio.
Here, a given uncertainty is filtered based on a comparator and a value. Some error checking is done on the comparator to ensure that it is valid.
Note: rows with NaN values for the given comparator will be dropped
from the dataset before filtering. This behavior is independent of the value
of exclude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rat
|
Tuple[str, str]
|
Isotope ratio to filter the data set on. Tuple of two strings. Each string represents an isotope. Example: ("29Si", "28Si"). |
required |
cmp
|
str
|
Comparison operator to use. Available operators are: "<", "<=", ">", ">=", "==", "!=". |
required |
value
|
float
|
Value to compare the isotope ratio against. |
required |
exclude
|
bool
|
Exclude the given isotope ratio value range from the data set. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Invalid comparator or isotope ratio names are not valid, not of length 2, or the chosen isotope ratio is not available in the database. |
Source code in pgdtools/sub_tools/filters.py
Sub tool to format header infor, etc.
Format
Formatting class.
Default formatting for strings are in LaTeX notation. These can directly be used, e.g., with matplotlib.
Source code in pgdtools/sub_tools/format.py
__init__(parent)
Initialize the Format class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
PresolarGrains
|
Parent class, must be of type |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Parent class is not of type |
Source code in pgdtools/sub_tools/format.py
ratio(rat)
Format an isotope ratio header in html style.
This can, e.g,. directly be used as an axis label for a plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rat
|
Tuple[str, str]
|
Isotope ratio to filter the data set on. Tuple of two strings. Each string represents an isotope. Example: ("29Si", "28Si"). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted isotope ratio header. |
Source code in pgdtools/sub_tools/format.py
Sub tool to add information querying capabilities.
Info
Class to obtain information about the database.
Note: This class will print and return values.
Source code in pgdtools/sub_tools/info.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
dbs
property
Get/print what databases are currently in the selection.
number_of_grains
property
Get/print how many presolar grains are in the currently filtered database.
Returns:
| Type | Description |
|---|---|
int
|
Number of presolar grains. |
pgd_types
property
Get/print what PGD types of presolar grains are in the current database.
Returns:
| Type | Description |
|---|---|
Set[str]
|
List of all PGD grain types available. |
__init__(parent)
Initialize the Info class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
PresolarGrains
|
Parent class, must be of type |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Parent class is not of type |
Source code in pgdtools/sub_tools/info.py
correlations(inp)
Get/print available correlations for a given element or isotope.
Source code in pgdtools/sub_tools/info.py
ratios(inp)
Get/print available ratios for a given element or isotope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inp
|
str
|
Input isotope or element. |
required |
Returns:
| Type | Description |
|---|---|
Union[None, List[Tuple[str, bool]]]
|
A tuple of tuples. In the latter, each entry consists of available isotope ratio and a boolean value to indicate if this is a delta-value. |
Source code in pgdtools/sub_tools/info.py
Sub tool to gather references for data sets and return them.
References
This class handles references for specific data sets.
Source code in pgdtools/sub_tools/references.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
dict
property
Return a dictionary representation of the class.
The keys are the reference IDs and the values are the full references, which contain further keys: - Number of grains - Reference - short - Reference - full - DOI - Comments
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary representation of the class. |
doi
property
Return a set of all DOIs for the references of the current database.
If no DOI is available for a given reference, it will not be included in the set.
table_full
property
Return a full reference table for every individual grain in the database.
The row indexes of the table are the PGD IDs. The following columns will be present: - Number of grains - Reference - short - Reference - full - DOI - Comments
Returns:
| Type | Description |
|---|---|
DataFrame
|
Full reference table for every grain. |
table_set
property
Return a set of references for all grains in dataset in table format.
__eq__(other)
Check if the references are equal.
Note: This will only check if the set of references are equal and has nothing to do with the number of grains that are associated with each reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Other reference set to compare against. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the references are equal, otherwise False. |
Source code in pgdtools/sub_tools/references.py
__getitem__(key)
Return the reference for the given item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Reference key. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Reference details. |
__init__(parent)
Initialize the Reference class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
PresolarGrains
|
Parent class, must be of type |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Parent class is not of type |
Source code in pgdtools/sub_tools/references.py
__iter__()
Iterate over the key, value pairs.
Returns:
| Type | Description |
|---|---|
iter
|
Iterator for the reference keys and values. |
__len__()
Return the number of individual references in the class.
Returns:
| Type | Description |
|---|---|
int
|
Number of references. |
__repr__()
Return a string representation of the class.
In order to keep it pretty, this will return the following: - Reference key - Short reference - DOI (if available) in parentheses
Returns:
| Type | Description |
|---|---|
str
|
String representation of the class. |
Source code in pgdtools/sub_tools/references.py
search(search_str)
Search all references information (except for notes) for keywords.
If you want to provide multiple keywords to search for, please provide
them separated by a comma. For example: "Name Firstname" would search
all references for "Name Firstname", while "Name, Firstname" would search
for "Name" and "Firstname" separately. For example, a reference with information
"Firstname Name" would in this case only match with the latter search.
All searches are case-insensitive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_str
|
str
|
Search string. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List of strings with all short references that match the search terms. |
Source code in pgdtools/sub_tools/references.py
Sub tool to gather used techniques for data sets and return them.
Techniques
This class handles techniques for specific data sets.
Source code in pgdtools/sub_tools/techniques.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
dict
property
Return a dictionary representation of the techniques.
The keys are the PGD Techniques and the values are the technique details. - Institution - Technique - Instrument - Reference - DOI
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary of techniques. |
table_full
property
Return a full techniques table for every individual grain in the database.
The row indexes of the table are the PGD IDs. The following columns will be present: - PGD Technique - Institution - Technique - Instrument - Reference - DOI
Returns:
| Type | Description |
|---|---|
DataFrame
|
Full reference table for every grain. |
table_set
property
Return a set of techniques for all grains in dataset in table format.
__eq__(other)
Check if the techniques are equal.
Note: This will only check if the set of techniques are equal and has nothing to do with the number of grains that are associated with each technique.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Other technique set to compare against. |
required |
Returns:
| Type | Description |
|---|---|
|
True if the techniques are equal, otherwise False. |
Source code in pgdtools/sub_tools/techniques.py
__getitem__(key)
Get a technique item based on the key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Technique key. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Technique details. |
__init__(parent)
Initialize the Techniques class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
PresolarGrains
|
Parent class, must be of type |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Parent class is not of type |
Source code in pgdtools/sub_tools/techniques.py
__iter__()
Iterate over the techniques key, value pairs.
Returns:
| Type | Description |
|---|---|
|
Key, value pairs of the techniques. |
__len__()
Return the number of individual techniques in the class.
Returns:
| Type | Description |
|---|---|
int
|
Number of unique techniques. |
__repr__()
Return a string representation of the class.
Simply print out all the PGD techniques, comma separated.
Returns:
| Type | Description |
|---|---|
str
|
String representation of the class. |