!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!
!!! CSO - CAMS Satellite Operator
!!!
!!! Settings for S5p/CHOCHO (glyoxal) processing.
!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


!-----------------------------------------------------------------------
! user specific settings:
!-----------------------------------------------------------------------

! include user specfic settings:
#include cso-user-settings.rc


!======================================================================
!===
!=== Inquire
!===
!======================================================================


!-----------------------------------------------------------
! inquire downloaded GlyRetro data
!-----------------------------------------------------------

! Obtain names of all available S5p files.
! Stored as csv with processing type, processor version, filenames, etc.

! renew table if file already exists?
cso.s5p.chocho.inquire-table-glyretro.renew                  :  False

! time range:
cso.s5p.chocho.inquire-table-glyretro.timerange.start        :  ${my.full-timerange.start}
cso.s5p.chocho.inquire-table-glyretro.timerange.end          :  ${my.full-timerange.end}

! output table, time templates are filled with date of today;
! base path is used for searching input files:
cso.s5p.chocho.inquire-table-glyretro.file                   :  ${my.work}/Copernicus-inquire/Copernicus_S5p_CHOCHO_glyretro__2022-09-22.csv

! filename filters relative to listing file that should be scanned for orbit files;
! names could include time templates ;
! if same orbit is found in multiple directories, the first found is used;
! remove existing table for safety to ensure that this is done correctly ...
cso.s5p.chocho.inquire-table-glyretro.patterns               :   %Y/%m/%d/S5P_RPRO_L2__CHOCHO_*.nc \
                                                                 %Y/%m/%d/S5P_OFFL_L2__CHOCHO_*.nc


!-----------------------------------------------------------------------
! inquire PAL portal
!-----------------------------------------------------------------------

! Obtain names of all available S5p files.
! Stored as csv with processing type, processor version, filenames, etc.

! inquire full time range:
cso.s5p.chocho.inquire-table-pal.timerange.start        :  ${my.full-timerange.start}
cso.s5p.chocho.inquire-table-pal.timerange.end          :  ${my.full-timerange.end}

! server url:
cso.s5p.chocho.inquire-table-pal.url                    :  https://data-portal.s5p-pal.com/cat/sentinel-5p/catalog.json

! product type (always 10 characters!):
cso.s5p.chocho.inquire-table-pal.producttype            :  L2__CHOCHO
                                                                
! target area;
!!~ empty for no limitation:
!cso.s5p.chocho.inquire-table-pal.area                   :  
!~ domain specified as:  west,south:east,north
cso.s5p.chocho.inquire-table-pal.area                   :  ${my.region.west},${my.region.south}:${my.region.east},${my.region.north}

! output table, date of today:
cso.s5p.chocho.inquire-table-pal.output.file            :  ${my.work}/Copernicus-inquire/Copernicus_S5p_CHOCHO_pal__%Y-%m-%d.csv



!-----------------------------------------------------------
! overview plot of versions
!-----------------------------------------------------------

! renew existing plots?
cso.s5p.chocho.inquire-plot.renew                    :  True

! listing files, here from two inquires:
cso.s5p.chocho.inquire-plot.file                     :  ${cso.s5p.chocho.inquire-table-glyretro.file} ; \
                                                        ${cso.s5p.chocho.inquire-table-pal.output.file}
!~ specify dates ("yyyy-mm-dd") to use historic tables,
!  default is table of today:
cso.s5p.chocho.inquire-plot.filedate                 :  2022-09-22 ;

! annote:
cso.s5p.chocho.inquire-plot.title                    :  S5p/CHOCHO %Y-%m-%d

! output figure, date of today:
cso.s5p.chocho.inquire-plot.output.file              :  ${my.work}/Copernicus-inquire/Copernicus_S5p_CHOCHO__%Y-%m-%d.png


!======================================================================
!===
!=== convert
!===
!======================================================================


! renew existing files (True|False) ?
cso.s5p.chocho.convert.renew                  :  True
!cso.s5p.chocho.convert.renew                  :  False

! time range:
cso.s5p.chocho.convert.timerange.start        :  ${my.timerange.start}
cso.s5p.chocho.convert.timerange.end          :  ${my.timerange.end}


!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! input files
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

! listing file or ';'-seperated list of listing files:
cso.s5p.chocho.convert.inquire.file                   :  ${cso.s5p.chocho.inquire-plot.file}
!~ historic inquire ...
cso.s5p.chocho.convert.inquire.filedate               :  ${cso.s5p.chocho.inquire-plot.filedate}

!! testing: produced only selected files ...
!!~ these files have "no-data" in "PRODUCT/delta_time", while qa_value is 1.0 ...
!cso.s5p.chocho.convert.whitelist                      :  S5p_OFFL_GLYOX_12808.nc \
!                                                        S5p_OFFL_GLYOX_12809.nc \
!                                                        S5p_OFFL_GLYOX_13094.nc \
!                                                        S5p_OFFL_GLYOX_13861.nc \
!                                                        S5p_OFFL_GLYOX_14398.nc \
!                                                        S5p_OFFL_GLYOX_14399.nc
!!~ testing: first orbit
!cso.s5p.chocho.convert.whitelist                      :  S5p_RPRO_GLYOX_01130.nc


! selection keyword:
my.s5p.chocho.selection                                :  Cxx

! Provide ';' seperated list of to decide if a particular orbit file should be processed.
! If more than one file is available for a particular orbit (from "OFFL" and "RPRO" processing),
! the file with the first match will be used.
! The expressions should include templates '%{header}' for the column values.
! Example to select files from collection '03', preferably from processing 'RPRO' but otherwise from 'OFFL':
!   (%{collection} == '03') and (%{processing} == 'RPRO') ; \
!   (%{collection} == '03') and (%{processing} == 'OFFL')
!
#if "${my.s5p.chocho.selection}" == "Cxx"
! strange archive, need to combine collections;
! prefere PAL_ for later years, otherwise RPRO or OFFL:
cso.s5p.chocho.convert.selection                      :  (%{processing} == 'PAL_') ; \
                                                         (%{processing} == 'RPRO') ; \
                                                         (%{processing} == 'OFFL')
#else
#error unsupported my.s5p.chocho.selection "${my.s5p.chocho.selection}"
#endif

