Skip to content

Commit 23bffa3

Browse files
authored
Merge pull request #195 from cbegeman/modify_weddell_region
Modify Western Weddell definition and add polygon functions
2 parents 7eac189 + a5cff9f commit 23bffa3

File tree

15 files changed

+88930
-79903
lines changed

15 files changed

+88930
-79903
lines changed

feature_creation_scripts/antarctic_ocean_regions/antarctic_ocean_regions.py

Lines changed: 71 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,15 @@ def get_longest_contour(contourValue, author):
106106
def stereo_to_lon_lat(x, y):
107107
return pyproj.transform(inProj, outProj, x, y)
108108

109-
ds = xarray.open_dataset('bedmap2.nc')
109+
with xarray.open_dataset('bedmap2.nc') as ds:
110+
# the bed but not under grounded ice
111+
bed = xarray.where(ds.icemask_grounded > 0.5, 0., ds.bed).values
112+
x = ds.x.values
113+
y = ds.y.values
110114

111115
# plot contours
112116
plt.figure()
113-
cs = plt.contour(ds.x.values, ds.y.values, ds.bed, (contourValue,))
117+
cs = plt.contour(x, y, bed, (contourValue,))
114118
paths = cs.collections[0].get_paths()
115119

116120
pathLengths = [len(paths[i]) for i in range(len(paths))]
@@ -125,7 +129,6 @@ def stereo_to_lon_lat(x, y):
125129
inProj = pyproj.Proj(init='epsg:3031')
126130
# lon/lat
127131
outProj = pyproj.Proj(init='epsg:4326')
128-
lon, lat = pyproj.transform(inProj, outProj, x, y)
129132

130133
poly = shapely.geometry.Polygon([(i[0], i[1]) for i in zip(x, y)])
131134

@@ -164,6 +167,30 @@ def stereo_to_lon_lat(x, y):
164167
return fc
165168

166169

170+
def make_polygon(lon_vector, lat_vector, name, author, tags):
171+
fc = FeatureCollection()
172+
173+
coordinates_list = []
174+
for idx in range(len(lon_vector)):
175+
coordinates_pair = [lon_vector[idx], lat_vector[idx]]
176+
coordinates_list.append(coordinates_pair)
177+
coordinates_list.append(coordinates_list[0])
178+
179+
fc.add_feature(
180+
{"type": "Feature",
181+
"properties": {"name": name,
182+
"author": author,
183+
"object": 'region',
184+
"component": 'ocean',
185+
"tags": tags,
186+
"zmin": -1000.,
187+
"zmax": -400.},
188+
"geometry": {
189+
"type": "Polygon",
190+
"coordinates": [coordinates_list]}})
191+
return fc
192+
193+
167194
def make_rectangle(lon0, lon1, lat0, lat1, name, author, tags):
168195
fc = FeatureCollection()
169196

@@ -186,9 +213,7 @@ def make_rectangle(lon0, lon1, lat0, lat1, name, author, tags):
186213
return fc
187214

188215

189-
def split_rectangle(lon0, lon1, lat0, lat1, name, author, tags, fcContour):
190-
fc = make_rectangle(lon0, lon1, lat0, lat1, name, author, tags)
191-
216+
def split_feature(fc, fcContour):
192217
fcDeep = fc.difference(fcContour)
193218

194219
props = fcDeep.features[0]['properties']
@@ -211,40 +236,49 @@ def split_rectangle(lon0, lon1, lat0, lat1, name, author, tags, fcContour):
211236
return fc
212237

213238

239+
def split_rectangle(lon0, lon1, lat0, lat1, name, author, tags, fcContour):
240+
fc = make_rectangle(lon0, lon1, lat0, lat1, name, author, tags)
241+
split_feature(fc, fcContour)
242+
return fc
243+
244+
245+
def split_polygon(lon_vector, lat_vector, name, author, tags, fcContour):
246+
fc = make_polygon(lon_vector, lat_vector, name, author, tags)
247+
split_feature(fc, fcContour)
248+
return fc
249+
250+
214251
def main():
215-
author = 'Xylar Asay-Davis'
252+
xylar = 'Xylar Asay-Davis'
253+
carolyn = 'Carolyn Begeman'
216254
timTags = 'Antarctic;Timmermann'
217255
orsiTags = 'Antarctic;Orsi'
256+
antTag = 'Antarctic'
218257

219258
# make a geometric fieatures object that knows about the geometric data
220259
# cache up a couple of directories
221260
gf = GeometricFeatures('../../geometric_data')
222261

223262
bedmap2_bin_to_netcdf('bedmap2.nc')
224263

225-
fcContour700 = get_longest_contour(contourValue=-700., author=author)
226-
fcContour800 = get_longest_contour(contourValue=-800., author=author)
264+
fcContour700 = get_longest_contour(contourValue=-700., author=xylar)
265+
fcContour800 = get_longest_contour(contourValue=-800., author=xylar)
227266

