# -*- coding: utf-8 -*- import numpy as np import xarray as xr import metpy.calc as mpcalc import itertools from matplotlib import pyplot as plt import cartopy.crs as ccrs import cartopy.feature as cfeature def populate_object(obj_props, path): # obj_props.num_nodes = len(path) # fill the properties defined in the .proto file. # vertices of path min_lat, max_lat, min_lon, max_lon = 90.0, -90.0, 180.0, -180.0 dist_deg = 0.0 for v_idx, v in enumerate(path.vertices): line_pt = obj_props.line_pts.add() line_pt.lon = v[0] line_pt.lat = v[1] if v[0] < min_lon: min_lon = v[0] if v[0] > max_lon: max_lon = v[0] if v[1] < min_lat: min_lat = v[1] if v[1] > max_lat: max_lat = v[1] if v_idx > 0: dist_deg = dist_deg + (((path.vertices[v_idx - 1][0] - v[0]) ** 2 + (path.vertices[v_idx - 1][1] - v[1]) ** 2) ** 0.5) # bounding box obj_props.bb.min.lat = min_lat obj_props.bb.min.lon = min_lon obj_props.bb.max.lat = max_lat obj_props.bb.max.lon = max_lon obj_props.length_deg = dist_deg # identify troughs in data (should contain U,V,cv), based on the cv climatology # def identify_troughs(data, cv_clim, cfg):