! target dir for downloads;
! here the local archive:
cso.s5p.chocho.convert.input.dir                      :  ${my.observations}/GlyRetro

! remove downloaded files?
! here all data comes from local archive, set False anyway ...
cso.s5p.chocho.convert.downloads.cleanup              :  False

! selection names:
cso.s5p.chocho.convert.filters                        :  lons lats valid quality

! filter settings:
cso.s5p.chocho.convert.filter.lons.var                :  PRODUCT/longitude
cso.s5p.chocho.convert.filter.lons.type               :  minmax
cso.s5p.chocho.convert.filter.lons.minmax             :  ${my.region.west} ${my.region.east}
cso.s5p.chocho.convert.filter.lons.units              :  degrees_east

! filter settings:
cso.s5p.chocho.convert.filter.lats.var                :  PRODUCT/latitude
cso.s5p.chocho.convert.filter.lats.type               :  minmax
cso.s5p.chocho.convert.filter.lats.minmax             :  ${my.region.south} ${my.region.north}
cso.s5p.chocho.convert.filter.lats.units              :  degrees_north

! skip pixel with "no data";
! - PRODUCT/qa_value seems always defined
! - however, some orbit files have "PRODUCT/delta_time" with no-data while qa_value==1.0,
!   for example:
!     2020/04/03/S5P_OFFL_L2__co___20200403T033959_20200403T052129_12808_01_010000_20210128.nc
!   therefore use the time delta to check:
cso.s5p.chocho.convert.filter.valid.var               :  PRODUCT/delta_time
cso.s5p.chocho.convert.filter.valid.type              :  valid

! comment in "PRODUCT/qa_value" variable:
!   "A continuous quality descriptor, 
!   varying between 0 (no data) and 1 (full quality data). 
!   Recommend to ignore data with qa_value < 0.5" 
! Also PUM section 5.4 suggest minimum of 0.5.
cso.s5p.chocho.convert.filter.quality.var             :  PRODUCT/qa_value
cso.s5p.chocho.convert.filter.quality.type            :  min
cso.s5p.chocho.convert.filter.quality.min             :  0.5
cso.s5p.chocho.convert.filter.quality.units           :  1

!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! output files
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

! output directory and filename:
! - times are taken from mid of selection, rounded to hours
! - use '%{processing}' for the processing name
! - use '%{orbit}' for orbit number
cso.s5p.chocho.convert.output.filename            :  ${my.work}/CSO-data/${my.region}/S5p/CHOCHO/${my.s5p.chocho.selection}/%Y/%m/S5p_CHOCHO_%{orbit}.nc

! pack variables on output:
cso.s5p.chocho.convert.output.packed              :  True
! zlib compression level, 0 for no compression:
cso.s5p.chocho.convert.output.complevel           :  1

! global attributes:
cso.s5p.chocho.convert.output.attrs               :  format conventions \
                                                     author institution email
!
cso.s5p.chocho.convert.output.attr.format         :  ${my.cso.format}
cso.s5p.chocho.convert.output.attr.conventions    :  ${my.cso.convention}
cso.s5p.chocho.convert.output.attr.author         :  ${my.attr.author}
cso.s5p.chocho.convert.output.attr.institution    :  ${my.attr.institution}
cso.s5p.chocho.convert.output.attr.email          :  ${my.attr.email}

! no need to swap layes:
cso.s5p.chocho.convert.swap_layers                :  False


! ~ variables

! which fields to be put out ?
cso.s5p.chocho.convert.output.vars    :  longitude longitude_bounds \
                                       latitude latitude_bounds \
                                       track_longitude track_longitude_bounds \
                                       track_latitude  track_latitude_bounds \
                                       time \
                                       qa_value \
                                       pressure kernel amf_trop vmr_apri \
                                       vcd vcd_errvar \
                                       cloud_fraction solar_zenith_angle


! 
! Describe per variable:
! * .dims :  dimensions list:
!     pixel       : selected pixels
!     corner      : number of footprint bounds (probably 4)
!     layer       : number of layers in atmospheric profile (layers in kernel)
!     layeri      : number of layer interfaces in atmospheric profile (layer+1)
!     retr        : number of layers in retrieval product (1 for columns) ;
!                   for error covariance use (retr,retr0) to avoid repeated dimensions
!     track_scan  : original scan index   in 2D track
!     track_pixel : original ground pixel in 2D track
! * .specal  : keyword to select special processing
!     * None                     : no special processing (default)
!     * track_longitude          : longitudes at centers of original 2D track
!     * track_latitude           : latitudes  at centers of original 2D track
!     * track_longitude_bounds   : longitude bounds at centers of original 2D track
!     * track_latitude_bounds    : latitude  bounds at centers of original 2D track
! * .units   : target units if different from original
! * .oper    : special postprocessing, currently supported:
!     * square      :  fill variable with squared valued (used to form variance from standard deviation)
! In case no special processing is needed:
! * .from : original variable (group path and variable name)
!

! center longitudes; remove bounds attribute, no coordinate ...
cso.s5p.chocho.convert.output.var.longitude.dims                   :   pixel
cso.s5p.chocho.convert.output.var.longitude.from                   :   PRODUCT/longitude
cso.s5p.chocho.convert.output.var.longitude.attrs                  :   { 'bounds' : None, \
                                                                        'valid_min' : None, 'valid_max' : None, \
                                                                        '_Shuffle'  : None }
! center latitudes; remove bounds attribute, no coordinate ...
cso.s5p.chocho.convert.output.var.latitude.dims                    :   pixel
cso.s5p.chocho.convert.output.var.latitude.from                    :   PRODUCT/latitude
cso.s5p.chocho.convert.output.var.latitude.attrs                   :   { 'bounds' : None, \
                                                                        'valid_min' : None, 'valid_max' : None, \
                                                                        '_Shuffle'  : None }

! corner longitudes; no units in file:
cso.s5p.chocho.convert.output.var.longitude_bounds.dims            :   pixel corner
cso.s5p.chocho.convert.output.var.longitude_bounds.from            :   PRODUCT/SUPPORT_DATA/GEOLOCATIONS/longitude_bounds
cso.s5p.chocho.convert.output.var.longitude_bounds.units           :   degrees_east
cso.s5p.chocho.convert.output.var.longitude_bounds.attrs           :   { '_Shuffle'  : None }
! corner latitudes, no units in file:
cso.s5p.chocho.convert.output.var.latitude_bounds.dims             :   pixel corner
cso.s5p.chocho.convert.output.var.latitude_bounds.from             :   PRODUCT/SUPPORT_DATA/GEOLOCATIONS/latitude_bounds
cso.s5p.chocho.convert.output.var.latitude_bounds.units            :   degrees_north
cso.s5p.chocho.convert.output.var.latitude_bounds.attrs            :   { '_Shuffle'  : None }

! original track:
!~ center lon; remove bounds attribute, no coordinate ...
cso.s5p.chocho.convert.output.var.track_longitude.dims             :   track_scan track_pixel
cso.s5p.chocho.convert.output.var.track_longitude.special          :   track_longitude
cso.s5p.chocho.convert.output.var.track_longitude.from             :   PRODUCT/longitude
cso.s5p.chocho.convert.output.var.track_longitude.attrs            :   { 'bounds' : None, \
                                                                        'valid_min' : None, 'valid_max' : None, \
                                                                        '_Shuffle'  : None }
!~ center lat; remove bounds attribute, no coordinate ...
cso.s5p.chocho.convert.output.var.track_latitude.dims              :   track_scan track_pixel
cso.s5p.chocho.convert.output.var.track_latitude.special           :   track_latitude
cso.s5p.chocho.convert.output.var.track_latitude.from              :   PRODUCT/latitude
cso.s5p.chocho.convert.output.var.track_latitude.attrs             :   { 'bounds' : None, \
                                                                        'valid_min' : None, 'valid_max' : None, \
                                                                        '_Shuffle'  : None }
!~ corner lons
cso.s5p.chocho.convert.output.var.track_longitude_bounds.dims      :   track_scan track_pixel corner
cso.s5p.chocho.convert.output.var.track_longitude_bounds.special   :   track_longitude_bounds
cso.s5p.chocho.convert.output.var.track_longitude_bounds.from      :   PRODUCT/SUPPORT_DATA/GEOLOCATIONS/longitude_bounds
cso.s5p.chocho.convert.output.var.track_longitude_bounds.units     :   degrees_east
cso.s5p.chocho.convert.output.var.track_longitude_bounds.attrs     :   { '_Shuffle'  : None }
!~ corner lats
cso.s5p.chocho.convert.output.var.track_latitude_bounds.dims       :   track_scan track_pixel corner
cso.s5p.chocho.convert.output.var.track_latitude_bounds.special    :   track_latitude_bounds
cso.s5p.chocho.convert.output.var.track_latitude_bounds.from       :   PRODUCT/SUPPORT_DATA/GEOLOCATIONS/latitude_bounds
cso.s5p.chocho.convert.output.var.track_latitude_bounds.units      :   degrees_north
cso.s5p.chocho.convert.output.var.track_latitude_bounds.attrs      :   { '_Shuffle'  : None }

! time value per scan line
cso.s5p.chocho.convert.output.var.time.dims                        :   pixel
cso.s5p.chocho.convert.output.var.time.special                     :   time-delta
cso.s5p.chocho.convert.output.var.time.tref                        :   PRODUCT/time
cso.s5p.chocho.convert.output.var.time.dt                          :   PRODUCT/delta_time
!~ skip attribute:
cso.s5p.chocho.convert.output.var.time.attrs                       :   { '_Shuffle'  : None, 'calendar' : None }

! quality flag:
cso.s5p.chocho.convert.output.var.qa_value.dims                    :   pixel
cso.s5p.chocho.convert.output.var.qa_value.from                    :   PRODUCT/qa_value
!~ skip some attributes, cf-checker complains ...
cso.s5p.chocho.convert.output.var.qa_value.attrs                   :   { 'coordinates' : None, '_Shuffle'  : None }

! convert mid level pressure (nlev) to half level pressure:
cso.s5p.chocho.convert.output.var.pressure.dims                    :   pixel layeri
cso.s5p.chocho.convert.output.var.pressure.special                 :   pmid_to_pressure
cso.s5p.chocho.convert.output.var.pressure.pmid                    :   PRODUCT/SUPPORT_DATA/DETAILED_RESULTS/glyoxal_profile_apriori_pressure
cso.s5p.chocho.convert.output.var.pressure.units                   :   Pa

! description:
cso.s5p.chocho.convert.output.var.vmr_apri.dims                    :   pixel layer
cso.s5p.chocho.convert.output.var.vmr_apri.from                    :   PRODUCT/SUPPORT_DATA/DETAILED_RESULTS/glyoxal_profile_apriori
!~ convert from "1" to ppb:
cso.s5p.chocho.convert.output.var.vmr_apri.units                   :   ppb
!~ skip some attributes:
cso.s5p.chocho.convert.output.var.vmr_apri.attrs                   :   { 'coordinates' : None, '_Shuffle'  : None }

! description:
cso.s5p.chocho.convert.output.var.kernel.dims                      :   pixel layer retr
cso.s5p.chocho.convert.output.var.kernel.from                      :   PRODUCT/SUPPORT_DATA/DETAILED_RESULTS/averaging_kernel
!~ skip some attributes:
cso.s5p.chocho.convert.output.var.kernel.attrs                     :   { 'coordinates' : None, '_Shuffle'  : None }

! tropospheric airmass factor:
cso.s5p.chocho.convert.output.var.amf_trop.dims                    :   pixel retr
cso.s5p.chocho.convert.output.var.amf_trop.from                    :   PRODUCT/SUPPORT_DATA/DETAILED_RESULTS/glyoxal_tropospheric_air_mass_factor
cso.s5p.chocho.convert.output.var.amf_trop.attrs                   :   { 'coordinates' : None, '_Shuffle'  : None }

! vertical column density:
cso.s5p.chocho.convert.output.var.vcd.dims                         :   pixel retr
cso.s5p.chocho.convert.output.var.vcd.from                         :   PRODUCT/glyoxal_tropospheric_vertical_column
!~ skip some attributes:
cso.s5p.chocho.convert.output.var.vcd.attrs                        :   { 'coordinates' : None, '_Shuffle'  : None, \
                                                                        'multiplication_factor_to_convert_to_DU' : None, \
                                                                        'multiplication_factor_to_convert_to_molecules_percm2' : None }