228267
fc = FeatureCollection()
229268

230-
fcWeddell = split_rectangle(
231-
lon0=-63., lon1=0., lat0=-80., lat1=-65., name='Weddell Sea',
232-
author=author, tags=timTags, fcContour=fcContour800)
233-
234-
# get rid of the Weddell Sea because we're not that happy with this
235-
# definition, but keep the deep/shelf ones
236-
fcWeddell.features = fcWeddell.features[1:]
237-
fc.merge(fcWeddell)
238-
239-
fcEW = split_rectangle(
240-
lon0=-20., lon1=25., lat0=-80., lat1=-55., name='Eastern Weddell Sea',
241-
author=author, tags=orsiTags, fcContour=fcContour800)
269+
fcEW = split_polygon(
270+
lon_vector=[-20., -20., 10., 25., 25.],
271+
lat_vector=[-80., -60., -55., -55., -80.],
272+
name='Eastern Weddell Sea',
273+
author=xylar, tags=antTag, fcContour=fcContour800)
242274

243275
fc.merge(fcEW)
244276

245-
fcWW = split_rectangle(
246-
lon0=-63., lon1=-20., lat0=-80., lat1=-60., name='Western Weddell Sea',
247-
author=author, tags=orsiTags, fcContour=fcContour800)
277+
fcWW = split_polygon(
278+
lon_vector=[-100., -86., -63., -66., -60., -51., -20., -20.],
279+
lat_vector=[-81., -75., -73., -67., -64., -60., -60., -85.],
280+
name='Western Weddell Sea',
281+
author=carolyn, tags=antTag, fcContour=fcContour800)
248282

249283
fc.merge(fcWW)
250284

@@ -258,40 +292,39 @@ def main():
258292
# now combine these into a single feature
259293
fcWeddell = fcWeddell.combine('Weddell Sea')
260294
props = fcWeddell.features[0]['properties']
261-
props['tags'] = orsiTags
295+
props['tags'] = antTag
262296
props['zmin'] = -1000.
263297
props['zmax'] = -400.
264298

265-
fc.merge(fcWeddell)
299+
split_feature(fcWeddell, fcContour800)
266300

267-
# add the Weddell Sea back as the sum of Eastern and Western
268-
fc.merge(make_rectangle(
269-
lon0=-63., lon1=45., lat0=-80., lat1=-58., name='Weddell Sea',
270-
author=author, tags=orsiTags))
301+
fc.merge(fcWeddell)
271302

272-
fc.merge(split_rectangle(
273-
lon0=-100., lon1=-63., lat0=-80., lat1=-67., name='Bellingshausen Sea',
274-
author=author, tags=timTags, fcContour=fcContour700))
303+
fc.merge(split_polygon(
304+
lon_vector=[-100., -86., -63., -66., -100.],
305+
lat_vector=[-81., -75., -73., -67., -67.],
306+
name='Bellingshausen Sea',
307+
author=carolyn, tags=antTag, fcContour=fcContour700))
275308

276309
fc.merge(split_rectangle(
277310
lon0=-140., lon1=-100., lat0=-80., lat1=-67., name='Amundsen Sea',
278-
author=author, tags=timTags, fcContour=fcContour800))
311+
author=xylar, tags=timTags, fcContour=fcContour800))
279312

280313
fc.merge(split_rectangle(
281314
lon0=-180., lon1=-140., lat0=-80., lat1=-67., name='Eastern Ross Sea',
282-
author=author, tags=timTags, fcContour=fcContour700))
315+
author=xylar, tags=timTags, fcContour=fcContour700))
283316

284317
fc.merge(split_rectangle(
285318
lon0=160., lon1=180., lat0=-80., lat1=-67., name='Western Ross Sea',
286-
author=author, tags=timTags, fcContour=fcContour700))
319+
author=xylar, tags=timTags, fcContour=fcContour700))
287320

288321
fc.merge(split_rectangle(
289322
lon0=25., lon1=160., lat0=-80., lat1=-62., name='East Antarctic Seas',
290-
author=author, tags=orsiTags, fcContour=fcContour800))
323+
author=xylar, tags=orsiTags, fcContour=fcContour800))
291324

292325
fc.merge(make_rectangle(
293326
lon0=-180., lon1=180., lat0=-80., lat1=-60., name='Southern Ocean 60S',
294-
author=author, tags=timTags))
327+
author=xylar, tags=timTags))
295328

296329
fcSO = gf.read('ocean', 'region', ['Southern Ocean'])
297330
props = fcSO.features[0]['properties']

