tactus.tasks package
Tasks submodule.
Submodules
tactus.tasks.addpert module
Addpert.
tactus.tasks.archive module
ARCHIVEHOUR // ARCHIVESTATIC.
- class ArchiveFDB(config)[source]
Bases:
ArchiveTaskArchving task for time dependent data dedicated for FDB.
- class ArchiveHour(config)[source]
Bases:
ArchiveTaskArchving task for time dependent data.
- class ArchiveMergedSQLites(config)[source]
Bases:
ArchiveTaskArchving task for time dependent data.
- class ArchiveStatic(config)[source]
Bases:
ArchiveTaskArchving task for static data.
- class ArchiveStaticMember(config)[source]
Bases:
ArchiveTaskArchving task for static data.
tactus.tasks.base module
Base site class.
- class Task(config, name)[source]
Bases:
objectBase Task class.
- archive_logs(files, target=None)[source]
Archive files in a log directory.
- Parameters:
files (str,list) – File(s) to be archived
target (str) – Target directory for archiving
- get_binary(binary_name, task_name=None)[source]
Determine binary path from task or system config section.
- Parameters:
binary_name (str) – Name of binary
task_name (str, Optional) – Optional name for task specific setting
- Returns:
full path to binary
- Return type:
bindir (str)
- get_task_setting(setting)[source]
Get task setting.
- Parameters:
setting (str) – Setting to find in task.{self.name}
- Returns:
Found setting
- Return type:
value
tactus.tasks.batch module
Batch process.
- class BatchJob(rte, wrapper='')[source]
Bases:
objectBatch job.
- run(cmd, logfile=None)[source]
Run command.
- Parameters:
cmd (str) – Command to run.
logfile (io.IOBase, str, optional) – Object to tee stdout into in addition to sys.stdout (e.g. open(“oops.log”, “a”)). If a string is given it will be used as a file name.
- Raises:
TypeError – Checks if cmd is of type str
ValueError – If logfile is not a open file handle
CalledProcessError – Execution error
tactus.tasks.bator module
Bator task — ODB subbase creation via the BATOR binary.
- class Bator(config)[source]
Bases:
OdbIngestionTaskRun BATOR for one observation type to produce an ECMA ODB subbase.
tactus.tasks.boundaries module
Boundary interpolation.
- class C903(config)[source]
Bases:
InterpolateBoundariesE927.
- class E927(config)[source]
Bases:
InterpolateBoundariesE927.
tactus.tasks.c903light module
C903Light.
tactus.tasks.canari module
Canari.
tactus.tasks.cleaning_tasks module
Clean tactus file systems.
tactus.tasks.collectlogs module
CollectLogs.
- class CollectLogs(config, config_label='staticlogs')[source]
Bases:
TaskCollect task and scheduler logfiles and store them as tarfiles.
- scan_logs(tarlog, parent, target, pattern='', exclude='')[source]
Search for files matching a pattern and add them to a tar file.
- Parameters:
tarlog (tarfile object) – Tar file used
parent (str) – Top search directory
target (str) – Main search directory
pattern (str) – Optional search pattern
exclude (str) – Optional string for files to be excluded
- Raises:
FileNotFoundError – If parent directory does not exist
- class CollectLogsHour(config)[source]
Bases:
CollectLogsCollectlog task for static data.
- class CollectLogsStatic(config)[source]
Bases:
CollectLogsCollectlog task for static data.
tactus.tasks.compilation module
Compialtion tasks.
- class TactusBundleBuild(config)[source]
Bases:
Tasktactus bundle build.
- get_install_subpath()[source]
Build install subpath by using the location of the env.sh file.
The arch build directory (
<bundle_dir>/source/arch/<arch>) may contain adefaultsymlink pointing at the actual build used, e.g. one selected by ecbundle based on compiler/toolchain. When that symlink exists, it is resolved and the path components coming after the arch directory name are returned, giving the subpath under which the build was actually installed (e.g.<toolchain>/<build_type>). When there is no such symlink, the subpath is empty (.), meaning installs go directly under the arch directory.- Returns:
- Subpath (relative to the arch directory) to append to
the install/build directories.
- Return type:
Path
tactus.tasks.creategrib module
CreateGrib.
- class GlGrib(config, name='')[source]
Bases:
TaskCreate grib files.
- convert2grib(infile, outfile, filetype)[source]
Convert FA to grib.
Namelist arguments are given in the creategrib.NAME config part per filetype :param infile: Input file :type infile: str :param outfile: Output file :type outfile: str :param filetype: filetype to look for in rules :type filetype: str
- Raises:
FileNotFoundError – Could not find file
tactus.tasks.discover_task module
Discover tasks.
- add_plugins_to_sys_path(reg: TactusPluginRegistry) None[source]
Add plugin root paths to
sys.pathso their task modules can be imported.Each plugin whose
tasks_pathexists is inserted at the front ofsys.path(if not already present), making the plugin’s packages importable by their fully-qualified module names.- Parameters:
reg (TactusPluginRegistry) – Registry of active tactus plugins.
- available_tasks(reg: TactusPluginRegistry)[source]
Create a list of available tasks.
- Parameters:
reg (TactusPluginRegistry) – tactus plugin registry
- Returns:
Task objects
- Return type:
known_types (list)
- create_task_index(config)[source]
Create a task index file.
- Parameters:
config (ConfigParse) – Config
- Returns:
Dict of known tasks, and their location
- Return type:
known_types(dict)
- discover(package, base)[source]
Discover task classes.
Plugin classes are discovered in a given namespace package, deriving from a given base class. The base class itself is ignored, as are classes imported from another module (based on
cls.__module__). Each discovered class is identified by the class name by changing it to lowercase and stripping the name of the base class, if it appears as a suffix.- Parameters:
package (types.ModuleType) – Namespace package containing the plugins
base (type) – Base class for the plugins
- Returns:
type): Discovered plugin classes
- Return type:
(dict of str
- discover_modules(package, what='plugin')[source]
Discover plugin modules.
- Parameters:
package (types.ModuleType) – Namespace package containing the plugins
what (str, optional) – String describing what is supposed to be discovered. Defaults to “plugin”.
- Yields:
tuple – str: Name of the imported module types.ModuleType: The imported module
- get_task(name, config) Task[source]
Create a tactus.tasks.Task object from configuration.
- Parameters:
name (_type_) – _description_
config (_type_) – _description_
- Returns:
The task object with name name. The task object has to be a subclass of Task to be retrievable.
- Return type:
- Raises:
NotImplementedError – If task name is not amongst the known task names.
tactus.tasks.e923 module
E923.
- class E923(config, taskname=None)[source]
Bases:
TaskMethods for the e923 work.
- constant_part(constant_file)[source]
Run the constant part of e923.
- Parameters:
constant_file – filename of the resulting file
- execute_part(part_nr: int, month: int | None = None)[source]
Generates namelist for E923 part and execute binary.
- Parameters:
part_nr – the number of the E923 part to execute
month – (optional) month number
- link_data_files(label: int | str, month: int | None = None, gunzip_flags: str | None = '') List[str][source]
Link/copy input files for E923 part.
- Parameters:
label – dataset label in input_data (or integer to get related part)
month – month number
gunzip_flags – Flags passed to gunzip when decompressing compressed (
*.Z) files
- Returns:
List of files where links can be removed for cleanup
- monthly_part(constant_file)[source]
Run the monthly part of e923.
- Parameters:
constant_file – filename of the input constant file
tactus.tasks.e923_update module
E923Update.
tactus.tasks.forecast module
Forecast.
- class Forecast(config)[source]
Bases:
PySurfexBaseTaskForecast task.
- accelerator_device_input()[source]
Copy the input files for GPU execution.
parallel_method: input file with parallelisation technique for each algorithm
synchost: input file defining optional device-to-host memory transfers
select_gpu: wrapper file for sbatch, binding GPU to MPI rank
- archive_output(filetype, periods)[source]
Archive forecast model output.
- Parameters:
filetype (str) – Filename template
periods (str) – Output list
- merge_output(filetype, periods)[source]
Merge distributed forecast model output.
- Parameters:
filetype (str) – File type (history, surfex, fullpos)
periods (str) – Output list
Final result is the expected output file name in the working directory (as if there was no IO server). NOTE: This function has been replaced by io_merge tasks. It is only called if n_io_merge=0.
tactus.tasks.generatewfptabfile module
Task to generate location/turbine tab-files as input for windfarm parameterization.
tactus.tasks.glbd module
GlBd.
tactus.tasks.gribmodify module
AddCalculatedFields.
- class AddCalculatedFields(config)[source]
Bases:
TaskCreate grib files.
- add_field_to_grib(fnames, params, operation, output_params, layer_weights, physical_range)[source]
Add fields to the same grib following specified modification.
- Parameters:
fnames (list) – list of grib files
params (list) – list of parameter dictionaries of input parameters
operation (str) – operation to compute new field
output_params (dict) – list of parameter dictionaries of output parameters
layer_weights (dict) – dict of level weights with level numbers as keys
physical_range (list) – list of physical range for each parameter
- Raises:
NotImplementedError – Operation not implemented yet”
- calc_patch_averaging(params, layer_weights, values_list, bitmap_list, physical_range, nature_weighting)[source]
Calculate patch averaging.
Bitmaps are used to mask out invalid values. This is necessary, as the values for a parameter may be missing in some tiles despite the fact that the tile fraction is not 0. This is solved by updating the layer weights to always sum to 1 while excluding missing data.
- find_in_files(param, fname, additional_files)[source]
Check if field with specified parameters exists.
Checks the main file and all additional files.
- Parameters:
param – parameter dictionary,
fname – main grib file
additional_files – list of additional grib files
- Returns:
True if field exists in any file
- Return type:
bool
- find_par(param, fname)[source]
Check if field with specified parameters already exists in grib.
- Parameters:
param – parameter dictionary,
fname – grib file
- Returns:
True if field exists
- Return type:
bool
- get_unique_values(dicts, key, exclude=None)[source]
Get unique values of a key in a list of dictionaries.
- get_value_for_params(params, match_dict, values_list, bitmap_list, apply_bitmap=False, return_bitmap=False)[source]
Get the index of the dict in the list that matches all key-value pairs.
tactus.tasks.interpolsstsic module
InterpolSstSic.
tactus.tasks.iomerge module
IO merge task.
- class IOmerge(config)[source]
Bases:
TaskIO merge task.
- check_fc_path()[source]
Check if fc_path exists.
- Raises:
FileNotFoundError – If directory is not present
- merge_output(lt, filetype)[source]
Merge distributed forecast model output.
- Parameters:
lt (timeDelta) – lead time
filetype (str) – Type of file
- static wait_for_file(filename, age_limit=15)[source]
Wait until a file is at least N seconds old.
- Parameters:
filename (str) – full path to file
age_limit (int) – minimum age of last modification
- wait_for_io(filetype, lt, maxtries=2)[source]
Wait for all io_server output to be stable.
- Parameters:
filetype (str) – kind of output file
lt (timeDelta) – lead time
maxtries (int) – maximum number of file search trials
- Returns:
List of files expected
- Return type:
file_list (list)
- Raises:
RuntimeError – In case of erroneous number of files
tactus.tasks.marsprep module
Marsprep.
- class Marsprep(config)[source]
Bases:
TaskMarsprep task.
- execute()[source]
Run task.
Define run sequence.
- Raises:
RuntimeError – If there is an issue with the work folder.
- get_bdmember_fetch_list(bddir: str, bdfile: str)[source]
Builds the list of missing files to fetch from MARS.
- get_geopotential_latlon(first_member, bdmember_list)[source]
Get geopotential in lat/lon.
- Parameters:
first_member (int) – First bdmember in ensemble
bdmember_list (List[int]) – Members to fetch data for
- get_gg_data(tag: str, steps: List[int], members_dict: Dict[str, List[int]])[source]
Get gridpoint surface data.
- get_gg_snow_data(tag: str, steps: List[int], members_dict: Dict[str, List[int]], param)[source]
Get soil gridpoint data.
- get_lat_lon_data(bdmember_list: List[int])[source]
Get Lat/Lon data.
- Parameters:
bdmember_list (List[int]) – Members to fetch data for
- get_lat_lon_sst_data(missing_steps_per_member: Dict[int, List[int]], members_dict: Dict[str, List[int]])[source]
Get lat/lon data for sst.
- get_sh_temperature_data(tag: str, steps: List[int], members_dict: Dict[str, List[int]], param)[source]
Get soil gridpoint data.
- get_ua_data(tag: str, steps: List[int], members_dict: Dict[str, List[int]])[source]
Get upper air data.
- property mars: dict
Get mars selection.
- update_data_request(request: BaseRequest, prefetch: bool, specify_domain: bool, bdmember: List[int] | None = None, grid: str | None = None, source: str | None = None, fieldset: str | None = None)[source]
Create ECMWF MARS system request.
- Parameters:
request – BaseRequest object to update
prefetch – Retrieve or stage
specify_domain – Use lat/lon and rotation or use global (default)
bdmember – Boundary members to retrieve in case of eps.
grid – Specific grid for some request. Default None.
source – Sorce for retrieve data from disk. Defaults None.
fieldset – Name of fieldset. Defaults None.
tactus.tasks.obs_ingestion module
Shared base for ODB observation-ingestion tasks (Bator, Obsconvert).
tactus.tasks.obsconvert module
Obsconvert task — ODB subbase creation via the OBSCONVERT binary.
- class Obsconvert(config)[source]
Bases:
OdbIngestionTaskRun OBSCONVERT for one observation type to produce an ECMA ODB subbase.
tactus.tasks.obsprep module
Observation preparation task.
Observation provider selection
da.obs_provider names the active provider convention. All provider
definitions live in configuration under da.providers.<name>:
e.g. obs_provider = “LACE”
Multi-file merging
All candidates found in the archive are merged into a single file per obs type.
BUFR / GRIB: files are concatenated byte-for-byte.
OBSOUL: files are merged via
obsoul_merge.pl(configured viada.obsoul_merge_script).NETCDF: only the first file is used; a warning is issued when more than one is found.
HDF: No merging performed - radar files should be linked as site${i}
Temporal windowing
obs_step in the active provider block (minutes, default 0 = disabled)
activates collection across multiple slots within the assimilation window.
When enabled, ObsPrep computes the slots covered by
[basetime + window_shift, basetime + window_shift + window_len] and
searches each slot’s date directory.
Example: basetime 00 UTC, window_shift=-90 min, window_len=180 min → slots 23, 00, 01 should be searched (three different hours, possibly across two calendar dates).
- class ObsPrep(config)[source]
Bases:
TaskObservation-preparation task.
Supported families as defined by da_stream: -
surfacestages only surface (SYNOP) observations for surface assimilation -upper_airstages all configured obs types for upper_air- DEFAULT_OBS_3DVAR = ['synop', 'gpssol', 'amdar', 'geowind', 'hrwind', 'temp', 'wp', 'seviri', 'amsua', 'amsub', 'iasi', 'ascat', 'radar']
- DEFAULT_OBS_SURFACE = ['synop']
- execute()[source]
Stage observation files and write obstypes availability list.
For each obs type, collects all matching files from all archive slots within the assimilation window, merges them, and copies the result into the working directory. Writes
obstypes_YYYYMMDDRRwith the list of successfully staged types — used by the Bator tasks.
tactus.tasks.odbmerge module
ODB merge task — merges per-obstype ECMA subbases into a single ECMA database.
Uses the SHUFFLE binary and merge_ioassign.
tactus.tasks.pertana module
Pertana.
tactus.tasks.pertsurf module
PertSurf.
tactus.tasks.prep_run module
Preparatory task for a tactus suite.
- class PrepRun(config)[source]
Bases:
TaskPreparatory run/cleaning task.
- create_famodeldefs(target_eccodes_definition_path: str)[source]
Create faModelName.def in tactus_eccodes_path.
- Parameters:
target_eccodes_definition_path (str) – Path to the where model name definitions should be created.
- Raises:
FileNotFoundError – If the source YAML file is not found.
ValueError – If the YAML file does not contain the required keys.
yaml.YAMLError – If the YAML file cannot be loaded.
tactus.tasks.serial module
Serial task.
tactus.tasks.sfx module
Surfex tasks.
- class Pgd(config)[source]
Bases:
PySurfexBaseTaskTask.
- class PgdFilterTownFrac(config)[source]
Bases:
TaskPgdFilterTownFrac.
Reduce Town frac in Pgd file made with eccoclimapII.
- class Prep(config)[source]
Bases:
PySurfexBaseTaskPrep.
tactus.tasks.sqlite module
ExtractSQLite.
tactus.tasks.toposoil module
Topography and SOILGRID data preparation tasks.
- class Soil(config)[source]
Bases:
TaskPrepare soil data task for PGD.
- static check_domain_validity(domain_properties: dict) None[source]
Check if domain is valid.
- Parameters:
domain_properties (dict) – Dict with domain properties
- Raises:
ValueError – If domain is outside soilgrid data area
- static coordinates_for_cutting_dataset(domain_properties: dict, halo: float = 5.0) tuple[source]
Get coordinates for cutting dataset.
- Parameters:
domain_properties (dict) – Dict with domain properties
halo (float) – Halo. Defaults to 5.0.
- Returns:
Coordinates for cutting dataset
- Return type:
tuple
- execute()[source]
Run task.
Define run sequence.
- Raises:
FileNotFoundError – If no tif files are found.
- static write_soil_header_file(header_file, soiltype, hdr_north, hdr_south, hdr_west, hdr_east, hdr_rows, hdr_cols, nodata=0, bits=8, write_fact=False, fact=10) None[source]
Write header file.
- Parameters:
header_file (str) – Header file
soiltype (str) – Soil type
hdr_north (float) – North
hdr_south (float) – South
hdr_west (float) – West
hdr_east (float) – East
hdr_rows (int) – Number of rows
hdr_cols (int) – Number of columns
nodata (int) – No data value. Defaults to 0.
bits (int) – Number of bits. Defaults to 8.
write_fact (bool) – Write factor. Defaults to False.
fact (int) – Factor. Defaults to 10
- class Topography(config)[source]
Bases:
TaskTopography data preparation.
- define_gmted_input(domain_properties: dict) tuple[source]
Define GMTED input files.
- Parameters:
domain_properties (dict) – Domain properties
- Returns:
GMTED input files
- Return type:
tuple
- gmted_header_coordinates(east: float, west: float, south: float, north: float) tuple[source]
Get GMTED header coordinates.
- Parameters:
east (float) – East
west (float) – West
south (float) – South
north (float) – North
- Returns:
Header coordinates
- Return type:
tuple
- static tif2bin(gd, bin_file) None[source]
Convert tif file to binary file used by surfex.
- Parameters:
gd – gdal dataset
bin_file (str) – Binary file
- static write_gmted_header_file(header_file, hdr_north, hdr_south, hdr_west, hdr_east, hdr_rows, hdr_cols) None[source]
Write header file.
- Parameters:
header_file (str) – Header file
hdr_north (float) – North
hdr_south (float) – South
hdr_west (float) – West
hdr_east (float) – East
hdr_rows (int) – Number of rows
hdr_cols (int) – Number of columns