-
Notifications
You must be signed in to change notification settings - Fork 2
/
zensemble.py
47 lines (39 loc) · 1.2 KB
/
zensemble.py
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
44
45
46
47
import pandas as pd
import numpy as np
spinup = 3 # in whole number days
nruns = 2
df = pd.DataFrame(
[
['ii', 'TIME', '0', str(24*60*60*12)],
['ii', 'TEMP', '0', '298'],
['ii', 'LAT', '0', '51.5'],
['ii', 'LON', '0', '0.1'],
['ii', 'JDAY', '0', '173.5'],
['ii', 'H2O', '0', '0.02'],
['ii', 'ALBEDO', '0', '0'],
['ii', 'PRESS', '0', '1013'],
['ii', 'NOx', '0', '0'],
['ii', 'DEPOS', '1', '0'],
['ii', 'FEMISS', '1', '0'],
['ii', 'H2', '0', '0.0000005'],
['ii', 'NO', '0', '0.00000001'],
['ii', 'NO2', '0', '0'],
['ii', 'O3', '0', '0.00000004'],
['ii', 'CH4', '0', '0.00000002'],
['ii', 'OH', '0', '1e-6'],
['s', 'SPINUP', '0', '1e99']
]
)
df.columns = ['Index', 'Species', 'Constrain', 'base']
col = list(df['base'])
for i,s in enumerate(np.linspace(spinup, spinup+1, nruns)):
col[-1]=str(s)
df['spin_'+str(i+1)] = col
with open('InitCons/ensemble.csv','w') as f:
f.write(','*(df.shape[1]-1))
f.write('\n')
f.write(','*(df.shape[1]-1))
f.write('\n')
f.write(','.join(df.columns))
f.write('\n')
f.write('\n'.join([','.join(i) for i in df.values]))