! error variance in vertical column density (after application of kernel),
! fill with single element 'covariance matrix', from square of standard error:
! use dims with different names to avoid that cf-checker complains:
cso.s5p.chocho.convert.output.var.vcd_errvar.dims                  :   pixel retr retr0
cso.s5p.chocho.convert.output.var.vcd_errvar.special               :   square
cso.s5p.chocho.convert.output.var.vcd_errvar.from                  :   PRODUCT/glyoxal_tropospheric_vertical_column_precision
!~ skip some attributes,
!  for example do not use "standard_name" since since modifier "standard_error" is not valid anymore:
cso.s5p.chocho.convert.output.var.vcd_errvar.attrs                 :   { 'coordinates' : None, '_Shuffle'  : None, \
                                                                        'multiplication_factor_to_convert_to_DU' : None, \
                                                                        'multiplication_factor_to_convert_to_molecules_percm2' : None, \
                                                                        'standard_name' : None, \
                                                                        'long_name'     : 'troposphere mole content of chochoal standard error' }

! description:
cso.s5p.chocho.convert.output.var.solar_zenith_angle.dims         :   pixel
cso.s5p.chocho.convert.output.var.solar_zenith_angle.from         :   PRODUCT/SUPPORT_DATA/GEOLOCATIONS/solar_zenith_angle
cso.s5p.chocho.convert.output.var.solar_zenith_angle.units        :   degree
!~ skip some attributes:
cso.s5p.chocho.convert.output.var.solar_zenith_angle.attrs        :   { 'coordinates' : None, '_Shuffle'  : None, \
                                                                        'valid_min' : None, 'valid_max' : None }

! description:
cso.s5p.chocho.convert.output.var.cloud_fraction.dims             :   pixel
cso.s5p.chocho.convert.output.var.cloud_fraction.from             :   PRODUCT/SUPPORT_DATA/INPUT_DATA/cloud_fraction_crb
cso.s5p.chocho.convert.output.var.cloud_fraction.units            :   1
!~ skip some attributes:
cso.s5p.chocho.convert.output.var.cloud_fraction.attrs            :   { 'coordinates' : None, '_Shuffle'  : None, \
                                                                       'standard_name' : None }


!======================================================================
!===
!=== listing
!===
!======================================================================

! csv file that will hold records per file with:
! - timerange of pixels in file
! - orbit number
cso.s5p.chocho.listing.file                :  ${my.work}/CSO-data/${my.region}/S5p/CHOCHO/${my.s5p.chocho.selection}__listing.csv

! renew table if file already exists?
cso.s5p.chocho.listing.renew               :  True

! time range:
cso.s5p.chocho.listing.timerange.start     :  ${my.timerange.start}
cso.s5p.chocho.listing.timerange.end       :  ${my.timerange.end}

! filename filters relative to listing file that should be scanned for orbit files;
! names could include time templates ;
! if same orbit is found in multiple directories, the first found is used;
! remove existing table for safety to ensure that this is done correctly ...
cso.s5p.chocho.listing.patterns            :  ${my.s5p.chocho.selection}/%Y/%m/S5p_*.nc

! extra columns to be added, read from global attributes:
cso.s5p.chocho.listing.xcolumns            :  orbit


!======================================================================
!===
!=== catalogue
!===
!======================================================================

! listing file with filenames/timerange.
cso.s5p.chocho.catalogue.input.listing               :  ${cso.s5p.chocho.listing.file}


! time range:
cso.s5p.chocho.catalogue.timerange.start             :  ${my.timerange.start}
cso.s5p.chocho.catalogue.timerange.end               :  ${my.timerange.end}

! target filenames; templates:
! - time values
! - %{orbit}   : from listing
! - %{varname} for variable
cso.s5p.chocho.catalogue.output.file                 :  ${my.work}/CSO-data-catalogue/${my.region}/S5p/CHOCHO/${my.s5p.chocho.selection}/%Y/%m/%d/S5p_CHOCHO_%{orbit}__%{varname}.png

! map domain (west east south north)
cso.s5p.chocho.catalogue.domain                      :  ${my.region.west} ${my.region.east} ${my.region.south} ${my.region.north}

! figure size (inches), default is (8,6):
cso.s5p.chocho.catalogue.figsize                     :  ${my.region.figsize}

! renew existing files?
cso.s5p.chocho.catalogue.renew                       :  False
!cso.s5p.chocho.catalogue.renew                       :  True

! variables to be plotted:
cso.s5p.chocho.catalogue.vars                        :  vcd vcd_errvar qa_value cloud_fraction

!! color for no-data values in track, default '0.8' (gray):
!cso.s5p.chocho.catalogue.color_nan                   :  white

!! extra keyword arguments for map:
!cso.s5p.chocho.catalogue.map                         :  resolution='h'

! convert units:
cso.s5p.chocho.catalogue.var.vcd.units                         :  umol/m2
! style:
cso.s5p.chocho.catalogue.var.vcd.vmin                          :   0.0
!cso.s5p.chocho.catalogue.var.vcd.vmax                          :  100.0
cso.s5p.chocho.catalogue.var.vcd.vmax                          :  None

! show error as std.dev, convert to vcd units:
cso.s5p.chocho.catalogue.var.vcd_errvar.units                  :  umol/m2
! style:
!cso.s5p.chocho.catalogue.var.vcd_errvar.vmax                   :  100.0
cso.s5p.chocho.catalogue.var.vcd_errvar.vmax                   :  None

! style:
cso.s5p.chocho.catalogue.var.qa_value.vmin                     :   0.5
cso.s5p.chocho.catalogue.var.qa_value.vmax                     :   1.0
cso.s5p.chocho.catalogue.var.qa_value.colors                   :   ['red','yellow','green']

! style:
cso.s5p.chocho.catalogue.var.cloud_fraction.vmax               :   1.0
cso.s5p.chocho.catalogue.var.cloud_fraction.colors             :   ['blue','cyan','white']


!-----------------------------------------------------------
! catalogue index
!-----------------------------------------------------------

