@@ -433,9 +433,9 @@ def crs(self) -> pyproj.crs.CRS:
433433 transform, set_crs
434434 """
435435 if len (self .ds .cf .grid_mapping_names ) == 0 :
436- logger .debug (
437- f'No grid-mapping specified, checking if coordinates are lon/lat..'
438- )
436+ # logger.debug(
437+ # f'No grid-mapping specified, checking if coordinates are lon/lat..'
438+ # )
439439 if self .tx .name == 'lon' or self .tx .name == 'longitude' :
440440 # assume this is in latlon projection
441441 return self .__gcrs__
@@ -932,11 +932,8 @@ def convex_hull(self):
932932
933933 from scipy .spatial import ConvexHull
934934
935- lon = self .ds .lon
936- lat = self .ds .lat
937- if 'status' in self .ds .variables :
938- lon = lon .where (self .ds .status == 0 )
939- lat = lat .where (self .ds .status == 0 )
935+ lon = self .ds .traj .tlon .values .ravel ()
936+ lat = self .ds .traj .tlat .values .ravel ()
940937 fin = np .isfinite (lat + lon )
941938 if np .sum (fin ) <= 3 :
942939 return None
@@ -980,12 +977,10 @@ def get_area_convex_hull(self):
980977 """
981978 from scipy .spatial import ConvexHull
982979
983- if 'status' in self .ds .variables :
984- lon = self .ds .lon .where (self .ds .status == 0 ) # OpenDrift specific
985- lat = self .ds .lat .where (self .ds .status == 0 )
986- else :
987- lon = self .ds .lon .where (np .isfinite (self .ds .lon ) is True )
988- lat = self .ds .lat .where (np .isfinite (self .ds .lat ) is True )
980+ lon = self .ds .traj .tlon .values .ravel ()
981+ lat = self .ds .traj .tlat .values .ravel ()
982+ lon = lon [np .isfinite (lon )]
983+ lat = lat [np .isfinite (lat )]
989984
990985 fin = np .isfinite (lat + lon )
991986 if np .sum (fin ) <= 3 :
@@ -996,10 +991,10 @@ def get_area_convex_hull(self):
996991 return xr .DataArray (0 ,
997992 name = "convex_hull_area" ,
998993 attrs = {"units" : "m2" })
999- lat = lat . where ( fin )
1000- lon = lon . where ( fin )
994+ lat = lat [ fin ]
995+ lon = lon [ fin ]
1001996 aea = pyproj .Proj (
1002- f'+proj=aea +lat_0={ lat .mean (). values } +lat_1={ lat .min (). values } +lat_2={ lat .max (). values } +lon_0={ lon .mean (). values } +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs'
997+ f'+proj=aea +lat_0={ lat .mean ()} +lat_1={ lat .min ()} +lat_2={ lat .max ()} +lon_0={ lon .mean ()} +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs'
1003998 )
1004999 x , y = aea (lat , lon , inverse = False )
10051000 fin = np .isfinite (x + y )
0 commit comments