From b9ce98cd480cdd790b9c4371fc7e87a1d8e3eb40 Mon Sep 17 00:00:00 2001 From: Anne Tipka <anne.tipka@ctbto.org> Date: Sat, 22 Oct 2022 22:33:00 +0000 Subject: [PATCH] added CONTROL file option for grib compression type / set packingType parameter in grib messages --- Source/Python/Classes/ControlFile.py | 4 ++++ Source/Python/Classes/EcFlexpart.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/Source/Python/Classes/ControlFile.py b/Source/Python/Classes/ControlFile.py index 5783535..5a14859 100644 --- a/Source/Python/Classes/ControlFile.py +++ b/Source/Python/Classes/ControlFile.py @@ -228,6 +228,9 @@ class ControlFile(object): Switch to select further parameters for retrievment to support WRF simulations. Default value is 0. + compression : str + Compression type for grib messages. Standard is "grid_simple". + ecfsdir : str Path to the ECMWF storage 'ectmp:/${USER}/econdemand/' @@ -395,6 +398,7 @@ class ControlFile(object): self.prefix = 'EN' self.cwc = 0 self.wrf = 0 + self.compression = 'grid_simple' self.ecfsdir = 'ectmp:/${USER}/econdemand/' self.mailfail = ['${USER}'] self.mailops = ['${USER}'] diff --git a/Source/Python/Classes/EcFlexpart.py b/Source/Python/Classes/EcFlexpart.py index 65ba97f..b7e02f6 100644 --- a/Source/Python/Classes/EcFlexpart.py +++ b/Source/Python/Classes/EcFlexpart.py @@ -1901,6 +1901,16 @@ class EcFlexpart(object): error_msg='RENAMING FOR NEW GRIB2 FORMAT ' 'FILES FAILED!') + if c.compression.lower() != 'grid_simple': + execute_subprocess(['grib_set', '-r', '-s', + 'packingType=' + c.compression, + ofile, ofile + '_2'], + error_msg='GRIB COMPRESSION FAILED!') + + execute_subprocess(['mv', ofile + '_2', ofile], + error_msg='RENAMING FOR NEW GRIB COMPRESSION ' + 'FILES FAILED!') + if c.ectrans and _config.FLAG_ON_ECMWFSERVER: execute_subprocess(['ectrans', '-overwrite', '-gateway', c.gateway, '-remote', c.destination, -- GitLab