! target location:
cso.s5p.chocho.catalogue-index.outdir                    :  ${my.work}/CSO-data-catalogue/${my.region}/S5p/CHOCHO/${my.s5p.chocho.selection}

! title:
cso.s5p.chocho.catalogue-index.header                    :  CSO catalogue
! show info on created page?
cso.s5p.chocho.catalogue-index.info                      :  True

! create new page for each value?
cso.s5p.chocho.catalogue-index.newpage                   :  True

! content type:
cso.s5p.chocho.catalogue-index.type                      :  list
! define row values:
cso.s5p.chocho.catalogue-index.name                      :  date
cso.s5p.chocho.catalogue-index.values                    :  TimeSeries( ${my.timerange.start}, ${my.timerange.end}, '1 day', '%Y%m%d' )

! create new page for each value:
cso.s5p.chocho.catalogue-index.date.newpage                   :  True
! content type:
cso.s5p.chocho.catalogue-index.date.type                      :  table-row
! define row values:
cso.s5p.chocho.catalogue-index.date.name                      :  orbit
cso.s5p.chocho.catalogue-index.date.values                    :  CsvFile( '%{date[0:4]}/%{date[4:6]}/%{date[6:8]}/orbits.csv' )

! content type:
cso.s5p.chocho.catalogue-index.date.orbit.type                :  table-col
! define column values:
cso.s5p.chocho.catalogue-index.date.orbit.name                :  var
cso.s5p.chocho.catalogue-index.date.orbit.values              :  ${cso.s5p.chocho.catalogue.vars}

! content type:
cso.s5p.chocho.catalogue-index.date.orbit.var.type            :  img
! define image:
cso.s5p.chocho.catalogue-index.date.orbit.var.img             :  %{date[0:4]}/%{date[4:6]}/%{date[6:8]}/S5p_CHOCHO_%{orbit}__%{var}.png
cso.s5p.chocho.catalogue-index.date.orbit.var.kwargs          :  height=300



!======================================================================
!===
!=== gridded orbits
!===
!======================================================================


!-----------------------------------------------------------
! gridded orbits
!-----------------------------------------------------------

! time range:
cso.s5p.chocho.gridded.timerange.start        :  ${my.timerange.start}
cso.s5p.chocho.gridded.timerange.end          :  ${my.timerange.end}
! create one gridded file per hour:
cso.s5p.chocho.gridded.timerange.step         :  hour

! renew existing files?
cso.s5p.chocho.gridded.renew                  :  True

! target directory, incl. subdir for resolution and filters:
my.gridded.dir                              :  ${my.work}/CSO-gridded/${my.region}__r01x01/S5p/CHOCHO/${my.s5p.chocho.selection}__${my.s5p.chocho.gridded-selection}

!~

! grid definition:
!~ same as pixel selection on conversion:
cso.s5p.chocho.gridded.grid.west              :  ${my.region.west}
cso.s5p.chocho.gridded.grid.east              :  ${my.region.east}
cso.s5p.chocho.gridded.grid.south             :  ${my.region.south}
cso.s5p.chocho.gridded.grid.north             :  ${my.region.north}
! resolution:
cso.s5p.chocho.gridded.grid.dlon              :  0.1
cso.s5p.chocho.gridded.grid.dlat              :  0.1

! level of recursive splitting of footprint into triangles,
! and assignment of centroids to grid cells;
! for 4-corner footprints, number of centroids is:
!  1 (levels=0), 4 (1), 8 (2), 16 (3), 64 (5), 256 (7)
cso.s5p.chocho.gridded.mapping.levels         :  5

!~

! keywords for source files; 
! the first one should have the footprints;
! here the only source are the converted files:
cso.s5p.chocho.gridded.sources                  :  data

! input files for each source type:
!~ here: specify listing file, 
!  this is only supported for a single source
cso.s5p.chocho.gridded.source.data.listing      :  ${cso.s5p.chocho.listing.file}
!!~ alternative: filename patterns with time templates,
!!  but here the source files do not have time stamps
!cso.s5p.chocho.gridded.source.data.filenames    :  ${my.work}/CSO-data/S5p/RPRO/CHOCHO/${my.region}/%Y/%m/S5p_*.nc

!~

! filter description:
my.s5p.chocho.gridded-selection                 :  qa08

! switch:
#if "${my.s5p.chocho.gridded-selection}" == "qa08"

! keywords for filters:
cso.s5p.chocho.gridded.filters                  :  quality

! minimum quality value required:
cso.s5p.chocho.gridded.filter.quality.var       :  qa_value
cso.s5p.chocho.gridded.filter.quality.type      :  min
cso.s5p.chocho.gridded.filter.quality.min       :  0.8
cso.s5p.chocho.gridded.filter.quality.units     :  1
       
#else
#error unsupported  my.s5p.chocho.gridded-selection "${my.s5p.chocho.gridded-selection}"
#endif
        
!~

! target file, might contain templates:
!   %Y,%m,etc     : time values
cso.s5p.chocho.gridded.output.file                 :  ${my.gridded.dir}/%Y/%m/S5p_CHOCHO_%Y%m%d_%H%M_gridded.nc

! pack floats as short values?
cso.s5p.chocho.gridded.output.packed            :  True
! zlib compression level (default 1, 0 for no compression):
cso.s5p.chocho.gridded.output.complevel         :  1

! data variables to be created:
cso.s5p.chocho.gridded.output.vars              :  yr

! input variables:
!   data:vcd    : variable "vcd" from source "data"
cso.s5p.chocho.gridded.output.yr.source         :  data:vcd


!-----------------------------------------------------------
! catalogue of gridded fields
!-----------------------------------------------------------

! time range:
cso.s5p.chocho.gridded-catalogue.timerange.start        :  ${my.timerange.start}
cso.s5p.chocho.gridded-catalogue.timerange.end          :  ${my.timerange.end}
! create one gridded file per hour:
cso.s5p.chocho.gridded-catalogue.timerange.step         :  hour

! renew existing files?
!cso.s5p.chocho.gridded-catalogue.renew                  :  True
cso.s5p.chocho.gridded-catalogue.renew                  :  False

! target directory for catalogue:
my.chocho.gridded-catalogue.output.dir                  :  ${my.gridded.dir}/catalogue

