1 Appendix F. Specifying Paths for NetCDF-C QuickStart {#nc_paths_quickstart}
2 ==============================
6 A key concept in netcdf-c is the notion of a "path".
7 A path specifies some dataset that is of interest to a user.
8 It is the primary argument to the *nc_open* and *nc_create*
9 functions in the NetCDF-C API, as defined by the file netcdf.h.
10 It is also the primary option for the NetCDF-C utilities:
11 *ncdump*, *nccopy*, and *ncgen*.
12 Hence understanding what kind of paths are acceptable is important
13 for using the NetCDF-C library.
15 ## Classification of Paths {#nc_paths_kinds}
17 Basically, there are two kinds of paths:
18 1. <a href="#qpaths_filesystem">File system paths</a>, and
19 2. <a href="#qpaths_url">Uniform Resource Locator (URL) paths</a>.
21 ### File System Paths {#qpaths_filesystem}
23 The most common form of path accepted by the NetCDF-C library is a file system path.
24 Every user of some computer operating system is familiar with the idea of a file system path.
26 Each operating system has some special quirks when specifying file system paths.
27 Here are some example paths for various version of Linux/Unix.
31 As a rule, Linux/Unix has a single root path typically indicated by "/",
32 and "/" is also used as the file separator.
34 For Windows, some example paths would be as follows:
38 Windows has a notion of a drive ("d:") and each drive serves as the root
39 of its own file system. Windows uses "\\" as its file separator, although
40 many programs also accept "/".
42 ## Uniform Resource Locator (URL) Paths {#qpaths_url}
44 The NetCDF-C library can access datasets that reside on remote computers,
45 Hence NetCDF-C now also accepts URLs to specify those remote datasets.
47 The general form of a URL is as follows:
49 <protocol>://<user>:<pwd>@<host>:<port>/<path>?<query>#<fragment>
51 * <protocol> - specifies the format of the messages between the local and remote computers. Some examples used by NetCDF-C are *http*, *https*, *s3*, *dap*, *dap4*, or *file*.
52 * <user:pwd> - Pass authorization credentials to the remote computer.
53 * <host>:<port> - The specific remote computer to access, such as *thredds.ucar.edu:8080*.
54 * <path> - A specification of file-path-like string that indicates some specific resource on the remote computer.
55 * <query> - A sequence of (key=value) pairs, separated by "&", and providing special information to the remote computer.
56 * <fragment> - A sequence of (key=value) pairs, separated by "&", and providing special information to the local computer.
58 Most parts of a URL are optional. As a rule, the protocol is always required,
59 and either the host is required or, if the protocol is "file", then the path is required.
60 The query and fragment are optional.
62 ### Examples of URL Paths for NetCDF-C
63 * https://thredds.ucar.edu/catalog
65 ## Addendum A. Amazon S3 Specific URLS {#nc_paths_s3_urls}
66 A URL path is required for accessing datasets on the Amazon S3 storage cloud.
67 Unfortunately S3 URLs are complicated.
68 It has the following features:
69 * Protocol: _https_ or _s3_. The _s3_ scheme is equivalent to "https" plus setting various tags in the query and/or fragment part of the URL.
70 * Host: Amazon S3 defines three forms: _Virtual_, _Path_, and _S3_
71 + _Virtual_: the host includes the bucket name as in __bucket.s3.<region>.amazonaws.com__ or __bucket.s3.amazonaws.com__
72 + _Path_: the host does not include the bucket name, but rather the bucket name is the first segment of the path. For example __s3.<region>.amazonaws.com/bucket__ or __s3.amazonaws.com/bucket__
73 + _S3_: the protocol is "s3:" and if the host is a single name, then it is interpreted as the bucket. The region is determined using an algorithm defined in the nczarr documentation.
74 + _Other_: It is possible to use other non-Amazon cloud storage, but that is cloud library dependent.
75 * Query: currently not used.
76 * Fragment: the fragment is of the form _key=value&key=value&..._. Depending on the key, the _value_ part may be left out and some default value will be used. The exact set of possible keys is defined in the nczarr documentation.
78 ## Addendum B. Known Fragment Keys {#nc_paths_frag_keys}
80 The fragment part of a URL is used to pass information deep into
81 the netcdf-c library to control its actions.
82 This appendix list known keys, although it may be somewhat out-of-date.
84 The current set of keys used in the netcdf-c library is as follows.
85 * _mode_ -- A special key that is used to provide single values for controlling the netcdf-c library. It consists of a comma separated sequence of values
86 primarily used to control the file format.
87 The *mode* key supports the following values
88 - _dap2_ -- Specifies that the URL accesses a resource using the DAP2 protocol
89 - _dap4_ -- Specifies that the URL accesses a resource using the DAP4 protocol
90 - _netcdf-3_ -- Specifies that a file is a netcdf-classic file
91 - _classic_ -- Alias for _netcdf-3_
92 - _netcdf-4_ -- Specifies that a file is a netcdf-enhanced file
93 - _enhanced_ -- Alias for _netcdf-4_
94 - _udf0_ -- Specifies that the file format is defined by a User Defined format
95 - _udf1_ -- Specifies that the file format is defined by a User Defined format
96 - _nczarr_ -- Specifies that the file is in NCZarr format
97 - _zarr_ -- Specifies that the file is in Zarr format
98 - _xarray_ --Specifies that the file is in Zarr format and uses the XARRAY convention
99 - _noxarray_ --Specifies that the file is in Zarr format and does not use the XARRAY convention
100 - _s3_ --Specifies that the file is remote and is stored on the Amazon S3 cloud
101 - _file_ --Specifies that the file is an NCZarr/Zarr file stored as a file tree
102 - _zip_ --Specifies that the file is an NCZarr/Zarr file stored as a zip file
103 - _bytes_ -- Specifies that the file is remote and is to be read using byte-range support
105 * _dap2_ -- equivalent to "mode=dap2"
106 * _dap4_ -- equivalent to "mode=dap4"
107 * _bytes_ -- equivalent to "mode=bytes"
108 * _log_ -- turn on logging for the duration of the data request
109 * _show=fetch_ -- log curl fetch commands