# Copyright 2018-2024 Institute of Computer Science of the Czech Academy of
# Sciences, Prague, Czech Republic. Authors: Pavel Krc, Martin Bures, Jaroslav
# Resler.
#
# This file is part of PALM-METEO.
#
# PALM-METEO is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# PALM-METEO is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# PALM-METEO. If not, see <https://www.gnu.org/licenses/>.


# ATTENTION: This file is part of program code. It stores inital values for
# configuration of core variables. It is not intended to be used as a user
# configuration file or a template thereof.

case: #case name (required)
# Optional scenario identification (for preparing multiple scenarios based on
# the same case)
scenario:
dnum: 1 #1 for root domain, 2 for nested domain *_N02 etc.

# Replacement strings to be used in paths. They are valid Python expressions
# and they may reference configuration values such as `dnum` or `scenario`.
path_strings:
    case: 'case'
    scenario: 'f"_{scenario}" if scenario else ""'
    domain: 'f"_N{dnum:02d}" if dnum != 1 else ""'

# All paths are either absolute or relative to paths.base. They may contain
# references to entries in path_strings
paths:
    base: '../JOBS/{case}{scenario}'

    palm_input:
        dynamic_driver: 'INPUT/{case}_dynamic{domain}'
        static_driver:  'INPUT/{case}_static{domain}'

    intermediate:
        import_data: 'METEO/import{domain}.nc'
        hinterp:     'METEO/hinterp{domain}.nc'
        vinterp:     'METEO/vinterp{domain}.nc'

    # Pickle file paths for snapshots. If they end with .zst, they will be
    # compressed (requires pyzstd OR python>=3.14).
    snapshot:
        setup_model:  'METEO/setup{domain}.pickle.zst'
        import_data:  'METEO/import{domain}.pickle.zst'
        hinterp:      'METEO/hinterp{domain}.pickle.zst'
        vinterp:      'METEO/vinterp{domain}.pickle.zst'

output:
    # Overwrite existing output files? Otherwise create a new file with
    # numerical suffix
    overwrite: false

    geostrophic_wind: false #not available with all plugins

    # LODs for output variables:
    # LOD2 = 3D data (unchanged, default),
    # LOD1 = vertical profile (via horizontal averaging).
    lod:
        pt: 2
        qv: 2
        uvw: 2

    default_precision: 'f4'
    fill_value: -9999.0

    check_mass_balance: false #re-verify final mass balance after balancing

intermediate_files:
    #netcdf_compression: ~ #TODO
    #netcdf_complevel: 4
    pickle_protocol: 5

    #after a successful stage, delete the intermediate file from the previous stage
    delete_after_success: false

domain:
    dz: #default=dx
    nz: #required
    dz_stretch_level: -1.0 #in metres
    dz_stretch_factor: 1.0
    dz_max: -1.0 #in metres

    # Check minimum number of free surface canopy layers above the top of
    # terrain, buildings and plant canopy
    nscl_free: 3

    # Ignore buildings in the static driver (for nscl_free and wind damping)
    ignore_buildings: false

    proj_palm: 'EPSG:32633' #reference coordinate system of PALM simulation
    proj_wgs84: 'EPSG:4326' #projection lon-lat

simulation:
    origin_time: #default: read from static driver
    timestep: 1 h
    length: 1 d

    timestep_rad: auto # default: detect from input files (if possible)
    #timestep_rad: 10 m # explicit

#Off by default (empty so that tasks may overwrite), switched on by tasks or manually
radiation:

chem_species: [] #empty list = disabled chemistry

chem_units:
    targets:
        ppmv: 'ppm'
        kgm3: 'kg/m3'
    regexes:
        ppmv: '^ppmv?$'
        ppbv: '^ppbv?$'
        ugm3: '^(micrograms?|[uµ]g)\s*(m(et(re|er)s?)?\s*\^?\s*-3|/\s*m(et(re|er)s?)?\s*\^?\s*3)\s*$'
        gm3:  '^g(rams?)?\s*(m(et(re|er)s?)?\s*\^?\s*-3|/\s*m(et(re|er)s?)?\s*\^?\s*3)\s*$'
        kgm3: '^(kilograms?|kg)\s*(m(et(re|er)s?)?\s*\^?\s*-3|/\s*m(et(re|er)s?)?\s*\^?\s*3)\s*$'

hinterp:
    validate: false
    max_input_grid_error: 0.01

vinterp:
    # Smoothing of PALM terrain for WRF vertical interpolation to avoid sharp
    # horizontal gradients. Sigma value in grid points.
    terrain_smoothing: off

    # Upper limit of vertical adaptation for terrain matching
    # [metres above highest obstacles]
    transition_level: 300.0

    # code used for the interpolation
    interpolator: prepared  #pure-Python interpolator with prepared weights (default)
    #interpolator: metpy     #legacy interpolator from the MetPy library (slow)
    #interpolator: fortran   #Fortran-based interpolator (fastest, must be compiled using f2py)

    wind_power_law: false #off by default
    #wind_power_law: 0.143

postproc:
    nox_post_sum: false

verbosity: 1 #can be overwritten by command-line switches -v (=2) or -s (=0)
log_datetime: true #prepend each log message with date+time

# The complete workflow - do not change!
full_workflow:
    - check_config
    - setup_model
    - import_data
    - hinterp
    - vinterp
    - write

# Workflow: optionally select a subset of stages
workflow: ~

# Ordered list of selected plugins. Typically extended by selected tasks.
plugins:
    - palmmeteo_stdplugins.setup_staticdriver.StaticDriverPlugin
    - palmmeteo_stdplugins.setup.SetupPlugin
    - palmmeteo_stdplugins.write.WritePlugin

# One or more tasks selected by the user will add required plugins and set
# necessary options. Tasks typically select input meteo and/or chemistry data
# sources.
tasks:
    - wrf         # WRF meteo inputs
    #- wrf_rad    # WRF radiation inputs
    #- icon       # ICON inputs
    #- aladin     # Aladin inputs
    #- aladin_rad # Aladin inputs
    #- camx       # CAMx chemistry inputs
    #- cams       # CAMS chemistry inputs
    #- synthetic  # Profiles and other synthetic inputs
    #- winddamp   # Postprocessor for wind damping near walls
