1 # Load required packages
2 library(ncdf4) # For reading netCDF files
4 print_variable_info <- function(x) {
5 cat("Variable:", deparse(substitute(x)),"class", class(x),"type",typeof(x),
8 cat(" min",min(x),"max",max(x),"\n")
10 # The array contains non-numeric values
15 # Open input netCDF file
16 nc_file <- nc_open("ts_smoke.nc")
19 lon <- ncvar_get(nc_file, "XLONG")
20 lat <- ncvar_get(nc_file, "XLAT")
21 pm25 <- ncvar_get(nc_file, "pm25")
22 times <- ncvar_get(nc_file, "Times")
24 print_variable_info(lon)
25 print_variable_info(lat)
26 print_variable_info(pm25)
27 print_variable_info(times)
28 cat("The first time frame is",times[1],"Zulu\n")
29 cat("The last time frame is",times[dim(times)],"Zulu\n")