def get_bounding_box(self):
        """Get the bounding box of this file."""
        from pyproj import Geod
        geod = Geod(ellps='WGS84')
        dataset_group = DATASET_KEYS[self.datasets[0]]
        idx = 0
        lons_ring = None
        lats_ring = None
        while True:
            path = 'Data_Products/{dataset_group}/{dataset_group}_Gran_{idx}/attr/'
            prefix = path.format(dataset_group=dataset_group, idx=idx)
            try:
                lats = self.file_content[prefix + 'G-Ring_Latitude']
                lons = self.file_content[prefix + 'G-Ring_Longitude']
                if lons_ring is None:
                    lons_ring = lons
                    lats_ring = lats
                else:
                    prev_lon = lons_ring[0]
                    prev_lat = lats_ring[0]
                    dists = list(geod.inv(lon, lat, prev_lon, prev_lat)[2] for lon, lat in zip(lons, lats))
                    first_idx = np.argmin(dists)
                    if first_idx == 2 and len(lons) == 8:
                        lons_ring = np.hstack((lons[:3], lons_ring[:-2], lons[4:]))
                        lats_ring = np.hstack((lats[:3], lats_ring[:-2], lats[4:]))
                    else:
                        raise NotImplementedError("Don't know how to handle G-Rings of length %d" % len(lons))

            except KeyError:
                break
            idx += 1

        return lons_ring, lats_ring
def get_bounding_box ( self ) : from pyproj import Geod geod = Geod ( ellps = 'WGS84' ) dataset_group = DATASET_KEYS [ self . datasets [ 0 ] ] idx = 0 lons_ring = None lats_ring = None while True : path = 'Data_Products/{dataset_group}/{dataset_group}_Gran_{idx}/attr/' prefix = path . format ( dataset_group = dataset_group , idx = idx ) try : lats = self . file_content [ prefix + 'G-Ring_Latitude' ] lons = self . file_content [ prefix + 'G-Ring_Longitude' ] if lons_ring is None : lons_ring = lons lats_ring = lats else : prev_lon = lons_ring [ 0 ] prev_lat = lats_ring [ 0 ] dists = list ( geod . inv ( lon , lat , prev_lon , prev_lat ) [ 2 ] for lon , lat in zip ( lons , lats ) ) first_idx = np . argmin ( dists ) if first_idx == 2 and len ( lons ) == 8 : lons_ring = np . hstack ( ( lons [ : 3 ] , lons_ring [ : - 2 ] , lons [ 4 : ] ) ) lats_ring = np . hstack ( ( lats [ : 3 ] , lats_ring [ : - 2 ] , lats [ 4 : ] ) ) else : raise NotImplementedError ( "Don't know how to handle G-Rings of length %d" % len ( lons ) ) except KeyError : break idx += 1 return lons_ring , lats_ring
Get the bounding box of this file.