How to organize data in matrix
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I have a dataset that is in netCDF format. These data are precipitation and have 5 variables. I reduced the 2D I need (lat, lon) and now I need to save to a 3D cell with fixed lat and lon and time varying. I am unable to save so that they are not subscribed to previous data. Any help will be appreciated.
4 comentarios
John D'Errico
el 1 de Oct. de 2019
Editada: John D'Errico
el 1 de Oct. de 2019
Sorry, but this is gibberish so far as you have written. You may understand what you are asking to do, but it makes no sense at all.
So give a SMALL, SIMPLE example, only a few numbers. Then show what you would hope to find as a result.
There is no need to even post a netcdf file, as that just means you have not read it into MATLAB yet. It is just a bunch of numbers.
If you want help, then make it easy for somone to help you.
Stephen23
el 2 de Oct. de 2019
Sorry it was not clear.
I have files in netCDF format with the following variables:
netcdf4_classic
Dimensions:
S = 1
M = 10
Y = 181
X = 360
L = 7
Variables:
S
Size: 1x1
Dimensions: S
Datatype: double
Attributes:
units = 'months since 1982-01-01'
calendar = 'standard'
axis = 'N'
M
Size: 10x1
Dimensions: M
Datatype: single
Attributes:
units = 'Unitless'
long_name = 'Ensemble Member'
axis = 'M'
Y
Size: 181x1
Dimensions: Y
Datatype: single
Attributes:
units = 'degrees_north'
long_name = 'latitude'
axis = 'Y'
X
Size: 360x1
Dimensions: X
Datatype: single
Attributes:
units = 'degrees_east'
long_name = 'longitude'
axis = 'X'
L
Size: 7x1
Dimensions: L
Datatype: single
Attributes:
units = 'months'
long_name = 'Lead'
standard_name = 'forecast_period'
axis = 'L'
pr
Size: 360x181x7x10x1
Dimensions: X,Y,L,M,S
Datatype: double
Attributes:
units = 'mm'
long_name = 'Precipitation'
missing_value = -999
fill_value = -999
For "M", I have a mean and for "L" I select 1, 2 or 3 as needed. I need to open these files one by one, select lat and lon for South America and write in a continuous matrix with monthly data from 1982/jan to 2010/dec.
That is, I need an organized 3D matrix like lat, lon and monthly interval precipitation. That way my matrix would be 60x45x348 (lat x lon x time) All the part of selecting and extracting the data I am doing. The problem is saving these files to a new array because I'm overwriting over the previously read data and the array ends up as 2D with the last read data.
Respuestas (1)
meghannmarie
el 3 de Oct. de 2019
Did you preallocate output array?
output_array = nan(60,45,348);
for time_idx = 1:348
output_array(:,:,time_idx) = ncread(file,'pr',start,count);
end
Ver también
Categorías
Más información sobre NetCDF en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!