-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiffmap2.py
110 lines (87 loc) · 2.85 KB
/
Diffmap2.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
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 6 10:55:53 2018
@author: andrew
"""
from IPython import get_ipython
get_ipython().magic('reset -sf')
#Get data
import numpy as np
import netCDF4
import sys
from glob import glob
from matplotlib import pyplot as plt
## Set up string to gather infiles ##
#fileloc = '/home/andrew/runs/'
#filename = 'ts_Ant_run*.nc'
runsloc = '/home/andrewjohnson/runs/'
file1 = runsloc + 'Ant_run1.nc'
file2 = runsloc + 'Ant_run2.nc'
#file2= runsloc + 'Ant_run3.nc'
#infiles = glob(fileloc+filename)
#print infiles
#file1 = '/home/andrew/runs/newruns/Ant_1yr_10km_fk.nc'
#file2 = '/home/andrew/runs/newruns/Ant_run5.nc'
#file3 = '/home/andrew/runs/newruns/ts_Ant_run5.nc'
#file4 = '/home/andrew/maps/end_evol-5km_Ant_spinup_W65_v1.nc'
file4 = '/home/andrew/maps/Ant_1yr_fk.nc'
dset1 = netCDF4.Dataset(file1,mode='r')
dset2 = netCDF4.Dataset(file2,mode='r')
thkmap1 = (dset1.variables['thk'])[:]
thkmap2 = (dset2.variables['thk'])[:]
tdiffmap = thkmap1-thkmap2
tdiffmap = tdiffmap[0,:,:]
tdiffmap=np.flipud(tdiffmap)
#def plotnormalize(inmap,midpoint):
midpoint = 0
inmap= tdiffmap
#outmap = inmap[:]
#rlen1 = abs(midpoint - np.min(inmap))
#rlen2 = abs(np.max(inmap)-midpoint)
#outmap[inmap<=midpoint]=(outmap[inmap<=midpoint]-np.min(inmap))/rlen1 * 0.5
#outmap[inmap>midpoint]=((outmap[outmap>midpoint]-midpoint)/rlen2)*0.5 + 0.5
#(n-xmin)/range
plt.figure(figsize=(12,10))
#colors = [(255,0,0),(255,150,150),(150,150,255),(0,0,255)]
#n_bins = [np.min(tdiffmap),-1,1,np.max(tdiffmap)]
maxval = np.max(np.abs(tdiffmap))
plt.imshow(tdiffmap,cmap='RdBu',vmin=-maxval,vmax=maxval)
#normmap = plotnormalize(tdiffmap,0)
#plt.imshow(tdiffmap,cmap='RdBu',norm=outmap)
plt.colorbar()
plt.title('Thickness Difference after 1000yrs (m)',fontsize=20)
titlestr='Ant_thk_diff.png'
plt.savefig('/home/andrewjohnson/github/pism/pism/PISM_ARC/figures/'+titlestr)
#tm1 = thkmap1[0,:,:]
#tm1 = np.flipud(tm1)
#plt.figure(figsize=(12,10))
#plt.imshow(tm1)
#colors = [(255,255,255),(0,0,0),(100,50,50),(200,100,100),(255,255,255)]
#n_bins = [10,20,1000,3000,np.max(tm1)]
##colors=[(255,255,255)]+colors
##n_nins=[10]+n_bins
#plt.colorbar()
#plt.title('Thickness after 1000yrs')
#titlestr='Ant_run1_fin_thkBAD.png'
#plt.savefig('/home/andrew/github/pism/pism/ARC/figures/'+titlestr)
#### Surf Vel
#plt.figure(figsize=(12,10))
#plt.imshow(tm1)
#colors = [(255,255,255),(0,0,0),(100,50,50),(200,100,100),(255,255,255)]
#n_bins = [10,20,1000,3000,np.max(tm1)]
##colors=[(255,255,255)]+colors
##n_nins=[10]+n_bins
#plt.colorbar()
#plt.title('Thickness after 1000yrs')
#titlestr='Ant_run1_fin_thk.png'
#plt.savefig('/home/andrew/github/pism/pism/ARC/figures/'+titlestr)
#dset = netCDF4.Dataset(infile,mode='r')
#
#print dset.variables.keys()
#
#vol=dset.variables['ice_volume']
#fvol=vol[-1]
#
#iarea = dset.variables['ice_area_glacierized']
#farea=iarea[-1]