Skip to content

Commit f5ad9c4

Browse files
committed
Normalize imports
1 parent 93bdf18 commit f5ad9c4

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

utils/readboundaries.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import numpy, sys
1+
import sys
2+
import numpy as np
23

34
lsd = 3
45

@@ -12,14 +13,14 @@ def quantize(data,least_significant_digit):
1213
This function is pure python.
1314
"""
1415
precision = pow(10.,-least_significant_digit)
15-
exp = numpy.log10(precision)
16+
exp = np.log10(precision)
1617
if exp < 0:
17-
exp = int(numpy.floor(exp))
18+
exp = int(np.floor(exp))
1819
else:
19-
exp = int(numpy.ceil(exp))
20-
bits = numpy.ceil(numpy.log2(pow(10.,-exp)))
20+
exp = int(np.ceil(exp))
21+
bits = np.ceil(np.log2(pow(10.,-exp)))
2122
scale = pow(2.,bits)
22-
return numpy.around(scale*data)/scale
23+
return np.around(scale*data)/scale
2324

2425
def interpolate_long_segments(coords, resolution):
2526
lookup_thresh = {'c': 0.5, 'l':0.1, 'i':0.05, 'h':0.01, 'f':0.005}
@@ -61,7 +62,7 @@ def get_coast_polygons(coastfile):
6162
polymeta.append([level,area,south,north,poly_id])
6263
if lons:
6364
#lons.append(lons[0]); lats.append(lats[0])
64-
b = numpy.empty((len(lons),2),numpy.float32)
65+
b = np.empty((len(lons),2),np.float32)
6566
b[:,0] = lons; b[:,1] = lats
6667
if lsd is not None:
6768
b = quantize(b,lsd)
@@ -72,7 +73,7 @@ def get_coast_polygons(coastfile):
7273
lat = float(linesplit[1])
7374
lons.append(lon); lats.append(lat)
7475
#lons.append(lons[0]); lats.append(lats[0])
75-
b = numpy.empty((len(lons),2),numpy.float32)
76+
b = np.empty((len(lons),2),np.float32)
7677
b[:,0] = lons; b[:,1] = lats
7778
if lsd is not None:
7879
b = quantize(b,lsd)
@@ -90,7 +91,7 @@ def get_boundary_lines(bdatfile, resolution):
9091
linesplit = line.split()
9192
if line.startswith('>'):
9293
if lons:
93-
b = numpy.empty((len(lons),2),numpy.float32)
94+
b = np.empty((len(lons),2),np.float32)
9495
b[:,0] = lons; b[:,1] = lats
9596
if lsd is not None:
9697
b = quantize(b,lsd)
@@ -99,7 +100,7 @@ def get_boundary_lines(bdatfile, resolution):
99100
continue
100101
lon, lat = [float(val) for val in linesplit]
101102
lats.append(lat); lons.append(lon)
102-
b = numpy.empty((len(lons),2),numpy.float32)
103+
b = np.empty((len(lons),2),np.float32)
103104
b[:,0] = lons; b[:,1] = lats
104105
if lsd is not None:
105106
b = quantize(b,lsd)
@@ -153,7 +154,7 @@ def get_boundary_lines(bdatfile, resolution):
153154
f.close()
154155
f2.close()
155156

156-
poly, polymeta = get_boundary_lines(statefile)
157+
poly, polymeta = get_boundary_lines(statefile, resolution)
157158
f = open('../lib/mpl_toolkits/basemap/data/states_'+resolution+'.dat','wb')
158159
f2 = open('../lib/mpl_toolkits/basemap/data/statesmeta_'+resolution+'.dat','w')
159160
offset = 0
@@ -166,7 +167,7 @@ def get_boundary_lines(bdatfile, resolution):
166167
f.close()
167168
f2.close()
168169

169-
poly, polymeta = get_boundary_lines(riverfile)
170+
poly, polymeta = get_boundary_lines(riverfile, resolution)
170171
f = open('../lib/mpl_toolkits/basemap/data/rivers_'+resolution+'.dat','wb')
171172
f2 = open('../lib/mpl_toolkits/basemap/data/riversmeta_'+resolution+'.dat','w')
172173
offset = 0

0 commit comments

Comments
 (0)