| Title: | Tools for Ocean Colour |
|---|---|
| Description: | Work with data from NASA's ocean colour data, primarily the 'Level-3 bin' files. There are functions to read and work with the ragged array 'L3 bins' mesh and calculate biophysical properties from remote sensing reflectance data. |
| Authors: | Michael D. Sumner [aut, cre], Norman Kuring [ctb] (Author of L3bin code (NASA)), Robert Johnson [ctb] (Developed southern ocean algorithm for chlorophyll) |
| Maintainer: | Michael D. Sumner <[email protected]> |
| License: | GPL-3 |
| Version: | 0.0.9 |
| Built: | 2026-05-11 08:01:55 UTC |
| Source: | https://github.com/sosoc/croc |
Read data from Ocean Color Level-3 bin files.
| Package: | roc |
| Type: | Package |
| Version: | 0.0-1 |
| Date: | 2014-08-28 |
| License: | GPL-3 |
Michael D. Sumner
https://github.com/mdsumner
Maintainer: Michael D. Sumner [email protected]
https://github.com/mdsumner, http://www.hdfgroup.org/, http://oceandata.sci.gsfc.nasa.gov/
Calculate bin boundaries from bin number
bin2bounds(bin, NUMROWS)bin2bounds(bin, NUMROWS)
bin |
bin number |
NUMROWS |
relevant number of L3 bin rows |
Generate longitude and latitude coordinates from bin number.
bin2lonlat(bins, nrows)bin2lonlat(bins, nrows)
bins |
bin number |
nrows |
number of rows in this grid |
mapping between bins and a given raster
binmap(bin, ras, init = NULL)binmap(bin, ras, init = NULL)
bin |
bin number |
ras |
RasterLayer |
init |
optional initial values for bin structure |
Estimate chlorophyll-a from Remote Sensing Reflectance wavelengths. Use SeaWiFS or MODISA with original or Johnson algorithm for the Southern Ocean.
chla(x, sensor, algo = c("oceancolor", "johnson"), quiet = TRUE, ...)chla(x, sensor, algo = c("oceancolor", "johnson"), quiet = TRUE, ...)
x |
list object with Remote Sensing Reflectance wavelengths (see Details) |
sensor |
which satellite sensor |
algo |
algorithm to use, oceancolor or Johnson et al. (2013) |
quiet |
logical to emit warnings or not |
... |
not used |
#f <- "S1998001.L3b_DAY_RRS.main" #x <- readL3(f) #asub <- x$bin_num < initlist()$totbins / 2 #ll <- bin2lonlat(x$bin_num[asub]) #sw <- swchl(x)[asub] #js <- swchl(x, johnson = TRUE)[asub] #par(mfrow = c(2,1)) #plot(ll, col = palr::chlPal(sw), pch = ".") #plot(ll, col = palr::chlPal(js), pch = ".") ## setup a polar raster#f <- "S1998001.L3b_DAY_RRS.main" #x <- readL3(f) #asub <- x$bin_num < initlist()$totbins / 2 #ll <- bin2lonlat(x$bin_num[asub]) #sw <- swchl(x)[asub] #js <- swchl(x, johnson = TRUE)[asub] #par(mfrow = c(2,1)) #plot(ll, col = palr::chlPal(sw), pch = ".") #plot(ll, col = palr::chlPal(js), pch = ".") ## setup a polar raster
Crop L3 list, returns bins that fall within the extent.
crop_init(x, ext)crop_init(x, ext)
x |
initbin object |
ext |
raster extent object, or object to create an extent from |
integer vector of bins
## Not run: init <- initbin(24) crop_init(init, extent(100, 110, -50, -45)) ## End(Not run)## Not run: init <- initbin(24) crop_init(init, extent(100, 110, -50, -45)) ## End(Not run)
Set up the basic values for the bin scheme for given number of rows.
initbin(NUMROWS = 2160)initbin(NUMROWS = 2160)
NUMROWS |
relevant number of L3 bin rows |
Bin number from longitude and latitude for a given grid with NUMROWS unique latitudes.
lonlat2bin(lon, lat, NUMROWS)lonlat2bin(lon, lat, NUMROWS)
lon |
longitude |
lat |
latitude |
NUMROWS |
number of rows |
Extract longitude and latitude of raster cells.
lonlatFromCell(object, cell = NULL, spatial = FALSE)lonlatFromCell(object, cell = NULL, spatial = FALSE)
object |
a raster object |
cell |
the cell numbers |
spatial |
return locations as SpatialPoints object instead of a matrix. |
Extract the longitude and latitude of the center of the requested
cells of a Raster* object, similar to xyFromCell.
from SGAT
the lon,lat locations for the requested cells.
SMI is the Standard Mapped Image, a longitude-latitude affine grid at zonally-native resolution. See details.
bin_smi(bins, value, platform = "MODISA")bin_smi(bins, value, platform = "MODISA")
bins |
bin index values |
value |
values with bins |
platform |
name of platform, e.g. MODISA, SeaWiFS |
SeaWiFS is 2160 rows for 9.2 km resolution MODISA is 4320 rows for 4.6 km resolution (also provided in 9.2km) VIIRS is 4320 rows like MODIS. The zonal spread of the L3 bins is applied to the longitude-latitude regular grid by _a simple method that changed slightly in 2017 ..._ is trivial but inherently lossy. The initial focus of 'roc' on the L3 bins was precisely to put focus on the statistical fidelity features of the L3 bins, as per Technical Report No. 32.
(There's no reason to differentiate MODISA and MODIST in terms of the grid it's just that this token was chosen to distinguish from SeaWiFS in the first versions, and this might be generalized in future).
Primary production
prod_BeFa(chla, irrad, stemp, daylength)prod_BeFa(chla, irrad, stemp, daylength)
Read the compound types (i.e. tables of variables) from ocean colour L3 NetCDF files.
read_binlist(file) read_compound(file, compound_vars = NULL, select_stat = c("sum", "sum_squared"))read_binlist(file) read_compound(file, compound_vars = NULL, select_stat = c("sum", "sum_squared"))
file |
file path |
compound_vars |
the variables to read |
select_stat |
defaults to "sum" and "sum_squared" |
‘read_binlist' for just the ’BinList' 'read_compound' for just the compound data (not implemented) read_L3_file for everything at once
Compound vars we would usually want for MODISA are "BinList" and 'c("Rrs_443", "Rrs_488", "Rrs_555", "Rrs_547")' since these are used for calculating chlorophyll-a. This function is not very general yet, you'll always get the BinList. This function is specific to files in this form, for any of the platforms (MODISA here): https://oceandata.sci.gsfc.nasa.gov/MODIS-Aqua/L3BIN
data frame of bin numbers, number of observations and scenes, weights and time record, a data frame of the compound variables and bin details
f <- system.file("extdata", "ocfiles", "S2008001.L3b_DAY_CHL.nc", package = "croc") bins <- read_binlist(f) bin2lonlat(bins$bin_num, 2160) bin2bounds(bins$bin_num, 2160) read_L3_file(system.file("extdata/ocfiles/S2008001.L3b_DAY_RRS.nc", package = "croc"))f <- system.file("extdata", "ocfiles", "S2008001.L3b_DAY_CHL.nc", package = "croc") bins <- read_binlist(f) bin2lonlat(bins$bin_num, 2160) bin2bounds(bins$bin_num, 2160) read_L3_file(system.file("extdata/ocfiles/S2008001.L3b_DAY_RRS.nc", package = "croc"))
Read ocean colour imagery from the NASA site, files will be downloaded and read in with
brick. If a file with an identical name is already present in the current working directory the download
is skipped.
read_smi_image(date, platform = c(A = "MODISA", S = "SeaWiFS"), tres = c(DAY = "", `8D` = "8 days", MO = "1 month", YR = "1 year"), varname = c(CHL = "chlor_a"))read_smi_image(date, platform = c(A = "MODISA", S = "SeaWiFS"), tres = c(DAY = "", `8D` = "8 days", MO = "1 month", YR = "1 year"), varname = c(CHL = "chlor_a"))
date |
date of image to find |
platform |
which satellite platform (currently MODISA and SeaWiFS) |
tres |
temporal resolution to read |
varname |
name of variable (currently chlorophyll-a) |