Mergetime multiple files and Remap to 0.25x0.25 degree grid - bash script
Added by Akhilesh Kumar about 5 years ago
Hello everyone,
I have multiple NetCDF files in a folder. I want to merge them all and then remap them. Finally, I want to multiply each value in the final remapped file with 86400. I want to automate this. Based on my limited understanding, I tried writing a bash script for it. To check the code, I ran it in a folder containing 8 files. When I run it, the Cygwin terminal keeps on running something (since it doesn't get back to ASUS@Akhi /cygdrive/f/WGET $ where it usually used to return to once the task was done) but even after quite a long time, nothing seems to happen.
I ran operators mergetime, sellonlat and remapbil one by one and they work fine. I am very new to CDO (few weeks) and Cygwin/UNIX/LINUX (whatever it is based on). I don't know what is happening or even whether the script is correct or not. Please help me out. I am using CDO 1.9.4 Cygwin64.
Here is the script I wrote.
#!/bin/bash
for i in .nc
do
echo $i
cdo mergetime "$i".nc merged_output.nc
done
cdo -f nc -sellonlatbox,85,89,25,21 -random,r1440x720 template_grid.nc
cdo remapbil,template_grid.nc merged_output.nc output_subset_remap.nc
cdo -mulc,86400 output_subset_remap.nc real_pr_output_1981_2020.nc #Multiply to every value; convert CORDEX pcp (kg m-2 s-1) to mm/day
Replies (1)
RE: Mergetime multiple files and Remap to 0.25x0.25 degree grid - bash script - Added by Karin Meier-Fleischer about 5 years ago
Hi Akhilesh,
you don't need to use a for loop. If all netCDF files are in the same folder than do
cdo -O -mergetime *.nc tmp.nc cdo -mulc,86400 -sellonlatbox,85,89,25,21 -remapbil,r1440x720 tmp.nc outfile.nc
-Karin