Simulation
,目录中有多个文件夹,每个文件夹中都有一些NetCDF文件。Simulation [Directory]:
----ACCESS [Folder]:
------ Rootzone_ACCESS_rcp26_xyz.nc
------ Rootzone_ACCESS_rcp45_xyz.nc
------ Rootzone_ACCESS_rcp85_xyz.nc
----CCSM4 [Folder]:
------ Rootzone_CCSM4_rcp45_xyz.nc
------ Rootzone_CCSM4_rcp85_xyz.nc
----- [Other folders with NetCDF files]
我想对所有文件夹中的每个文件执行2个操作。操作定义如下。
#lets say test.nc is the each individual file ncatted -O -a units,lon,c,c,"degrees_east" -a units,lat,a,c,"degrees_north" test.nc # and I want to add '0.25res' at the end of each re-gridded file cdo remapnn,r1440x720 test.nc test_0.25res.nc
最后,我想将所有重新网格化的文件存储在同一'Simulation`目录中的另一个文件夹中(我们将该文件夹称为Regridded_0.25
文件夹)。最终结果应如下所示。
Simulation [Directory]: ----ACCESS [Folder]: ------ Rootzone_ACCESS_rcp26_xyz.nc ------ Rootzone_ACCESS_rcp45_xyz.nc ------ Rootzone_ACCESS_rcp85_xyz.nc ----CCSM4 [Folder]: ------ Rootzone_CCSM4_rcp45_xyz.nc ------ Rootzone_CCSM4_rcp85_xyz.nc ----- [Other folders with NetCDF files] -----Regridded_0.25 [Folder]: ------ Rootzone_ACCESS_rcp26_xyz_0.25res.nc ------ Rootzone_ACCESS_rcp45_xyz_0.25res.nc ------ Rootzone_ACCESS_rcp85_xyz_0.25res.nc ------ Rootzone_CCSM4_rcp45_xyz_0.25res.nc ------ Rootzone_CCSM4_rcp85_xyz_0.25res.nc ------ [Other NetCDF files]
[有人可以帮助我创建可以执行以下操作的shell script
吗?我对shell
中的大数据操作没有足够的经验,但这会大大减少时间。非常感谢。
#!/bin/sh
for i in $(ls -R ./*/*.nc);
do
#path=$i
file=$(basename -s .nc $i)
#echo $file
ncatted -O -a units,lon,c,c,"degrees_east" -a units,lat,a,c,"degrees_north" ${i}
cdo remapnn,r1440x720 ${i} ./Regridded/${file}_0.25res.nc;
done