! input files:
cso.s5p.chocho.gridded-catalogue.input.file             :  ${my.gridded.dir}/%Y/%m/S5p_CHOCHO_%Y%m%d_%H%M_gridded.nc
!!~ idem for daily average:
!cso.s5p.chocho.gridded-catalogue.input.file             :  ${my.gridded.dir}/S5p_CHOCHO_%Y%m%d_aver_gridded.nc

! target files, time tempates and variable name are replaced:
cso.s5p.chocho.gridded-catalogue.output.file            :  ${my.chocho.gridded-catalogue.output.dir}/%Y/%m/%d/S5p_CHOCHO_%Y%m%d_%H%M_gridded_%{var}.png
!!~ idem for daily average:
!cso.s5p.chocho.gridded-catalogue.output.file            :  ${my.chocho.gridded-catalogue.output.dir}/%Y/%m/%d/S5p_CHOCHO_%Y%m%d_aver_gridded_%{var}.png

! figure size (inches), default is (8,6):
cso.s5p.chocho.gridded-catalogue.figsize                :  (6,6)

! variables to be plotted:
cso.s5p.chocho.gridded-catalogue.vars                   :  yr

! variable:
cso.s5p.chocho.gridded-catalogue.var.yr.source          :  yr
! convert units:
cso.s5p.chocho.gridded-catalogue.var.yr.units           :  umol/m2
! style:
cso.s5p.chocho.gridded-catalogue.var.yr.vmin            :   0.0
!gcso.s5p.chocho.gridded-catalogue.var.yr.vmax            : 100.0
cso.s5p.chocho.gridded-catalogue.var.yr.vmax            : None




!-----------------------------------------------------------
! gridded catalogue index
!-----------------------------------------------------------

! target location:
cso.s5p.chocho.gridded-catalogue-index.outdir                    :  ${my.chocho.gridded-catalogue.output.dir}

! title:
cso.s5p.chocho.gridded-catalogue-index.header                    :  CSO catalogue
! show info on created page?
cso.s5p.chocho.gridded-catalogue-index.info                      :  True

! create new page for each value?
cso.s5p.chocho.gridded-catalogue-index.newpage                   :  True

! content type:
cso.s5p.chocho.gridded-catalogue-index.type                      :  list
! define row values:
cso.s5p.chocho.gridded-catalogue-index.name                      :  date
cso.s5p.chocho.gridded-catalogue-index.values                    :  TimeSeries( ${my.timerange.start}, ${my.timerange.end}, '1 day', '%Y%m%d' )

! create new page for each value:
cso.s5p.chocho.gridded-catalogue-index.date.newpage              :  True
! content type:
cso.s5p.chocho.gridded-catalogue-index.date.type                 :  table-row
! define row values:
cso.s5p.chocho.gridded-catalogue-index.date.name                 :  time
cso.s5p.chocho.gridded-catalogue-index.date.values               :  Range( 0, 23, 1, '%2.2i00' )

! content type:
cso.s5p.chocho.gridded-catalogue-index.date.time.type            :  table-col
! define column values:
cso.s5p.chocho.gridded-catalogue-index.date.time.name            :  var
cso.s5p.chocho.gridded-catalogue-index.date.time.values          :  ${cso.s5p.chocho.gridded-catalogue.vars}

! content type:
cso.s5p.chocho.gridded-catalogue-index.date.time.var.type        :  img
! define image:
cso.s5p.chocho.gridded-catalogue-index.date.time.var.img         :  %{date[0:4]}/%{date[4:6]}/%{date[6:8]}/S5p_CHOCHO_%{date}_%{time}_gridded_%{var}.png
cso.s5p.chocho.gridded-catalogue-index.date.time.var.kwargs      :  height=300



!======================================================================
!===
!=== simulation catalogue
!===
!======================================================================


!-----------------------------------------------------------
! simulation catalogue
!-----------------------------------------------------------

! time range:
cso.s5p.chocho.sim-catalogue.timerange.start        :  ${my.timerange.start}
cso.s5p.chocho.sim-catalogue.timerange.end          :  ${my.timerange.end}
cso.s5p.chocho.sim-catalogue.timerange.step         :  hour

! input files:
cso.s5p.chocho.sim-catalogue.input.data.file        :  ${my.work}/CSO-oper/CSO_output_%Y%m%d_%H%M_data.nc
cso.s5p.chocho.sim-catalogue.input.state.file       :  ${my.work}/CSO-oper/CSO_output_%Y%m%d_%H%M_state.nc

! target files, time tempates and variable name are replaced:
cso.s5p.chocho.sim-catalogue.output.file            :  ${my.work}/CSO-data-sim-catalogue/S5p/CHOCHO/${my.region}/%Y/%m/%d/S5p_CHOCHO_%Y%m%d_%H%M_%{var}.png

! map domain used for simulations (west east south north):
cso.s5p.chocho.sim-catalogue.domain                 :  ${my.region.west} ${my.region.east} ${my.region.south} ${my.region.north}

! figure size (inches), default is (8,6):
cso.s5p.chocho.sim-catalogue.figsize                :  ${my.region.figsize}

! renew existing files?
cso.s5p.chocho.sim-catalogue.renew                  :  False
!cso.s5p.chocho.sim-catalogue.renew                  :  True

! variables to be plotted:
cso.s5p.chocho.sim-catalogue.vars                   :  yr ys yr_m ys_m

! variable:
cso.s5p.chocho.sim-catalogue.var.yr.source          :  data:yr
! convert units:
cso.s5p.chocho.sim-catalogue.var.yr.units           :  umol/m2
! style:
cso.s5p.chocho.sim-catalogue.var.yr.vmin            :   0.0
cso.s5p.chocho.sim-catalogue.var.yr.vmax            : 100.0

! variable:
cso.s5p.chocho.sim-catalogue.var.ys.source          :  state:ys
! convert units:
cso.s5p.chocho.sim-catalogue.var.ys.units           :  umol/m2
! style:
cso.s5p.chocho.sim-catalogue.var.ys.vmin            :   0.0
cso.s5p.chocho.sim-catalogue.var.ys.vmax            : 100.0

