Skip to content

Commit 5c7b40c

Browse files
committed
style fix (pre-commit)
1 parent c3a6cf1 commit 5c7b40c

File tree

3 files changed

+80
-66
lines changed

3 files changed

+80
-66
lines changed

pcmdi_metrics/sea_ice/generate_sector_masks.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
default = '',
2525
help = "Explicit path to obs monthly PR climatology")
2626
P.add_argument("--outpd", "--outpathdata",
27-
type = str,
27+
type = str,
2828
dest = 'outpathdata',
2929
default = '/export/gleckler1/processing/metrics_package/my_test/sea_ice/git_data/',
3030
help = "Output path for sector scale masks")
@@ -95,8 +95,8 @@
9595
alist = os.listdir(area_dir) # LIST OF ALL AREACELLO FILES
9696

9797
for a in alist:
98-
if string.find(a,mod) != -1:
99-
areaf = a
98+
if string.find(a,mod) != -1:
99+
areaf = a
100100
print mod,' ', a
101101
# w = sys.stdin.readline()
102102

@@ -161,9 +161,9 @@
161161

162162
###############################################################
163163

164-
sectors = ['ca','na','np','sp','sa','io']
164+
sectors = ['ca','na','np','sp','sa','io']
165165

166-
for sector in sectors:
166+
for sector in sectors:
167167
mask = getmask(sector,lats,lons,lons_a,lons_p,land_mask)
168168

169169
g = cdms2.open(sec_mask_dir + 'mask_' + mod + '_' + sector + '.nc','w+')
@@ -193,5 +193,3 @@
193193
print 'failed for ', mods_failed
194194

195195
# Calculate the Sea Ice Covered Area
196-
197-

pcmdi_metrics/sea_ice/ice_area_cmip5_ssmi_reg_rms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import cdtime, datetime
66
import gc
77

8-
import numpy as np
8+
import numpy as np
99
import pylab
1010
import matplotlib.pyplot as plt
1111

Lines changed: 74 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,77 @@
1-
def getmask(sector,lats,lons,lons_a,lons_p,land_mask):
2-
import MV2 as MV
3-
#Arctic Regions
4-
#Central Arctic
5-
if sector == 'ca':
6-
lat_bound1=MV.logical_and(MV.greater(lats,80.),MV.less_equal(lats,90.))
7-
lat_bound2=MV.logical_and(MV.greater(lats,65.),MV.less_equal(lats,90.))
8-
lon_bound1=MV.logical_and(MV.greater(lons_a,-120.),MV.less_equal(lons_a,90.))
9-
lon_bound2=MV.logical_and(MV.greater(lons_p,90.),MV.less_equal(lons_p,240.))
10-
reg1=MV.logical_and(lat_bound1,lon_bound1)
11-
reg2=MV.logical_and(lat_bound2,lon_bound2)
12-
mask=MV.where(MV.logical_or(reg1,reg2),1,0)
13-
mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land
14-
15-
#NA region
16-
if sector == 'na':
17-
lat_bound=MV.logical_and(MV.greater(lats,45.),MV.less_equal(lats,80.))
18-
lon_bound=MV.logical_and(MV.greater(lons_a,-120.),MV.less_equal(lons_a,90.))
19-
lat_bound3=MV.logical_and(MV.greater(lats,45.),MV.less_equal(lats,50.))
20-
lon_bound3=MV.logical_and(MV.greater(lons_a,30.),MV.less_equal(lons_a,60.))
21-
reg3=MV.logical_and(lat_bound3,lon_bound3)
22-
23-
mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0)
24-
mask=MV.where(MV.equal(reg3,True),0,mask) # Masking out the Black and Caspian Seas
25-
mask=MV.where(MV.equal(land_mask,True),0,mask) # 0 - Land
26-
mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land
27-
28-
#NP region
29-
if sector == 'np':
30-
lat_bound=MV.logical_and(MV.greater(lats,45.),MV.less_equal(lats,65.))
31-
lon_bound=MV.logical_and(MV.greater(lons_p,90.),MV.less_equal(lons_p,240.))
32-
mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0)
33-
mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land
34-
35-
#Antarctic Regions
36-
37-
#SA region
38-
if sector == 'sa':
39-
lat_bound=MV.logical_and(MV.greater(lats,-90.),MV.less_equal(lats,-55.))
40-
lon_bound=MV.logical_and(MV.greater(lons_a,-60.),MV.less_equal(lons_a,20.))
41-
mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0)
42-
mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land
43-
44-
#SP region
45-
if sector == 'sp':
46-
lat_bound=MV.logical_and(MV.greater(lats,-90.),MV.less_equal(lats,-55.))
47-
lon_bound=MV.logical_and(MV.greater(lons_p,90.),MV.less_equal(lons_p,300.))
48-
mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0)
49-
mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land
50-
51-
#IO region
52-
if sector == 'io':
53-
lat_bound=MV.logical_and(MV.greater(lats,-90.),MV.less_equal(lats,-55.))
54-
lon_bound=MV.logical_and(MV.greater(lons_p,20.),MV.less_equal(lons_p,90.))
55-
mask=MV.where(MV.logical_and(lat_bound,lon_bound),1,0)
56-
mask=MV.where(MV.equal(land_mask,0),0,mask) # 0 - Land
57-
58-
return mask
1+
def getmask(sector, lats, lons, lons_a, lons_p, land_mask):
2+
import MV2 as MV
593

