Normalizing and Transforming Data¶
Contents
Before performing model calculations on your data, it may be desired to normalize the input composition to a total of 100 wt%. VESIcal has multiple methods for normalizing sample data using various routines. Each of the normalization routines can be accessed by the user at any time to normalize either a signle sample or all samples in a BatchFile object.
The standard normalization type returns the composition normalized to 100%, including any volatiles. The FixedVolatiles type the oxides to 100%, but volatiles remain fixed while other major element oxides are reduced proporitonally so that the total is 100 wt%. The AdditionalVolatiles type normalizes oxides to 100% assuming the sample is volatile-free. If H2O or CO2 concentrations are passed to the function, their un-normalized values will be retained in addition to the normalized non-volatile oxides, summing to >100%.
Normalization types are: ‘none’, ‘standard’, ‘fixedvolatiles’, ‘additionalvolatiles’.
import VESIcal as v
Default normalizations and how to change them¶
MagmaSat¶
Currently, no models force any kind of normalization onto samples. For testing purposes, MagmaSat (the default model) has an attribute called ‘normalization_type’. By default, this is set to ‘none’ such that no normalization is performed on samples. To change the type of normalization performed during all calculations, you can create a copy of the MagmaSat() model object, set its normalization type, and then use that model object for calculations, like so:
# make a copy of the MagmaSat() model object and give it a name
magmasatNorm = v.models.magmasat.MagmaSat()
# set normalization_type to be whatever you want. Let's say 'standard'.
magmasatNorm.normalization_type = 'standard'
# now you can do a calculation and set model=magmasatNorm
test_calc = v.calculate_saturation_pressure(sample=<your-sample>, temperature=<temperature>, model=magmasatNorm).result
Normalizing an entire dataset¶
Import an Excel file¶
myfile = v.BatchFile('example_data.xlsx')
myfile.get_data()
Label | SiO2 | TiO2 | Al2O3 | Fe2O3 | Cr2O3 | FeO | MnO | MgO | NiO | CoO | CaO | Na2O | K2O | P2O5 | H2O | CO2 | Press | Temp |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BT-ex | 77.5 | 0.08 | 12.5 | 0.207 | 0 | 0.473 | 0 | 0.03 | 0 | 0 | 0.43 | 3.98 | 4.88 | 0 | 5.5 | 0.05 | 500 | 900 |
TVZMa-ex | 78.37 | 0.13 | 11.94 | 0 | 0 | 0.99 | 0.04 | 0.05 | 0 | 0 | 0.53 | 3.8 | 4.14 | 0 | 4.06 | 0.005 | 600 | 800 |
TVZOh-ex | 77.9 | 0.08 | 12.15 | 0 | 0 | 0.95 | 0.05 | 0.06 | 0 | 0 | 0.55 | 4.05 | 4.12 | 0 | 4.63 | 0.005 | 50 | 900 |
Oh48-FTIR1-MI1-a | 78.27 | 0.0298 | 12.02 | 0 | 0 | 0.9828 | 0.0336 | 0.0515 | 0 | 0 | 0.4772 | 4.05 | 4.09 | 0 | 4.214912406 | 0.004565932 | 250 | 950 |
Oh48-FTIR1-MI1-b | 78.27 | 0.0298 | 12.02 | 0 | 0 | 0.9828 | 0.0336 | 0.0515 | 0 | 0 | 0.4772 | 4.05 | 4.09 | 0 | 4.005815793 | 0.004447963 | 500 | 1025 |
Oh48-FTIR1-MI1-IRc | 78.27 | 0.0298 | 12.02 | 0 | 0 | 0.9828 | 0.0336 | 0.0515 | 0 | 0 | 0.4772 | 4.05 | 4.09 | 0 | 3.885649341 | 0.004654367 | 5000 | 925 |
Oh50-4.1 | 77.91 | 0.0984 | 12.07 | 0 | 0 | 1.0556 | 0.0257 | 0.0999 | 0 | 0 | 0.5216 | 4.04 | 4.18 | 0 | 4.641842879 | 0.004565932 | 1000 | 862 |
Oh50-4.2 | 77.91 | 0.0984 | 12.07 | 0 | 0 | 1.0556 | 0.0257 | 0.0999 | 0 | 0 | 0.5216 | 4.04 | 4.18 | 0 | 4.402133476 | 0.004447963 | 100 | 770 |
Oh49-4.1 | 77.92 | 0.0099 | 12.11 | 0 | 0 | 1.002 | 0.0672 | 0.0546 | 0 | 0 | 0.5346 | 4.01 | 4.3 | 0 | 4.283934433 | 0.004565932 | 1000 | 855 |
Oh49-4.2 | 77.92 | 0.0099 | 12.11 | 0 | 0 | 1.002 | 0.0672 | 0.0546 | 0 | 0 | 0.5346 | 4.01 | 4.3 | 0 | 4.230532593 | 0.004447963 | 500 | 1000 |
Ma55-5a.1 | 77.68 | 0.0096 | 12.27 | 0 | 0 | 1.0272 | 0.0628 | 0.0342 | 0 | 0 | 0.6064 | 3.97 | 4.35 | 0 | 4.459767403 | 0.004654367 | 5000 | 1010 |
Ma57-3b.2 | 77.9 | 0.0498 | 12.07 | 0 | 0 | 1.0844 | 0.0748 | 0.0355 | 0 | 0 | 0.4759 | 4.1 | 4.21 | 0 | 3.712506046 | 0.004447963 | 1000 | 1012 |
Ma57-3c.1 | 77.65 | 0.159 | 12.28 | 0 | 0 | 0.9769 | 0.0597 | 0.0577 | 0 | 0 | 0.5598 | 4.08 | 4.18 | 0.0064 | 4.443973024 | 0.004654367 | 100 | 885 |
Ma57-3c.2 | 77.65 | 0.159 | 12.28 | 0 | 0 | 0.9769 | 0.0597 | 0.0577 | 0 | 0 | 0.5598 | 4.08 | 4.18 | 0.0064 | 4.283171078 | 0.004644523 | 1000 | 885 |
Standard Normalization¶
Returns the composition normalized to 100%, including any volatiles.
standard = myfile.get_data(normalization='standard', asBatchFile=True)
standard.get_data()
Label | SiO2 | TiO2 | Al2O3 | Fe2O3 | Cr2O3 | FeO | MnO | MgO | NiO | CoO | CaO | Na2O | K2O | P2O5 | H2O | CO2 | Press | Temp |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BT-ex | 73.36930796 | 0.07573606 | 11.83375935 | 0.195967055 | 0 | 0.447789454 | 0 | 0.028401022 | 0 | 0 | 0.407081322 | 3.767868977 | 4.61989965 | 0 | 5.206854113 | 0.047335037 | 500 | 900 |
TVZMa-ex | 75.31593869 | 0.124933929 | 11.47470088 | 0 | 0 | 0.951419922 | 0.038441209 | 0.048051511 | 0 | 0 | 0.509346019 | 3.651914853 | 3.978665129 | 0 | 3.901782711 | 0.004805151 | 600 | 800 |
TVZOh-ex | 74.51336745 | 0.076522072 | 11.62178966 | 0 | 0 | 0.908699603 | 0.047826295 | 0.057391554 | 0 | 0 | 0.526089244 | 3.873929887 | 3.9408867 | 0 | 4.428714907 | 0.004782629 | 50 | 900 |
Oh48-FTIR1-MI1-a | 75.09759353 | 0.028592159 | 11.53281045 | 0 | 0 | 0.942965567 | 0.032238139 | 0.049412624 | 0 | 0 | 0.457858332 | 3.885847116 | 3.924225853 | 0 | 4.044075363 | 0.004380868 | 250 | 950 |
Oh48-FTIR1-MI1-b | 75.24864373 | 0.028649669 | 11.55600738 | 0 | 0 | 0.944862234 | 0.032302982 | 0.049512012 | 0 | 0 | 0.458779261 | 3.893663052 | 3.932118984 | 0 | 3.851184431 | 0.004276264 | 500 | 1025 |
Oh48-FTIR1-MI1-IRc | 75.33552773 | 0.028682749 | 11.56935024 | 0 | 0 | 0.945953196 | 0.03234028 | 0.049569179 | 0 | 0 | 0.45930898 | 3.898158775 | 3.936659108 | 0 | 3.739969895 | 0.004479867 | 5000 | 925 |
Oh50-4.1 | 74.44986167 | 0.09402986 | 11.53394725 | 0 | 0 | 1.008718701 | 0.024558612 | 0.095463242 | 0 | 0 | 0.498434705 | 3.860575551 | 3.994357872 | 0 | 4.435689389 | 0.00436315 | 1000 | 862 |
Oh50-4.2 | 74.62087493 | 0.094245849 | 11.56044103 | 0 | 0 | 1.011035754 | 0.024615024 | 0.095682523 | 0 | 0 | 0.499579622 | 3.869443392 | 4.003533015 | 0 | 4.216288686 | 0.004260184 | 100 | 770 |
Oh49-4.1 | 74.7098662 | 0.009492142 | 11.61109445 | 0 | 0 | 0.960719789 | 0.064431507 | 0.052350599 | 0 | 0 | 0.512575648 | 3.844796759 | 4.122849392 | 0 | 4.107445692 | 0.004377826 | 1000 | 855 |
Oh49-4.2 | 74.74822318 | 0.009497015 | 11.61705573 | 0 | 0 | 0.961213034 | 0.064464587 | 0.052377477 | 0 | 0 | 0.51283881 | 3.846770726 | 4.124966115 | 0 | 4.058326418 | 0.004266907 | 500 | 1000 |
Ma55-5a.1 | 74.35298514 | 0.009188834 | 11.74447899 | 0 | 0 | 0.983205282 | 0.060110292 | 0.032735223 | 0 | 0 | 0.580428041 | 3.799965899 | 4.163690594 | 0 | 4.268756687 | 0.004455022 | 5000 | 1010 |
Ma57-3b.2 | 75.10797083 | 0.048015108 | 11.63739676 | 0 | 0 | 1.045533807 | 0.072119079 | 0.034227638 | 0 | 0 | 0.458843175 | 3.953051097 | 4.059108565 | 0 | 3.579445389 | 0.004288543 | 1000 | 1012 |
Ma57-3c.1 | 74.33600615 | 0.152214101 | 11.7559067 | 0 | 0 | 0.935207269 | 0.057152087 | 0.055237444 | 0 | 0 | 0.535908516 | 3.905871282 | 4.001603422 | 0.006126857 | 4.254310445 | 0.004455725 | 100 | 885 |
Ma57-3c.2 | 74.45062181 | 0.152448794 | 11.77403266 | 0 | 0 | 0.936649227 | 0.057240208 | 0.055322613 | 0 | 0 | 0.536734811 | 3.911893587 | 4.007773331 | 0.006136304 | 4.106693498 | 0.004453156 | 1000 | 885 |
FixedVolatiles Normalization¶
Normalizes the oxides to 100%, but volatiles remain fixed while other major element oxides are reduced proporitonally so that the total is 100 wt%.
fixed_vols = myfile.get_data(normalization='fixedvolatiles', asBatchFile=True)
fixed_vols.get_data()
Label | SiO2 | TiO2 | Al2O3 | Fe2O3 | Cr2O3 | FeO | MnO | MgO | NiO | CoO | CaO | Na2O | K2O | P2O5 | H2O | CO2 | Press | Temp |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BT-ex | 73.14023781 | 0.0754996 | 11.79681255 | 0.195355216 | 0 | 0.446391387 | 0 | 0.02831235 | 0 | 0 | 0.405810352 | 3.756105116 | 4.60547562 | 0 | 5.5 | 0.05 | 500 | 900 |
TVZMa-ex | 75.19177868 | 0.124727973 | 11.45578458 | 0 | 0 | 0.949851485 | 0.038377838 | 0.047972297 | 0 | 0 | 0.508506351 | 3.645894589 | 3.972106211 | 0 | 4.06 | 0.005 | 600 | 800 |
TVZOh-ex | 74.35625563 | 0.076360725 | 11.59728506 | 0 | 0 | 0.906783605 | 0.047725453 | 0.057270543 | 0 | 0 | 0.524979982 | 3.865761686 | 3.93257732 | 0 | 4.63 | 0.005 | 50 | 900 |
Oh48-FTIR1-MI1-a | 74.96374108 | 0.028541197 | 11.5122546 | 0 | 0 | 0.941284844 | 0.032180678 | 0.049324552 | 0 | 0 | 0.457042254 | 3.87892106 | 3.917231392 | 0 | 4.214912406 | 0.004565932 | 250 | 950 |
Oh48-FTIR1-MI1-b | 75.12748531 | 0.02860354 | 11.53740096 | 0 | 0 | 0.943340904 | 0.032250971 | 0.049432292 | 0 | 0 | 0.458040577 | 3.887393836 | 3.925787849 | 0 | 4.005815793 | 0.004447963 | 500 | 1025 |
Oh48-FTIR1-MI1-IRc | 75.22137344 | 0.028639286 | 11.55181946 | 0 | 0 | 0.944519814 | 0.032291276 | 0.049494068 | 0 | 0 | 0.458612999 | 3.892251979 | 3.930693974 | 0 | 3.885649341 | 0.004654367 | 5000 | 925 |
Oh50-4.1 | 74.28909143 | 0.093826808 | 11.50904035 | 0 | 0 | 1.00654043 | 0.024505579 | 0.095257095 | 0 | 0 | 0.497358363 | 3.852238857 | 3.985732283 | 0 | 4.641842879 | 0.004565932 | 1000 | 862 |
Oh50-4.2 | 74.47593869 | 0.094062795 | 11.53798716 | 0 | 0 | 1.009072017 | 0.024567214 | 0.095496679 | 0 | 0 | 0.498609288 | 3.861927767 | 3.995756947 | 0 | 4.402133476 | 0.004447963 | 100 | 770 |
Oh49-4.1 | 74.57221102 | 0.009474652 | 11.58970066 | 0 | 0 | 0.958949634 | 0.06431279 | 0.052254142 | 0 | 0 | 0.511631212 | 3.837712605 | 4.115252918 | 0 | 4.283934433 | 0.004565932 | 1000 | 855 |
Oh49-4.2 | 74.6139102 | 0.00947995 | 11.59618137 | 0 | 0 | 0.959485857 | 0.064348752 | 0.052283361 | 0 | 0 | 0.511917305 | 3.839858571 | 4.117554079 | 0 | 4.230532593 | 0.004447963 | 500 | 1000 |
Ma55-5a.1 | 74.20446831 | 0.00917048 | 11.7210199 | 0 | 0 | 0.981241373 | 0.059990224 | 0.032669835 | 0 | 0 | 0.579268661 | 3.792375633 | 4.155373805 | 0 | 4.459767403 | 0.004654367 | 5000 | 1010 |
Ma57-3b.2 | 75.00419281 | 0.047948765 | 11.62131717 | 0 | 0 | 1.044089174 | 0.07201943 | 0.034180345 | 0 | 0 | 0.458209183 | 3.947589095 | 4.053500022 | 0 | 3.712506046 | 0.004447963 | 1000 | 1012 |
Ma57-3c.1 | 74.18859291 | 0.151912251 | 11.73259396 | 0 | 0 | 0.933352691 | 0.057038751 | 0.055127905 | 0 | 0 | 0.534845774 | 3.89812568 | 3.993667977 | 0.006114707 | 4.443973024 | 0.004654367 | 100 | 885 |
Ma57-3c.2 | 74.31345141 | 0.152167917 | 11.75233977 | 0 | 0 | 0.934923512 | 0.057134746 | 0.055220684 | 0 | 0 | 0.535745912 | 3.904686178 | 4.000389271 | 0.006124998 | 4.283171078 | 0.004644523 | 1000 | 885 |
AdditionalVolatiles Normalization¶
Normalizes oxides to 100% assuming the sample is volatile-free. If H_2O or CO_2 concentrations are passed to the function, their un-normalized values will be retained in addition to the normalized non-volatile oxides, summing to >100%.
additional_vols = myfile.get_data(normalization='additionalvolatiles', asBatchFile=True)
additional_vols.get_data()
Label | SiO2 | TiO2 | Al2O3 | Fe2O3 | Cr2O3 | FeO | MnO | MgO | NiO | CoO | CaO | Na2O | K2O | P2O5 | H2O | CO2 | Press | Temp |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BT-ex | 77.43804956 | 0.079936051 | 12.49000799 | 0.206834532 | 0 | 0.472621902 | 0 | 0.029976019 | 0 | 0 | 0.429656275 | 3.976818545 | 4.876099121 | 0 | 5.5 | 0.05 | 500 | 900 |
TVZMa-ex | 78.37783778 | 0.130013001 | 11.94119412 | 0 | 0 | 0.99009901 | 0.040004 | 0.050005001 | 0 | 0 | 0.530053005 | 3.800380038 | 4.140414041 | 0 | 4.06 | 0.005 | 600 | 800 |
TVZOh-ex | 77.97017316 | 0.080072065 | 12.16094485 | 0 | 0 | 0.95085577 | 0.050045041 | 0.060054049 | 0 | 0 | 0.550495446 | 4.053648283 | 4.12371134 | 0 | 4.63 | 0.005 | 50 | 900 |
Oh48-FTIR1-MI1-a | 78.26616496 | 0.02979854 | 12.01941105 | 0 | 0 | 0.982751845 | 0.033598354 | 0.051497477 | 0 | 0 | 0.477176618 | 4.04980156 | 4.0897996 | 0 | 4.214912406 | 0.004565932 | 250 | 950 |
Oh48-FTIR1-MI1-b | 78.26616496 | 0.02979854 | 12.01941105 | 0 | 0 | 0.982751845 | 0.033598354 | 0.051497477 | 0 | 0 | 0.477176618 | 4.04980156 | 4.0897996 | 0 | 4.005815793 | 0.004447963 | 500 | 1025 |
Oh48-FTIR1-MI1-IRc | 78.26616496 | 0.02979854 | 12.01941105 | 0 | 0 | 0.982751845 | 0.033598354 | 0.051497477 | 0 | 0 | 0.477176618 | 4.04980156 | 4.0897996 | 0 | 3.885649341 | 0.004654367 | 5000 | 925 |
Oh50-4.1 | 77.90906509 | 0.098398819 | 12.06985516 | 0 | 0 | 1.055587333 | 0.025699692 | 0.099898801 | 0 | 0 | 0.521593741 | 4.039951521 | 4.179949841 | 0 | 4.641842879 | 0.004565932 | 1000 | 862 |
Oh50-4.2 | 77.90906509 | 0.098398819 | 12.06985516 | 0 | 0 | 1.055587333 | 0.025699692 | 0.099898801 | 0 | 0 | 0.521593741 | 4.039951521 | 4.179949841 | 0 | 4.402133476 | 0.004447963 | 100 | 770 |
Oh49-4.1 | 77.91353318 | 0.009899178 | 12.10899495 | 0 | 0 | 1.001916841 | 0.067194423 | 0.054595469 | 0 | 0 | 0.534555632 | 4.009667198 | 4.29964313 | 0 | 4.283934433 | 0.004565932 | 1000 | 855 |
Oh49-4.2 | 77.91353318 | 0.009899178 | 12.10899495 | 0 | 0 | 1.001916841 | 0.067194423 | 0.054595469 | 0 | 0 | 0.534555632 | 4.009667198 | 4.29964313 | 0 | 4.230532593 | 0.004447963 | 500 | 1000 |
Ma55-5a.1 | 77.67207745 | 0.009599021 | 12.26874859 | 0 | 0 | 1.027095236 | 0.062793595 | 0.034196512 | 0 | 0 | 0.606338154 | 3.969595101 | 4.349556345 | 0 | 4.459767403 | 0.004654367 | 5000 | 1010 |
Ma57-3b.2 | 77.8996884 | 0.049799801 | 12.06995172 | 0 | 0 | 1.084395662 | 0.074799701 | 0.035499858 | 0 | 0 | 0.475898096 | 4.0999836 | 4.20998316 | 0 | 3.712506046 | 0.004447963 | 1000 | 1012 |
Ma57-3c.1 | 77.64262395 | 0.158984896 | 12.27883351 | 0 | 0 | 0.976807203 | 0.059694329 | 0.057694519 | 0 | 0 | 0.559746824 | 4.079612437 | 4.179602938 | 0.006399392 | 4.443973024 | 0.004654367 | 100 | 885 |
Ma57-3c.2 | 77.64262395 | 0.158984896 | 12.27883351 | 0 | 0 | 0.976807203 | 0.059694329 | 0.057694519 | 0 | 0 | 0.559746824 | 4.079612437 | 4.179602938 | 0.006399392 | 4.283171078 | 0.004644523 | 1000 | 885 |
Normalize a single sample composition¶
Extract a single sample from your dataset¶
Here, a composition is extracted from a BatchFile object and returned as a Sample object. Set asSampleClass=False to return as a dictionary.
SampleName = 'BT-ex'
extracted_bulk_comp = myfile.get_sample_composition(SampleName, asSampleClass=True)
The normalization type can be passed to get_sample_composition directly:
extracted_bulk_comp = myfile.get_sample_composition(SampleName, normalization=<normalization-type>, asSampleClass=True)
Or, normalization can be done to any Sample object, as shown below.
Standard Normalization¶
In the following three examples, the normalized composition is returned as a dictionary, not as a Sample object.
single_standard = extracted_bulk_comp.get_composition(normalization='standard')
single_standard
{'SiO2': 73.3693079617533,
'TiO2': 0.07573605983148728,
'Al2O3': 11.833759348669886,
'Fe2O3': 0.1959670548139733,
'Cr2O3': 0.0,
'FeO': 0.44778945375366846,
'MnO': 0.0,
'MgO': 0.028401022436807727,
'NiO': 0.0,
'CoO': 0.0,
'CaO': 0.4070813215942441,
'Na2O': 3.7678689766164917,
'K2O': 4.619899649720724,
'P2O5': 0.0,
'H2O': 5.2068541134147495,
'CO2': 0.04733503739467954}
FixedVolatiles Normalization¶
single_fixed = extracted_bulk_comp.get_composition(normalization='fixedvolatiles')
single_fixed
{'SiO2': 73.1402378097522,
'TiO2': 0.07549960031974419,
'Al2O3': 11.79681254996003,
'Fe2O3': 0.19535521582733809,
'Cr2O3': 0.0,
'FeO': 0.4463913868904875,
'MnO': 0.0,
'MgO': 0.02831235011990407,
'NiO': 0.0,
'CoO': 0.0,
'CaO': 0.405810351718625,
'Na2O': 3.756105115907274,
'K2O': 4.6054756195043955,
'P2O5': 0.0,
'CO2': 0.05,
'H2O': 5.5}
AdditionalVolatiles Normalization¶
single_additional = extracted_bulk_comp.get_composition(normalization='additionalvolatiles')
single_additional
{'SiO2': 77.4380495603517,
'TiO2': 0.07993605115907274,
'Al2O3': 12.490007993605113,
'Fe2O3': 0.20683453237410068,
'Cr2O3': 0.0,
'FeO': 0.4726219024780175,
'MnO': 0.0,
'MgO': 0.029976019184652272,
'NiO': 0.0,
'CoO': 0.0,
'CaO': 0.4296562749800159,
'Na2O': 3.9768185451638685,
'K2O': 4.8760991207034365,
'P2O5': 0.0,
'H2O': 5.5,
'CO2': 0.05}