Extracting subregions from netcdf files - this video makes the cut!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] so let's say we have a global net cdf file and we're only actually interested in a small sub region which is marked here in red now we want to specify the latitude and longitude bounds of this small sub-region and then what we want to do is find a way where we can actually export this into a new file now we're going to find this very easy to do using climate data operators directly from the command line there's only one thing we need to be careful of that we don't drop the file [Music] so let's assume we have a file which is here in this directory i type ls and we can see it's called t2m.nc and we can either look at the contents if you remember using ncedump t2m.nc but that would give us all of the numbers from the variables so we use minus h for the header see that in the file we have the two meter temperature and the file is on 1440 longitude points and 721 latitude points now we can either look at the longitude or latitude itself by using minus v and we can i type it correctly we can see the latitude points that run from -19 if i scroll up we see they go to 90 with a quarter of a degree resolution we could also see that the file was global by using nc view so if i open it nc view we see that we have a global map of two meter temperature so now let's assume that we only want to look at the data over africa so i'm going to quit this for the moment so what i'm going to use is cdo climate data operators and the command that we need is cell long lat box we have a comma and now we need to specify the longitude bounds so let's say we are interested in africa we might go from -20 to 60 and then in latitude i'm going to go from minus 40 to 40. and we need a space and we need input file output file so we'll type in t2m.nc which was our input file and now we need to think of a name for the output so i'm going to call it t2m underscore africa dot nc we see we have a message cdo cell long lap box process one variable and now if i open the new file using nc view t2m underscore africa we've discarded all of the data apart from the data within the longitude latitude box that i chose so just to recap we need to define the sub region that we wish to extract in terms of the longitude bounds and the latitude bounds and the command that we're using is cdo cell long lap box and then we need to specify those bounds in order oh you're still there now quickly there's two things i want to tell you about which are common mistakes now the first is if you look at the command right above my head one common error is that people insert spaces between the longitude and latitudes so this part of the command that's highlighted now has to be without any spaces the second error that people commonly make is they forget the order of longitude and latitude now with cdo it's always longitude first the way i remember that is i long to be first long first so if you remember that you never mix up the order in cdo longitude always comes first so what we've seen is a first example of a very simple to use commanding cdo where we can manipulate net cdf files directly from the command line i hope you found the video useful if so please click subscribe and feel free to check out my other videos on climate unboxed you
Info
Channel: Climate Unboxed
Views: 1,184
Rating: undefined out of 5
Keywords: netcdf, cdo, subregions, extract
Id: ewii1p1kChw
Channel Id: undefined
Length: 4min 59sec (299 seconds)
Published: Tue Mar 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.