有问题请联系我,如果有更高效的数据处理方式也可教教我
MERRA-2数据下载
建议Google浏览器,直接进NASA MERRA-2官网
点击Data Access,MDISC
需要注册一个EarthData账号并登录(网上很多教程)
搜索你需要的数据集
点击Subset
按需选择要素下载
点击GetData
点击即可下载,下载前需要设置浏览器下载地址,若需批量下载时可使用Down Them All插件(需要魔法)
MERRA-2数据处理
有时候下载的数据会有问题,所以需要先过一遍检查一下,有问题的重新下载
vvv = ["U50M","V50M"];
for idx = 1:length(vvv)
vname = vvv(idx);
% 生成日期序列
for year = 1993:2023%在这里改年份
startDate = datetime(year, 1, 1);
endDate = datetime(year, 12, 31);
dateSequence = startDate:endDate;
date = datestr(dateSequence, 'yyyymmdd');
for n = 1:length(date)
day=str2double(date(n,:));
versions = [100, 200, 300, 400, 401];
for v = versions
ncFile = sprintf('MERRA2_%d.tavg1_2d_slv_Nx.%d.SUB.nc',v,day);
filePath = fullfile('F:\MERRA2数据\MERRA50米风速',ncFile);%改原始数据路径
if isfile(filePath)
try
Variable = ncread(filePath,vname);
catch ME
newRow = table(day, 'VariableNames', {'day'});
errorDates = [errorDates; newRow];
continue;
end
break
end%if
end%版本
end%每一天
end%每一年
end%所有变量
我个人喜欢处理成年值mat文件
vvv = ["U50M","V50M"];
for idx = 1:length(vvv)
vname = vvv(idx);
% 生成日期序列
for year = 1993:2023%在这里改年份
startDate = datetime(year, 1, 1);
endDate = datetime(year, 12, 31);
dateSequence = startDate:endDate;
date = datestr(dateSequence, 'yyyymmdd');
for n = 1:length(date)
day=str2double(date(n,:));
versions = [100, 200, 300, 400, 401];
for v = versions
ncFile = sprintf('MERRA2_%d.tavg1_2d_slv_Nx.%d.SUB.nc',v,day);
filePath = fullfile('F:\MERRA2数据\MERRA50米风速',ncFile);%改原始数据路径
if isfile(filePath)
Variable = ncread(filePath,vname);
Variable = permute(Variable, [2, 1, 3]);
Variable = flip(Variable, 1);
break%跳出当前循环
end%if
end%版本
year_data(:,:,n*24-23:n*24)=Variable;
end%每一天
if (size(year_data,3)/24)>length(date)
disp(year);disp("错误");
end
time = Time_change2(year);
filename = sprintf('%s%d.mat', vname, year); % vname 和 year 的组合
filePath = fullfile('F:\MERRA2预处理为mat', vname, filename);
save(filePath, 'year_data', 'time');
clear("year_data")
end%每一年
end%所有变量