How to plot satellite data?

34 次查看(过去 30 天)
A.G. Bruno
A.G. Bruno 2019-1-8
评论: Meg Noah 2023-4-24
I am currently working with IDL to plot spectral images of trace gases concentration from satellite observation (such as TROPOMI on S5P and IASI on Metop satellites) but I want to switch to MATLAB. In this process I am having several trouble:
  1. I can not find a function or a tool to read native format images (.nat extension).
  2. I read files in NetCDF or HDF5 formats but I can not find a good way to plot this data.
I attacched an example of what I am trying to obtain. If some one has an sample code I would be grateful if he shared it.
  2 个评论
Clare Davis
Clare Davis 2019-2-1
Hello, I am having the same trouble - did you get a good answer in the end? Thanks
Meg Noah
Meg Noah 2023-4-24
I do not have a .nat extension file. Can you post one here?

请先登录,再进行评论。

回答(3 个)

Meg Noah
Meg Noah 2020-1-10
编辑:Meg Noah 2020-1-10
Here's a solution
clc
close all
clear all
filename = 'W_XX-EUMETSAT-Darmstadt,HYPERSPECT+SOUNDING,METOPA+IASI_C_EUMP_20181108012658_62544_eps_o_l2.nc';
info = ncinfo(filename);
% to get a listing on console of variable names
varnames = {info.Variables.Name}';
idx = find(contains(varnames,'integrated_co') & ~contains(varnames,'integrated_co2'));
% learning about the data
Attributes = info.Variables(idx).Attributes;
for i = 1:length(Attributes)
if (isnumeric(Attributes(i).Value))
fprintf(1,'%s = %f\n',Attributes(i).Name,Attributes(i).Value);
else
fprintf(1,'%s = %s\n',Attributes(i).Name,Attributes(i).Value);
end
end
dataCO = ncread(filename,'integrated_co');
% they seem to have made the missing data value a really big value
minval = min(dataCO(:));
dataCO(dataCO == max(dataCO(:))) = -300;
maxval = max(dataCO(:));
fprintf(1,'minval = %f\n',minval);
fprintf(1,'maxval = %f\n',maxval);
minval = 2e-4;
maxval = 67e-4;
m = 63/(maxval-minval);
b = -m*minval;
scaleddataCO = uint8(m*dataCO+b);
scaleddataCO(dataCO<0) = nan; % missing data
colorvals = colormap(jet);
lat = ncread(filename,'lat');
lon = ncread(filename,'lon');
[ny,nx] = size(dataCO);
figure()
hold on
for i = 1:64
idx = find(scaleddataCO == i);
plot(lon(idx),lat(idx),'s', 'markerfacecolor',colorvals(i,:),'markeredgecolor','none');
end
xlim([-180 180])
ylim([-90 90]);
axis equal
axis tight
set(gca,'ytick',[-90 -60 -30 0 30 60 90]);
set(gca,'xtick',[-180 -150 -120 -90 -60 -30 0 30 60 90 120 150 180]);
grid on
box on
title('Integrated CO 10^{-4} kg/m^2');
colormap(jet)
hb = colorbar;
hb.Ticks = [0 0.2 0.4 0.6 0.8 1];
vals = linspace(2,67,6);
for j = 1:length(vals)
hb.TickLabels{j} = num2str(vals(j));
end
Here's how to plot it with map functions
hfig = figure('color','white','position',[32 200 1200 650]);
worldmap('World')
load coastlines
plotm(coastlat,coastlon,'k')
hfig.Name = 'Integrated CO';
hold on;
for i = 1:64
idx = find(scaleddataCO == i);
if (~isempty(idx))
plotm(lat(idx),lon(idx),'s', 'markerfacecolor',colorvals(i,:),'markeredgecolor','none');
end
end
title('Integrated CO 10^{-4} kg/m^2');
colormap(jet)
hb = colorbar('southoutside');
hb.Ticks = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
vals = linspace(2,67,11);
for j = 1:length(vals)
hb.TickLabels{j} = num2str(vals(j));
end
CO_Map.png
  2 个评论
Visweshwaran R
Visweshwaran R 2020-1-27
@Meg Noah, the code is well written and precise. I too faced the same problem in plotting the netCDF file for soil moisture data (ASCAT). While I try to adjust this code for my datasets, I faced a few problems.
1) After printing the min and max value. you have assigned the same with 2e-4 and 67e-4.What is the need for it?
2)While calculating 'm', you used 63, why?
3)Similarly, you used for loop till 64, why that number particularly?
I know these questions may be basic but I am struck and 5 min of your time will be really helpful to me.
Thank you in advance.
Hugo
Hugo 2023-4-24
What would it look like without the missing data part?
I'm having trouble adapting the code to a random satellite ncDEF file cause it doesnt plot all my data

请先登录,再进行评论。


KSSV
KSSV 2019-1-8
Reading netCDF files is very easy in MATLAB. You need to just know ncdisp, ncread ..once you have read the data use pcolor to get the data you wanted to plot.
  7 个评论
KSSV
KSSV 2019-1-9
What are the dimensions of each variable?
Try:
pcolor(lon,lat,int_co') ;
I have asked you to attach the data/ file so that you can get more help straight away.
A.G. Bruno
A.G. Bruno 2019-1-10
It still doesn't work.
Sorry, I did not understand that you mean the data file. I've attached a dropbox link because the file is too large to upload it.
https://www.dropbox.com/s/2dkep0bzimms66m/W_XX-EUMETSAT-Darmstadt%2CHYPERSPECT%2BSOUNDING%2CMETOPA%2BIASI_C_EUMP_20181108012658_62544_eps_o_l2.7z?dl=0

请先登录,再进行评论。


ming lei
ming lei 2019-3-31
I also encountered a similar problem. Is it finally solved?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by