Skip to content

Instantly share code, notes, and snippets.

@trondkr
Last active March 13, 2022 19:35
Show Gist options
  • Save trondkr/6ae27a07424c15f585e7c0cbdf62fe98 to your computer and use it in GitHub Desktop.
Save trondkr/6ae27a07424c15f585e7c0cbdf62fe98 to your computer and use it in GitHub Desktop.
Add fake point to NetCDF4 file to wrap globally
for file in era5*.nc
do
 name=${file##*/}
 base=${name%.nc}
newfile="${base}_halo.nc"
 
if [ ! -f "$newfile" ]
then
echo "$0: Creating '${file}'"
  cdo sethalo,0,1 "$file" "$newfile"
fi
done
@trondkr
Copy link
Author

trondkr commented Jan 11, 2022

This function uses CDOto add a fake number to ensure that the longitudes are completely wrapping the globe -180 to 180. Thanks to CDO community for help : https://code.mpimet.mpg.de/boards/1/topics/12323

@trondkr
Copy link
Author

trondkr commented Mar 13, 2022

Updated to check if file already exists or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment