Skip to content
Snippets Groups Projects
Commit a693fd8a authored by Frisinghelli Daniel's avatar Frisinghelli Daniel
Browse files

Adjusted constant parameters.

parent 40ee4efa
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ import pathlib
# locals
from climax.core.constants import (CORDEX_VARIABLES, CORDEX_EXPERIMENTS,
EUROCORDEX_GCMS, EUROCORDEX_RCMS,
CDO_RESAMPLING_MODES)
CDO_RESAMPLING_MODES, ERA5_VARIABLES)
# epilogue to display at the end of each parser
EPILOGUE = 'Author: Daniel Frisinghelli, daniel.frisinghelli@gmail.com'
......@@ -20,8 +20,8 @@ EPILOGUE = 'Author: Daniel Frisinghelli, daniel.frisinghelli@gmail.com'
LOGGER = logging.getLogger(__name__)
# parser to preprocess Cordex data: climax.main.preprocess.py
def preprocess_parser():
# parser to preprocess Cordex data: climax.main.preprocess_CORDEX.py
def preprocess_cordex_parser():
# define command line argument parser
parser = argparse.ArgumentParser(
......@@ -118,3 +118,64 @@ def preprocess_parser():
.format(default)), default=None, metavar='')
return parser
# parser to preprocess ERA5 data: climax.main.preprocess_ERA5.py
def preprocess_era5_parser():
# define command line argument parser
parser = argparse.ArgumentParser(
description='Reproject and resample ERA5 data to a target grid.',
epilog=EPILOGUE,
formatter_class=lambda prog: argparse.RawDescriptionHelpFormatter(
prog, max_help_position=50, indent_increment=2))
# positional arguments
# positional argument: path to the target grid file
parser.add_argument('grid', type=pathlib.Path,
help='Path to the target grid file.')
# positional argument: path to search for Cordex NetCDF files
parser.add_argument('source', type=pathlib.Path,
help='Path to search for ERA5 NetCDF files.')
# positional argument: path to save the reprojected NetCDF files
parser.add_argument('target', type=pathlib.Path,
help='Path to save the remapped ERA5 NetCDF files.')
# optional arguments
# default values
default = '(default: %(default)s)'
# optional argument: name of the variable of interest
parser.add_argument('-var', '--variable', type=str,
help='Name of the variable of interest.',
choices=ERA5_VARIABLES, default=None, nargs='+',
metavar='')
# optional argument: resampling mode
parser.add_argument('-m', '--mode', type=str,
help='Resampling mode {}.'.format(default),
default='bilinear', choices=CDO_RESAMPLING_MODES,
metavar='')
# optional argument: whether to overwrite files
parser.add_argument('-o', '--overwrite', type=bool,
help='Overwrite existing files {}.'.format(default),
default=False, nargs='?', const=True, metavar='')
# optional argument: whether to aggregate time periods of simulations
parser.add_argument('-a', '--aggregate', type=bool,
help=('Aggregate time periods of ERA5 to a '
'single NetCDF file {}.'.format(default)),
default=False, nargs='?', const=True, metavar='')
# optional argument: dry run, print files which would be processed
parser.add_argument('-d', '--dry-run', type=bool,
help=('Print files which would be processed {}.'
.format(default)), default=False, nargs='?',
const=True, metavar='')
return parser
......@@ -30,3 +30,7 @@ EUROCORDEX_RCMS = ['SMHI-RCA4', 'CLMcom-CCLM4-8-17',
# climate data operator (cdo) resampling modes
CDO_RESAMPLING_MODES = ['bilinear', 'conservative']
# ERA5 variables to use for the downscaling
ERA5_VARIABLES = ['geopotential', 'temperature', 'u_component_of_wind',
'v_component_of_wind', 'specific_humidity']
......@@ -13,3 +13,6 @@ HERE = pathlib.Path(__file__).parent
# calibration period
P_CAL = (datetime.datetime.strptime('1970-01-01', '%Y-%m-%d').date(),
datetime.datetime.strptime('2000-01-01', '%Y-%m-%d').date())
# path to ERA5 reanalysis data
ERA5_PATH = pathlib.Path('/mnt/CEPH_PROJECTS/FACT_CLIMAX/REANALYSIS/')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment