-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge-stats.py
executable file
·97 lines (79 loc) · 4.52 KB
/
merge-stats.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
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
#! /usr/bin python
#------------------------------------------------------------------------------
# PROGRAM: merge-stats.py
#------------------------------------------------------------------------------
# Version 0.1
# 6 September, 2023
# Michael Taylor
# https://patternizer.github.io
# michael DOT a DOT taylor AT uea DOT ac DOT uk
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# IMPORT PYTHON LIBRARIES
#------------------------------------------------------------------------------
# Dataframe libraries:
import pandas as pd
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# SETTINGS:
#------------------------------------------------------------------------------
city, location_lat, location_lon = 'London', 51.5, -0.1
#city, location_lat, location_lon = 'Rennes', 48.1, -1.7
#city, location_lat, location_lon = 'Kisumu', -0.1, 34.8
#city, location_lat, location_lon = 'Nairobi', -1.3, 36.8
#city, location_lat, location_lon = 'Homa', -0.5, 34.5
#city, location_lat, location_lon = 'Beijing', 39.9, 116.4
#city, location_lat, location_lon = 'Ningbo', 29.9, 121.6
#------------------------------------------------------------------------------
# LOAD: CSV files, merge dataframes, sort by variable name, and save
#------------------------------------------------------------------------------
filename1 = 'OUT/stats-regridded-etccdi-percentile-based-yearly-' + city + '.csv'
filename2 = 'OUT/stats-regridded-etccdi-baseline-independent-yearly-' + city + '.csv'
filename3 = 'OUT/stats-regridded-tas-monthly-' + city + '.csv'
filename4 = 'OUT/stats-regridded-pr-monthly-' + city + '.csv'
df1 = pd.read_csv( filename1, index_col=0)
df2 = pd.read_csv( filename2, index_col=0)
df3 = pd.read_csv( filename3, index_col=0)
df4 = pd.read_csv( filename4, index_col=0)
df = pd.concat([df1, df2, df3, df4])
df = df.sort_index(ascending=True)
df.to_csv('stats-regridded-etccdi-yearly-' + city + '.csv')
filename1 = 'OUT/stats-1981-2010-difference-regridded-etccdi-percentile-based-yearly-' + city + '.csv'
filename2 = 'OUT/stats-1981-2010-difference-regridded-etccdi-baseline-independent-yearly-' + city + '.csv'
filename3 = 'OUT/stats-1981-2010-difference-regridded-tas-monthly-' + city + '.csv'
filename4 = 'OUT/stats-1981-2010-difference-regridded-pr-monthly-' + city + '.csv'
df1 = pd.read_csv( filename1, index_col=0)
df2 = pd.read_csv( filename2, index_col=0)
df3 = pd.read_csv( filename3, index_col=0)
df4 = pd.read_csv( filename4, index_col=0)
df = pd.concat([df1, df2, df3, df4])
df = df.sort_index(ascending=True)
df.to_csv('stats-1981-2010-difference-regridded-etccdi-yearly-' + city + '.csv')
filename1 = 'OUT/stats-regridded-etccdi-percentile-based-yearly-bias_adjusted-' + city + '.csv'
filename2 = 'OUT/stats-regridded-etccdi-baseline-independent-yearly-bias_adjusted-' + city + '.csv'
filename3 = 'OUT/stats-regridded-tas-monthly-bias_adjusted-' + city + '.csv'
filename4 = 'OUT/stats-regridded-pr-monthly-bias_adjusted-' + city + '.csv'
filename5 = 'OUT/stats-regridded-hi-daily-' + city + '.csv'
df1 = pd.read_csv( filename1, index_col=0)
df2 = pd.read_csv( filename2, index_col=0)
df3 = pd.read_csv( filename3, index_col=0)
df4 = pd.read_csv( filename4, index_col=0)
df5 = pd.read_csv( filename5, index_col=0)
df = pd.concat([df1, df2, df3, df4, df5])
df = df.sort_index(ascending=True)
df.to_csv('stats-regridded-etccdi-yearly-bias_adjusted-' + city + '.csv')
filename1 = 'OUT/stats-1981-2010-difference-regridded-etccdi-percentile-based-yearly-bias_adjusted-' + city + '.csv'
filename2 = 'OUT/stats-1981-2010-difference-regridded-etccdi-baseline-independent-yearly-bias_adjusted-' + city + '.csv'
filename3 = 'OUT/stats-1981-2010-difference-regridded-tas-monthly-bias_adjusted-' + city + '.csv'
filename4 = 'OUT/stats-1981-2010-difference-regridded-pr-monthly-bias_adjusted-' + city + '.csv'
filename5 = 'OUT/stats-1981-2010-difference-regridded-hi-daily-' + city + '.csv'
df1 = pd.read_csv( filename1, index_col=0)
df2 = pd.read_csv( filename2, index_col=0)
df3 = pd.read_csv( filename3, index_col=0)
df4 = pd.read_csv( filename4, index_col=0)
df5 = pd.read_csv( filename5, index_col=0)
df = pd.concat([df1, df2, df3, df4, df5])
df = df.sort_index(ascending=True)
df.to_csv('stats-1981-2010-difference-regridded-etccdi-yearly-bias_adjusted-' + city + '.csv')
#------------------------------------------------------------------------------
print('** END')