爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 935|回复: 0

[源程序] matlab对全球CMIP6数据进行查看和读取

[复制链接]

新浪微博达人勋

发表于 2023-10-1 17:33:38 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
matlab对全球CMIP6数据进行查看和读取

在使用GCMs或CMIP6数据进行计算和处理时,首先需要下载数据、查看数据信息和读取数据。本文简单介绍如何使用matlab对全球范围内的GCMs/CMIP数据进行下载、查看及读取。
1.对GCMs或CMIP6数据进行下载
途径1:从官网直接下载CMIP6官网
提醒:可能下载比较缓慢,甚至会出现无法下载(自动回复:请不要使用迅雷等下载工具,点我查看下载帮助)的情况。
640 (8) - 副本.png

途径2:从其他网站间接下载

640 (9).png 640 (10).png

2.对数据进行查看和读取本文下载了一个例子,tas_Amon_ACCESS-CM2_historical_r1i1p1f1_gn_185001-201412.nc(历史1850-2014年逐月表面气温,气候模式是ACCESS-CM2)
第1步:查看文件概况
ncinfo('tas_Amon_ACCESS-CM2_historical_r1i1p1f1_gn_185001-201412.nc')

matlab运行结果为:
640 (11).png



第2步:查看文件详细信息
ncdisp('tas_Amon_ACCESS-CM2_historical_r1i1p1f1_gn_185001-201412.nc')

matlab运行结果为:
ncdisp('tas_Amon_ACCESS-CM2_historical_r1i1p1f1_gn_185001-201412.nc')
Source:
           tas_Amon_ACCESS-CM2_historical_r1i1p1f1_gn_185001-201412.nc
Format:
           netcdf4_classic
Global Attributes:
           Conventions           = 'CF-1.7 CMIP-6.2'
           activity_id           = 'CMIP'
           branch_method         = 'standard'
           branch_time_in_child  = 0
           branch_time_in_parent = 0
           creation_date         = '2019-11-08T06:41:46Z'
           data_specs_version    = '01.00.30'
           experiment            = 'all-forcing simulation of the recent past'
           experiment_id         = 'historical'
           external_variables    = 'areacella'
           forcing_index         = 1
           frequency             = 'mon'
           further_info_url      = '***furtherinfo.es-doc.org/CMIP6.CSIRO-ARCCSS.ACCESS-CM2.historical.none.r1i1p1f1'
           grid                  = 'native atmosphere N96 grid (144x192 latxlon)'
           grid_label            = 'gn'
           history               = '2019-11-08T06:41:46Z ; CMOR rewrote data to be consistent with CMIP6, CF-1.7 CMIP-6.2 and CF standards.'
           initialization_index  = 1
           institution           = 'CSIRO (Commonwealth Scientific and Industrial Research Organisation, Aspendale, Victoria 3195, Australia), ARCCSS (Australian Research Council Centre of Excellence for Climate System Science)'
           institution_id        = 'CSIRO-ARCCSS'
           mip_era               = 'CMIP6'
           nominal_resolution    = '250 km'
           notes                 = 'Exp: CM2-historical; Local ID: bj594; Variable: tas (['fld_s03i236'])'
           parent_activity_id    = 'CMIP'
           parent_experiment_id  = 'piControl'
           parent_mip_era        = 'CMIP6'
           parent_source_id      = 'ACCESS-CM2'
           parent_time_units     = 'days since 0950-01-01'
           parent_variant_label  = 'r1i1p1f1'
           physics_index         = 1
           product               = 'model-output'
           realization_index     = 1
           realm                 = 'atmos'
           run_variant           = 'forcing: GHG, Oz, SA, Sl, Vl, BC, OC, (GHG = CO2, N2O, CH4, CFC11, CFC12, CFC113, HCFC22, HFC125, HFC134a)'
           source                = 'ACCESS-CM2 (2019):
                                   aerosol: UKCA-GLOMAP-mode
                                   atmos: MetUM-HadGEM3-GA7.1 (N96; 192 x 144 longitude/latitude; 85 levels; top level 85 km)
                                   atmosChem: none
                                   land: CABLE2.5
                                   landIce: none
                                   ocean: ACCESS-OM2 (GFDL-MOM5, tripolar primarily 1deg; 360 x 300 longitude/latitude; 50 levels; top grid cell 0-10 m)
                                   ocnBgchem: none
                                   seaIce: CICE5.1.2 (same grid as ocean)'
           source_id             = 'ACCESS-CM2'
           source_type           = 'AOGCM'
           sub_experiment        = 'none'
           sub_experiment_id     = 'none'
           table_id              = 'Amon'
           table_info            = 'Creation Date:(30 April 2019) MD5:e14f55f257cceafb2523e41244962371'
           title                 = 'ACCESS-CM2 output prepared for CMIP6'
           variable_id           = 'tas'
           variant_label         = 'r1i1p1f1'
           version               = 'v20191108'
           cmor_version          = '3.4.0'
           tracking_id           = 'hdl:21.14100/d893128b-e107-4dcc-b543-46c77896f295'
           license               = 'CMIP6 model data produced by CSIRO is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License***.  Consult*** for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment.  Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file).  The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law.'
