largest_separation = 0 sum_separation = 0 sum_separation_count = 0 for code in merged_codes: for code_ref in code.all_refs: diff = position_difference(code.position, code_ref.position) sum_separation += diff sum_separation_count += 1 if diff > largest_separation: largest_separation = diff average_separation = 0 if sum_separation_count > 0: average_separation = sum_separation / sum_separation_count print "From average position largest separation is {} and average is {} meters".format(largest_separation, average_separation) if not os.path.exists(out_directory): os.makedirs(out_directory) # Write everything out to CSV file. all_results_filename = time.strftime("_results_all-%Y%m%d-%H%M%S.csv") all_results_filepath = os.path.join(out_directory, all_results_filename) export_results(all_codes, [], all_results_filepath) print 'Output all codes to {}'.format(all_results_filepath) # Write averaged results out to file. avg_results_filename = time.strftime("_results_averaged-%Y%m%d-%H%M%S.csv") avg_results_filepath = os.path.join(out_directory, avg_results_filename) export_results(merged_codes, [], avg_results_filepath) print 'Output merged codes to {}'.format(avg_results_filepath)
sys.exit(ExitReason.bad_arguments) else: survey_items = parse_survey_file(survey_filepath) if convert_coords: print "Converting coordinates" east_offset, north_offset = calculate_east_north_offsets(items, survey_items) convert_coordinates(items, east_offset, north_offset) # Now that items are in same coordinates run accuracy checks run_survey_verification(items, survey_items) # Write everything out to CSV file to be imported into database. all_results_filename = time.strftime('results_all-%Y%m%d-%H%M%S.csv') all_results_filepath = os.path.join(out_directory, all_results_filename) all_output_items = [ref for item in items for ref in item.all_refs] export_results(all_output_items, rows, all_results_filepath) print "Exported all results to " + all_results_filepath # Output all averaged results to one file. avg_results_filename = time.strftime("results_averaged-%Y%m%d-%H%M%S.csv") avg_results_filepath = os.path.join(out_directory, avg_results_filename) print 'Output averaged {} items'.format(len(items)) export_results(items, rows, avg_results_filepath) print "Exported averaged results to " + avg_results_filepath # And output just codes to another file. just_codes_results_filename = time.strftime("results_just_codes-%Y%m%d-%H%M%S.csv") just_codes_results_filepath = os.path.join(out_directory, just_codes_results_filename) export_results(codes, rows, just_codes_results_filepath) print "Exported just code results to " + just_codes_results_filepath
warn_about_bad_group_lengths(groups, plant_spacing) # KLM - not reliable since not all numbers were actually planted #warn_about_missing_single_codes(single_code_ids) warn_about_missing_single_code_lengths(single_segments, plant_spacing) if not os.path.exists(out_directory): os.makedirs(out_directory) # Write averaged results out to file. import time from src.processing.export_results import export_results from src.util.numbering import number_serpentine avg_results_filename = time.strftime("_results_averaged-%Y%m%d-%H%M%S.csv") avg_results_filepath = os.path.join(out_directory, avg_results_filename) sorted_rows = sorted(rows, key=lambda r: r.number) items = number_serpentine(sorted_rows) export_results(items, [], avg_results_filepath) print 'Output codes to {}'.format(avg_results_filepath) # extra_ids = ['123', '302', '488', '645', '647'] # extra_groups = [group for group in groups if group.id in extra_ids] # for group in extra_groups: # length = group.length # # expected_plants = length / plant_spacing # print "Group ID {} has {} expected plants".format(group.id, expected_plants)