Current section
Files
Jump to
Current section
Files
lib/netcdf_nif.ex
defmodule NetcdfNif do
@moduledoc """
Documentation for NetcdfNif.
See the `c_src/netcdf_nif.c` file for detailed documentation on
functions and parameters.
Also, see the `test.exs` file for a sample Elixir script and
`test.erl` for the Erlang version.
iex> c "test.exs"
NetcdfNif.Test.run()
Inspect the `hello.nc` file with
ncdump hello.nc
"""
@on_load :load_nifs
def load_nifs() do
:erlang.load_nif('./priv/netcdf_nif_ex', 0)
end
@doc """
nc type for a variable
https://docs.unidata.ucar.edu/netcdf-c/current/netcdf_8h.html#afe40bef4fdf46f2820e9cd64c64a11b5
"""
def nc_type(:nat) do
0
end
def nc_type(:byte) do
1
end
def nc_type(:char) do
2
end
def nc_type(:short) do
3
end
def nc_type(:int) do
4
end
def nc_type(:long) do
nc_type(:int)
end
def nc_type(:float) do
5
end
def nc_type(:double) do
6
end
def nc_type(:ubyte) do
7
end
def nc_type(:ushort) do
8
end
def nc_type(:uint) do
9
end
def nc_type(:int64) do
10
end
def nc_type(:uint64) do
11
end
def nc_type(:string) do
12
end
@doc """
Create the NetCDF file.
Argument is file path.
Returns the file id.
https://docs.unidata.ucar.edu/netcdf-c/current/group__datasets.html#ga041eacc9554e03d78a154a76e31e5b30
## Example
iex> NetcdfNif.nc_create("hello.nc")
6255
"""
def nc_create(_) do
:nif_not_loaded
end
@doc """
Close the NetCDF file.
Argument is file id.
Returns nil.
https://docs.unidata.ucar.edu/netcdf-c/current/group__datasets.html#ga07cbeee9c98b5b21713df60310edc3b1
## Example
iex> NetcdfNif.nc_close(6255)
nil
"""
def nc_close(_) do
:nif_not_loaded
end
@doc """
Define a dimension.
Arguments are: file id, dimension name, dimension size.
Returns dimension id.
https://docs.unidata.ucar.edu/netcdf-c/current/group__dimensions.html#ga6a1e2683ca1acf91437b790979ac7b8a
## Example
iex> NetcdfNif.nc_def_dim(6255, 'latitude', 6)
111
"""
def nc_def_dim(_, _, _) do
:nif_not_loaded
end
@doc """
Define a variable.
Arguments are: file id, variable name, nc type, number of dimensions, dimension id.
Returns variable id.
https://docs.unidata.ucar.edu/netcdf-c/current/group__variables.html#gac7e8662c51f3bb07d1fc6d6c6d9052c8
## Example
iex> NetcdfNif.nc_def_var(6255, 'latitude', NetcdfNif.nc_type(:double), 1, 111)
222
"""
def nc_def_var(_, _, _, _, _) do
:nif_not_loaded
end
@doc """
Define a text attribute for a variable.
Arguments are: file id, variable id, attribute name, attribute value (string).
https://docs.unidata.ucar.edu/netcdf-c/current/group__attributes.html#ga4fbf52b467add3788ecbf17d211af079
## Example
iex> NetcdfNif.nc_put_att_text(6255, 222, 'units', 'degrees_north')
"""
def nc_put_att_text(_, _, _, _) do
:nif_not_loaded
end
def nc_enddef(_) do
:nif_not_loaded
end
@doc """
Put a single (double) value into given variable.
Arguments are: file id, variable id, value (of double type).
Returns nil.
*NOTE* It still needs some work as I'm not sure of the `indexp` variable.
https://docs.unidata.ucar.edu/netcdf-c/current/group__variables.html#ga29e99cbc7ed704a14100e17d9eec8a66
## Example
iex> NetcdfNif.nc_put_var1_double(6255, 222, 1.0)
nil
"""
def nc_put_var1_double(_, _, _) do
:nif_not_loaded
end
@doc """
Put a list of (double) values into given variable.
Arguments are: file id, variable id, list of doubles.
Returns nil.
https://docs.unidata.ucar.edu/netcdf-c/current/group__variables.html#ga29e99cbc7ed704a14100e17d9eec8a66
## Example
iex> NetcdfNif.nc_put_var_double(6255, 222, {1.0, 2.0, 3.0})
nil
"""
def nc_put_var_double(_, _, _) do
:nif_not_loaded
end
end