@@ -412,6 +412,20 @@ def load(self):
412412 self .setup_coordinates ()
413413 self .init_pos_interpolator ()
414414
415+ @staticmethod
416+ def c_to_bounds (c ):
417+ """
418+ Centred coordinates to bounds coordinates
419+
420+ :param array c: centred coordinates to translate
421+ :return: bounds coordinates
422+ """
423+ bounds = concatenate ((c , (2 * c [- 1 ] - c [- 2 ],)))
424+ d = bounds [1 :] - bounds [:- 1 ]
425+ bounds [:- 1 ] -= d / 2
426+ bounds [- 1 ] -= d [- 1 ] / 2
427+ return bounds
428+
415429 def setup_coordinates (self ):
416430 x_name , y_name = self .coordinates
417431 if self .is_centered :
@@ -1416,7 +1430,7 @@ def convolve_filter_with_dynamic_kernel(
14161430 demi_x , demi_y = k_shape [0 ] // 2 , k_shape [1 ] // 2
14171431 values_sum = filter2D (tmp_matrix .data , - 1 , kernel )[demi_x :- demi_x , demi_y ]
14181432 kernel_sum = filter2D (m .astype (float ), - 1 , kernel )[demi_x :- demi_x , demi_y ]
1419- with errstate (invalid = "ignore" ):
1433+ with errstate (invalid = "ignore" , divide = "ignore" ):
14201434 if extend :
14211435 data_out [:, i ] = ma .array (
14221436 values_sum / kernel_sum ,
@@ -1871,31 +1885,47 @@ def init_speed_coef(self, uname="u", vname="v"):
18711885 """Draft"""
18721886 self ._speed_ev = (self .grid (uname ) ** 2 + self .grid (vname ) ** 2 ) ** 0.5
18731887
1874- def display (self , ax , name , factor = 1 , ** kwargs ):
1888+ def display (self , ax , name , factor = 1 , ref = None , ** kwargs ):
18751889 """
18761890 :param matplotlib.axes.Axes ax: matplotlib axes use to draw
18771891 :param str,array name: variable to display, could be an array
18781892 :param float factor: multiply grid by
1893+ :param float,None ref: if define use like west bound
18791894 :param dict kwargs: look at :py:meth:`matplotlib.axes.Axes.pcolormesh`
18801895
18811896 .. minigallery:: py_eddy_tracker.RegularGridDataset.display
18821897 """
18831898 if "cmap" not in kwargs :
18841899 kwargs ["cmap" ] = "coolwarm"
18851900 data = self .grid (name ) if isinstance (name , str ) else name
1886- return ax .pcolormesh (self .x_bounds , self .y_bounds , data .T * factor , ** kwargs )
1901+ if ref is None :
1902+ x = self .x_bounds
1903+ else :
1904+ x = (self .x_c - ref ) % 360 + ref
1905+ i = x .argsort ()
1906+ x = self .c_to_bounds (x [i ])
1907+ data = data [i ]
1908+ return ax .pcolormesh (x , self .y_bounds , data .T * factor , ** kwargs )
18871909
1888- def contour (self , ax , name , factor = 1 , ** kwargs ):
1910+ def contour (self , ax , name , factor = 1 , ref = None , ** kwargs ):
18891911 """
18901912 :param matplotlib.axes.Axes ax: matplotlib axes use to draw
18911913 :param str,array name: variable to display, could be an array
18921914 :param float factor: multiply grid by
1915+ :param float,None ref: if define use like west bound
18931916 :param dict kwargs: look at :py:meth:`matplotlib.axes.Axes.contour`
18941917
18951918 .. minigallery:: py_eddy_tracker.RegularGridDataset.contour
18961919 """
18971920 data = self .grid (name ) if isinstance (name , str ) else name
1898- return ax .contour (self .x_c , self .y_c , data .T * factor , ** kwargs )
1921+ if ref is None :
1922+ x = self .x_c
1923+ else :
1924+ x = (self .x_c - ref ) % 360 + ref
1925+ i = x .argsort ()
1926+ x = x [i ]
1927+ data = data [i ]
1928+ return ax .contour (x , self .y_c , data .T * factor , ** kwargs )
18991929
19001930 def regrid (self , other , grid_name , new_name = None ):
19011931 """
0 commit comments