Package 'croc'

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

Help Index


R tools for ocean colour.

Description

Read data from Ocean Color Level-3 bin files.

Details

Package: roc
Type: Package
Version: 0.0-1
Date: 2014-08-28
License: GPL-3

Author(s)

Michael D. Sumner
https://github.com/mdsumner

Maintainer: Michael D. Sumner [email protected]

References

https://github.com/mdsumner, http://www.hdfgroup.org/, http://oceandata.sci.gsfc.nasa.gov/


Calculate bin boundaries from bin number

Description

Calculate bin boundaries from bin number

Usage

bin2bounds(bin, NUMROWS)

Arguments

bin

bin number

NUMROWS

relevant number of L3 bin rows


Longitude and latitude from bin number.

Description

Generate longitude and latitude coordinates from bin number.

Usage

bin2lonlat(bins, nrows)

Arguments

bins

bin number

nrows

number of rows in this grid


Bin map

Description

mapping between bins and a given raster

Usage

binmap(bin, ras, init = NULL)

Arguments

bin

bin number

ras

RasterLayer

init

optional initial values for bin structure


Estimate chlorophyll-a from NASA ocean colour.

Description

Estimate chlorophyll-a from Remote Sensing Reflectance wavelengths. Use SeaWiFS or MODISA with original or Johnson algorithm for the Southern Ocean.

Usage

chla(x, sensor, algo = c("oceancolor", "johnson"), quiet = TRUE, ...)

Arguments

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

Examples

#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 init object with an extent

Description

Crop L3 list, returns bins that fall within the extent.

Usage

crop_init(x, ext)

Arguments

x

initbin object

ext

raster extent object, or object to create an extent from

Value

integer vector of bins

Examples

## Not run:  init <- initbin(24)
crop_init(init, extent(100, 110, -50, -45))

## End(Not run)

Initialize values for a particular binning

Description

Set up the basic values for the bin scheme for given number of rows.

Usage

initbin(NUMROWS = 2160)

Arguments

NUMROWS

relevant number of L3 bin rows


Generate bin number from longitude latitude.

Description

Bin number from longitude and latitude for a given grid with NUMROWS unique latitudes.

Usage

lonlat2bin(lon, lat, NUMROWS)

Arguments

lon

longitude

lat

latitude

NUMROWS

number of rows


Raster cell longitude and latitudes

Description

Extract longitude and latitude of raster cells.

Usage

lonlatFromCell(object, cell = NULL, spatial = FALSE)

Arguments

object

a raster object

cell

the cell numbers

spatial

return locations as SpatialPoints object instead of a matrix.

Details

Extract the longitude and latitude of the center of the requested cells of a Raster* object, similar to xyFromCell.

from SGAT

Value

the lon,lat locations for the requested cells.


Standard Mapped Image

Description

SMI is the Standard Mapped Image, a longitude-latitude affine grid at zonally-native resolution. See details.

Usage

bin_smi(bins, value, platform = "MODISA")

Arguments

bins

bin index values

value

values with bins

platform

name of platform, e.g. MODISA, SeaWiFS

Details

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

Description

Primary production

Usage

prod_BeFa(chla, irrad, stemp, daylength)

Read Level-3 ocean colour.

Description

Read the compound types (i.e. tables of variables) from ocean colour L3 NetCDF files.

Usage

read_binlist(file)

read_compound(file, compound_vars = NULL, select_stat = c("sum",
  "sum_squared"))

Arguments

file

file path

compound_vars

the variables to read

select_stat

defaults to "sum" and "sum_squared"

Details

‘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

Value

data frame of bin numbers, number of observations and scenes, weights and time record, a data frame of the compound variables and bin details

Examples

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 NASA ocean colour browser images (PNG format)

Description

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.

Usage

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"))

Arguments

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)