tree_index = np.all( (census_plot == plot[i], np.any( (tree_tag == tree[i], alt_tag == tree[i]), axis=0)), axis=0) tree_index_alt = np.all( (field_data['plot'] == plot[i], field_data['tag'] == tree[i]), axis=0) # first case scenario - we have located tree in canopy map if tree_index_alt.sum() == 1: subplot[i] = field_data['subplot'][tree_index_alt] tree_xy = np.asarray([ field_data['Xfield'][tree_index_alt] + plot_origin[plot[i]][0], field_data['Yfield'][tree_index_alt] + plot_origin[plot[i]][1] ]) tree_pts = lidar.filter_lidar_data_by_neighbourhood( plot_pts[plot[i]], tree_xy, radius) if tree_pts.size > 0: heights, first_return_profile, n_ground_returns = LAD.bin_returns( tree_pts, max_height, layer_thickness) LAD_tree = LAD.estimate_LAD_MacArthurHorn(first_return_profile, n_ground_returns, layer_thickness, 1.) I_tree = clim.estimate_canopy_light_transmittance( LAD_tree, heights, k) """ # subplot based profile subplot_poly = subplot_polygons[plot[i]][subplot_labels[plot[i]] == subplot[i],:,:][0] sp_pts = lidar.filter_lidar_data_by_polygon(plot_pts[plot[i]],subplot_poly) heights_sp,first_return_profile_sp,n_ground_returns_sp = LAD.bin_returns(sp_pts, max_height,layer_thickness) LAD_sp = LAD.estimate_LAD_MacArthurHorn(first_return_profile_sp, n_ground_returns_sp, layer_thickness, 1.) I_sp=clim.estimate_canopy_light_transmittance(LAD_sp,heights_sp,k)
weights = results_iter['weights'] / np.sum( np.isfinite( results_iter['raster_values'][0]. values) * results_iter['weights']) cover_mc[ii] = np.sum( (results_iter['raster_values'] [0].values >= gap_ht) * weights) quantiles_mc[ii] = st.weighted_quantiles( results_iter['raster_values'] [0].values, results_iter['weights'], quantiles) # now get canopy cover directly from LiDAR point cloud pts_sub = lidar_tools.filter_lidar_data_by_neighbourhood( lidar_pts, [ subplot['geometry']['coordinates'] [0] + xerr, subplot['geometry'] ['coordinates'][1] + yerr ], radius) point_heights = np.zeros(pts_sub.shape[0]) for idx in range(0, point_heights.size): dist, pixel_id = dem_trees[0].query( pts_sub[idx, :2], k=1) point_heights[idx] = pts_sub[ idx, 2] - ZZ[pixel_id] point_weights = 1 / pts_sub[:, 7] canopy_mask = point_heights >= gap_ht cover_fraction_from_pointcloud_mc[ ii] = np.sum( point_weights[canopy_mask] /