1
- import numpy , sys
1
+ import sys
2
+ import numpy as np
2
3
3
4
lsd = 3
4
5
@@ -12,14 +13,14 @@ def quantize(data,least_significant_digit):
12
13
This function is pure python.
13
14
"""
14
15
precision = pow (10. ,- least_significant_digit )
15
- exp = numpy .log10 (precision )
16
+ exp = np .log10 (precision )
16
17
if exp < 0 :
17
- exp = int (numpy .floor (exp ))
18
+ exp = int (np .floor (exp ))
18
19
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 )))
21
22
scale = pow (2. ,bits )
22
- return numpy .around (scale * data )/ scale
23
+ return np .around (scale * data )/ scale
23
24
24
25
def interpolate_long_segments (coords , resolution ):
25
26
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):
61
62
polymeta .append ([level ,area ,south ,north ,poly_id ])
62
63
if lons :
63
64
#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 )
65
66
b [:,0 ] = lons ; b [:,1 ] = lats
66
67
if lsd is not None :
67
68
b = quantize (b ,lsd )
@@ -72,7 +73,7 @@ def get_coast_polygons(coastfile):
72
73
lat = float (linesplit [1 ])
73
74
lons .append (lon ); lats .append (lat )
74
75
#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 )
76
77
b [:,0 ] = lons ; b [:,1 ] = lats
77
78
if lsd is not None :
78
79
b = quantize (b ,lsd )
@@ -90,7 +91,7 @@ def get_boundary_lines(bdatfile, resolution):
90
91
linesplit = line .split ()
91
92
if line .startswith ('>' ):
92
93
if lons :
93
- b = numpy .empty ((len (lons ),2 ),numpy .float32 )
94
+ b = np .empty ((len (lons ),2 ),np .float32 )
94
95
b [:,0 ] = lons ; b [:,1 ] = lats
95
96
if lsd is not None :
96
97
b = quantize (b ,lsd )
@@ -99,7 +100,7 @@ def get_boundary_lines(bdatfile, resolution):
99
100
continue
100
101
lon , lat = [float (val ) for val in linesplit ]
101
102
lats .append (lat ); lons .append (lon )
102
- b = numpy .empty ((len (lons ),2 ),numpy .float32 )
103
+ b = np .empty ((len (lons ),2 ),np .float32 )
103
104
b [:,0 ] = lons ; b [:,1 ] = lats
104
105
if lsd is not None :
105
106
b = quantize (b ,lsd )
@@ -153,7 +154,7 @@ def get_boundary_lines(bdatfile, resolution):
153
154
f .close ()
154
155
f2 .close ()
155
156
156
- poly , polymeta = get_boundary_lines (statefile )
157
+ poly , polymeta = get_boundary_lines (statefile , resolution )
157
158
f = open ('../lib/mpl_toolkits/basemap/data/states_' + resolution + '.dat' ,'wb' )
158
159
f2 = open ('../lib/mpl_toolkits/basemap/data/statesmeta_' + resolution + '.dat' ,'w' )
159
160
offset = 0
@@ -166,7 +167,7 @@ def get_boundary_lines(bdatfile, resolution):
166
167
f .close ()
167
168
f2 .close ()
168
169
169
- poly , polymeta = get_boundary_lines (riverfile )
170
+ poly , polymeta = get_boundary_lines (riverfile , resolution )
170
171
f = open ('../lib/mpl_toolkits/basemap/data/rivers_' + resolution + '.dat' ,'wb' )
171
172
f2 = open ('../lib/mpl_toolkits/basemap/data/riversmeta_' + resolution + '.dat' ,'w' )
172
173
offset = 0
0 commit comments