Dimensions:
           time = 1980  (UNLIMITED)
           lat  = 144
           lon  = 192
           bnds = 2
Variables:
    time     
           Size:       1980x1
           Dimensions: time
           Datatype:   double
           Attributes:
                       bounds        = 'time_bnds'
                       units         = 'days since 1850-01-01'
                       calendar      = 'proleptic_gregorian'
                       axis          = 'T'
                       long_name     = 'time'
                       standard_name = 'time'
    time_bnds
           Size:       2x1980
           Dimensions: bnds,time
           Datatype:   double
    lat      
           Size:       144x1
           Dimensions: lat
           Datatype:   double
           Attributes:
                       bounds        = 'lat_bnds'
                       units         = 'degrees_north'
                       axis          = 'Y'
                       long_name     = 'Latitude'
                       standard_name = 'latitude'
    lat_bnds
           Size:       2x144
           Dimensions: bnds,lat
           Datatype:   double
    lon      
           Size:       192x1
           Dimensions: lon
           Datatype:   double
           Attributes:
                       bounds        = 'lon_bnds'
                       units         = 'degrees_east'
                       axis          = 'X'
                       long_name     = 'Longitude'
                       standard_name = 'longitude'
    lon_bnds
           Size:       2x192
           Dimensions: bnds,lon
           Datatype:   double
    height   
           Size:       1x1
           Dimensions:
           Datatype:   double
           Attributes:
                       units         = 'm'
                       axis          = 'Z'
                       positive      = 'up'
                       long_name     = 'height'
                       standard_name = 'height'
    tas      
           Size:       192x144x1980
           Dimensions: lon,lat,time
           Datatype:   single
           Attributes:
                       standard_name = 'air_temperature'
                       long_name     = 'Near-Surface Air Temperature'
                       comment       = 'near-surface (usually, 2 meter) air temperature'
                       units         = 'K'
                       cell_methods  = 'area: time: mean'
                       cell_measures = 'area: areacella'
                       history       = '2019-11-08T06:41:45Z altered by CMOR: Treated scalar dimension: 'height'. 2019-11-08T06:41:45Z altered by CMOR: replaced missing value flag (-1.07374e+09) with standard missing value (1e+20).'
                       coordinates   = 'height'
                       missing_value = 1.000000020040877e+20
                       _FillValue    = 1.000000020040877e+20

从结果显示得出,变量tas的范围(size)是三维的,为192*144*1980.

第3步:读取数据
dataname = 'out_tas_Amon_ACCESS-CM2_historical_r1i1p1f1_gn_198001-201412.nc';
lon = ncread(dataname, 'lon');
lat = ncread(dataname, 'lat');
ta = ncread(dataname, 'tas');
time = ncread(dataname, 'time');
missing_index = ncreadatt( dataname, 'tas', 'missing_value' );  %缺失值处理missing_value
ta( ta == missing_index ) = nan;

代码中加入了缺失值的处理,记为nan。

matlab运行结果为:
640 (12).png


640 (8).png
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表