美文网首页
如何读写模式数据

如何读写模式数据

作者: Aerosols | 来源:发表于2022-04-19 12:38 被阅读0次

    matlab是个好东西。

    clc;
    clear;
    tic;
    
    %%
    filename = {'allsec_201911.grd','allsec_201912.grd'};
    dx = [360,225,228];
    dy = [180,120,150];
    dz = 14;
    vars =  29;
    dvars = 406;
    %%%% Position of BC is 1-14.
    out_folder ="D:\python\模式\emit\new_half\";
    
    file = dir("D:\python\模式\emit\xshun");
    N = length(file);
    
    %%
    for d = 1:3  %%% Three layers.
        for i =1:2    %%% Two month.
            
            %%% Read data to the file.
            temp  = strcat(file(1).folder,"\",file(d+2).name,"\",filename(i));
            disp(temp);
            fid = fopen(temp,'r','b');
            data1 = fread(fid,'float');
            fclose(fid);
            
            data1=reshape(data1,dx(d),dy(d),dvars);
            data1(:,:,1:14) = data1(:,:,1:14)*0.5;
            data = reshape(data1,dx(d)*dy(d)*dvars,1);
            
            %%% Write data to new file.
            foutname = strcat(out_folder,file(d+2).name,"\",filename(i));
            fid2 = fopen(foutname,"w");
            fwrite(fid2,data,"float","b");
            fclose(fid2);
            
        end
    end
    toc;
    

    相关文章

      网友评论

          本文标题:如何读写模式数据

          本文链接:https://www.haomeiwen.com/subject/bfmfertx.html