diff --git a/climax/main/preprocess.py b/climax/main/preprocess.py index 726544dc53529f8730d14c938e99921a49634bdb..e1b6944bdf9b59644f29535556d3107dd56697f2 100644 --- a/climax/main/preprocess.py +++ b/climax/main/preprocess.py @@ -179,9 +179,14 @@ if __name__ == '__main__': # set encoding of time: calendar ds.time.encoding = ds.time_bnds.encoding + # set NetCDF file compression for each variable + for _, var in ds.data_vars.items(): + var.encoding['zlib'] = True + var.encoding['complevel'] = 5 + # save aggregated netcdf file - LOGGER.info('Saving aggregated NetCDF: {}'.format(filename)) - ds.to_netcdf(filename) + LOGGER.info('Compressing NetCDF: {}'.format(filename)) + ds.to_netcdf(filename, engine='h5netcdf') # remove single netcdf files from disk if args.remove: