4. Convert to NetCDF file


Introduction

There is always a need to convert GrADS dataset into NetCDF format, because NetCDF is self-describing. This is equivalent to combining both the CTL file and binary data file into a single (.nc) one.


Converting

Since the loading of CTL dataset is simple, and also that we could make use of xarray’s to_netcdf() function, the whole converting process is simple:

from xgrads import open_CtlDataset

open_CtlDataset('input.ctl').to_netcdf('output.nc')