How to extract certain time in matrix data
Show older comments
Hi.
I have a 476x160x140 precipittaion data (precip/time,lon,lat), from 1981 to 2011 in nc file. Can I extract certain data for a certain year and time? Its like selyear in CDO but I need to do it in Matlab.
Thank you in advance!
10 Comments
Nurul Ain Basirah Zakaria
on 29 Oct 2020
Walter Roberson
on 29 Oct 2020
It is not obvious how the 476 precip/time is layed out? Is it like 4 hours a day measured for 17 selected weeks a year??
Nurul Ain Basirah Zakaria
on 29 Oct 2020
per isakson
on 29 Oct 2020
Edited: per isakson
on 29 Oct 2020
Maybe NetCDF/GRIB reader or some other submission to of File Exchange could be useful. The summary includes this paragraph
Technically speaking, MATLAB-CDI consists of mex-interfaces to the CDI library that read GRIB/netCDF. CDI is the basic library underlying the famous CDO (Climate Data Operators) developed by Max-Planck Institut für Meteorologie in Hamburg. The MATLAB-CDI interface package has been developed by The MathWorks Consulting on behalf of the Rossby Centre, SMHI.
Walter Roberson
on 29 Oct 2020
30 years, 12 months per year, gives 360 entries. You have 116 extra entries. Even if your 1981-2011 is 31 years, that would still be an extra 476-12*31 = 104 entries.
Nurul Ain Basirah Zakaria
on 29 Oct 2020
Walter Roberson
on 29 Oct 2020
So row index is (year - 1981)*12+month ?
If you were to
data4 = reshape(YourData, [], 12, size(YourData,2), size(YourData,3));
then rows would correspond to years, and dimension 2 would correspond to months, and dimension 3 would correspond to lon, and dimension 4 would correspond to lat. That might make it easier to do month-by-month comparisons across years.
Nurul Ain Basirah Zakaria
on 29 Oct 2020
Walter Roberson
on 29 Oct 2020
Yes if you do the reshape then it becomes easy.
Nurul Ain Basirah Zakaria
on 1 Nov 2020
Answers (0)
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!