当前位置:   article > 正文

处理GRACE数据而进行的水文模型GLDAS的处理matlab程序代码_matlab controlfile_path

matlab controlfile_path
function [gldas,time,num_file]=readgldas(controlfile_path)
% Read the Control File
fid=fopen(controlfile_path,'r');
num_file= fscanf(fid,'%d',1);
lat= fscanf(fid,'%d',1);
lon= fscanf(fid,'%d',1);
dir_in=fscanf(fid,'%s',1);
file_name=cell(num_file,1);
for i = 1:num_file 
    file_name{i} = fscanf(fid,'%s',1);
end
%ini
gldas=zeros(num_file,lat,lon);
SWE=zeros(num_file,lat,lon);
SoilMoi0_10cm_inst=zeros(num_file,lat,lon);
SoilMoi100_200cm_inst=zeros(num_file,lat,lon);
SoilMoi10_40cm_inst=zeros(num_file,lat,lon);
SoilMoi40_100cm_inst=zeros(num_file,lat,lon);
time=zeros(num_file,1);
for ii=1:num_file
    file=char(strcat(dir_in,file_name(ii)));
    SWE(ii,:,:)=rot90(ncread(file,'SWE_inst'));
    SoilMoi0_10cm_inst(ii,:,:)=rot90(ncread(file,'SoilMoi0_10cm_inst'));
    SoilMoi100_200cm_inst(ii,:,:)=rot90(ncread(file,'SoilMoi100_200cm_inst'));
    SoilMoi10_40cm_inst(ii,:,:)=rot90(ncread(file,'SoilMoi10_40cm_inst'));
    SoilMoi40_100cm_inst(ii,:,:)=rot90(ncread(file,'SoilMoi40_100cm_inst'));
    time(ii,:,:)=ncread(file,'time');
end
for j=1:num_file
    gldas(j,:,:)=SWE(j,:,:)+SoilMoi0_10cm_inst(j,:,:)+SoilMoi100_200cm_inst(j,:,:)+SoilMoi10_40cm_inst(j,:,:)+SoilMoi40_100cm_inst(j,:,:);
end
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

gldas=zeros(num_file,lat,lon);
SWE=zeros(num_file,lat,lon);
SoilMoi0_10cm_inst=zeros(num_file,lat,lon);
SoilMoi100_200cm_inst=zeros(num_file,lat,lon);
SoilMoi10_40cm_inst=zeros(num_file,lat,lon);
SoilMoi40_100cm_inst=zeros(num_file,lat,lon);
time=zeros(num_file,1);
这几个变量只是我需要的,也是grace需要的,只用下载这几个就可以,处理也就只处理这几个。
其中需要一个控制文件

180                           //文件数
150                           //纬度范围
360                           //经度范围
clm    						  //模型类型
E:\GLDAS\gldas_clm\           //文件夹
GLDAS_CLM10_M.A200201.001.grb.SUB.nc4          //文件名
GLDAS_CLM10_M.A200202.001.grb.SUB.nc4
GLDAS_CLM10_M.A200203.001.grb.SUB.nc4
GLDAS_CLM10_M.A200204.001.grb.SUB.nc4
GLDAS_CLM10_M.A200205.001.grb.SUB.nc4
GLDAS_CLM10_M.A200206.001.grb.SUB.nc4
GLDAS_CLM10_M.A200207.001.grb.SUB.nc4
GLDAS_CLM10_M.A200208.001.grb.SUB.nc4
GLDAS_CLM10_M.A200209.001.grb.SUB.nc4
GLDAS_CLM10_M.A200210.001.grb.SUB.nc4
GLDAS_CLM10_M.A200211.001.grb.SUB.nc4
................................
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/191027
推荐阅读
相关标签
  

闽ICP备14008679号