-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbjerrum_plot.py
More file actions
43 lines (27 loc) · 978 Bytes
/
bjerrum_plot.py
File metadata and controls
43 lines (27 loc) · 978 Bytes
1
2
3
4
5
6
7
8
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
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 8 20:39:42 2021
@author: watda
create a bjerrum plot for seawater
so that this time consuming operation does not have to be repeated everytime
"""
# import the package
import PyCO2SYS as pyco2
#package to work with html documents
#import dash_html_components as html
import pandas
import numpy as np
import pandas as pd
#for the line plot take range of pH
# use much less datapoints to make app smaller
pH_range=np.linspace(0,14,100)
#fractions
lines=pd.DataFrame(data=np.zeros([pH_range.size,4]),columns=['pH','CO2_frac','HCO3_frac','CO3_frac'])
lines['pH']=pH_range
for item in lines.index:
res=pyco2.sys(par1=pH_range[item],par2=400,par1_type=3,par2_type=4)
lines.loc[item,'CO2_frac']=res['CO2']/res['dic']
lines.loc[item,'CO3_frac']=res['CO3']/res['dic']
lines.loc[item,'HCO3_frac']=res['HCO3']/res['dic']
#save it as csv
lines.to_csv('bjerrum_plot.csv', index=False, encoding='utf-8')