TNO Intern

Commit 2587f9f4 authored by Arjo Segers's avatar Arjo Segers
Browse files

Support packed output for gridded averages.

parent cf48cce8
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@
#    Use pixel centers as mapping points when mapping level is zero,
#    this solves for the moment a problem with pixels crossing the date line.
#
# 2022-10, Arjo Segers
#    Support packing of output variables.
#


########################################################################
@@ -153,6 +156,18 @@ class CSO_GriddedAverage( utopya.UtopyaRc ) :
        !   %{basename}   : basename (without extension) of first source file
        <rcbase>.output.file            :   /scratch/CSO-data/S5p/OFFL/CH4/Middle-East_r01x01_qa08/%Y/%m/%{basename}_gridded.nc

    To reduce file size, by default all variables are written to file as short-integers (2 bytes) 
    accompanied by ``add_offset`` and ``scale_factor`` attributes. 
    A flag is available to disable packing.
    In addition, ``zlib`` compression is enabled.
    The default compression level is 1 (out of 9); set the following flag to a higher level
    to have stronger compression (on expense of computation time), or set to 0 to disable compression::
    
        ! pack floats as shorts:
        <rcbase>.output.packed              :  True
        ! zlib compression level (default 1, 0 for no compression):
        <rcbase>.output.complevel           :  1

    Existing files are replaced if the following flag is set::
    
        ! renew existing files?
@@ -289,6 +304,10 @@ class CSO_GriddedAverage( utopya.UtopyaRc ) :

        # target file:
        outfile_template = self.GetSetting( 'output.file' )
        # pack floats as shorts?
        packed = self.GetSetting( 'output.packed', 'bool' )
        # compression level:
        complevel = self.GetSetting( 'output.complevel', 'int' )

        # variables:
        vkeys = self.GetSetting( 'output.vars' ).split()
@@ -564,7 +583,8 @@ class CSO_GriddedAverage( utopya.UtopyaRc ) :

                    # write:
                    outf.Write( outfile, attrs=sources[stype0]['file'].ds.attrs, 
                                   history=history, unlimited_dims=['time'] )
                                   history=history, unlimited_dims=['time'],
                                   packed=packed, complevel=complevel )
                    
                    # increase counter:
                    nfile += 1