Read & write NetCDF file via DataFrames.
using Pkg
Pkg.add("NCDataFrame")
using NCDataFrame
df = readnc("data.nc") # DataFrame
using NCDataFrame
using DataFrames
df = DataFrame()
df[!,:x] = 1:10
df[!,:y] = 'a':'j'
writenc(df, "data.nc")
fillmissing(1:3, 5) # [1,2,3,missing,missing]
fillmissing([1,2,3], 5) # [1,2,3,missing,missing]
fillmissing(1:5, 5) # 1:5
fillmissing([1,2,3,4,5], 5) # [1,2,3,4,5]
using NCDataFrame
using DataFrames
df = DataFrame()
df[!, :x] = fillmissing(1:3, 5) # [1,2,3,missing,missing]
df[!, :y] = 1:5 # [1,2,3,4,5]
writenc(df, "data.nc") # It works!
dg = readnc("data.nc") # It works too!
dg[!,:x] |> skipmissing |> collect # Remove missing from x
Error on install NCDatasets
For error message such as :
ERROR: LoadError: InitError: could not load library "$HOME/.julia/artifacts/0a7f440ba143b238cc3dd0def2956d34d76755f3/lib/libnetcdf.so"
You can solve it by following procedures.
- Install
libnetcdf
cd $HOME/.julia/artifacts/0a7f440ba143b238cc3dd0def2956d34d76755f3/lib/
unlink libnetcdf.so
unlink libnetcdf.so.18
ln -s /usr/lib/libnetcdf.so $PWD/libnetcdf.so
ln -s /usr/lib/libnetcdf.so.18 $PWD/libnetcdf.so.18
- In julia,
using NCDataFrame
than finish!
NCDataFrame.jl uses below packages inside.