Daytime length variations with latitude and season (3/3)

[This article was first published on R on BitFoam, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

It is time to conclude this series, but not before making some closing arguments.

Resolution

It is possible to increase the resolution of the plot by decreasing the length of the step for the different dimensions: latitude, longitude and days in the year. For instance, the values (lat_step = 5, lon_step = 1, year_step = 10) result in the following plot 1.

  • Points in the sphere (N) = num_lat_pts \(\times\) num_lon_pts = 1776
  • Days in the year = 37
Figure 1: Daylength by latitude and day in the year for ( lat_step = 5, lon_step = 1, year_step = 10)

Figure 1: Figure 1: Daylength by latitude and day in the year for ( lat_step = 5, lon_step = 1, year_step = 10)

Is there a better way of generating the grid?

While it is possible to smooth the contours by increasing the number of points in the grid at the expense of computation and rendering time, something struck me: the resolution around the poles is higher than at the Equator.

The number of points in each parallel is constant irrespective of the length of the parallel, being the Equator the largest parallel and the closer to the Poles, the shorter.

In the first post of this series the construction method of the grid is analogous to sampling the angles \(\theta\) [0,\(\pi\)] and \(\phi\) [0,\(2\pi\)] at equal distances as per the step parameters, lat_step and lon_step respectively. This results in a grid of a number of points equal to latitude points \(\times\) longitude points.

The figure 2 shows the points as a function of the angles \(\theta\) and \(\phi\) and then plotted on the unit sphere. While the points are equidistributed in the \(\phi\)\(\theta\) plane, that is not the case on the unit sphere.

 1m <- list(
 2  l = 0,
 3  r = 0,
 4  b = 0,
 5  t = 0,
 6  pad = 4
 7)
 8
 9lat_step <- 5
10lat_pts <- seq(from =0, to = pi, by = pi/(180/lat_step))
11num_lat_pts <- length(lat_pts)
12lon_step <- 1
13lon_pts <- seq(from = 0, to = 2*pi, by = pi/24)
14num_lon_pts <- length(lon_pts)
15dfgridr <- data.frame(x = rep(lon_pts, num_lat_pts), y = rep(lat_pts, each=num_lon_pts))
16fig_rect <- plot_ly(width = 400)
17fig_rect <- fig_rect %>% add_trace(data = dfgridr, x = ~x , y = ~y ,type ='scatter', mode='markers', marker = list(size = 3))
18
19scene = list(camera = list(eye = list(x = 0, y = 2, z = 0))) 
20fig_sph <- plot_ly(width = 800)
21fig_sph <- fig_sph %>% add_trace(data = coor_lat_lon, x = coor_lat_lon[,'x'], y = coor_lat_lon[,'y'], z = coor_lat_lon[,'z'], type ='scatter3d', mode='markers', marker = list(size = 2))
22
23fig <- subplot(fig_rect, fig_sph, widths = c(0.4,0.5)) %>%
24  layout(title = 'Points distribution', scene = list(camera = list(eye = list(x = 0, y = 2, z = 0)), domain = list(x = c(0.5, 1), y = c(0,1))), showlegend = F) %>%
25  config(displayModeBar = FALSE, scrollZoom = FALSE)  %>%  
26  layout(xaxis = list(title = 'φ [0,2π]',
27                      zeroline = F,
28                      showgrid = F
29                     ),
30         yaxis = list(title = 'θ [0,π]',
31                      zeroline = F,
32                      showgrid = F))
33fig
To leave a comment for the author, please follow the link and comment on their blog: R on BitFoam.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)