4+
# Arctic Regions
5+
# Central Arctic
6+
if sector == "ca":
7+
lat_bound1 = MV.logical_and(MV.greater(lats, 80.0), MV.less_equal(lats, 90.0))
8+
lat_bound2 = MV.logical_and(MV.greater(lats, 65.0), MV.less_equal(lats, 90.0))
9+
lon_bound1 = MV.logical_and(
10+
MV.greater(lons_a, -120.0), MV.less_equal(lons_a, 90.0)
11+
)
12+
lon_bound2 = MV.logical_and(
13+
MV.greater(lons_p, 90.0), MV.less_equal(lons_p, 240.0)
14+
)
15+
reg1 = MV.logical_and(lat_bound1, lon_bound1)
16+
reg2 = MV.logical_and(lat_bound2, lon_bound2)
17+
mask = MV.where(MV.logical_or(reg1, reg2), 1, 0)
18+
mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land
6019

20+
# NA region
21+
if sector == "na":
22+
lat_bound = MV.logical_and(MV.greater(lats, 45.0), MV.less_equal(lats, 80.0))
23+
lon_bound = MV.logical_and(
24+
MV.greater(lons_a, -120.0), MV.less_equal(lons_a, 90.0)
25+
)
26+
lat_bound3 = MV.logical_and(MV.greater(lats, 45.0), MV.less_equal(lats, 50.0))
27+
lon_bound3 = MV.logical_and(
28+
MV.greater(lons_a, 30.0), MV.less_equal(lons_a, 60.0)
29+
)
30+
reg3 = MV.logical_and(lat_bound3, lon_bound3)
6131

32+
mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0)
33+
mask = MV.where(
34+
MV.equal(reg3, True), 0, mask
35+
) # Masking out the Black and Caspian Seas
36+
mask = MV.where(MV.equal(land_mask, True), 0, mask) # 0 - Land
37+
mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land
38+
39+
# NP region
40+
if sector == "np":
41+
lat_bound = MV.logical_and(MV.greater(lats, 45.0), MV.less_equal(lats, 65.0))
42+
lon_bound = MV.logical_and(
43+
MV.greater(lons_p, 90.0), MV.less_equal(lons_p, 240.0)
44+
)
45+
mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0)
46+
mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land
47+
48+
# Antarctic Regions
49+
50+
# SA region
51+
if sector == "sa":
52+
lat_bound = MV.logical_and(MV.greater(lats, -90.0), MV.less_equal(lats, -55.0))
53+
lon_bound = MV.logical_and(
54+
MV.greater(lons_a, -60.0), MV.less_equal(lons_a, 20.0)
55+
)
56+
mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0)
57+
mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land
58+
59+
# SP region
60+
if sector == "sp":
61+
lat_bound = MV.logical_and(MV.greater(lats, -90.0), MV.less_equal(lats, -55.0))
62+
lon_bound = MV.logical_and(
63+
MV.greater(lons_p, 90.0), MV.less_equal(lons_p, 300.0)
64+
)
65+
mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0)
66+
mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land
67+
68+
# IO region
69+
if sector == "io":
70+
lat_bound = MV.logical_and(MV.greater(lats, -90.0), MV.less_equal(lats, -55.0))
71+
lon_bound = MV.logical_and(
72+
MV.greater(lons_p, 20.0), MV.less_equal(lons_p, 90.0)
73+
)
74+
mask = MV.where(MV.logical_and(lat_bound, lon_bound), 1, 0)
75+
mask = MV.where(MV.equal(land_mask, 0), 0, mask) # 0 - Land
76+
77+
return mask

0 commit comments

Comments
 (0)