def calculate_bestfit_LAD_profile(subplot_coordinate_file, LAI_file, las_file, Plot_name, minimum_height=0): subplot_polygons, subplot_labels = aux.load_boundaries( subplot_coordinate_file) field_LAI = aux.load_field_LAI(LAI_file) lidar_pts = lidar.load_lidar_data(las_file) n_subplots = subplot_polygons[Plot_name].shape[0] max_height = 80 layer_thickness = 1 n_layers = np.ceil(max_height / layer_thickness) subplot_lidar_profiles = np.zeros((n_subplots, n_layers)) n_ground_returns = np.zeros(n_subplots) subplot_LAI = np.zeros(n_subplots) for i in range(0, n_subplots): print "Subplot: ", subplot_labels[Plot_name][i] sp_pts = lidar.filter_lidar_data_by_polygon( lidar_pts, subplot_polygons[Plot_name][i, :, :]) heights, subplot_lidar_profiles[ i, :], n_ground_returns[i] = bin_returns(sp_pts, max_height, layer_thickness) subplot_LAI[i] = field_LAI['LAI'][np.all( (field_LAI['Subplot'] == subplot_labels[Plot_name][i], field_LAI['Plot'] == Plot_name), axis=0)] kmin = 0.20 kmax = 5. kinc = 0.005 misfit, ks, best_k_LAD_profiles, best_k = minimise_misfit_for_k( kmin, kmax, kinc, subplot_LAI, subplot_lidar_profiles, n_ground_returns, layer_thickness, minimum_height) return heights, best_k_LAD_profiles
MacArthurHorn_LAD = {} radiative_LAD = {} radiative_DTM_LAD = {} inventory_LAD = {} lidar_profiles = {} lidar_profiles_adjusted = {} MacArthurHorn_LAI = {} radiative_LAI = {} radiative_DTM_LAI = {} inventory_LAI = {} Hemisfer_LAI = {} # load coordinates and lidar points for target areas subplot_polygons, subplot_labels = aux.load_boundaries(subplot_coordinate_file) all_lidar_pts = lidar.load_lidar_data(las_file) # load field data and retrieve allometric relationships field_data = field.load_crown_survey_data(field_file) a, b, CF, r_sq, p, H, D = field.retrieve_crown_allometry(allometry_file) a_ht, b_ht, CF_ht, a_A, b_A, CF_A = field.calculate_allometric_equations_from_survey( field_data) # load LAI estimates from hemiphotos field_LAI = aux.load_field_LAI(LAI_file) # loop through all plots to be analysed for pp in range(0, N_plots): print Plots[pp] Plot_name = Plots[pp] # clip LiDAR point cloud to plot level (this makes subsequent processing much faster)