! variable:
cso.s5p.chocho.sim-catalogue.var.yr_m.source        :  state:yr_m
! convert units:
cso.s5p.chocho.sim-catalogue.var.yr_m.units         :  umol/m2
! style:
cso.s5p.chocho.sim-catalogue.var.yr_m.vmin          :   0.0
cso.s5p.chocho.sim-catalogue.var.yr_m.vmax          : 100.0

! variable:
cso.s5p.chocho.sim-catalogue.var.ys_m.source        :  state:ys_m
! convert units:
cso.s5p.chocho.sim-catalogue.var.ys_m.units         :  umol/m2
! style:
cso.s5p.chocho.sim-catalogue.var.ys_m.vmin          :   0.0
cso.s5p.chocho.sim-catalogue.var.ys_m.vmax          : 100.0



!-----------------------------------------------------------
! sim catalogue index
!-----------------------------------------------------------

! target location:
cso.s5p.chocho.sim-catalogue-index.outdir                    :  ${my.work}/CSO-sim-catalogue/S5p/CHOCHO/${my.region}

! title:
cso.s5p.chocho.sim-catalogue-index.header                    :  CSO catalogue
! show info on created page?
cso.s5p.chocho.sim-catalogue-index.info                      :  True

! create new page for each value?
cso.s5p.chocho.sim-catalogue-index.newpage                   :  True

! content type:
cso.s5p.chocho.sim-catalogue-index.type                      :  list
! define row values:
cso.s5p.chocho.sim-catalogue-index.name                      :  date
cso.s5p.chocho.sim-catalogue-index.values                    :  TimeSeries( ${my.timerange.start}, ${my.timerange.end}, '1 day', '%Y%m%d' )

! create new page for each value:
cso.s5p.chocho.sim-catalogue-index.date.newpage              :  True
! content type:
cso.s5p.chocho.sim-catalogue-index.date.type                 :  table-row
! define row values:
cso.s5p.chocho.sim-catalogue-index.date.name                 :  time
cso.s5p.chocho.sim-catalogue-index.date.values               :  Range( 0, 23, 1, '%2.2i00' )

! content type:
cso.s5p.chocho.sim-catalogue-index.date.time.type            :  table-col
! define column values:
cso.s5p.chocho.sim-catalogue-index.date.time.name            :  var
cso.s5p.chocho.sim-catalogue-index.date.time.values          :  ${cso.s5p.chocho.sim-catalogue.vars}

! content type:
cso.s5p.chocho.sim-catalogue-index.date.time.var.type        :  img
! define image:
cso.s5p.chocho.sim-catalogue-index.date.time.var.img         :  %{date[0:4]}/%{date[4:6]}/%{date[6:8]}/S5p_CHOCHO_%{date}_%{time}_%{var}.png
cso.s5p.chocho.sim-catalogue-index.date.time.var.kwargs      :  height=300



!======================================================================
!===
!=== gridded simulated orbits
!===
!======================================================================


!-----------------------------------------------------------
! gridded orbits
!-----------------------------------------------------------

! time range:
cso.s5p.chocho.sim-gridded.timerange.start        :  ${my.timerange.start}
cso.s5p.chocho.sim-gridded.timerange.end          :  ${my.timerange.end}
! create one gridded file per hour:
cso.s5p.chocho.sim-gridded.timerange.step         :  hour

! renew existing files?
cso.s5p.chocho.sim-gridded.renew                  :  True
!cso.s5p.chocho.sim-gridded.renew                  :  False

! target directory, incl. subdir for resolution and filters:
my.sim-gridded.dir                              :  ${my.work}/CSO-sim-gridded/${my.region}__r01x01__qa08

!~

! testing ..
my.gridded.region                           :  ${my.region}
! grid definition:
!!~ same as pixel selection on conversion:
!cso.s5p.chocho.sim-gridded.grid.west              :  ${my.region.west}
!cso.s5p.chocho.sim-gridded.grid.east              :  ${my.region.east}
!cso.s5p.chocho.sim-gridded.grid.south             :  ${my.region.south}
!cso.s5p.chocho.sim-gridded.grid.north             :  ${my.region.north}
!~ observation operator tutorial:
cso.s5p.chocho.sim-gridded.grid.west              :  -10
cso.s5p.chocho.sim-gridded.grid.east              :   30
cso.s5p.chocho.sim-gridded.grid.south             :   35
cso.s5p.chocho.sim-gridded.grid.north             :   65
! resolution:
cso.s5p.chocho.sim-gridded.grid.dlon              :  0.1
cso.s5p.chocho.sim-gridded.grid.dlat              :  0.1

! level of recursive splitting of footprint into triangles,
! and assignment of centroids to grid cells;
! for 4-corner footprints, number of centroids is:
!  1 (levels=0), 4 (1), 8 (2), 16 (3), 64 (5), 256 (7)
cso.s5p.chocho.sim-gridded.mapping.levels         :  5

!~

! keywords for source files; 
! the first one should have the footprints:
cso.s5p.chocho.sim-gridded.sources                :  data state

! input files for each source type:
cso.s5p.chocho.sim-gridded.source.data.filenames    :  ${my.work}/CSO-oper/CSO_output_%Y%m%d_%H%M_data.nc
cso.s5p.chocho.sim-gridded.source.state.filenames   :  ${my.work}/CSO-oper/CSO_output_%Y%m%d_%H%M_state.nc

!~

! keywords for filters:
cso.s5p.chocho.sim-gridded.filters                  :  quality

! minimum quality value required:
cso.s5p.chocho.sim-gridded.filter.quality.var       :  qa_value
cso.s5p.chocho.sim-gridded.filter.quality.type      :  min
cso.s5p.chocho.sim-gridded.filter.quality.min       :  0.8
cso.s5p.chocho.sim-gridded.filter.quality.units     :  1
        
!~

! target file, might contain templates:
!   %Y,%m,etc     : time values
!   %{basename}   : basename (without extension) of first source file
cso.s5p.chocho.sim-gridded.output.file              :  ${my.sim-gridded.dir}/%Y/%m/CSO_output_%Y%m%d_%H%M_gridded.nc

! pack variables on output:
cso.s5p.chocho.sim-gridded.output.packed            :  True
! zlib compression level, 0 for no compression:
cso.s5p.chocho.sim-gridded.output.complevel         :  1

! data variables to be created:
cso.s5p.chocho.sim-gridded.output.vars              :  yr ys yr_m ys_m

! input variables:
!   data:yr    : from data file
!   state:ys    : from state file
cso.s5p.chocho.sim-gridded.output.yr.source         :  data:yr
cso.s5p.chocho.sim-gridded.output.ys.source         :  state:ys
cso.s5p.chocho.sim-gridded.output.yr_m.source       :  state:yr_m
cso.s5p.chocho.sim-gridded.output.ys_m.source       :  state:ys_m


!-----------------------------------------------------------
! catalogue of gridded simulations
!-----------------------------------------------------------

! time range:
cso.s5p.chocho.sim-gridded-catalogue.timerange.start        :  ${my.timerange.start}
cso.s5p.chocho.sim-gridded-catalogue.timerange.end          :  ${my.timerange.end}
! hourly fields:
cso.s5p.chocho.sim-gridded-catalogue.timerange.step         :  hour

! renew existing files?
cso.s5p.chocho.sim-gridded-catalogue.renew                  :  True
!cso.s5p.chocho.sim-gridded-catalogue.renew                  :  False

! input files:
cso.s5p.chocho.sim-gridded-catalogue.input.file             :  ${my.sim-gridded.dir}/%Y/%m/CSO_output_%Y%m%d_%H%M_gridded.nc
!!~ idem for daily average:
!cso.s5p.chocho.sim-gridded-catalogue.input.file             :  ${my.sim-gridded.dir}/CSO_output_%Y%m%d_aver_gridded.nc

! target files, time tempates and variable name are replaced:
cso.s5p.chocho.sim-gridded-catalogue.output.file            :  ${my.sim-gridded.dir}/catalogue/%Y/%m/%d/S5p_CHOCHO_%Y%m%d_%H%M_gridded_%{var}.png
!!~ idem for daily average:
!cso.s5p.chocho.sim-gridded-catalogue.output.file            :  ${my.sim-gridded.dir}/catalogue/%Y/%m/%d/S5p_CHOCHO_%Y%m%d_aver_gridded_%{var}.png

! figure size (inches), default is (8,6):
cso.s5p.chocho.sim-gridded-catalogue.figsize                :  (6,6)

! variables to be plotted:
cso.s5p.chocho.sim-gridded-catalogue.vars                   :  yr ys yr_m ys_m

! variable:
cso.s5p.chocho.sim-gridded-catalogue.var.yr.source          :  yr
! convert units:
cso.s5p.chocho.sim-gridded-catalogue.var.yr.units           :  umol/m2
! style:
cso.s5p.chocho.sim-gridded-catalogue.var.yr.vmin            :   0.0
cso.s5p.chocho.sim-gridded-catalogue.var.yr.vmax            : 100.0

! variable:
cso.s5p.chocho.sim-gridded-catalogue.var.ys.source          :  ys
! convert units:
cso.s5p.chocho.sim-gridded-catalogue.var.ys.units           :  umol/m2
! style:
cso.s5p.chocho.sim-gridded-catalogue.var.ys.vmin            :   0.0
cso.s5p.chocho.sim-gridded-catalogue.var.ys.vmax            : 100.0

! variable:
cso.s5p.chocho.sim-gridded-catalogue.var.yr_m.source        :  yr_m
! convert units:
cso.s5p.chocho.sim-gridded-catalogue.var.yr_m.units         :  umol/m2
! style:
cso.s5p.chocho.sim-gridded-catalogue.var.yr_m.vmin          :   0.0
cso.s5p.chocho.sim-gridded-catalogue.var.yr_m.vmax          : 100.0

! variable:
cso.s5p.chocho.sim-gridded-catalogue.var.ys_m.source        :  ys_m
! convert units:
cso.s5p.chocho.sim-gridded-catalogue.var.ys_m.units         :  umol/m2
! style:
cso.s5p.chocho.sim-gridded-catalogue.var.ys_m.vmin          :   0.0
cso.s5p.chocho.sim-gridded-catalogue.var.ys_m.vmax          : 100.0



!-----------------------------------------------------------
! gridded catalogue index
!-----------------------------------------------------------

! target location:
cso.s5p.chocho.sim-gridded-catalogue-index.outdir                    :  ${my.sim-gridded.dir}/catalogue

! title:
cso.s5p.chocho.sim-gridded-catalogue-index.header                    :  CSO catalogue
! show info on created page?
cso.s5p.chocho.sim-gridded-catalogue-index.info                      :  True

! create new page for each value?
cso.s5p.chocho.sim-gridded-catalogue-index.newpage                   :  True

! content type:
cso.s5p.chocho.sim-gridded-catalogue-index.type                      :  list
! define row values:
cso.s5p.chocho.sim-gridded-catalogue-index.name                      :  date
cso.s5p.chocho.sim-gridded-catalogue-index.values                    :  TimeSeries( ${my.timerange.start}, ${my.timerange.end}, '1 day', '%Y%m%d' )

! create new page for each value:
cso.s5p.chocho.sim-gridded-catalogue-index.date.newpage              :  True
! content type:
cso.s5p.chocho.sim-gridded-catalogue-index.date.type                 :  table-row
! define row values:
cso.s5p.chocho.sim-gridded-catalogue-index.date.name                 :  time
cso.s5p.chocho.sim-gridded-catalogue-index.date.values               :  Range( 0, 23, 1, '%2.2i00' )

! content type:
cso.s5p.chocho.sim-gridded-catalogue-index.date.time.type            :  table-col
! define column values:
cso.s5p.chocho.sim-gridded-catalogue-index.date.time.name            :  var
cso.s5p.chocho.sim-gridded-catalogue-index.date.time.values          :  ${cso.s5p.chocho.sim-gridded-catalogue.vars}

! content type:
cso.s5p.chocho.sim-gridded-catalogue-index.date.time.var.type        :  img
! define image:
cso.s5p.chocho.sim-gridded-catalogue-index.date.time.var.img         :  %{date[0:4]}/%{date[4:6]}/%{date[6:8]}/S5p_CHOCHO_%{date}_%{time}_gridded_%{var}.png
cso.s5p.chocho.sim-gridded-catalogue-index.date.time.var.kwargs      :  height=300


!======================================================================
!===
!=== end
!===
!======================================================================


