Title: | What the Package Does (one line, title case) |
---|---|
Description: | What the package does (one paragraph). |
Authors: | First Last [aut, cre] |
Maintainer: | First Last <[email protected]> |
License: | GPL-3 |
Version: | 0.0.0.9000 |
Built: | 2024-12-25 06:12:34 UTC |
Source: | https://github.com/hypertidy/ncapi |
A data frame of the names of the NetCDF data types. Column 'name' is the descriptive name, and 'id' is the 0-based index, corresponding to the value returned by nc_inq_var.
See code in data-raw/ for the creation.
http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html
Return the descriptive name of the NetCDF data type from its ID number. The ID is 0-based. http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html
nc_types(x)
nc_types(x)
x |
id integer, or character coercible to integer |
type names
Close a connection.
Rnc_close(ncid)
Rnc_close(ncid)
ncid |
file connection provided by 'Rnc_open' |
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) Rnc_close(con)
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) Rnc_close(con)
once we have a given ID (group-less file, or specific group) find its contents
Rnc_inq(grpid)
Rnc_inq(grpid)
grpid |
group ID provided by 'Rnc_inq_grps' |
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) groupids <- Rnc_inq_grps(con) l3b <- Rnc_inq(groupids[1]) Rnc_close(con) print(basename(f_l3b)) print(l3b) f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi")
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) groupids <- Rnc_inq_grps(con) l3b <- Rnc_inq(groupids[1]) Rnc_close(con) print(basename(f_l3b)) print(l3b) f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi")
This is a structured list of the *names* of available attributes for the given variable. "Global" is variable -1. See Rnc_inq_variable for the variables and the number of attributes. To get the attribute values we need to map its type to the right function call of the API. This probably best done in R?
Rnc_inq_att(grpid, varid, attid)
Rnc_inq_att(grpid, varid, attid)
grpid |
con |
varid |
variable id (can be global at -1) |
attid |
attribute id (within variable) f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") con <- Rnc_open(f_l3m) vars <- tibble::as_tibble(Rnc_inq_variable(con)) lapply(seq_len(vars$natts[1])-1, function(iatt) Rnc_inq_att(con, vars$id[1], iatt)) Rnc_inq_att(con, vars$id[1], seq_len(vars$natts[1])[5]) Rnc_close(con) |
Dimension inquiry
Rnc_inq_dimension(grpid)
Rnc_inq_dimension(grpid)
grpid |
group ID provided by 'Rnc_inq_grps' |
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) groupids <- Rnc_inq_grps(con) Rnc_inq_dimension(groupids[1]) Rnc_close(con) f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") con <- Rnc_open(f_l3m) ## watch out because if only one, the file con is the one ##groupids <- Rnc_inq_grps(con) tibble::as_tibble(Rnc_inq_dimension(con)) Rnc_close(con) ## that should be the same as #ncmeta::nc_dims(f_l3m)
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) groupids <- Rnc_inq_grps(con) Rnc_inq_dimension(groupids[1]) Rnc_close(con) f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") con <- Rnc_open(f_l3m) ## watch out because if only one, the file con is the one ##groupids <- Rnc_inq_grps(con) tibble::as_tibble(Rnc_inq_dimension(con)) Rnc_close(con) ## that should be the same as #ncmeta::nc_dims(f_l3m)
Dimension inquiry
Rnc_inq_dims(grpid)
Rnc_inq_dims(grpid)
grpid |
group ID provided by 'Rnc_inq_grps' |
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) groupids <- Rnc_inq_grps(con) Rnc_inq_dims(groupids[1]) Rnc_close(con) f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") # ncmeta::nc_dims(f_l3m) # A tibble: 4 x 4 id name length unlim <int> <chr> <dbl> <lgl> 1 0 lat 2160 FALSE 2 1 lon 4320 FALSE 3 2 rgb 3 FALSE 4 3 eightbitcolor 256 FALSE
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) groupids <- Rnc_inq_grps(con) Rnc_inq_dims(groupids[1]) Rnc_close(con) f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") # ncmeta::nc_dims(f_l3m) # A tibble: 4 x 4 id name length unlim <int> <chr> <dbl> <lgl> 1 0 lat 2160 FALSE 2 1 lon 4320 FALSE 3 2 rgb 3 FALSE 4 3 eightbitcolor 256 FALSE
Inquire group name by ID
Rnc_inq_grpname(grpid)
Rnc_inq_grpname(grpid)
grpid |
group ID provided by 'Rnc_inq_grps' |
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) groupids <- Rnc_inq_grps(con) Rnc_inq_grpname(groupids[1]) lapply(Rnc_inq_grps(con), Rnc_inq_grpname) Rnc_close(con)
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) groupids <- Rnc_inq_grps(con) Rnc_inq_grpname(groupids[1]) lapply(Rnc_inq_grps(con), Rnc_inq_grpname) Rnc_close(con)
Inquire group IDs
Rnc_inq_grps(ncid)
Rnc_inq_grps(ncid)
ncid |
file connection provided by 'Rnc_open' |
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) Rnc_inq_grps(con) Rnc_close(con)
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") con <- Rnc_open(f_l3b) Rnc_inq_grps(con) Rnc_close(con)
We already know this from Rnc_inq_variable
Rnc_inq_natts(grpid, varid)
Rnc_inq_natts(grpid, varid)
grpid |
con |
varid |
variable id |
Dimensions of variables
Rnc_inq_vardims(grpid, ivar)
Rnc_inq_vardims(grpid, ivar)
grpid |
group ID provided by 'Rnc_inq_grps' |
ivar |
index of variable |
f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") con <- Rnc_open(f_l3m) variables <- tibble::as_tibble(Rnc_inq_variable(con)) setNames(lapply(variables$id, function(x) Rnc_inq_vardims(con, x)), variables$name) Rnc_close(con)
f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") con <- Rnc_open(f_l3m) variables <- tibble::as_tibble(Rnc_inq_variable(con)) setNames(lapply(variables$id, function(x) Rnc_inq_vardims(con, x)), variables$name) Rnc_close(con)
Variable inquiry
Rnc_inq_variable(grpid)
Rnc_inq_variable(grpid)
grpid |
group ID provided by 'Rnc_inq_grps' |
f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") con <- Rnc_open(f_l3m) tibble::as_tibble(Rnc_inq_variable(con)) Rnc_close(con) ## that should be the same as # ncmeta::nc_vars(f_l3m) # # A tibble: 4 x 5 # id name type ndims natts # <int> <chr> <chr> <int> <int> # 0 chlor_a float 2 12 # 1 lat float 1 5 # 2 lon float 1 5 # 3 palette ubyte 2 0
f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") con <- Rnc_open(f_l3m) tibble::as_tibble(Rnc_inq_variable(con)) Rnc_close(con) ## that should be the same as # ncmeta::nc_vars(f_l3m) # # A tibble: 4 x 5 # id name type ndims natts # <int> <chr> <chr> <int> <int> # 0 chlor_a float 2 12 # 1 lat float 1 5 # 2 lon float 1 5 # 3 palette ubyte 2 0
Pass a character data source name to the internal nc_open library function.
Rnc_open(dsn)
Rnc_open(dsn)
dsn |
data source name, i.e. file path or server path |
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") Rnc_open(f_l3b) f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") Rnc_open(f_l3m) u_cst <- "http://coastwatch.pfeg.noaa.gov/erddap/griddap/erdQSwind3da" Rnc_open(u_cst)
f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi") Rnc_open(f_l3b) f_l3m <- system.file("extdata", "oceandata", "S2008001.L3m_DAY_CHL_chlor_a_9km.nc", package = "ncapi") Rnc_open(f_l3m) u_cst <- "http://coastwatch.pfeg.noaa.gov/erddap/griddap/erdQSwind3da" Rnc_open(u_cst)