def ugrid_corner_plotting(path, show=True): # path = '/home/benkoziol/htmp/ugrid_splits/src_subset_1.nc' # path = '/home/benkoziol/l/data/ocgis/ugrid-cesm-subsetting/UGRID_1km-merge-10min_HYDRO1K-merge-nomask_c130402.nc' rd = RequestDataset(path) vc = rd.get_raw_field() vc.load() face_nodes = vc['landmesh_face_node'].get_value() face_node_x = vc['landmesh_node_x'].get_value() face_node_y = vc['landmesh_node_y'].get_value() for ctr, idx in enumerate(range(face_nodes.shape[0])): if ctr % 1000 == 0: print '{} of {}'.format(ctr, face_nodes.shape[0]) curr_face_indices = face_nodes[idx, :] curr_face_node_x = face_node_x[curr_face_indices] curr_face_node_y = face_node_y[curr_face_indices] face_coords = np.zeros((4, 2)) face_coords[:, 0] = curr_face_node_x face_coords[:, 1] = curr_face_node_y plt.scatter(face_coords[:, 0], face_coords[:, 1], marker='o', color='b') if show: plt.show()
def ugrid_corner_plotting(path, show=True): # path = '/home/benkoziol/htmp/ugrid_splits/src_subset_1.nc' # path = '/home/benkoziol/l/data/ocgis/ugrid-cesm-subsetting/UGRID_1km-merge-10min_HYDRO1K-merge-nomask_c130402.nc' rd = RequestDataset(path) vc = rd.get_raw_field() vc.load() face_nodes = vc['landmesh_face_node'].get_value() face_node_x = vc['landmesh_node_x'].get_value() face_node_y = vc['landmesh_node_y'].get_value() for ctr, idx in enumerate(range(face_nodes.shape[0])): if ctr % 1000 == 0: print '{} of {}'.format(ctr, face_nodes.shape[0]) curr_face_indices = face_nodes[idx, :] curr_face_node_x = face_node_x[curr_face_indices] curr_face_node_y = face_node_y[curr_face_indices] face_coords = np.zeros((4, 2)) face_coords[:, 0] = curr_face_node_x face_coords[:, 1] = curr_face_node_y plt.scatter(face_coords[:, 0], face_coords[:, 1], marker='o', color='b') if show: plt.show()
def plot_centers(path): rd = RequestDataset(path) vc = rd.get_raw_field() x = vc[FACE_CENTER_X].get_value() # [::100] y = vc[FACE_CENTER_Y].get_value() # [::100] plt.scatter(x, y, marker='o', color='b')
def plot_centers(path): rd = RequestDataset(path) vc = rd.get_raw_field() x = vc[FACE_CENTER_X].get_value() # [::100] y = vc[FACE_CENTER_Y].get_value() # [::100] plt.scatter(x, y, marker='o', color='b')
def analyze_weights(): folder = '/home/benkoziol/htmp/esmf_weights_full_20170628' for f in os.listdir(folder): if f.startswith('esmf_weights'): f = os.path.join(folder, f) print f rd = RequestDataset(f) vc = rd.get_raw_field() weights = vc['S'].get_value() wmin, wmax = weights.min(), weights.max() if wmin < 0: raise ValueError('min less than 0: {}'.format(f)) if wmax > 1.0 + 1e-6: raise ValueError('max greater than 1 ({}): {}'.format(wmax, f))
def analyze_weights(): folder = '/home/benkoziol/htmp/esmf_weights_full_20170628' for f in os.listdir(folder): if f.startswith('esmf_weights'): f = os.path.join(folder, f) print f rd = RequestDataset(f) vc = rd.get_raw_field() weights = vc['S'].get_value() wmin, wmax = weights.min(), weights.max() if wmin < 0: raise ValueError('min less than 0: {}'.format(f)) if wmax > 1.0 + 1e-6: raise ValueError('max greater than 1 ({}): {}'.format(wmax, f))
def resolution(): rd = RequestDataset(IN_PATH) vc = rd.get_raw_field() x = vc[FACE_CENTER_X].get_value() x = np.sort(x) y = vc[FACE_CENTER_Y].get_value() y = np.sort(y) dx = np.diff(x) sx = {dx.min(), dx.mean(), dx.max()} dy = np.diff(y) sy = {dy.min(), dy.mean(), dy.max()} print sx, sy
def resolution(): rd = RequestDataset(IN_PATH) vc = rd.get_raw_field() x = vc[FACE_CENTER_X].get_value() x = np.sort(x) y = vc[FACE_CENTER_Y].get_value() y = np.sort(y) dx = np.diff(x) sx = {dx.min(), dx.mean(), dx.max()} dy = np.diff(y) sy = {dy.min(), dy.mean(), dy.max()} print sx, sy
def ugrid_area(): # path = '/home/benkoziol/htmp/src_subset_1.nc' path = '/home/benkoziol/l/data/ocgis/ugrid-cesm-subsetting/UGRID_1km-merge-10min_HYDRO1K-merge-nomask_c130402.nc' rd = RequestDataset(path) vc = rd.get_raw_field() vc.load() face_nodes = vc['landmesh_face_node'].get_value() face_node_x = vc['landmesh_node_x'].get_value() face_node_y = vc['landmesh_node_y'].get_value() face_center_x = vc['landmesh_face_x'].get_value() face_center_y = vc['landmesh_face_y'].get_value() areas = [] for ctr, idx in enumerate(range(face_nodes.shape[0])): if ctr % 10000 == 0: print '{} of {}'.format(ctr, face_nodes.shape[0]) curr_face_indices = face_nodes[idx, :] curr_face_node_x = face_node_x[curr_face_indices] curr_face_node_y = face_node_y[curr_face_indices] face_coords = np.zeros((4, 2)) face_coords[:, 0] = curr_face_node_x face_coords[:, 1] = curr_face_node_y poly = Polygon(face_coords) parea = poly.area poly = shapely.geometry.box(*poly.bounds) pt = Point(face_center_x[idx], face_center_y[idx]) if not poly.intersects(pt): print idx, np.array(pt), poly.bounds # if parea > 1: # print idx # print face_nodes[idx, :] # print face_coords # print poly.bounds # sys.exit() areas.append(parea)
def ugrid_area(): # path = '/home/benkoziol/htmp/src_subset_1.nc' path = '/home/benkoziol/l/data/ocgis/ugrid-cesm-subsetting/UGRID_1km-merge-10min_HYDRO1K-merge-nomask_c130402.nc' rd = RequestDataset(path) vc = rd.get_raw_field() vc.load() face_nodes = vc['landmesh_face_node'].get_value() face_node_x = vc['landmesh_node_x'].get_value() face_node_y = vc['landmesh_node_y'].get_value() face_center_x = vc['landmesh_face_x'].get_value() face_center_y = vc['landmesh_face_y'].get_value() areas = [] for ctr, idx in enumerate(range(face_nodes.shape[0])): if ctr % 10000 == 0: print '{} of {}'.format(ctr, face_nodes.shape[0]) curr_face_indices = face_nodes[idx, :] curr_face_node_x = face_node_x[curr_face_indices] curr_face_node_y = face_node_y[curr_face_indices] face_coords = np.zeros((4, 2)) face_coords[:, 0] = curr_face_node_x face_coords[:, 1] = curr_face_node_y poly = Polygon(face_coords) parea = poly.area poly = shapely.geometry.box(*poly.bounds) pt = Point(face_center_x[idx], face_center_y[idx]) if not poly.intersects(pt): print idx, np.array(pt), poly.bounds # if parea > 1: # print idx # print face_nodes[idx, :] # print face_coords # print poly.bounds # sys.exit() areas.append(parea)