Skip to content

Instantly share code, notes, and snippets.

@nmathewa
Created March 1, 2022 07:30
Show Gist options
  • Save nmathewa/a28073e0d9a5957018b5eb783e03b4e4 to your computer and use it in GitHub Desktop.
Save nmathewa/a28073e0d9a5957018b5eb783e03b4e4 to your computer and use it in GitHub Desktop.
julia subset data
using NCDataFrame
using NCDatasets
using Pkg
Pkg.add("IntervalSets")
using IntervalSets
using PlotlyJS
ds = NCDataset("ECMWF_ERA-40_subset.nc","r")
temp = ds["p2t"][:]
function selectnc(latmin,latmax,lonmin,lonmax,ncfile)
nc = NCDataset(ncfile,"r")
lats,lons = nc["latitude"][:],nc["longitude"][:]
lonindices = findall((x -> x>(lonmin) && x<(lonmax)),lons)
latindices = findall((y -> y>(latmin) && y<(latmax)),lats)
subdata = nc["p2t"][lonindices,latindices,:]
return subdata
end
dd = selectnc(4,25,77,99,"ECMWF_ERA-40_subset.nc")#
#plot(contour(x=ds["longitude"][:],y=ds["latitude"][:],z=temp[:,:,1]))
plot(contour(z=dd[:,:,1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment