Package 'ncapi'

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

Help Index


NetCDF types

Description

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.

Details

See code in data-raw/ for the creation.

http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html


NetCDF types

Description

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

Usage

nc_types(x)

Arguments

x

id integer, or character coercible to integer

Value

type names


Close a connection.

Description

Close a connection.

Usage

Rnc_close(ncid)

Arguments

ncid

file connection provided by 'Rnc_open'

Examples

f_l3b <- system.file("extdata", "oceandata", "S2008001.L3b_DAY_CHL.nc", package = "ncapi")
 con <- Rnc_open(f_l3b)
 Rnc_close(con)

Source inquiry

Description

once we have a given ID (group-less file, or specific group) find its contents

Usage

Rnc_inq(grpid)

Arguments

grpid

group ID provided by 'Rnc_inq_grps'

Examples

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

Attribute details

Description

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?

Usage

Rnc_inq_att(grpid, varid, attid)

Arguments

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

Description

Dimension inquiry

Usage

Rnc_inq_dimension(grpid)

Arguments

grpid

group ID provided by 'Rnc_inq_grps'

Examples

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

Description

Dimension inquiry

Usage

Rnc_inq_dims(grpid)

Arguments

grpid

group ID provided by 'Rnc_inq_grps'

Examples

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

Description

Inquire group name by ID

Usage

Rnc_inq_grpname(grpid)

Arguments

grpid

group ID provided by 'Rnc_inq_grps'

Examples

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

Description

Inquire group IDs

Usage

Rnc_inq_grps(ncid)

Arguments

ncid

file connection provided by 'Rnc_open'

Examples

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

Description

We already know this from Rnc_inq_variable

Usage

Rnc_inq_natts(grpid, varid)

Arguments

grpid

con

varid

variable id


Dimensions of variables

Description

Dimensions of variables

Usage

Rnc_inq_vardims(grpid, ivar)

Arguments

grpid

group ID provided by 'Rnc_inq_grps'

ivar

index of variable

Examples

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

Description

Variable inquiry

Usage

Rnc_inq_variable(grpid)

Arguments

grpid

group ID provided by 'Rnc_inq_grps'

Examples

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

Open a connection.

Description

Pass a character data source name to the internal nc_open library function.

Usage

Rnc_open(dsn)

Arguments

dsn

data source name, i.e. file path or server path

Examples

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)