CESM tx0.1v3 regrid to uniform 0.1×0.1 grid – Eddy’s World

From global tripole output to global/regional uniform

1.Find Source grid tx0.1v3

1.1 install pop_tools

conda install -c conda-forge pop-tools

1.2 output NetCDF grid file

python3
import xarray as xr
import pop_tools
ds = pop_tools.get_grid('POP_tx0.1v3', scrip=True)
ds.info()
ds.to_netcdf('./tx0.1v3_grid.nc')

2. Generate destination grid(Global/Regional)

For global grids, one should specify only two more arguments, the latitude (lat_typ) and longitude (lon_typ) grid-types. These types are chosen as described below from a small selection of options that together define the most common rectangular global grids. For regional grids, one must specify the bounding box, i.e., the edges of the rectangular grid on the North (lat_nrt), South (lat_sth), East (lat_est), and West (lat_nrt) sides. Specifying a bounding box for global grids is redundant and will cause an error to ensure the user intends a global grid. NCO assumes that regional grids are uniform, though it will attempt to produce regional grids of other types if the user specifies other latitude (lat_typ) and longitude (lon_typ) grid-types, e.g., Gaussian or Cap. Edges of a regional bounding box may be specified individually, or in the single-argument forms. —From 3.24 Grid Generation

Global destination grid: lat(-89.95:0.1:89.95),lon(0:0.1:360)

ncremap -g grid_0.1x0.1_uni_global.nc -G ttl='Equi-Angular grid 1800x3600'#latlon=1800,3600#lat_typ=uni 

Regional destination grid of KOE:
center: lat(25.0:0.1:45.0),lon(140.0:0.1:170.0)
edge: snwe=24.95,45.05,139.95,170.05
grid number: latlon=201,301
see: http://nco.sourceforge.net/nco.html#grid

ncremap -g grid_0.1x0.1_uni_regional_KOE.nc -G ttl='Equi-Angular Kuroshio&Oyashio Region grid 201x301'#latlon=201,301#snwe=24.95,45.05,139.95,170.05

3. Generate weight-file/map-file(Global/Regional)

ncremap -a bilinear -s tx0.1v3_grid.nc -g grid_0.1x0.1_uni_global.nc -m tx0.1v3_to_0.1x0.1_uni_global.nc

ncremap -a bilinear -s tx0.1v3_grid.nc -g grid_0.1x0.1_uni_regional_KOE.nc -m tx0.1v3_to_0.1x0.1_uni_regional_KOE.nc

4. remap(Global/Regional)

 ncks -v SSH g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.nc ./g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.SSH.nc

 ncremap -m tx0.1v3_to_0.1x0.1_uni_regional_KOE.nc g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.SSH.nc g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.SSH.remap.KOE.nc

 ncremap -m tx0.1v3_to_0.1x0.1_uni_global.nc g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.SSH.nc g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.SSH.remap.global.nc

ncremap -v SSH -d grid_0.1x0.1_uni_regional_KOE.nc g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.extract.nc g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.SSH.remap.nc

Ref:
https://pop-tools.readthedocs.io/en/latest/examples/get-model-grid.html
http://nco.sourceforge.net/nco.html#ncremap
http://nco.sourceforge.net/nco.html#Grid-Generation
http://nco.sourceforge.net/nco.html#grid

From Regional tripole grid output remap to uniform regional output

1st try(failed)

I have FOSI tripole grid global output, then use ncks to extract a KOE regional tripole grid output with all Surface variables of a smaller region:

ncks -F -d nlon,2500,2801 -d nlat,1440,1664 -O /ihesp/archive/g.e20.G.TL319_t13.control.001_contd/ocn/hist/g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.nc /scratch/user/hengkai.yao/DATA/g.e20.G.TL319_t13.control.001_contd/ocn/hist/g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.extract.nc

then make a tripole grid file FOSI_make_regional_grid_file.m named tx0.1v3_grid_KOE.nc which is same as the regional output g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.extract.nc and with the same format as global tripole grid file tx0.1v3_grid.nc.

them make a uniform destination grid:

ncremap -g grid_0.1x0.1_uni_regional_KOE.nc -G ttl='Equi-Angular Kuroshio&Oyashio Region grid 201x301'#latlon=201,301#snwe=24.95,45.05,139.95,170.05

then make a map-file:

ncremap -a bilinear -s tx0.1v3_grid_KOE.nc -g grid_0.1x0.1_uni_regional_KOE.nc -m tx0.1v3_to_0.1x0.1_uni_regional_KOE.nc

then remap the regional tripole grid output to a uniform grid:

ncremap -v SSH -m tx0.1v3_to_0.1x0.1_uni_regional_KOE.nc g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.extract.nc g.e20.G.TL319_t13.control.001_contd.pop.h.0148-01-05.SSH.remap.nc

Then I plot the remapped SSH, the result is not correct.

2nd try(Success with Matlab scatter interpolation)

FOSI_tripole_interp_to_uniform_grid.m

Dig more of global grid file

File "tx0.1v3_grid.nc"
File type: NetCDF-3/CDM
 
netcdf file:/Users/yao/test/tx0.1v3_grid.nc {
  dimensions:
    grid_rank = 2;
    grid_size = 8640000;
    grid_corners = 4;
  variables:
    double grid_corner_lat(grid_size=8640000, grid_corners=4);
      :units = "degrees";

    double grid_corner_lon(grid_size=8640000, grid_corners=4);
      :units = "degrees";

    double grid_center_lat(grid_size=8640000);
      :units = "degrees";

    double grid_center_lon(grid_size=8640000);
      :units = "degrees";

    int grid_imask(grid_size=8640000);
      :units = "unitless";

    int grid_dims(grid_rank=2);

  // global attributes:
  :lateral_dims = 2400, 3600; // int
  :vertical_dims = 62; // int
  :vert_grid_file = "tx0.1v3_vert_grid";
  :horiz_grid_fname = "inputdata/ocn/pop/tx0.1v3/grid/horiz_grid_200709.ieeer8";
  :topography_fname = "inputdata/ocn/pop/tx0.1v3/grid/topography_20170718.ieeei4";
  :region_mask_fname = "inputdata/ocn/pop/tx0.1v3/grid/region_mask_20170718.ieeei4";
  :type = "tripole";
  :conventions = "SCRIP";
  :title = "POP_tx0.1v3 grid";
}

Ten articles before and after

MATLAB 绘制颜色红蓝间断图例 – Eddy’s World

如何阻止将我添加到电报组? -Telgram.cn

您应该知道的12种电报技巧-Telgram.cn

电报营销方法(已更新2021年)-Telgram.cn

在电报中创建虚拟帐户-添加电报成员

Telegram:新手指南、使用教程及频道推荐 – Telgram.cn

DDNS搭建与扶墙回国 – Eddy’s World

手把手教你系列之一:我的TAMU留学准备 – Eddy’s World

使用Zotero进行从未有过的畅快学术体验 – Eddy’s World

MATLAB编码方式-解决中文乱码问题 – Eddy’s World