Created
March 1, 2022 07:30
-
-
Save nmathewa/a28073e0d9a5957018b5eb783e03b4e4 to your computer and use it in GitHub Desktop.
julia subset data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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