geometric_data/ocean/region/Bellingshausen_Sea/region.geojson

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"type": "Feature",
66
"properties": {
77
"name": "Bellingshausen Sea",
8-
"tags": "Antarctic;Timmermann",
8+
"tags": "Antarctic",
99
"object": "region",
1010
"component": "ocean",
11-
"author": "Xylar Asay-Davis",
11+
"author": "Carolyn Begeman",
1212
"zmax": -400.0,
1313
"zmin": -1000.0
1414
},
@@ -18,14 +18,18 @@
1818
[
1919
[
2020
-100.0,
21-
-80.0
21+
-81.0
2222
],
2323
[
24-
-63.0,
25-
-80.0
24+
-86.0,
25+
-75.0
2626
],
2727
[
2828
-63.0,
29+
-73.0
30+
],
31+
[
32+
-66.0,
2933
-67.0
3034
],
3135
[
@@ -34,7 +38,7 @@
3438
],
3539
[
3640
-100.0,
37-
-80.0
41+
-81.0
3842
]
3943
]
4044
]

geometric_data/ocean/region/Bellingshausen_Sea_Deep/region.geojson

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,17 @@
55
"type": "Feature",
66
"properties": {
77
"name": "Bellingshausen Sea Deep",
8-
"tags": "Antarctic;Timmermann;Deep",
8+
"tags": "Antarctic;Deep",
99
"object": "region",
1010
"component": "ocean",
11-
"author": "Xylar Asay-Davis",
11+
"author": "Carolyn Begeman",
1212
"zmax": -400.0,
1313
"zmin": -1000.0
1414
},
1515
"geometry": {
1616
"type": "Polygon",
1717
"coordinates": [
1818
[
19-
[
20-
-100.0,
21-
-71.006346
22-
],
2319
[
2420
-100.0,
2521
-67.0
@@ -6267,6 +6263,10 @@
62676263
[
62686264
-100.0,
62696265
-71.006346
6266+
],
6267+
[
6268+
-100.0,
6269+
-67.0
62706270
]
62716271
]
62726272
]

geometric_data/ocean/region/Bellingshausen_Sea_Shelf/region.geojson

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"type": "Feature",
66
"properties": {
77
"name": "Bellingshausen Sea Shelf",
8-
"tags": "Antarctic;Timmermann;Shelf",
8+
"tags": "Antarctic;Shelf",
99
"object": "region",
1010
"component": "ocean",
11-
"author": "Xylar Asay-Davis",
11+
"author": "Carolyn Begeman",
1212
"zmax": -200.0,
1313
"zmin": -1000.0
1414
},
@@ -17,20 +17,20 @@
1717
"coordinates": [
1818
[
1919
[
20-
-72.825769,
20+
-66.0,
2121
-67.0
2222
],
2323
[
2424
-63.0,
25-
-67.0
25+
-73.0
2626
],
2727
[
28-
-63.0,
29-
-80.0
28+
-86.0,
29+
-75.0
3030
],
3131
[
3232
-100.0,
33-
-80.0
33+
-81.0
3434
],
3535
[
3636
-100.0,
@@ -6275,6 +6275,10 @@
62756275
[
62766276
-72.825769,
62776277
-67.0
6278+
],
6279+
[
6280+
-66.0,
6281+
-67.0
62786282
]
62796283
]
62806284
]

geometric_data/ocean/region/Eastern_Weddell_Sea/region.geojson

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "Feature",
66
"properties": {
77
"name": "Eastern Weddell Sea",
8-
"tags": "Antarctic;Orsi",
8+
"tags": "Antarctic",
99
"object": "region",
1010
"component": "ocean",
1111
"author": "Xylar Asay-Davis",
@@ -21,17 +21,21 @@
2121
-80.0
2222
],
2323
[
24-
25.0,
25-
-80.0
24+
-20.0,
25+
-60.0
2626
],
2727
[
28-
25.0,
28+
10.0,
2929
-55.0
3030
],
3131
[
32-
-20.0,
32+
25.0,
3333
-55.0
3434
],
35+
[
36+
25.0,
37+
-80.0
38+
],
3539
[
3640
-20.0,
3741
-80.0

geometric_data/ocean/region/Eastern_Weddell_Sea_Deep/region.geojson

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "Feature",
66
"properties": {
77
"name": "Eastern Weddell Sea Deep",
8-
"tags": "Antarctic;Orsi;Deep",
8+
"tags": "Antarctic;Deep",
99
"object": "region",
1010
"component": "ocean",
1111
"author": "Xylar Asay-Davis",
@@ -18,10 +18,10 @@
1818
[
1919
[
2020
-20.0,
21-
-73.090735
21+
-60.0
2222
],
2323
[
24-
-20.0,
24+
10.0,
2525
-55.0
2626
],
2727
[
@@ -10659,6 +10659,10 @@
1065910659
[
1066010660
-20.0,
1066110661
-73.090735
10662+
],
10663+
[
10664+
-20.0,
10665+
-60.0
1066210666
]
1066310667
]
1066410668
]

0 commit comments

Comments
 (0)