Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

summer climatology MODISA L3bin #7

Open
mdsumner opened this issue Apr 3, 2017 · 2 comments
Open

summer climatology MODISA L3bin #7

mdsumner opened this issue Apr 3, 2017 · 2 comments

Comments

@mdsumner
Copy link
Member

mdsumner commented Apr 3, 2017

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
Copy link
Member Author

mdsumner commented Apr 3, 2017

image

@mdsumner
Copy link
Member Author

mdsumner commented Apr 5, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant