@@ -1256,7 +1256,9 @@ def scatter(self, ax, name, ref=None, factor=1, **kwargs):
1256
1256
x = (x - ref ) % 360 + ref
1257
1257
return ax .scatter (x , self .latitude , c = self [name ] * factor , ** kwargs )
1258
1258
1259
- def display (self , ax , ref = None , extern_only = False , intern_only = False , nobs = True , ** kwargs ):
1259
+ def display (
1260
+ self , ax , ref = None , extern_only = False , intern_only = False , nobs = True , ** kwargs
1261
+ ):
1260
1262
if not extern_only :
1261
1263
lon_s = flatten_line_matrix (self .obs ["contour_lon_s" ])
1262
1264
lat_s = flatten_line_matrix (self .obs ["contour_lat_s" ])
@@ -1287,14 +1289,23 @@ def grid_count(self, bins, intern=False, center=False):
1287
1289
1288
1290
regular_grid = RegularGridDataset .with_array (
1289
1291
coordinates = ("lon" , "lat" ),
1290
- datas = dict (count = grid , lon = x_bins [:- 1 ], lat = y_bins [:- 1 ],),
1292
+ datas = dict (
1293
+ count = grid ,
1294
+ lon = (x_bins [1 :] + x_bins [:- 1 ]) / 2 ,
1295
+ lat = (y_bins [1 :] + y_bins [:- 1 ]) / 2 ,
1296
+ ),
1297
+ variables_description = dict (
1298
+ count = dict (long_name = "Number of times pixel is in eddies" )
1299
+ ),
1300
+ centered = True ,
1291
1301
)
1292
1302
if center :
1293
1303
x , y = (self .longitude - x0 ) % 360 + x0 , self .latitude
1294
1304
grid [:] = histogram2d (x , y , (x_bins , y_bins ))[0 ]
1295
1305
grid .mask = grid .data == 0
1296
1306
else :
1297
- x , y = (self [x_name ] - x0 ) % 360 + x0 , self [y_name ]
1307
+ x_ref = ((self .longitude - x0 ) % 360 + x0 - 180 ).reshape (- 1 , 1 )
1308
+ x , y = (self [x_name ] - x_ref ) % 360 + x_ref , self [y_name ]
1298
1309
for x_ , y_ in zip (x , y ):
1299
1310
i , j = BasePath (create_vertice (x_ , y_ )).pixels_in (regular_grid )
1300
1311
grid_count_ (grid , i , j )
0 commit comments