sosoc / croc

Ocean colour with R
3 stars 1 forks source link

summer climatology MODISA L3bin #7

Open mdsumner opened 7 years ago

mdsumner commented 7 years ago

Using this script to create a summer Southern Ocean climatology for MODISA using Johnson 2013:

https://github.com/mdsumner/roc/blob/master/inst/examples/calc_L3_SO.R

That script results in a large data frame of bin-values, the aggregated mean of ~1300 days of MODISA between 21 December and day 080.

The plot below was created with this code. Here the bins are all aggregated up into a 15km polar map, but we can easily bin it into a different grid.

## now the map
library(raster)
library(feather)
library(dplyr)
x <- read_feather("inst/examples/MODISA_SO_summer_355_080.feather")
map <- raster(extent(-9e6, 9e6, -9e6, 9e6), crs = "+proj=laea +ellps=WGS84 +lat_0=-90 +no_defs", res = 15e3)
bin_to_gridcell <- function(bins, gridmap, nrow = 4320) {
  xy <- do.call(cbind, roc::bin2lonlat(bins, nrows = nrow))
  cellFromXY(gridmap, rgdal::project(xy, projection(gridmap)))
} 
# 
summ <- x %>% mutate(grid_cell = bin_to_gridcell(bin_num, map))  %>% group_by(grid_cell) %>% 
  summarize(count = sum(count), chl_sum = sum(sum)) %>% mutate(mean_chl = chl_sum/count) 
summ <- summ %>% filter(!is.na(grid_cell))
map <- setValues(map, NA_real_)
map[summ$grid_cell] <- summ$mean_chl
library(palr)
pal <- chlPal(palette = TRUE)
plot(map, col =pal$cols, breaks = pal$breaks, legend = FALSE)

writeRaster(map, "L3_SO_summer.nc")

image

mdsumner commented 7 years ago

image

mdsumner commented 7 years ago

Updated to ensure complete seasons (though by luck they already all were afaict).

Added the standard calcs for the NASA algorithm as well, so we can rebin both algos and do cross checks properly.

I also tried building one huge SO database but it's too hard atm.

Outputs will be written to accessible folder as per the script.

https://github.com/mdsumner/roc/blob/master/inst/examples/MODISA_climatology/calc_L3_SO.R

@raymondben