In [1]:
import glob
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
%pylab inline
Populating the interactive namespace from numpy and matplotlib
In [2]:
files = glob.glob("mascons/*area.txt")
files
Out[2]:
['mascons/MODICE.v0.4.1strikes.MOD44W.Alaskag.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Altaigl.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Baffing.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Ellesme.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.FrnJLnd.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Greenland.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.HghMtnA.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Him+Kar.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Iceland.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Nov_Zem.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.NW_Amer.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Pam+Kun.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Scandin.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Sev_Zem.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Sib+Kam.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Svalbar.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Tianshn.area.txt',
'mascons/MODICE.v0.4.1strikes.MOD44W.Tib+Qil.area.txt']
In [3]:
import re
In [4]:
def read_mascon_data(mascon,filename):
df = pd.read_csv( filename, delim_whitespace=True, index_col=0 )
df.head()
df = df[['MODICE_area_km^2','MODICE_NS_km^2']]
df.columns = [ mascon + '_modice', mascon + '_ns']
return df
In [5]:
p = re.compile('MOD44W.([\+\w]+).area')
data = []
for file in files:
mascon = p.findall(file)
print "next file: " + file
df = read_mascon_data( mascon[0], file )
data.append(df)
df = pd.concat(data, axis=1)
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Alaskag.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Altaigl.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Baffing.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Ellesme.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.FrnJLnd.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Greenland.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.HghMtnA.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Him+Kar.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Iceland.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Nov_Zem.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.NW_Amer.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Pam+Kun.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Scandin.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Sev_Zem.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Sib+Kam.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Svalbar.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Tianshn.area.txt
next file: mascons/MODICE.v0.4.1strikes.MOD44W.Tib+Qil.area.txt
In [8]:
df
Out[8]:
Alaskag_modice
Alaskag_ns
Altaigl_modice
Altaigl_ns
Baffing_modice
Baffing_ns
Ellesme_modice
Ellesme_ns
FrnJLnd_modice
FrnJLnd_ns
...
Sev_Zem_modice
Sev_Zem_ns
Sib+Kam_modice
Sib+Kam_ns
Svalbar_modice
Svalbar_ns
Tianshn_modice
Tianshn_ns
Tib+Qil_modice
Tib+Qil_ns
Year
2000
97236.1
22.5
837.2
0
29432.3
0.4
81634.3
43.8
6498.8
0.0
...
10878.0
85.0
1654.8
0
24578.2
88.9
12157.0
0
5972.9
0
2001
87438.4
21.7
659.0
0
28321.6
0.2
87312.0
47.0
6271.3
0.0
...
10824.8
90.4
1292.5
0
21979.3
86.1
9522.0
0
5403.4
0
2002
77934.4
20.0
628.7
0
28723.0
0.4
84377.8
41.6
6399.8
0.0
...
10618.3
82.6
1627.8
0
20886.9
85.6
9409.3
0
6001.9
0
2003
71370.6
19.5
591.0
0
28716.2
1.5
81390.6
43.4
6379.0
0.0
...
11098.1
80.7
1202.5
0
20384.0
82.9
9954.4
0
6469.0
0
2004
62306.4
19.7
614.8
0
30161.3
0.2
89719.6
43.4
6191.0
0.0
...
10175.9
80.5
2573.8
0
20311.6
89.1
9548.0
0
6039.2
0
2005
70990.4
20.2
706.0
0
28601.8
1.7
80634.6
42.9
6271.7
0.0
...
10070.7
79.0
1442.3
0
22453.1
88.7
10030.6
0
6577.1
0
2006
78790.0
19.5
671.7
0
29243.4
2.6
84899.2
46.6
6355.2
0.0
...
10535.0
82.9
1037.2
0
22841.8
89.9
7943.9
0
5380.6
0
2007
73246.7
20.6
565.8
0
27649.8
0.2
78539.7
40.4
6338.9
0.0
...
11732.4
82.4
1073.9
0
22954.5
87.8
7846.0
0
5952.1
0
2008
93178.6
21.7
447.1
0
25691.0
0.2
77498.7
47.4
5237.0
0.0
...
10965.2
79.4
1035.1
0
23975.0
84.8
7567.8
0
6783.4
0
2009
68973.3
20.6
1131.3
0
24784.9
0.2
79492.8
41.0
6490.4
0.0
...
10331.5
86.5
766.3
0
23242.0
91.0
13225.8
0
6382.7
0
2010
63777.0
20.0
776.2
0
24472.6
0.4
74825.5
39.1
6309.9
0.0
...
10448.7
85.4
556.0
0
22384.4
84.8
9049.6
0
4762.0
0
2011
77238.3
17.8
438.8
0
25417.9
0.2
74545.4
45.3
6324.5
0.0
...
9897.3
85.0
776.2
0
21811.3
89.1
8845.9
0
5808.7
0
2012
85493.0
17.2
365.1
0
23850.1
0.0
75783.7
46.8
6359.9
0.0
...
10474.1
82.4
785.2
0
23479.2
91.7
7339.2
0
6180.2
0
2013
66276.1
19.5
986.1
0
26960.7
1.3
89829.7
42.7
6102.1
0.0
...
11544.8
83.5
975.4
0
21302.9
87.4
7895.1
0
4922.8
0
2014
69280.4
0.0
662.4
0
26331.5
0.0
81926.4
0.6
6521.5
0.2
...
11445.8
0.0
519.0
0
21884.0
0.0
7056.5
0
5225.7
0
15 rows × 36 columns
In [12]:
modice_cols = [col for col in df.columns if 'modice' in col]
modice_cols.remove('Greenland_modice')
df_modice = df[modice_cols]
df_modice
Out[12]:
Alaskag_modice
Altaigl_modice
Baffing_modice
Ellesme_modice
FrnJLnd_modice
HghMtnA_modice
Him+Kar_modice
Iceland_modice
Nov_Zem_modice
NW_Amer_modice
Pam+Kun_modice
Scandin_modice
Sev_Zem_modice
Sib+Kam_modice
Svalbar_modice
Tianshn_modice
Tib+Qil_modice
Year
2000
97236.1
837.2
29432.3
81634.3
6498.8
80815.3
23320.9
7780.5
18464.1
25864.9
39364.5
6074.8
10878.0
1654.8
24578.2
12157.0
5972.9
2001
87438.4
659.0
28321.6
87312.0
6271.3
69535.7
20568.2
7812.3
17486.5
22831.1
34042.1
2965.3
10824.8
1292.5
21979.3
9522.0
5403.4
2002
77934.4
628.7
28723.0
84377.8
6399.8
78934.5
22744.6
7360.0
18390.7
22831.5
40778.7
2329.7
10618.3
1627.8
20886.9
9409.3
6001.9
2003
71370.6
591.0
28716.2
81390.6
6379.0
82491.0
22530.1
7460.0
18138.7
17251.5
43537.5
2570.5
11098.1
1202.5
20384.0
9954.4
6469.0
2004
62306.4
614.8
30161.3
89719.6
6191.0
86236.3
22031.3
7545.3
17230.7
15041.1
48617.8
3066.2
10175.9
2573.8
20311.6
9548.0
6039.2
2005
70990.4
706.0
28601.8
80634.6
6271.7
82436.7
21055.9
7437.3
17862.8
18378.9
44773.1
4333.1
10070.7
1442.3
22453.1
10030.6
6577.1
2006
78790.0
671.7
29243.4
84899.2
6355.2
68542.0
18208.0
7166.6
18309.1
16537.3
37009.5
2058.1
10535.0
1037.2
22841.8
7943.9
5380.6
2007
73246.7
565.8
27649.8
78539.7
6338.9
69054.2
19603.3
7156.3
17603.7
25406.8
35652.9
5095.8
11732.4
1073.9
22954.5
7846.0
5952.1
2008
93178.6
447.1
25691.0
77498.7
5237.0
69678.4
22345.8
7443.3
17749.7
22809.0
32981.4
3299.9
10965.2
1035.1
23975.0
7567.8
6783.4
2009
68973.3
1131.3
24784.9
79492.8
6490.4
81312.5
18784.4
7561.4
18754.1
15719.2
42919.7
3355.3
10331.5
766.3
23242.0
13225.8
6382.7
2010
63777.0
776.2
24472.6
74825.5
6309.9
76436.7
21292.0
6816.7
18771.5
16708.4
41333.2
1752.5
10448.7
556.0
22384.4
9049.6
4762.0
2011
77238.3
438.8
25417.9
74545.4
6324.5
65652.9
18287.2
5744.3
17846.9
23143.6
32711.2
2407.6
9897.3
776.2
21811.3
8845.9
5808.7
2012
85493.0
365.1
23850.1
75783.7
6359.9
81194.2
20075.1
6978.3
18294.5
19852.3
47599.7
5699.8
10474.1
785.2
23479.2
7339.2
6180.2
2013
66276.1
986.1
26960.7
89829.7
6102.1
64791.3
16417.7
7401.4
17212.4
13826.8
35555.6
2212.5
11544.8
975.4
21302.9
7895.1
4922.8
2014
69280.4
662.4
26331.5
81926.4
6521.5
72242.7
20127.5
7145.6
19013.0
13506.1
39833.1
1959.8
11445.8
519.0
21884.0
7056.5
5225.7
In [13]:
ns_cols = [col for col in df.columns if '_ns' in col]
ns_cols.remove('Greenland_ns')
df_ns = df[ns_cols]
df_ns
Out[13]:
Alaskag_ns
Altaigl_ns
Baffing_ns
Ellesme_ns
FrnJLnd_ns
HghMtnA_ns
Him+Kar_ns
Iceland_ns
Nov_Zem_ns
NW_Amer_ns
Pam+Kun_ns
Scandin_ns
Sev_Zem_ns
Sib+Kam_ns
Svalbar_ns
Tianshn_ns
Tib+Qil_ns
Year
2000
22.5
0
0.4
43.8
0.0
3.9
3.9
0
2.4
1.5
0
0.4
85.0
0
88.9
0
0
2001
21.7
0
0.2
47.0
0.0
3.9
3.9
0
1.9
1.5
0
0.2
90.4
0
86.1
0
0
2002
20.0
0
0.4
41.6
0.0
3.9
3.9
0
0.9
1.3
0
0.0
82.6
0
85.6
0
0
2003
19.5
0
1.5
43.4
0.0
3.9
3.9
0
0.9
1.3
0
0.2
80.7
0
82.9
0
0
2004
19.7
0
0.2
43.4
0.0
3.9
3.9
0
1.1
0.4
0
0.0
80.5
0
89.1
0
0
2005
20.2
0
1.7
42.9
0.0
3.9
3.9
0
0.9
1.7
0
0.4
79.0
0
88.7
0
0
2006
19.5
0
2.6
46.6
0.0
3.9
3.9
0
1.1
1.1
0
0.0
82.9
0
89.9
0
0
2007
20.6
0
0.2
40.4
0.0
3.9
3.9
0
0.2
0.9
0
0.0
82.4
0
87.8
0
0
2008
21.7
0
0.2
47.4
0.0
3.9
3.9
0
0.6
1.9
0
0.2
79.4
0
84.8
0
0
2009
20.6
0
0.2
41.0
0.0
3.9
3.9
0
1.9
0.4
0
0.2
86.5
0
91.0
0
0
2010
20.0
0
0.4
39.1
0.0
3.9
3.9
0
0.6
0.9
0
0.0
85.4
0
84.8
0
0
2011
17.8
0
0.2
45.3
0.0
3.9
3.9
0
0.6
1.9
0
0.0
85.0
0
89.1
0
0
2012
17.2
0
0.0
46.8
0.0
3.9
3.9
0
0.6
2.6
0
0.0
82.4
0
91.7
0
0
2013
19.5
0
1.3
42.7
0.0
3.9
3.9
0
1.1
2.1
0
0.0
83.5
0
87.4
0
0
2014
0.0
0
0.0
0.6
0.2
3.4
3.4
0
0.0
0.0
0
0.0
0.0
0
0.0
0
0
In [14]:
ax = df_modice.plot( style='-o')
ax.legend(bbox_to_anchor=(1.5,1.0))
ax.set(title="MODICE.v0.4 (1strike) by mascon", ylabel='MODICE area ($km^2$)' )
Out[14]:
[<matplotlib.text.Text at 0x1094a6890>, <matplotlib.text.Text at 0x1094d2f50>]
In [15]:
ax = df_ns.plot( style='-o')
ax.legend(bbox_to_anchor=(1.5,1.0))
ax.set(title="MODICE.v0.4 (1strike) never_seen by mascon", ylabel='MODICE area ($km^2$)' )
Out[15]:
[<matplotlib.text.Text at 0x10a3034d0>, <matplotlib.text.Text at 0x10a155d10>]
In [ ]:
Content source: mjbrodzik/ipython_notebooks
Similar notebooks: