创建一个NetCDF文件,其数据被屏蔽以仅保留着陆点 [英] Create a NetCDF file with data masked to retain land points only
问题描述
我已在研究生中使用basemap.gs
脚本屏蔽了NetCDF文件.这是我使用口罩得到的:
I have masked a NetCDF file using basemap.gs
script in grads. Here is what I got using the mask:
所以,我想获得一个仅包含大陆数据的NetCDF文件,有人可以帮我吗?
So, I would like to obtain a NetCDF file which only contains the continental data, can anyone help me with this?
推荐答案
如果我正确理解了这个问题,则希望拥有一个netcdf文件,该文件的所有值都设置为在海点上丢失(即_Fillvalue).如果是这样,可以从命令行中找到两种解决方案:
If I have understood the question correctly, the desire is to have a netcdf file with all the values set to missing (i.e. _Fillvalue) over the sea points. If so there are two solutions from the command line:
一种方法是使用CDO创建陆地-海洋遮罩,然后将所有海洋点设置为丢失:
One way is to use CDO to create a land-sea mask and then set all the sea points to missing:
cdo -f nc2 setctomiss,0 -gtc,0 -remapcon,your_data_.nc -topo seamask.nc
- 其中 remapcon 将地形重新映射到数据文件的域和分辨率.
- 当内置地形大于海平面时,gtc会产生1.
- 然后setctomiss将所有零"点都设置为丢失.
- where remapcon remaps the topography to the domain and resolution of your data file.
- The gtc,produces 1 when the built in topography is greater then sea level.
- Then the setctomiss sets all the "zero" points to missing.
您现在可以使用它来屏蔽您的数据文件:
You can now use this to mask your datafile:
cdo mul datafile.nc seamask.nc masked_datafile.nc
但是,在某些情况下,我发现重新映射过程在边缘留下了海洋"数据的痕迹,在这种情况下,为了安全起见,您可以使用第二种方法:
However, in some circumstances I have found that the remapping process leaves traces of "ocean" data around the edges, in this case to be safer you can use the second method:
从此thredds服务器以1 km的分辨率下载netcdf数据文件,以获取到海洋的距离":
Download the netcdf data file for "distance to ocean" at 1km resolution from this thredds server: https://pae-paha.pacioos.hawaii.edu/thredds/ncss/dist2coast_1deg_land/dataset.html
然后,您可以掩盖海洋一定距离内的任何点以安全使用,这可能会掩盖少量的陆地数据.
Then you can mask out any points within a certain distance of the ocean to play it safe, at the expense of possibly masking out a small amount of land data.
我首先将距离文件重新映射到目标分辨率:
I remapped the distance file to the target resolution first:
cdo remapbil,your_data.nc distance.nc remap_dist.nc
然后屏蔽(例如,在这种情况下,距离海岸5公里以内的所有点,此文件中的海点已经丢失")并相乘
then mask (e.g. in this case all points within 5km of the coast, sea points are already "missing" in this file) and multiply
cdo mul your_data.nc -gtc,5 remap_dist.nc masked_data.nc
如前所述,这比较安全一些,有些困难,但是可能会掩盖一些陆地数据.
As said, this is a little safer, a little more longwinded, but may mask some land data.
这篇关于创建一个NetCDF文件,其数据被屏蔽以仅保留着陆点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!