ncdf4::nc_open("~/Data/Satellite/OR_ABI-L2-AODC-M6_G17_s20202522231174_e20202522233547_c20202522235327.nc")
# Error in R_nc4_open: NetCDF: HDF error
# Error in ncdf4::nc_open("~/Data/Satellite/OR_ABI-L2-AODC-M6_G17_s20202522231174_e20202522233547_c20202522235327.nc") :
# Error in nc_open trying to open file /Users/Tate/Data/Satellite/OR_ABI-L2-AODC-M6_G17_s20202522231174_e20202522233547_c20202522235327.nc
This is a problem when making plots, generating movies, and averaging scans, since these all rely on scan files being converted into valid SpatialPointDataFrames by goesaodc_createScanSPDF(). What should happen when a file can't be opened? Should the scripts halt? Or should goesaodc_createScanSPDF() return something special?
I think the best option would be for goesaodc_createScanSPDF() to return an SPDF of points at the standard satellite reading locations, but have each AOD and DQF reading set to NA. This way an SPDF is still technically being created, and it can be plotted*, rasterized (the raster cells will be NA as well, which is fine), and averaged with other SPDFs with no extra code or checks. It is a more complicated solution to implement though over just returning NULL or an empty SPDF (which have their own drawbacks).
The main issue is will be that a color legend can't be drawn since all the points have NA values:
# SPDF with NAs
spdf <- sp::SpatialPointsDataFrame(
coords = data.frame(lon = 0, lat = 0),
data = data.frame(AOD = NA, DQF = NA)
)
# Error: Discrete value supplied to continuous scale
goesaodc_plotScanSPDF(
spdf
)
# Error: Binned scales only support continuous data
goesaodc_plotScanSPDF(
spdf,
breaks = c(-Inf, 0, 1, 2, 3, 4, 5, Inf)
)
Legends pose an issue for animations too: How do we guarantee a consistent legend is drawn across all of the individual frames (plots)? Will requiring the user to set the limits param for ggplot2::scale/fill_color_*() do the trick? What about when a scan's AOD values are NA and the legend for that frame can't even be drawn? Is it possible to draw an invisible second ggplot2::geom_point() or ggplot2::geom_raster() layer that sets some dummy values and uses the color/fill aes() so the legend is drawn for that?
This is obviously necessary for animations since they have to have a consistent color/fill legend. Therefore, the animation script should require the user to set the scale limits and force the plot to draw invisible points/cells so the legend is drawn even with NA data.
This doesn't seem completely necessary for individual plots though (plots not used for animation frames), since they don't have to be consistent. But I think the user should be able to set the color scale limits and toggle some sort of forceColorLegend param that guarantees drawing a color legend even when given an SPDF full of NAs. These will be disabled by default, but then the animation script can set them as necessary.
This logic should be applied to goesaodc_plotScanPoints() and goesaodc_plotScanRaster() in their own way.
Some scan files cannot be read due to errors:
This is a problem when making plots, generating movies, and averaging scans, since these all rely on scan files being converted into valid SpatialPointDataFrames by
goesaodc_createScanSPDF()
. What should happen when a file can't be opened? Should the scripts halt? Or shouldgoesaodc_createScanSPDF()
return something special?I think the best option would be for
goesaodc_createScanSPDF()
to return an SPDF of points at the standard satellite reading locations, but have each AOD and DQF reading set to NA. This way an SPDF is still technically being created, and it can be plotted*, rasterized (the raster cells will be NA as well, which is fine), and averaged with other SPDFs with no extra code or checks. It is a more complicated solution to implement though over just returning NULL or an empty SPDF (which have their own drawbacks).The main issue is will be that a color legend can't be drawn since all the points have NA values:
Legends pose an issue for animations too: How do we guarantee a consistent legend is drawn across all of the individual frames (plots)? Will requiring the user to set the
limits
param forggplot2::scale/fill_color_*()
do the trick? What about when a scan's AOD values are NA and the legend for that frame can't even be drawn? Is it possible to draw an invisible secondggplot2::geom_point()
orggplot2::geom_raster()
layer that sets some dummy values and uses the color/fillaes()
so the legend is drawn for that?limits
and toggle some sort offorceColorLegend
param that guarantees drawing a color legend even when given an SPDF full of NAs. These will be disabled by default, but then the animation script can set them as necessary.goesaodc_plotScanPoints()
andgoesaodc_plotScanRaster()
in their own way.