forked from ua-snap/atm-tundra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_ice_content.py
73 lines (65 loc) · 2.91 KB
/
read_ice_content.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
import numpy as np
import gdal, os, sys, glob, random
import pylab as pl
def read_ice_content(self):
"""
The purpose of this module is to read (input) the ground ice
content of each predisposed element.
If the fractional area of cohorts is > 0.0, then there will be
an assigned ice content. The possible ice content values are:
Poor, Pore, Wedge, and Massive
If there is no input file, ice content will be randomly assigned.
"""
print ' Reading ground ice content.'
ice_content = ('poor', 'pore', 'wedge', 'massive')
self.ice = {}
ice = np.zeros(self.ATTM_nrows * self.ATTM_ncols)
for i in range(0, self.ATTM_nrows * self.ATTM_ncols):
if self.ATTM_Total_Fractional_Area[i] == 0.0 :
self.ice[i] = 'none'
ice[i] = 0.0 # redundant, but explicit
else:
if self.Terrestrial['Ice_Distribution'].lower() == 'poor':
self.ice[i] = 'poor'
ice[i] = 1.
elif self.Terrestrial['Ice_Distribution'].lower() == 'pore':
self.ice[i] = 'poor'
ice[i] = 2.
elif self.Terrestrial['Ice_Distribution'].lower() == 'wedge':
self.ice[i] = 'wedge'
ice[i] = 3.
elif self.Terrestrial['Ice_Distribution'].lower() == 'massive':
self.ice[i] = 'massive'
ice[i] = 4.
elif self.Terrestrial['Ice_Distribution'].lower() == 'random':
self.ice[i] = random.choice(ice_content)
if self.ice[i] == 'poor' : ice[i] = 1.
if self.ice[i] == 'pore' : ice[i] = 2.
if self.ice[i] == 'wedge' : ice[i] = 3.
if self.ice[i] == 'massive' : ice[i] = 4.
print ' done.'
print ' '
#=================================================================
# Output figures, files, plots
#=================================================================
# if PLOT == 'TRUE' or FIGURE == 'TRUE':
if self.Terrestrial['Ice_Distribution_Figure'].lower() == 'yes':
ice_plot = np.reshape(ice, [self.ATTM_nrows, self.ATTM_ncols])
# ---------------------------
# Change to output directory
# --------------------------
os.chdir(self.control['Run_dir']+self.Output_directory)
# --------------------------
# Figure / file creation
# --------------------------
fig = pl.figure()
pl.imshow(ice_plot, interpolation='nearest', cmap='bone')
pl.colorbar( extend = 'max', shrink = 0.92)
pl.title('Ground Ice Content')
pl.savefig('./Initialization/Ground_Ice_Content.png', format = 'png')
ice_plot.tofile('./Initialization/Ground_Ice_Content.bin')
pl.close()
# ----------------------------
# Move back to run directory
# ----------------------------
os.chdir(self.control['Run_dir'])