Normalizing and Transforming Data

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()
Output

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()
Output

SiO2

TiO2

Al2O3

Fe2O3

Cr2O3

FeO

MnO

MgO

NiO

CoO

CaO

Na2O

K2O

P2O5

H2O

CO2

Press

Temp

BT-ex

73.3693079617533

0.07573605983148728

11.833759348669886

0.1959670548139733

0.0

0.44778945375366846

0.0

0.028401022436807727

0.0

0.0

0.4070813215942441

3.7678689766164917

4.619899649720724

0.0

5.2068541134147495

0.04733503739467954

500

900

TVZMa-ex

75.31593868627169

0.12493392917207247

11.474700879342656

0.0

0.0

0.9514199221565519

0.038441208976022295

0.048051511220027876

0.0

0.0

0.5093460189322955

3.6519148527221184

3.9786651290183075

0.0

3.9017827110662626

0.004805151122002787

600

800

TVZOh-ex

74.5133674494237

0.07652207183509493

11.621789659955043

0.0

0.0

0.9086996030417523

0.04782629489693433

0.0573915538763212

0.0

0.0

0.5260892438662778

3.873929886651681

3.9408866995073892

0.0

4.428714907456119

0.004782629489693433

50

900

Oh48-FTIR1-MI1-a

75.0975937702406

0.02859215912039312

11.532810490843133

0.0

0.0

0.9429655699168578

0.03223813914245668

0.04941262398322972

0.0

0.0

0.4578583332970335

3.88584712877826

3.924225865852613

0.0

4.044074985988403

0.004380932837037416

250

950

Oh48-FTIR1-MI1-b

75.24864355354957

0.028649668811751336

11.556007352927889

0.0

0.0

0.94486223181843

0.03230298228439077

0.049512011537087036

0.0

0.0

0.4587792603009308

3.893663043207816

3.9321189744987572

0.0

3.8511846215038426

0.004276299559552683

500

1025

Oh48-FTIR1-MI1-IRc

75.33552824378235

0.028682748711699423

11.569350319282789

0.0

0.0

0.9459532024784629

0.03234028042661411

0.049569179820554365

0.0

0.0

0.45930898272560283

3.898158801422237

3.9366591352634446

0.0

3.7399695922438303

0.004479513842424467

5000

925

Oh50-4.1

74.44986153482016

0.09402985977443593

11.533947230461806

0.0

0.0

1.0087186989623431

0.024558611750030525

0.09546324178319258

0.0

0.0

0.49843470384497746

3.860575543584565

3.994357864401852

0.0

4.435689495781982

0.0043632148346552276

1000

862

Oh50-4.2

74.62087523917397

0.0942458493586795

11.560441074789242

0.0

0.0

1.0110357579575413

0.024615023663801455

0.09568252389158619

0.0

0.0

0.4995796242427563

3.869443408628711

4.003533031700003

0.0

4.216288247712112

0.004260218881579333

100

770

Oh49-4.1

74.70986645803131

0.009492141657270407

11.611094491873194

0.0

0.0

0.9607197919782775

0.06443150700692639

0.05235059944312769

0.0

0.0

0.5125756494926018

3.844796772288316

4.122849406693207

0.0

4.107445290747176

0.004377890788595623

1000

855

Oh49-4.2

74.74822286148112

0.009497014968283667

11.617055683425775

0.0

0.0

0.9612130301232558

0.06446458645138002

0.052377476491746275

0.0

0.0

0.5128388082873179

3.846770709375505

4.124966097335329

0.0

4.058326790385657

0.004266941674638963

500

1000

Ma55-5a.1

74.35298568826587

0.009188834482586925

11.744479073056414

0.0

0.0

0.9832052896368009

0.06011029224025613

0.03273522284421592

0.0

0.0

0.5804280448167408

3.799965926653135

4.1636906249222

0.0

4.268756332698255

0.0044546703835374535

5000

1010

Ma57-3b.2

75.10797084160093

0.048015108445593396

11.637396765829566

0.0

0.0

1.045533807196817

0.07211907854880295

0.03422763754655755

0.0

0.0

0.4588431748846968

3.953051096926364

4.059108565380487

0.0

3.579445345279441

0.004288578360763041

1000

1012

Ma57-3c.1

74.33600642676657

0.15221410202003716

11.7559067472079

0.0

0.0

0.9352072720966936

0.05715208736224037

0.0552374445695355

0.0

0.0

0.535908517678093

3.9058712971179346

4.001603436753178

0.006126856936655584

4.254310437712519

0.004455373778624232

100

885

Ma57-3c.2

74.45062152893753

0.15244879360078642

11.774032612689668

0.0

0.0

0.9366492230730078

0.05724020740859717

0.05532261252053696

0.0

0.0

0.5367348091680517

3.911893571642821

4.0077733160458315

0.006136303641792661

4.106693407143862

0.00445361412751983

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()
Output

SiO2

TiO2

Al2O3

Fe2O3

Cr2O3

FeO

MnO

MgO

NiO

CoO

CaO

Na2O

K2O

P2O5

CO2

H2O

Press

Temp

BT-ex

73.1402378097522

0.07549960031974419

11.79681254996003

0.19535521582733809

0.0

0.4463913868904875

0.0

0.02831235011990407

0.0

0.0

0.405810351718625

3.756105115907274

4.6054756195043955

0.0

0.05

5.5

500

900

TVZMa-ex

75.19177867786779

0.12472797279727973

11.455784578457846

0.0

0.0

0.9498514851485149

0.03837783778377838

0.047972297229722974

0.0

0.0

0.5085063506350636

3.6458945894589463

3.972106210621062

0.0

0.005

4.06

600

800

TVZOh-ex

74.35625563006705

0.07636072465218695

11.597285056550895

0.0

0.0

0.9067836052447201

0.04772545290761685

0.057270543489140215

0.0

0.0

0.5249799819837854

3.865761685516964

3.9325773195876286

0.0

0.005

4.63

50

900

Oh48-FTIR1-MI1-a

74.96374134607406

0.028541197037345176

11.51225464392245

0.0

0.0

0.9412848472584846

0.03218067853875161

0.04932455192695558

0.0

0.0

0.45704225591346037

3.8789210738673816

3.9172314054611332

0.0

0.004566

4.214912

250

950

Oh48-FTIR1-MI1-b

75.1274851204291

0.02860353975455203

11.537400934554208

0.0

0.0

0.9433409017038167

0.03225097099842108

0.04943229185769897

0.0

0.0

0.4580405762037661

3.8873938257025413

3.9257878387958995

0.0

0.004448

4.005816

500

1025

Oh48-FTIR1-MI1-IRc

75.22137399457428

0.028639286380967337

11.55181954024253

0.0

0.0

0.9445198206447886

0.03229127591947995

0.04949406874563147

0.0

0.0

0.4586130020468998

3.892252008151601

3.930694003293839

0.0

0.004654

3.885649

5000

925

Oh50-4.1

74.28909127900464

0.09382680762230851

11.509040325216095

0.0

0.0

1.0065404281108625

0.024505578820054157

0.0952570943238681

0.0

0.0

0.4973583623556516

3.852238849533805

3.985732275012699

0.0

0.004566

4.641843

1000

862

Oh50-4.2

74.4759390316316

0.09406279554245348

11.53798721745339

0.0

0.0

1.0090720220997347

0.02456721387643348

0.09549667962084454

0.0

0.0

0.4986092901925176

3.861927784466586

3.9957569651164175

0.0

0.004448

4.402133

100

770

Oh49-4.1

74.57221130646157

0.009474652103875379

11.589700704841498

0.0

0.0

0.9589496371801141

0.06431279003842681

0.05225414190622178

0.0

0.0

0.5116312136092703

3.8377126198525517

4.115252934006477

0.0

0.004566

4.283934

1000

855

Oh49-4.2

74.61390985028243

0.009479950045146252

11.596181317850617

0.0

0.0

0.9594858530541964

0.0643487518215988

0.052283360855049026

0.0

0.0

0.5119173024378976

3.839858553640047

4.117554060013019

0.0

0.004448

4.230533

500

1000

Ma55-5a.1

74.20446891137105

0.009170480195020108

11.721019999260076

0.0

0.0

0.9812413808671514

0.059990224609089864

0.03266983569475913

0.0

0.0

0.5792686656521036

3.7923756639822743

4.155373838368487

0.0

0.004654

4.459767

5000

1010

Ma57-3b.2

75.00419281722876

0.04794876511293955

11.621317166931334

0.0

0.0

1.0440891744673022

0.07201943033027869

0.03418034460862157

0.0

0.0

0.4582091830772677

3.9475890956436177

4.05350002259991

0.0

0.004448

3.712506

1000

1012

Ma57-3c.1

74.18859321814428

0.1519122514061164

11.73259400796924

0.0

0.0

0.9333526943310383

0.05703875099965503

0.055127905070018336

0.0

0.0

0.5348457757053078

3.8981256964588353

3.99366799294067

0.00611470697483739

0.004654

4.443973

100

885

Ma57-3c.2

74.31345109814566

0.1521679166079222

11.752339722926319

0.0

0.0

0.9349235077627622

0.05713474604712552

0.0552206842030007

0.0

0.0

0.5357459101705336

3.9046861620146074

4.000389254220848

0.006124997901199385

0.004645

4.283171

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()
Output

SiO2

TiO2

Al2O3

Fe2O3

Cr2O3

FeO

MnO

MgO

NiO

CoO

CaO

Na2O

K2O

P2O5

H2O

CO2

Press

Temp

BT-ex

77.4380495603517

0.07993605115907274

12.490007993605113

0.20683453237410068

0.0

0.4726219024780175

0.0

0.029976019184652272

0.0

0.0

0.4296562749800159

3.9768185451638685

4.8760991207034365

0.0

5.5

0.05

500

900

TVZMa-ex

78.37783778377838

0.13001300130013002

11.941194119411941

0.0

0.0

0.9900990099009901

0.040004000400040006

0.05000500050005

0.0

0.0

0.5300530053005301

3.8003800380038006

4.14041404140414

0.0

4.06

0.005

600

800

TVZOh-ex

77.97017315584026

0.08007206485837252

12.160944850365327

0.0

0.0

0.9508557701931738

0.050045040536482836

0.06005404864377939

0.0

0.0

0.5504954459013112

4.053648283455109

4.123711340206185

0.0

4.63

0.005

50

900

Oh48-FTIR1-MI1-a

78.26616495791707

0.0297985398715463

12.019411048858608

0.0

0.0

0.9827518451595874

0.03359835368066965

0.05149747662364545

0.0

0.0

0.4771766183457012

4.049801559723575

4.089799599819609

0.0

4.214912

0.004566

250

950

Oh48-FTIR1-MI1-b

78.26616495791707

0.0297985398715463

12.019411048858608

0.0

0.0

0.9827518451595874

0.03359835368066965

0.05149747662364545

0.0

0.0

0.4771766183457012

4.049801559723575

4.089799599819609

0.0

4.005816

0.004448

500

1025

Oh48-FTIR1-MI1-IRc

78.26616495791707

0.0297985398715463

12.019411048858608

0.0

0.0

0.9827518451595874

0.03359835368066965

0.05149747662364545

0.0

0.0

0.4771766183457012

4.049801559723575

4.089799599819609

0.0

3.885649

0.004654

5000

925

Oh50-4.1

77.90906509121889

0.09839881921416942

12.069855161738058

0.0

0.0

1.0555873329520045

0.025699691603700753

0.09989880121438542

0.0

0.0

0.5215937408751095

4.039951520581752

4.179949840601912

0.0

4.641843

0.004566

1000

862

Oh50-4.2

77.90906509121889

0.09839881921416942

12.069855161738058

0.0

0.0

1.0555873329520045

0.025699691603700753

0.09989880121438542

0.0

0.0

0.5215937408751095

4.039951520581752

4.179949840601912

0.0

4.402133

0.004448

100

770

Oh49-4.1

77.91353317674633

0.009899178368195441

12.108994953418865

0.0

0.0

1.001916840902205

0.06719442286290238

0.054595468576108176

0.0

0.0

0.5345556318825537

4.009667197622597

4.299643129620241

0.0

4.283934

0.004566

1000

855

Oh49-4.2

77.91353317674633

0.009899178368195441

12.108994953418865

0.0

0.0

1.001916840902205

0.06719442286290238

0.054595468576108176

0.0

0.0

0.5345556318825537

4.009667197622597

4.299643129620241

0.0

4.230533

0.004448

500

1000

Ma55-5a.1

77.67207744810031

0.009599020899868213

12.26874858764406

0.0

0.0

1.0270952362858987

0.06279359505330455

0.03419651195578051

0.0

0.0

0.6063381535083423

3.969595101299668

4.349556345252784

0.0

4.459767

0.004654

5000

1010

Ma57-3b.2

77.89968840124641

0.0497998008007968

12.06995172019312

0.0

0.0

1.0843956624173505

0.0747997008011968

0.035499858000568

0.0

0.0

0.4758980964076144

4.0999836000656

4.2099831600673605

0.0

3.712506

0.004448

1000

1012

Ma57-3c.1

77.64262395072467

0.15898489643483865

12.27883351081647

0.0

0.0

0.9768072033156848

0.05969432903874132

0.05769451902069302

0.0

0.0

0.5597468240517149

4.079612436818501

4.179602937720916

0.006399392057754512

4.443973

0.004654

100

885

Ma57-3c.2

77.64262395072467

0.15898489643483865

12.27883351081647

0.0

0.0

0.9768072033156848

0.05969432903874132

0.05769451902069302

0.0

0.0

0.5597468240517149

4.079612436818501

4.179602937720916

0.006399392057754512

4.283171

0.004645

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}