Skip to content

Instantly share code, notes, and snippets.

@nmathewa
Created February 11, 2022 01:48
Show Gist options
  • Save nmathewa/c4ae0e84c7ba1cab220cfe64db874f6e to your computer and use it in GitHub Desktop.
Save nmathewa/c4ae0e84c7ba1cab220cfe64db874f6e to your computer and use it in GitHub Desktop.
reading netcdf files (Julia)
using NCDataFrame
using NCDatasets
using PlotlyJS
using Pkg
using Statistics
using NaNStatistics
import NaNStatistics ; na=NaNStatistics
ds = NCDataset("ECMWF_ERA-40_subset.nc","r")
@show keys(ds)
temp = collect(ds["p2t"])
n_temp = coalesce.(temp, NaN)
#nanmean(x) = mean(filter(!isnan,x),2)
A = [1 2; 3 4]
#ff = nanmean(collect(temp))
dd = na.nanmean(n_temp,dims=(2,3))[:]
times = ds["time"][:]
p = scatter(y=dd,x=times)
layout = Layout(
title="Temperature Time Series",
xaxis_title="Date",
yaxis_title="Temperature(K)"
)
plot(p,layout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment