美文网首页
使用Matlab处理nc文件

使用Matlab处理nc文件

作者: 荔枝猪 | 来源:发表于2019-10-20 20:49 被阅读0次

    需求

    读取处理nc文件

    函数

    ncinfo:返回有关 NetCDF 数据源的信息
    ncread: 读取NetCDF中某个变量的数据
    ncreadatt:读取NetCDF中属性值

    说明

    finfo = ncinfo(source) 将 source 所指定的整个 NetCDF 数据源的变量等相关信息返回到结构体 finfo 中。
    data = ncread(source,variable) source为nc文件路径,variable为变量名
    attvalue = ncreadatt(source,location,attname) 读取 source 中 location 指定的组或变量属性 attname

    代码

    % 查看nc文件的变量等信息
    finfo = ncinfo('D:\vpd\MERRA\MERRA2_100.statM_2d_slv_Nx.198001.nc4.nc');
    % 提取想要的变量数据
    data = ncread('D:\vpd\MERRA\MERRA2_100.statM_2d_slv_Nx.198001.nc4.nc','t2m');
    % ‘/’代表读取全局属性,中的RangeBeginningDate
    time_begin = ncreadatt('D:\MERRA\MERRA2_100.198001.nc4.nc','/','RangeBeginningDate');
    

    相关文章

      网友评论

          本文标题:使用Matlab处理nc文件

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