Creating arrays based on NetCDF files
이전 댓글 표시
I'm working on a code that creates an array type (nlines, ncolumns, nfiles) with nfiles equal to the number of grids that it has ( k = 1:nfiles), after that I need to calculate the estatistics for each grid, for each value of K, and the statistics for each pixel. Then I need to calculate the average to each pixel e then create a grid to represent the averages of the values.
댓글 수: 21
dpb
2023년 8월 13일
So, what's the question?
Star Strider
2023년 8월 13일
My impression is that OP is informing us of his objective, and will let us know how it turns out!
Vasco
2023년 8월 13일
Vasco
2023년 8월 13일
dpb
2023년 8월 13일
Well, it must not have been well formed either, then, if it got no answers.
We can't answer what isn't asked nor explained, the Crystal Ball Toolbox has yet to be released.
Vasco
2023년 8월 14일
dpb
2023년 8월 14일
We can try, certainly. But, we need as precise a description of the result you're looking for and what you have to start with. If that is a NetCDF file, then we need you to attach it (preferably it is a small(ish) example that illustrates, not a huge one).
Then, probably the easiest way to combat the language barrier is to actually show us from the input what it is that you're trying to create as output, and more importantly, the "HOW/WHY" of why the result is what it is.
Vasco
2023년 8월 14일
Vasco
2023년 8월 14일
Vasco
2023년 8월 14일
load pixel_media.mat
whos
pixel_media=squeeze(pixel_media);
imagesc(pixel_media)
figure
imagesc(pixel_media.')
Well, that's not what you're wanting, either, it would seem! :)
figure
imagesc(pixel_media.')
hAx=gca; hAx.YDir='normal';
Something like that, maybe?
To compute statistics, presuming all the files are over the same coordinates and the same resolution, you'd just create the 3D array of each observation a plane (how many of them are there, you may run into memory issues and need to see about memory saving or other techniques than holding everything in memory at one time); then to compute statistics simply use the optional 'dim' argument for the various statistical functions like mean to operate over the 3rd dimension. "Piece o' cake!" :)
BTW, your English comprehension and grammar seem just fine to me -- far better than my abilities in your native language would be, for sure!
Vasco
2023년 8월 14일
NOTA BENE: In MATLAB images go from top LH corner down so to flip the display vertically, set the y-axis direction from bottom up as for an "ordinary" graph instead.
For real, you'll undoubtedly want to use the imagesc(x,y,C) form where x,y are the latitude/longitude associated with the image in order to display on actual coordinates instead of against pixel number.
Vasco
2023년 8월 15일
Vasco
2023년 8월 15일
_"... the coordinates are correct, ..."
You sure about that?
load pixel_media.mat
pixel_media=squeeze(pixel_media).'; % go ahead and transpose the data
imagesc(pixel_media)
hAx=gca; hAx.YDir='normal';
[xlim ylim]
You observe that imagesc scales the image to a midpoint between each pixel, not the actual latitude/longitude of the data points in the array. That the array size happens to be 180 x 360 is just fortuitous matchup to the numbers you expected although the latitude not being centered is unusual representation I'd think in any presentation.
Try
pixel_media=flipud(pixel_media); % flip the latitude direction to match MATLAB image
lat=linspace(-180,180,size(pixel_media,1));
lon=linspace(0,360,size(pixel_media,2));
imagesc(lon,lat,pixel_media)
xlim([lon(1) lon(end)]), ylim([lat(1) lat(end)])
xticks(linspace(lon(1),lon(end),9)), yticks(linspace(lat(1),lat(end),7))
Vasco
2023년 8월 15일
Vasco
2023년 8월 15일
dpb
2023년 8월 15일
Yeah, my foohpah on the latitude range; was just typing, not thinking.
I dunno where you want the origin to be for longitude; is the present 0 on Greenwich, maybe? Looks like it could be chosen that way is why I left it at 0.
I hadn't seen the plaint about colormap until now; there's where I'm at the limits of my image processing; I've never fully figured out how to neatly manipulate them to do special things; the default with imagesc scales the data over the range linearly.
I think to change the sea color you need to change its value if stay with indexed colors. Limiting the colormap to a range just causes points outside those to be max'ed out at one or the other end.
Vasco
2023년 8월 15일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




