Commit bc725991 authored by luroth's avatar luroth
Browse files

Azimuth angle frequency calculation

parent f22a706c
###
# PhenoFly Planning Tool
# Copyright (C) 2018 ETH Zürich, Lukas Roth (lukas.roth@usys.ethz.ch)
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
......
###
# PhenoFly Planning Tool
# Copyright (C) 2018 ETH Zürich, Lukas Roth (lukas.roth@usys.ethz.ch)
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
......
###
# PhenoFly Planning Tool
# Copyright (C) 2018 ETH Zürich, Lukas Roth (lukas.roth@usys.ethz.ch)
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
......@@ -1011,17 +1011,21 @@ server_ <- function(input, output, session) {
plot1 <- ggplot(data=data.frame(gcp_counts = derived_values$hit_per_image), aes(x=gcp_counts)) +
geom_histogram(col="white", fill="lightgrey", binwidth = 1, aes(y=..count../sum(..count..))) +
scale_x_continuous("Number of visible GCPs on image", breaks= seq(0,max(derived_values$hit_per_image),1)) +
scale_y_continuous("Frequency of images with corresponding number of visible GCPs", limits = c(0,1), expand=c(0,0)) +
scale_y_continuous("Frequency of images", limits = c(0,1), expand=c(0,0)) +
ggtheme_default
plot1
})
table_hits_gcp <- reactive({
table1 <- tableGrob(derived_values$hit_per_gcp, cols=c("Position (x)", "Position (y)", "Recover frequency"), theme = ttheme_minimal())
table1
})
output$plot_hits_gcp <- renderPlot({
validate_inputs(input)
table1 <- tableGrob(derived_values$hit_per_gcp, cols=c("Position (x)", "Position (y)", "Recover frequency"), theme = ttheme_minimal())
grid.arrange(plot_hits_gcp(), table1, nrow=1)
grid.arrange(plot_hits_gcp(), table_hits_gcp(), nrow=1)
})
......@@ -1129,10 +1133,10 @@ server_ <- function(input, output, session) {
plot_viewing_geometry <- reactive({
req(pixel_frequency(), derived_values$f>0, derived_values$circle_of_confusion>0, input$n_pix_x>0, input$n_pix_y>0)
withProgress(message = 'Ploting geometry', {
withProgress(message = 'Viewing geometry', {
showModal(modalDialog(
tags$p('Calculating ploting geometry'), title="Calculation in progress", footer=NULL))
tags$p('Calculating zenith angle frequency'), title="Calculation in progress", footer=NULL))
ret_list <- pixel_frequency()
pixel_frequency_data_xy <- ret_list[[1]]
......@@ -1143,6 +1147,7 @@ server_ <- function(input, output, session) {
incProgress(0.4)
zenith_angle <- (pi/2 - atan((derived_values$f/derived_values$circle_of_confusion)/(sqrt(delta_x**2 + delta_y**2))))*180 / pi
incProgress(0.6)
dim(zenith_angle) <- NULL
......@@ -1166,10 +1171,58 @@ server_ <- function(input, output, session) {
})
})
plot_viewing_geometry2 <- reactive({
req(pixel_frequency(), derived_values$f>0, derived_values$circle_of_confusion>0, input$n_pix_x>0, input$n_pix_y>0)
withProgress(message = 'Viewing geometry', {
showModal(modalDialog(
tags$p('Calculating azimuth angle frequency'), title="Calculation in progress", footer=NULL))
ret_list <- pixel_frequency()
pixel_frequency_data_xy <- ret_list[[1]]
incProgress(0.2)
delta_x <- replicate(input$n_pix_x, seq(-input$n_pix_y/2+1, input$n_pix_y/2, 1))
delta_y <- t(replicate(input$n_pix_y, seq(-input$n_pix_x/2+1, input$n_pix_x/2, 1)))
incProgress(0.4)
azimuth_angle <- atan2(delta_y, delta_x)*180 / pi
incProgress(0.6)
dim(azimuth_angle) <- NULL
dim(pixel_frequency_data_xy) <- NULL
azimuth_frequencies <- data.table(azimuth_angle= round(azimuth_angle), freq=pixel_frequency_data_xy)
azimuth_frequencies <- azimuth_frequencies[,list(freq = sum(freq)), by = 'azimuth_angle']
azimuth_frequencies$freq <- azimuth_frequencies$freq / sum(azimuth_frequencies$freq)
incProgress(0.8)
plot_azimuth <- ggplot(azimuth_frequencies) +
geom_bar(aes(x=azimuth_angle, y=freq), fill="lightgrey", color="lightgrey", stat="identity", width=1) +
scale_y_continuous("Frequency", expand=c(0,0)) +
scale_x_continuous("Azimuth angle (deg)") +
ggtheme_default
incProgress(1)
removeModal()
plot_azimuth
})
})
output$plot_viewing_geometry <- renderPlot({
validate_inputs(input)
plot_viewing_geometry()
})
output$plot_viewing_geometry2 <- renderPlot({
validate_inputs(input)
plot_viewing_geometry2()
})
#########################
### Mission briefing
......@@ -1296,11 +1349,11 @@ server_ <- function(input, output, session) {
content = function(file) {
plot = grid.arrange(
arrangeGrob(photographic_properties_plot(), plot_mapping_area() + theme(legend.position = "bottom"), nrow=1),
arrangeGrob(plot_viewing_geometry_x(), plot_viewing_geometry_y(), plot_viewing_geometry(), nrow=1),
arrangeGrob(plot_recovery_frequency(), plot_hits_gcp(), nrow=1, widths=c(3,1)),
arrangeGrob(plot_viewing_geometry_x(), plot_viewing_geometry_y(), plot_viewing_geometry(), plot_viewing_geometry2(), nrow=1),
arrangeGrob(plot_recovery_frequency(), plot_hits_gcp(), table_hits_gcp(), nrow=1, widths=c(1,1,1)),
ncol=1, heights = c(2,1,1)
)
ggsave(file, plot = plot, device = "pdf", width = 30, height = 35, units = "cm")
ggsave(file, plot = plot, device = "pdf", width = 35, height = 45, units = "cm")
}
)
......
###
# PhenoFly Planning Tool
# Copyright (C) 2018 ETH Zürich, Lukas Roth (lukas.roth@usys.ethz.ch)
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
......@@ -294,7 +294,9 @@ ui_ <- fluidPage(
column(6, h4("Plot center viewing geometry"),
tabsetPanel(type="pills",
tabPanel("Zenith angle",
plotOutput("plot_viewing_geometry", height = "500px"))
plotOutput("plot_viewing_geometry", height = "500px")),
tabPanel("Azimuth angle",
plotOutput("plot_viewing_geometry2", height = "500px"))
))
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment