PYSURFEX documentation¶
Python API to SURFEX (pysurfex)¶
- An API in python to the external surface model SURFEX.
Prepare input and namelists to a SURFEX binary
Create atmospheric forcing for offline SURFEX runs
Read SURFEX output
Quality control of observations with titanlib
Optimal interpolation with gridpp
Monitor the observations usage
See online documentation in https://metno.github.io/pysurfex/
Installation of pregenerated packages from pypi (pip)¶
All releases will trigger an autmomatic pre-built package on pypi which can be installed by pip
pip3 install pysurfex
User installation:
pip3 install pysurfex --user
Run pysurfex from pre-built container¶
Releases also trigger an update of the pysurfex container in the github container registry. Below is an example to run pgd without any arguments.
podman run -it ghcr.io/metno/pysurfex:latest poetry run pgd
Installation on debian based Linux system¶
Install the required pacakges (some might be obsolete if the pip packages contain the needed depedencies):
sudo apt-get update
sudo apt-get install -y libudunits2-dev libproj-dev libeccodes0 libeccodes-dev libnetcdf-dev netcdf-bin ca-certificates
The following depencies are needed. Install the non-standard ones e.g. with pip or your system installation system.
General dependencies (from pypi)¶
numpy
pyproj
pyyaml
toml
f90nml
To read NetCDF files:
NetCDF4
cfunits
To read grib files:
eccodes
from ECMWF https://software.ecmwf.int/wiki/display/ECC/Releases installed with ENABLE_PYTHON=ON
To plot:
matplotlib
To get observations from frost.met.no API:
requests
For Quality control of observations
titanlib
For optimal interpolation and observation operators
gridpp
For testing:
pytest
Install pysurfex¶
Download the source code, then install pysurfex
by executing the following inside the extracted
folder:
poetry install
This will install pysurfex
in a poetry environment and this environment can be activated interactively by:
poetry shell
or
Run pysurfex client applications¶
poetry run [command]
# e.g.
poetry run python # will run python inside the pysurfex poetry environment
Run pysurfex client applications¶
import sys
from pysurfex.cli import parse_args_surfex_binary, run_surfex_binary
argv = sys.argv[1:]
kwargs = parse_args_surfex_binary(argv, "pgd")
run_surfex_binary("pgd", **kwargs)
Examples¶
Examples¶
All examples here assume you have an installation or that you have a working poetry environment.
You can use pysurfex with poetry from inside a container if you set the variable CONTAINER in the examples.
If you have a system-wide installation you can run pysurfex entry points directly:
# Run pgd entry point
pgd
# Use empty env variables in examples
export LOCAL=""
export CONTAINER=""
export POETRY=""
This is how you run the pgd entry point with poetry
# Run pgd entry point
poetry run pgd
# Use empty env variables in examples
export LOCAL=""
export CONTAINER=""
export POETRY="poetry run"
This is how to create an apptainer container on ECMWF-atos and run it.
# Load singularity/apptainer
module load apptainer/1.1.8
# First time creation
singularity pull /scratch/$USER/pysurfex.sif docker://ghcr.io/metno/pysurfex:latest
# Run pgd entry point
singularity exec /scratch/$USER/pysurfex.sif poetry run pgd
# Assume set in variables with local bindings
export LOCAL="/local/"
# X11 not working yet
# export CONTAINER="singularity exec --bind .:$LOCAL --env=QT_X11_NO_MITSHM=1 --bind=/tmp/.X11-unix:/tmp/.X11-unix:rw /scratch/$USER/pysurfex.sif"
export CONTAINER="singularity exec --bind .:$LOCAL /scratch/$USER/pysurfex.sif"
export POETRY="poetry run"
This is how to create a container with podman and run it. Podman is recommended as you can run docker containers without root/sudo.
# Run pgd entry point
podman run -it docker://ghcr.io/metno/pysurfex:latest poetry run pgd
# Assume set in a variables with local bindings
export LOCAL="/local/"
export CONTAINER="podman -v .:$LOCAL --env='DISPLAY' --env='QT_X11_NO_MITSHM=1' --volume='/tmp/.X11-unix:/tmp/.X11-unix:rw' run -it docker://ghcr.io/metno/pysurfex:latest"
export POETRY="poetry run"
Create forcing from MET-Nordic analysis¶
# Local address: /lustre/storeB/project/metproduction/products/yr_short/met_analysis_1_0km_nordic_@YYYY@@MM@@DD@T@HH@Z.nc
# Thredds: https://thredds.met.no/thredds/dodsC/metpparchivev3/@YYYY@/@MM@/@DD@/met_analysis_1_0km_nordic_@YYYY@@MM@@DD@T@HH@Z.nc
# Thredds example:
$CONTAINER $POETRY create_forcing -p https://thredds.met.no/thredds/dodsC/metpparchivev3/@YYYY@/@MM@/@DD@/met_analysis_1_0km_nordic_@YYYY@@MM@@DD@T@HH@Z.nc \
2023013010 2023013011 -d examples/domains/drammen.json -a \
--rain_converter calcrain \
--snow_converter calcsnow \
--zref screen --uref screen \
--qa_converter rh2q_mslp \
--co2 constant \
--dir_sw_converter analysis \
--sca_sw constant \
--lw_converter analysis \
--wind_converter none \
--wind_dir_converter none \
--ps_converter mslp2ps
Example on a Lambert conf proj domain
{
"nam_pgd_grid": {
"cgrid": "CONF PROJ"
},
"nam_conf_proj": {
"xbeta": 0.0,
"xlat0": 63.0,
"xlon0": 15.0,
"xrpk": 0.8910065241883678
},
"nam_conf_proj_grid": {
"nimax": 50,
"njmax": 50,
"xdx": 1000.0,
"xdy": 1000.0,
"xlatcen": 61.5,
"xloncen": 9.0
}
}
Example on a system json file for ECMWF-atos
{
"sand_dir": "/perm/sbu/soilgrid_carra2/",
"clay_dir": "/perm/sbu/soilgrid_carra2/",
"soilgrid_dir": "/perm/sbu/soilgrid_carra2/",
"soc_top_dir": "/ec/res4/hpcperm/hlam/data/climate/PGD/",
"soc_sub_dir": "/ec/res4/hpcperm/hlam/data/climate/PGD/",
"ecoclimap_cover_dir": "/ec/res4/hpcperm/hlam/data/climate/PGD/",
"ecoclimap_bin_dir": "/scratch/sbu/sfx_data/test_default/lib/offline/MY_RUN/ECOCLIMAP",
"flake_dir": "/ec/res4/hpcperm/hlam/data/climate/PGD/",
"ecoclimap_sg_cover_dir": "/ec/res4/hpcperm/hlam/data/climate/ECOCLIMAP-SG/COVER/",
"albnir_soil_dir": "/ec/res4/hpcperm/hlam/data/climate/ECOCLIMAP-SG/ALBNIR_SAT/",
"albvis_soil_dir": "/ec/res4/hpcperm/hlam/data/climate/ECOCLIMAP-SG/ALBVIS_SAT/",
"albnir_veg_dir": "/ec/res4/hpcperm/hlam/data/climate/ECOCLIMAP-SG/ALBNIR_SAT",
"albvis_veg_dir": "/ec/res4/hpcperm/hlam/data/climate/ECOCLIMAP-SG/ALBVIS_SAT/",
"tree_height_dir": "/ec/res4/hpcperm/hlam/data/climate/ECOCLIMAP-SG/HT/",
"lai_dir": "/ec/res4/hpcperm/hlam/data/climate/ECOCLIMAP-SG/LAI_SAT/",
"oro_dir": "/perm/sbu/gmted_carra2/"
}
Run SURFEX binaries¶
Assume that you have your surfex binaries in PATH and that they are called PGD, PREP, OFFLINE and SODA
Assume that you have system paths defined in a file called system.json
Assume that you have a namelist directory consistent with your SURFEX version
If you want to modify local input and run in containers you have to bind the local data to the container similar to the rte.json and system.json below.
mkdir tutorial
cd tutorial
# Example namelists
# open surfex 8.1
export NAM_DIR="examples/nam_open_surfex_8_1"
# cy43
export NAM_DIR="examples/nam_cy43_dev"
# cy46
export NAM_DIR="examples/nam_hm_cy46"
# Use only one openMP thread
export OMP_NUM_THREADS=1
# Dump environment
$CONTAINER $POETRY dump_environ -o ${LOCAL}rte.json
# Create PGD
$CONTAINER $POETRY poetry run pgd -c pysurfex/cfg/config_exp_surfex.toml -r ${LOCAL}rte.json --domain examples/domains/drammen.json -s ${LOCAL}system.json -n $NAM_DIR -o PGD.nc PGD
# Create PREP (from namelist values)
$CONTAINER $POETRY prep -c pysurfex/cfg/config_exp_surfex.toml -r ${LOCAL}rte.json --domain examples/domains/drammen.json -s ${LOCAL}system.json -n $NAM_DIR --pgd PGD.nc -o PREP.nc --prep_file ${NAM_DIR}/prep_from_namelist_values.json --prep_filetype json --dtg 2021010103 PREP
# Use forcing created above.
# Run Offline
$CONTAINER $POETRY offline -c pysurfex/cfg/config_exp_surfex.toml -r ${LOCAL}rte.json --domain examples/domains/drammen.json -s ${LOCAL}system.json -n $NAM_DIR --pgd PGD.nc --prep PREP.nc -o SURFOUT.nc OFFLINE --forcing $PWD
Plot MEPS data from thredds¶
You can plot data interpolated to surfex points using matplotlib. It is also possible to plot directly from a containes as demonstrated below.
$CONTAINER $POETRY plot_points -v air_temperature_2m -g examples/domains/drammen.json -it netcdf -i https://thredds.met.no/thredds/dodsC/meps25epsarchive/2023/04/13/meps_det_2_5km_20230413T06Z.nc -t 2023041307
Classes¶
- class pysurfex.ecoclimap.ExternalSurfexInputFile(system_file_paths)[source]¶
Wrapper around external input data to surfex.
Can have special treatment for each format. Uses internally the SystemFilePaths class
- class pysurfex.ecoclimap.EcoclimapSG(config, system_file_paths=None, veg_types=20, decades=36)[source]¶
Ecoclimap SG.
- class pysurfex.configuration.ConfigurationFromHarmonie(env, conf)[source]¶
Set the configuration from Harmonie environment.
This class sets up a SURFEX configuration from an environment based Harmonie run with it’s corresponding configuration.
Some settings imply several changes in SURFEX configuration
- class pysurfex.configuration.ConfigurationFromHarmonieAndConfigFile(env, conf_file)[source]¶
Initialize a configuration from envrionment and a toml configuration file.
- class pysurfex.configuration.ConfigurationFromTomlFile(filename)[source]¶
Configuration from a TOML file.
- class pysurfex.bufr.BufrObservationSet(bufrfile, variables, valid_dtg, valid_range, lonrange=None, latrange=None, label='bufr', use_first=False, sigmao=None)[source]¶
Create observation data set from bufr observations.
- class pysurfex.titan.FirstGuess(geo_in, fg_field, negdiff=None, posdiff=None, max_distance=5000, operator='bilinear')[source]¶
First guess check.
- class pysurfex.titan.Fraction(geo_in, fraction_field, minval=None, maxval=None, max_distance=5000, operator='bilinear')[source]¶
Fraction test.
- class pysurfex.titan.Sct(num_min=5, num_max=100, inner_radius=50000, outer_radius=150000, num_iterations=5, num_min_prof=20, min_elev_diff=200, min_horizonal_scale=10000, vertical_scale=200, pos=4, neg=8, eps2=0.5, cmin=0.9, cmax=1.1, missing_elev_to_zero=False)[source]¶
Spatial consistency check.
- class pysurfex.titan.Buddy(diff_elev_max=200000.0, adjust_for_elev_diff=True, distance_lim=1000000.0, priorities=1, buddies_min=1, thresholds=1.0, obs_to_check=1)[source]¶
Buddy test.
- class pysurfex.titan.Climatology(an_time, minval=None, maxval=None, offset=0)[source]¶
Climatology QC test.
- class pysurfex.titan.QCDataSet(analysis_time, observations, flags, lafs, providers, passed_tests=None, fg_dep=None, an_dep=None, remove_invalid_elevs=False)[source]¶
QC data set.
- class pysurfex.titan.TitanDataSet(var, settings, tests, datasources, an_time, test_flags=None)[source]¶
Titan QC data set.
- class pysurfex.titan.Departure(operator, geo, dataset, grid_values, mode, max_distance=5000)[source]¶
Departure. Difference between an observation and a value.
- class pysurfex.file.SurfexIO(filename, geo, extension)[source]¶
Abstract Surfex IO class.
Used for internal surfex file format files.
- class pysurfex.file.SurfexSurfIO(surfexfile, csurf_filetype, input_file=None, symlink=True, archive_file=None)[source]¶
Surfex surf file.
Class for surfex restart files.
- class pysurfex.file.PGDFile(csurf_filetype, cpgdfile, input_file=None, symlink=True, archive_file=None, lfagmap=False, masterodb=False)[source]¶
PGD file.
- class pysurfex.file.PREPFile(csurf_filetype, cprepfile, input_file=None, symlink=True, archive_file=None, lfagmap=False, masterodb=False)[source]¶
PREP file.
- class pysurfex.file.SURFFile(csurf_filetype, csurffile, archive_file=None, input_file=None, lfagmap=False, masterodb=False)[source]¶
SURFOUT file.
- class pysurfex.file.SurfexFileVariable(varname, validtime=None, patches=1, layers=1, basetime=None, interval=None, datatype='float', tiletype='FULL')[source]¶
Surfex Variable.
- class pysurfex.file.AsciiSurfexFile(filename, geo=None)[source]¶
Input from an ASCII surfex file (.txt).
- class pysurfex.file.FaSurfexFile(filename, geo=None, masterodb=False, lfagmap=True)[source]¶
FA surfex file.
- class pysurfex.file.SurfFileTypeExtension(csurf_filetype, masterodb=False, lfagmap=True)[source]¶
Extension of a surfex file.
- class pysurfex.file.NetCDFSurfexFile(filename, geo)[source]¶
Reading surfex NetCDF time series output.
- class pysurfex.namelist_legacy.BaseNamelist(program, config, input_path, forc_zs=False, prep_file=None, prep_filetype=None, prep_pgdfile=None, prep_pgdfiletype=None, dtg=None, fcint=3, geo=None)[source]¶
Base namelist.
- class pysurfex.namelist_legacy.Namelist(program, config, input_path, forc_zs=False, prep_file=None, prep_filetype=None, prep_pgdfile=None, prep_pgdfiletype=None, dtg=None, fcint=3, geo=None)[source]¶
Base namelist.
- class pysurfex.variable.Variable(var_type, var_dict, initial_basetime, prefer_forecast=True)[source]¶
New combined variable.
- class pysurfex.obs.ObservationSet(observations, label='', sigmao=None)[source]¶
Set of observations.
- class pysurfex.obs.NetatmoObservationSet(filenames, variable, target_time, dt=3600, re=True, lonrange=None, latrange=None, label='netatmo', sigmao=None)[source]¶
Observation set from netatmo.
- class pysurfex.obs.MetFrostObservations(varname, stations=None, level=None, num_tries=3, wmo=None, providers=None, xproviders=None, blacklist=None, validtime=None, dt=3600, lonrange=None, latrange=None, unit=None, label='frost', sigmao=None)[source]¶
Observations from MET-Norway obs API (frost).
- class pysurfex.obs.JsonObservationSet(filename, label='json', var=None, sigmao=None)[source]¶
JSON observation set.
- class pysurfex.obs.ObservationFromTitanJsonFile(an_time, filename, label='', sigmao=None)[source]¶
Observation set from titan json file.
- class pysurfex.geo.SurfexGeo(proj, lons, lats)[source]¶
Abstract surfex geometry class.
- Parameters:
ABC (_type_) – _description_
Geo (_type_) – _description_
- class pysurfex.observation.Observation(obstime, lon, lat, value, elev=nan, stid='NA', varname=None, sigmao=1.0)[source]¶
Observation class.
- class pysurfex.run.SURFEXBinary(binary, batch, iofile, settings, input_data, **kwargs)[source]¶
SURFEX binary class.
- class pysurfex.run.PerturbedOffline(binary, batch, io, pert_number, settings, input_data, surfout=None, archive_data=None, pgdfile=None, print_namelist=False, negpert=False)[source]¶
Pertubed offline.
- class pysurfex.run.Masterodb(pgdfile, prepfile, surffile, settings, input_data, binary=None, archive_data=None, print_namelist=True, batch=None)[source]¶
Masterodb.
- class pysurfex.obsoul.ObservationDataSetFromObsoul(content, an_time=None, label='', obnumber=None, obtypes=None, subtypes=None, neg_dt=None, pos_dt=None, sigmao=None)[source]¶
Observation set from obsoul file.
- class pysurfex.obsoul.ObservationDataSetFromObsoulFile(filename, an_time=None, neg_dt=None, pos_dt=None, label='', obnumber=None, obtypes=None, subtypes=None, sigmao=None)[source]¶
Observation set from obsoul file.
- class pysurfex.forcing.SurfexOutputForcing(base_time, geo, ntimes, var_objs, time_step_intervall)[source]¶
Main output class for SURFEX forcing.
- class pysurfex.forcing.NetCDFOutput(base_time, geo, fname, ntimes, var_objs, att_objs, att_time, cache, time_step, fmt='netcdf', diskless_write=False)[source]¶
Forcing in NetCDF format.
- class pysurfex.forcing.AsciiOutput(base_time, geo, fname, ntimes, var_objs, att_objs, att_time, cache, time_step)[source]¶
Forcing in ASCII format.
- class pysurfex.binary_input.InputDataFromNamelist(nml, input_data, program, platform, basetime=None, validtime=None)[source]¶
Binary input data for offline executables.
- class pysurfex.netcdf.NetCDFReadVariable(name, level=None, units=None, member=None)[source]¶
NetCDF read variable.
- class pysurfex.namelist.NamelistGenerator(program, config, definitions, assemble=None, consistency=True)[source]¶
Namelist class.
- class pysurfex.read.ConvertedInput(geo, var_name, converter)[source]¶
Converted input.
- Parameters:
geo (surfex.Geo) – Surfex geometry
var_name (str) – Variable name
converter (surfex.Converter) – Converter
- class pysurfex.read.Converter(name, initial_time, defs, conf, fileformat)[source]¶
Converter.
Main interface to read a field is done through a converter. The converter name is default “None” to read a plain field without any conversion.
- class pysurfex.pseudoobs.SentinelObservationSet(filename, validtime, fg_geo, grid_sm_fg, label='sentinel', step=2, fg_threshold=1.0)[source]¶
JSON observation set.
- class pysurfex.pseudoobs.CryoclimObservationSet(filenames, validtime, fg_geo, snow_fg, gelevs_fg, perm_snow=None, perm_snow_geo=None, slope=None, slope_geo=None, label='cryo', step=2, fg_threshold=0.4, new_snow_depth=0.1, glaf=None, laf_threshold=0.1, cryo_varname='classed_value_c')[source]¶
JSON observation set.
- class pysurfex.interpolation.ObsOperator(operator, geo, dataset, grid_values, max_distance=5000)[source]¶
Obs operator. Class to convert a field to an observation point.
- class pysurfex.platform_deps.SystemFilePaths(system_file_paths)[source]¶
Matches files and paths depending on possibly system specific settings.
User can provide a default system dir to nest dependencies.
- class pysurfex.cmd_parsing.LoadFromFile(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶
Load arguments from a file.
- class pysurfex.timeseries.TimeSeries(times, values, lons, lats, stids, stids_file=None, varname='NA')[source]¶
Time series.
- class pysurfex.timeseries.TimeSeriesFromConverter(var, geo, converter, start, end, interval=3600, cache=None, stids_file=None)[source]¶
Time-Series from a converter.
- class pysurfex.binary_input_legacy.PgdInputData(config, system_file_paths, check_existence=True)[source]¶
PGD input.
- class pysurfex.binary_input_legacy.PrepInputData(config, system_file_paths, check_existence=True, prep_file=None, prep_pgdfile=None)[source]¶
Input data for PREP.
- class pysurfex.binary_input_legacy.OfflineInputData(config, system_file_paths, check_existence=True)[source]¶
Input data for offline.
Class methods¶
- ExternalSurfexInputFile.__init__(system_file_paths)[source]¶
Construct ExternalSurfexInputFile.
- Parameters:
system_file_paths (surfex.SystemFilePaths) – Match system specific files.
- Ecoclimap.__init__(config, system_file_paths=None)[source]¶
Construct ecoclimap data object.
- Parameters:
config (surfex.Configuration) – Surfex configuration.
system_file_paths (surfex.SystemFilePaths, optional) – Mapping of local file structure to look for inut files. Defaults to None.
- Ecoclimap.set_input(check_existence=True)[source]¶
Set input.
- Parameters:
check_existence (bool, optional) – _description_. Defaults to True.
- Raises:
RuntimeError – System file path must be set for this method
- Returns:
File mappings.
- Return type:
dict
- Ecoclimap.set_bin_files(check_existence=True)[source]¶
Set bin files.
- Parameters:
check_existence (bool, optional) – Check if files exist. Defaults to True.
- Returns:
File mappings.
- Return type:
dict
- EcoclimapSG.__init__(config, system_file_paths=None, veg_types=20, decades=36)[source]¶
Construct ecoclimap SG.
- Parameters:
config (_type_) – _description_
system_file_paths (_type_, optional) – _description_. Defaults to None.
veg_types (int, optional) – _description_. Defaults to 20.
decades (int, optional) – _description_. Defaults to 36.
- EcoclimapSG.set_input(check_existence=True)[source]¶
Set input data.
- Parameters:
check_existence (bool, optional) – Check if files are existing. Defaults to True.
- Raises:
RuntimeError – System file path must be set for this method
- Returns:
Mapping of files.
- Return type:
dict
- Configuration.__init__(conf)[source]¶
Construct the pysurfex configuration.
Encapsulation of settings dictionary. Settings for a deterministic run or an individual member.
- Parameters:
conf (dict) – Actual psyurfex settings to run
- Configuration.dump_json(filename, indent=None)[source]¶
Dump configuration to json file.
- Parameters:
filename (str) – Filename
indent (int, optional) – Indentation. Defaults to None.
- Configuration.update_setting(setting, value, sep='#')[source]¶
Update the setting.
- Parameters:
setting (_type_) – _description_
value (_type_) – _description_
sep (str, optional) – _description_. Defaults to “#”.
- ConfigurationFromHarmonie.__init__(env, conf)[source]¶
Constuct the Configuration object.
- Parameters:
env (dict) – System environment e.g. os.environ
conf (dict) – The default configuration for this deterministic run/ensemble member
- Raises:
NotImplementedError – soil_texture not implemented
- ConfigurationFromHarmonieAndConfigFile.__init__(env, conf_file)[source]¶
Initialize a configuration from envrionment and a toml configuration file.
- Parameters:
env (dict) – System environment e.g. os.environ
conf_file (str) – Filename with configuration
- ConfigurationFromTomlFile.__init__(filename)[source]¶
Construct the configuration.
- Parameters:
filename (str) – File name
- static BufrObservationSet.td2rh(t_d, temp, kelvin=True)[source]¶
Convert dew point to temperature.
- Parameters:
t_d (float) – Dew point temperature
temp (float) – Temperature
kelvin (bool, optional) – Kelvin. Defaults to True.
- Raises:
RuntimeError – Dew point temperature is probably not Kelvin
RuntimeError – Temperature is probably not Kelvin
- Returns:
Relative humidity (percent)
- Return type:
float
- static BufrObservationSet.inside_window(obs_dtg, valid_dtg, valid_range)[source]¶
Check if inside window.
- Parameters:
obs_dtg (as_datetime) – Observation datetime
valid_dtg (as_datetime) – Valid datetime
valid_range (as_timedelta) – Window
- Returns:
True if inside window
- Return type:
bool
- abstract QualityControl.set_input(size)[source]¶
Set input to test.
- Parameters:
size (int) – Number of observations.
- Raises:
NotImplementedError – Must be implemented by child class.
- abstract QualityControl.test(dataset, mask, code=1)[source]¶
The quality control test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 1.
- Raises:
NotImplementedError – Must be implemented by child class.
- static QualityControl.set_flags(global_flags, flags, mask, code)[source]¶
Set flags.
- Parameters:
global_flags (list) – Global flags
flags (list) – Test flags
mask (list) – Active data
code (int) – Code to use for flagging.
- Returns:
Updated global flags.
- Return type:
list
- Plausibility.__init__(minval=None, maxval=None)[source]¶
Construct plausibility test.
- Parameters:
minval (float, optional) – Default minimum value. Defaults to None.
maxval (float, optional) – Default maximum value. Defaults to None.
- Plausibility.set_input(size, minval=None, maxval=None)[source]¶
Set input.
- Parameters:
size (size) – Observation data set size
minval (float, optional) – Minimum value. Defaults to None.
maxval (float, optional) – Maximum value. Defaults to None.
- Raises:
RuntimeError – You must set minval and maxval
- Plausibility.test(dataset, mask, code=102)[source]¶
Do the test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 102.
- Raises:
ModuleNotFoundError – titanlib was not loaded properly
- Returns:
Global flags.
- Return type:
global_flags(list)
- FirstGuess.set_input(size, posdiff=None, negdiff=None)[source]¶
Set input.
- Parameters:
size (int) – Observation data set size
posdiff (float, optional) – Positive diff. Defaults to None.
negdiff (float, optional) – Negative diff. Defaults to None.
- Raises:
RuntimeError – You must set negdiff and posdiff
- FirstGuess.test(dataset, mask, code=108)[source]¶
Do the test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 108.
- Returns:
Global flags.
- Return type:
global_flags(list)
- Raises:
ModuleNotFoundError – titanlib was not loaded properly
- Fraction.set_input(size, minval=None, maxval=None)[source]¶
Set input.
- Parameters:
size (int) – Observation set size.
minval (float, optional) – Minimum value. Defaults to None.
maxval (float, optional) – Maximum value. Defaults to None.
- Raises:
RuntimeError – You must set min and max
- Fraction.test(dataset, mask, code=151)[source]¶
Perform test.
- Parameters:
dataset (QCDataSet) – QC data set.
mask (list) – Active data
code (int, optional) – Flag. Defaults to 151.
- Returns:
Global flags.
- Return type:
global_flags(list)
- Raises:
ModuleNotFoundError – titanlib was not loaded properly
- Sct.set_input(size, neg=None, pos=None, eps2=None)[source]¶
Set input.
- Parameters:
size (int) – Observation set size.
neg (float, optional) – Minimum value. Defaults to None.
pos (float, optional) – Maximum value. Defaults to None.
eps2 (float, optional) – Epsilon 2. Defaults to None.
- Sct.test(dataset, mask, code=105)[source]¶
Do the test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 105.
- Raises:
ModuleNotFoundError – titanlib was not loaded properly
RuntimeError – Longitude is not defined!
RuntimeError – Latitude is not defined!
RuntimeError – Value is not defined!
- Returns:
Global flags.
- Return type:
global_flags(list)
- Buddy.test(dataset, mask, code=104)[source]¶
Do the test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 104.
- Raises:
ModuleNotFoundError – titanlib was not loaded properly
RuntimeError – Buddy check failed!
- Returns:
Global flags.
- Return type:
global_flags(list)
- Climatology.__init__(an_time, minval=None, maxval=None, offset=0)[source]¶
Construct test.
- Parameters:
an_time (datetime.datetime) – Analysis time
minval (float, optional) – Minimum value. Defaults to None.
maxval (float, optional) – Maximum value. Defaults to None.
offset (int, optional) – Offset. Defaults to 0.
- Climatology.set_input(size, minval=None, maxval=None, offset=None)[source]¶
Set input.
- Parameters:
size (int) – Observation set size.
minval (float, optional) – Minimum value. Defaults to None.
maxval (float, optional) – Maximum value. Defaults to None.
offset (int, optional) – Offset. Defaults to 0.
- Raises:
RuntimeError – You must set min and max values!
- Climatology.test(dataset, mask, code=103)[source]¶
Do the test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 103.
- Returns:
Global flags.
- Return type:
global_flags(list)
- Redundancy.__init__(an_time)[source]¶
Construct test.
- Parameters:
an_time (datetime.datetime) – Analysis time.
- Redundancy.test(dataset, mask, code=115)[source]¶
Do the test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 115.
- Returns:
Flags.
- Return type:
flags(list)
- Blacklist.__init__(blacklist)[source]¶
Construct test.
- Parameters:
blacklist (dict) – Blacklist positions/stids
- Raises:
RuntimeError – You must set blacklist as a dict
RuntimeError – Blacklist must have the same length for both lons and lats
- Blacklist.test(dataset, mask, code=100)[source]¶
Do the test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 100.
- Returns:
Flags.
- Return type:
flags(list)
- DomainCheck.__init__(domain_geo, max_distance=5000)[source]¶
Construct test.
- Parameters:
domain_geo (surfex.Geo) – Surfex geometry
max_distance (int, optional) – Maximum distance to grid border. Defaults to 5000.
- Raises:
RuntimeError – Domain geo was not set!
- DomainCheck.test(dataset, mask, code=199)[source]¶
Do the test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 199.
- Returns:
Flags.
- Return type:
flags(list)
- NoMeta.test(dataset, mask, code=101)[source]¶
Do the test.
- Parameters:
dataset (QCDataSet) – The data set to perform the test on.
mask (list) – Active data.
code (int, optional) – Code to use for flagging. Defaults to 101.
- Returns:
Flags.
- Return type:
flags(list)
- QCDataSet.get_stid_index(stid)[source]¶
Get station ID index.
- Parameters:
stid (str) – Station ID
- Returns:
Index to station ID.
- Return type:
int
- QCDataSet.get_pos_index(lon, lat)[source]¶
Get position index in dict.
- Parameters:
lon (float) – Longitude
lat (float) – Latitude
- Returns:
Index position if found, else None.
- Return type:
int
- abstract QCDataSet.perform_tests()[source]¶
Perform the test.
- Raises:
NotImplementedError – Must be implemented by child class.
- QCDataSet.write_output(filename, indent=None)[source]¶
Dump QC data to a json file.
- Parameters:
filename (str) – Filename
indent (int, optional) – Indentation in file. Defaults to None.
- TitanDataSet.__init__(var, settings, tests, datasources, an_time, test_flags=None)[source]¶
Titan Data set.
- Parameters:
var (str) – Variable name.
settings (dict) – Titan test/configuration settings
tests (list) – Tests to perform in order.
datasources (list) – List of observations sets.
an_time (datetime.datetime) – Analysis time
test_flags (dict, optional) – Dictionary to set custom test flags. Defaults to None.
- Raises:
ModuleNotFoundError – itanlib was not loaded properly
- Departure.__init__(operator, geo, dataset, grid_values, mode, max_distance=5000)[source]¶
Construct a departure object.
- Parameters:
operator (str) – Interpolation operator.
geo (surfex.Geo) – Surfex geometry.
dataset (QCDataSet) – QC data set.
grid_values (np.darray) – Values in the grid.
mode (str) – What kind of departure (analysis/first_guess)
max_distance (int, optional) – Max allowed deviation in meters from grid borders. Defaults to 5000.
- Raises:
NotImplementedError – Mode not implemented
- Departure.get_departure(pos=None)[source]¶
Get departure.
- Parameters:
pos (int, optional) – Position. Defaults to None.
- Returns:
Departures
- Return type:
list
- Departure.get_values(pos=None)[source]¶
Get the obs values.
- Parameters:
pos (int, optional) – Position. Defaults to None.
- Returns:
Observation equivalent of the input field.
- Return type:
float
- SurfexIO.__init__(filename, geo, extension)[source]¶
Construct a surfex IO object.
- Parameters:
filename (str) – Name of file
geo (surfex.Geometry) – Geometry
extension (str) – File extension
- abstract SurfexIO.field(var, validtime=None)[source]¶
Abstract method to read field.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
- Raises:
NotImplementedError – Must be implemented by child class.
- abstract SurfexIO.points(var, geo_out, validtime=None, interpolation='bilinear')[source]¶
Abstract method to read points.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
geo_out (surfex.Geometry) – Surfex geometry to interpolate to.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
interpolation (str, optional) – Interpolation type.. Defaults to “nearest”.
- Raises:
NotImplementedError – Must be implemented by child class.
- static SurfexIO.interpolate_field(field, geo_in, geo_out, interpolation='bilinear')[source]¶
Interpolate a field to points.
- Parameters:
field (np.darray) – Field to interpolate
geo_in (surfex.Geo) – Input geometry
geo_out (surfex.Geo) – Target geometry
interpolation (str, optional) – Interpolation type. Defaults to “bilinear”.
- Returns:
(np.array, surfex.Interpolator)
- Return type:
tuple
- AsciiSurfexFile.__init__(filename, geo=None)[source]¶
Construct the ASCII object.
- Parameters:
filename (str) – Filename
geo (surfex.geo.Geo, optional) – Geometry, Defaults to None.
- AsciiSurfexFile.get_geo()[source]¶
Get the geometry object.
- Raises:
FileNotFoundError – _description_
RuntimeError – No grid found
NotImplementedError – _description_
- Returns:
Surfex geometry
- Return type:
surfex.Geometry
- AsciiSurfexFile.read(read_par, read_tile, datatype)[source]¶
Read the file.
- Parameters:
read_par (str) – Parameter to read
read_tile (str) – Tile to read
datatype (str) – Datatype
- Raises:
NotImplementedError – Datatype not implemented
RuntimeError – Could not read datatype
- Returns:
Values read
- Return type:
numpy.array
- AsciiSurfexFile.field(var, validtime=None)[source]¶
Read a field in file.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
- Returns:
Field, surfex.Geo in read file
- Return type:
np.darray
- AsciiSurfexFile.points(var, geo_out, validtime=None, interpolation='nearest')[source]¶
Read points.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
geo_out (surfex.Geo) – Surfex geometry for points.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
interpolation (str, optional) – Interpolation type. Defaults to “nearest”.
- Returns:
Interpolated points
- Return type:
np.darray
- NCSurfexFile.__init__(filename, geo=None)[source]¶
Construct NC file object.
- Parameters:
filename (str) – File name
geo (surfex.Geo, optional) – Surfex geometry. Defaults to None.
- NCSurfexFile.get_geo()[source]¶
Get geometry in file.
- Raises:
NotImplementedError – Grid not implemented
- Returns:
Surfex geometry in file
- Return type:
surfex.Geometry
- NCSurfexFile.field(var, validtime=None)[source]¶
Read field.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
validtime (_type_, optional) – Valid time. Defaults to None.
validtime – _description_. Defaults to None.
- Raises:
RuntimeError – Mismatch in times in file and the wanted time
- Returns:
Field, surfex.Geo in read file
- Return type:
np.darray
- NCSurfexFile.points(var, geo_out, validtime=None, interpolation='nearest')[source]¶
Read points.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
geo_out (surfex.Geo) – Surfex geometry for points.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
interpolation (str, optional) – Interpolation type. Defaults to “nearest”.
- Returns:
Interpolated points
- Return type:
np.darray
- FaSurfexFile.__init__(filename, geo=None, masterodb=False, lfagmap=True)[source]¶
Construct the surfex FA file.
- Parameters:
filename (str) – File name.
geo (surfex.Geo, optional) – Surfex geometry. Defaults to None.
masterodb (bool, optional) – _description_. Defaults to False.
lfagmap (bool, optional) – _description_. Defaults to True.
- FaSurfexFile.field(var, validtime=None)[source]¶
Read field from FA file.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
- Returns:
Field, surfex.Geo in read file
- Return type:
np.darray
- FaSurfexFile.points(var, geo_out, validtime=None, interpolation='nearest')[source]¶
Read points.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
geo_out (surfex.Geo) – Surfex geometry for points.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
interpolation (str, optional) – Interpolation type. Defaults to “nearest”.
- Returns:
Interpolated points, surfex.Interpolator
- Return type:
tuple
- SurfFileTypeExtension.__init__(csurf_filetype, masterodb=False, lfagmap=True)[source]¶
Construct an extension object.
- Parameters:
csurf_filetype (str) – Surfex file type.
masterodb (bool, optional) – File created with masterodb. Defaults to False.
lfagmap (bool, optional) – File created with lfagmap=True. Defaults to True.
- NetCDFSurfexFile.__init__(filename, geo)[source]¶
Construct a NetCDF surfex time series file.
- Parameters:
filename (str) – Name of file.
geo (surfex.Geometry) – Surfex geometry for time series.
- NetCDFSurfexFile.read(var, times)[source]¶
Read a field, return a 2D array.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
times (list) – List of datetime.datetime objects
- Raises:
ValueError – times must be list or tuple
ValueError – patches must be list or tuple
ValueError – patches must be list or tuple
RuntimeError – Variable not found!
NotImplementedError – Dimension not implemented
RuntimeError – Mismatch in points
- Returns:
(np.array. surfex.Geometry)
- Return type:
(tuple)
- NetCDFSurfexFile.field(var, validtime=None)[source]¶
Read field.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
- Returns:
(np.array, surfex.Geometry)
- Return type:
tuple
- NetCDFSurfexFile.points(var, geo_out, validtime=None, interpolation='nearest')[source]¶
Read points.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
geo_out (surfex.Geometry) – Surfex geometry to interpolate to.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
interpolation (str, optional) – Interpolation type.. Defaults to “nearest”.
- Returns:
points, surfex.Interpolator
- Return type:
tuple
- TexteSurfexFile.__init__(filename, geo)[source]¶
Construct the Texte file.
- Parameters:
filename (str) – Filename
geo (surfex.Geometry) – Geometry
- TexteSurfexFile.read(variable, times)[source]¶
Read file.
- Parameters:
variable (SurfexFileVariable) – Variable in surfex file.
times (list) – List of datetime.datetime to read.
- Raises:
RuntimeError – Basetime must be set for TEXTE
RuntimeError – Interval must be set for TEXTE
RuntimeError – times must be list or tuple
RuntimeError – Dimension of domain does not match end of line
- Returns:
(np.array, surfex.Geometry)
- Return type:
tuple
- TexteSurfexFile.field(var, validtime=None)[source]¶
Read field.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
- Returns:
(np.array, surfex.Geometry)
- Return type:
tuple
- TexteSurfexFile.points(var, geo_out, validtime=None, interpolation='nearest')[source]¶
Read points.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
geo_out (surfex.Geometry) – Geometry in file.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
interpolation (str, optional) – Interpolation type. Defaults to “nearest”.
- Returns:
(np.array, surfex.Interpolator)
- Return type:
tuple
- ForcingFileNetCDF.__init__(fname, geo)[source]¶
Construct forcing netcdf file.
- Parameters:
fname (str) – File name.
geo (surfex.Geo) – Surfex input geometry.
- ForcingFileNetCDF.read_field(variable, times)[source]¶
Read file.
- Parameters:
variable (_type_) – _description_
times (_type_) – _description_
- Raises:
RuntimeError – You must set time!
RuntimeError – No points found
RuntimeError – Valid time not found in file!
- Returns:
field, geo
- Return type:
tuple
- ForcingFileNetCDF.field(var, validtime=None)[source]¶
Read field.
- Parameters:
var (_type_) – _description_
validtime (list, optional) – Validtime. Defaults to None.
- Returns:
field, geo
- Return type:
tuple
- ForcingFileNetCDF.points(var, geo_out, validtime=None, interpolation=None)[source]¶
Read points.
- Parameters:
var (SurfexFileVariable) – Variable in surfex file.
geo_out (surfex.Geo) – Surfex geometry for points.
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
interpolation (str, optional) – Interpolation type. Defaults to “nearest”.
- Returns:
Interpolated points, surfex.Interpolator
- Return type:
tuple
- BaseNamelist.prolog(check_parsing)[source]¶
Prolog.
- Parameters:
check_parsing (_type_) – _description_
- BaseNamelist.set_offline_namelist()[source]¶
Set offline namelist.
- Raises:
RuntimeError – Mismatch in nnco/cobs_m
- BaseNamelist.set_soda_namelist()[source]¶
Set SODA namelist.
- Raises:
RuntimeError – Mismatch in nnco/cobs_m/xerrobs_m
RuntimeError – You must provide a DTG when using a list for snow
RuntimeError – Mismatch in nncv/cvar_m/xsigma_m/xtprt_m
- static BaseNamelist.set_direct_data_namelist(lnamelist_section, ldtype, ldname, linput_path)[source]¶
Set direct data namelist.
- Parameters:
lnamelist_section (_type_) – _description_
ldtype (_type_) – _description_
ldname (_type_) – _description_
linput_path (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- static BaseNamelist.capitalize_namelist_dict(dict_in)[source]¶
Capitalize namelist.
- Parameters:
dict_in (dict) – _description_
- Returns:
_description_
- Return type:
_type_
- static BaseNamelist.lower_case_namelist_dict(dict_in)[source]¶
Lower case namelist.
- Parameters:
dict_in (dict) – Namelist dictionary to lower case
- Returns:
Namelist in lower case
- Return type:
dict
- static BaseNamelist.merge_namelist_dicts(old_dict, new_dict)[source]¶
Merge namelist dicts.
- Parameters:
old_dict (dict) – Old dictionary
new_dict (dict) – New dictionary
- Returns:
Merged dictionary
- Return type:
dict
- static BaseNamelist.ascii2nml(input_data)[source]¶
Convert dict to a namelist object.
- Parameters:
input_data (dict) – Namelist settings
- Returns:
Namelist object.
- Return type:
f90nml.Namelist
- static BaseNamelist.ascii_file2nml(input_fname, input_fmt='json')[source]¶
Convert a file wih namelist settings to a Namelist object.
- Parameters:
input_fname (str) – Filname
input_fmt (str, optional) – File format. Defaults to “json”.
- Returns:
Namelist object.
- Return type:
f90nml.Namelist
- static BaseNamelist.nml2ascii(input_data, output_file, output_fmt='json', indent=2)[source]¶
Dump a namelist object as a dict in a json or yaml file.
- Parameters:
input_data (f90nml.Namelist) – Namelist object.
output_file (str) – Filename
output_fmt (str, optional) – File format. Defaults to “json”.
indent (int, optional) – Indentation. Defaults to 2.
- static BaseNamelist.merge_json_namelist_file(old_dict, my_file)[source]¶
Merge json files with namelists.
- Parameters:
old_dict (dict) – Exististing settings
my_file (str) – Filename with new settings
- Raises:
FileNotFoundError – Namelist input not found
- Returns:
Merged settings.
- Return type:
dict
- Namelist.prolog(merged_dict, check_parsing=True)[source]¶
Prolog.
- Parameters:
merged_dict (dict) – Merged settings.
check_parsing (bool, optional) – Check if parsing is ok. Defaults to True.
- Returns:
Merged settings
- Return type:
merged_dict(dict)
- Namelist.prepare_offline_perturbation(merged_dict)[source]¶
Prepare for offline pertubations.
- Parameters:
merged_dict (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- Namelist.set_obs(merged_dict)[source]¶
Set obs.
- Parameters:
merged_dict (dict) – Merged settings
- Raises:
RuntimeError – Mismatch in nnco/cobs_m/xerrobs_m
- Returns:
_description_
- Return type:
_type_
- Namelist.set_soda_namelist(merged_dict)[source]¶
Set SODA namelist.
- Parameters:
merged_dict (dict) – Merged dict
- Raises:
RuntimeError – You must provide a DTG when using a list for snow
RuntimeError – Mismatch in nncv/cvar_m
RuntimeError – Mismatch in nncv/cvar_m/xsigma_m/xtprt_m
- Returns:
Merged dict.
- Return type:
dict
- static Namelist.sub(merged_dict, nam_block, key, value, vtype=None, decade=None, var=None)[source]¶
Substitute key with value.
- Parameters:
merged_dict (dict) – Merged dict
nam_block (str) – Namelist block
key (str) – Key
value (any) – Value
vtype (int, optional) – Veg type. Defaults to None.
decade (int, optional) – Decade type. Defaults to None.
var (int, optional) – Var type. Defaults to None.
- Returns:
Merged dict
- Return type:
dict
- static Namelist.delete(merged_dict, nam_block, key)[source]¶
Delete key from namelist block.
- Parameters:
merged_dict (_type_) – _description_
nam_block (_type_) – _description_
key (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- static Namelist.get_filetype_from_suffix(fname)[source]¶
Get the file type from suffix.
- Parameters:
fname (str) – File name
- Returns:
fname, format
- Return type:
tuple
- static Namelist.set_direct_data_namelist(lnamelist_section, ldtype, ldname, linput_path)[source]¶
Set direct data namelist.
- Parameters:
lnamelist_section (_type_) – _description_
ldtype (_type_) – _description_
ldname (_type_) – _description_
linput_path (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- static Namelist.capitalize_namelist_dict(dict_in)[source]¶
Capitalize namelist.
- Parameters:
dict_in (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- static Namelist.lower_case_namelist_dict(dict_in)[source]¶
Lower case namelist.
- Parameters:
dict_in (dict) – Namelist dictionary to lower case
- Returns:
Namelist in lower case
- Return type:
dict
- static Namelist.merge_namelist_dicts(old_dict, new_dict)[source]¶
Merge namelist dicts.
- Parameters:
old_dict (dict) – Old dictionary
new_dict (dict) – New dictionary
- Returns:
Merged dictionary
- Return type:
dict
- static Namelist.ascii2nml(input_data)[source]¶
Convert dict to a namelist object.
- Parameters:
input_data (dict) – Namelist settings
- Returns:
Namelist object.
- Return type:
f90nml.Namelist
- static Namelist.ascii_file2nml(input_fname, input_fmt='json')[source]¶
Convert a file wih namelist settings to a Namelist object.
- Parameters:
input_fname (str) – Filname
input_fmt (str, optional) – File format. Defaults to “json”.
- Returns:
Namelist object.
- Return type:
f90nml.Namelist
- static Namelist.nml2ascii(input_data, output_file, output_fmt='json', indent=2)[source]¶
Dump a namelist object as a dict in a json or yaml file.
- Parameters:
input_data (f90nml.Namelist) – Namelist object.
output_file (str) – Filename
output_fmt (str, optional) – File format. Defaults to “json”.
indent (int, optional) – Indentation. Defaults to 2.
- static Namelist.merge_json_namelist_file(old_dict, my_file)[source]¶
Merge json files with namelists.
- Parameters:
old_dict (dict) – Exististing settings
my_file (str) – Filename with new settings
- Returns:
Merged settings.
- Return type:
dict
- Variable.__init__(var_type, var_dict, initial_basetime, prefer_forecast=True)[source]¶
Construct variable.
- Parameters:
var_type (str) – Variable type.
var_dict (dict) – Variable definitions
initial_basetime (datetime) – Initial basetime
prefer_forecast (bool, optional) – Prefer forecasts instead of analysis. Defaults to True.
- Raises:
RuntimeError – No filepattern provided
RuntimeError – variable must have attribute
RuntimeError – You can not have larger offset than the frequency of forecasts
- Variable.get_filename(validtime, previoustime=None)[source]¶
Get the filename.
- Parameters:
validtime (datetime.datetime) – Valid time.
previoustime (datetime.datetime, optional) – Previous valid time. Defaults to None.
- Returns:
Parsed filename
- Return type:
str
- Variable.get_filehandler(validtime, cache=None, previoustime=None)[source]¶
Get the file handler.
- Parameters:
validtime (datetime.datetime) – Valid time.
cache (surfex.Cache, optional) – Cache. Defaults to None.
previoustime (datetime.datetime, optional) – Previous valid time. Defaults to None.
- Raises:
NotImplementedError – Variable type not implemented
- Returns:
Filehandler and file name
- Return type:
tuple
- Variable.read_var_field(validtime, cache=None)[source]¶
Read points for a variable.
- Parameters:
validtime (datetime.datetime) – Valid time
cache (surfex.Cache, optional) – Cache. Defaults to None.
- Returns:
A numpy array with point values for variable
- Return type:
numpy.darray
- Raises:
NotImplementedError – “Field not defined for point data”
- Variable.read_var_points(var, geo, validtime, previoustime=None, cache=None)[source]¶
Read points for a variable.
- Parameters:
var (object) – Variable object
geo (surfex.Geo) – Surfex geometry
validtime (datetime.datetime) – Valid time
previoustime (datetime.datetime, optional) – Previous valid time for accumulated variables. Defaults to None.
cache (surfex.Cache, optional) – Cache. Defaults to None.
- Returns:
A numpy array with point values for variable
- Return type:
numpy.darray
- Variable.set_var(validtime=None)[source]¶
Set the variable.
- Parameters:
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
- Raises:
NotImplementedError – Variable not implemented
RuntimeError – You must provide name
RuntimeError – grib1 needs type or levelType
- Returns:
accumulated, instant, var
- Return type:
tuple
- Variable.read_variable(geo, validtime, cache=None)[source]¶
Read the variable.
- Parameters:
geo (surfex.Geometry) – Geometry to read
validtime (datetime.datetime) – Valid time.
cache (surfex.cache) – Cache. Defaults to None
- Raises:
RuntimeError – Negative accumulated value found
- Returns:
Field read and interpolated.
- Return type:
np.darray
- Variable.deaccumulate(field, previous_field, instant)[source]¶
Deaccumulate variable.
- Parameters:
field (_type_) – _description_
previous_field (_type_) – _description_
instant (_type_) – _description_
- Raises:
RuntimeError – “Should not be negative values”
- Returns:
_description_
- Return type:
_type_
- Variable.get_basetime(validtime, previoustime=None, allow_different_basetime=False)[source]¶
Get the basetime of the file.
- Parameters:
validtime (datetime.datetime) – Valid time
previoustime (datetime.datetime, optional) – Previous valid time. Defaults to None.
allow_different_basetime (bool, optional) – Allow different base times. Defaults to False.
- Raises:
RuntimeError – “Negative offset does not make sense here”
NotImplementedError – _description_
- Returns:
Base time.
- Return type:
datetime.datetime
- Variable.rotate_geographic_wind(field, interpolator)[source]¶
Rotate wind.
- Parameters:
field (_type_) – _description_
interpolator (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- Grib.field(gribvar, time)[source]¶
Read field in grib file.
- Parameters:
gribvar (GribVariable1/2) – Grib variable to read.
time (datetime.datetime) – Valid time to read.
- Returns:
Field
- Return type:
np.ndarray
- Raises:
NotImplementedError – NotImplementedError
RuntimeError – If eccodes not available
- static Grib.read_geo_info(gid, keys)[source]¶
Set geo keys in dict.
- Parameters:
gid (int) – grib id
keys (dict) – Geometry keys
- Returns:
Geometry
- Return type:
dict
- static Grib.read_field_in_message(gid, time)[source]¶
Get field.
- Parameters:
gid (int) – grib id
time (str) – time
- Returns:
Field object
- Return type:
Field
- Grib.points(gribvar, geo, validtime=None, interpolation='bilinear')[source]¶
Read a 2-D field and interpolates it to requested positions.
- Parameters:
gribvar (GribVariable1/2) – Grib variable
geo (surfex.Geo) – Surfex geometry
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
interpolation (str, optional) – Interpolation method. Defaults to “bilinear”.
- Returns:
vector with interpolated values
- Return type:
np.array
- Grib2Variable.__init__(discipline, pca, pnr, typ, lev, tsp=-1)[source]¶
Construct a grib2 variable.
- Parameters:
discipline (int) – discipline
pca (int) – parameterCatergory
pnr (int) – parameterNumber
typ (int) – levelType
lev (int) – level
tsp (int, optional) – typeOfStatisticalProcessing. Defaults to -1.
- Grib2Variable.matches(gid)[source]¶
Check if matches.
- Parameters:
gid (int) – Grib ID
- Raises:
ModuleNotFoundError – If not eccodes found
- Returns:
True if matches
- Return type:
bool
- ObservationSet.__init__(observations, label='', sigmao=None)[source]¶
Create an observation set.
- Parameters:
observations (list) – Observation objects.
label (str, optional) – Name of set. Defaults to “”.
sigmao (float, optional) – Observation error relative to normal background error. Defaults to None.
- ObservationSet.get_stid_index(stid)[source]¶
Get station ID index.
- Parameters:
stid (str) – Station ID.
- Returns:
Found index
- Return type:
int
- ObservationSet.get_pos_index(lon, lat)[source]¶
Get position index.
- Parameters:
lon (float) – Longitude
lat (float) – Latitude
- Returns:
Found position index.
- Return type:
int
- ObservationSet.get_obs()[source]¶
Get observations.
- Returns:
- times, lons, lats, stids, elevs,
values, varnames, sigmaos
- Return type:
(list, list , list, list, list, list, list)
- ObservationSet.matching_obs(my_obs)[source]¶
Match the observations.
- Parameters:
my_obs (Observation) – Observation to match.
- Returns:
True if found
- Return type:
bool
- ObservationSet.points(geo, validtime=None)[source]¶
Extract points from observations.
- Parameters:
geo (surfex.Geo) – Surfex geometry
validtime (datetime.datetime, optional) – Valid time. Defaults to None.
- Returns:
Values in points.
- Return type:
np.ndarray
- ObservationSet.write_json_file(filename, indent=None)[source]¶
Write a json file.
- Parameters:
filename (str) – Name of file
indent (int, optional) – Indentation in file. Defaults to None.
- JsonObservationSet.__init__(filename, label='json', var=None, sigmao=None)[source]¶
Construct an observation data set from a json file.
- Parameters:
filename (str) – Filename
label (str, optional) – Label of set. Defaults to “json”.
var (str, optional) – Variable name. Defaults to None.
sigmao (float, optional) – Observation error relative to normal background error. Defaults to None.
- Raises:
RuntimeError – Varname is not found
- ObservationFromTitanJsonFile.__init__(an_time, filename, label='', sigmao=None)[source]¶
Constuct obs set from a titan json file.
- Parameters:
an_time (_type_) – _description_
filename (_type_) – _description_
label (str, optional) – _description_. Defaults to “”.
sigmao (float, optional) – Observation error relative to normal background error. Defaults to None.
- Geo.__init__(lons, lats)[source]¶
Construct geometry.
- Parameters:
lons (np.ndarray) – Longitudes
lats (np.ndarray) – Latitudes
- Raises:
Exception – _description_
- Geo.is_identical(geo_to_check)[source]¶
Check if geometries are identical.
- Parameters:
geo_to_check (surfex.Geo) – Geo to check.
- Returns:
True if identical.
- Return type:
bool
- SurfexGeo.__init__(proj, lons, lats)[source]¶
Construct a surfex geometry.
- Parameters:
proj (str) – Proj string
lons (np.ndarray) – Lons
lats (np.ndarray) – Lats
- abstract SurfexGeo.update_namelist(nml)[source]¶
Update namelist.
- Parameters:
nml (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- abstract SurfexGeo.subset(geo)[source]¶
Find subset of geo.
- Parameters:
geo (surfex.Geo) – Geometry to check.
- ConfProj.__init__(from_json)[source]¶
Construct conf proj geo.
- Parameters:
from_json (dict) – Domain definition
- Raises:
KeyError – Missing keys1
KeyError – Missing keys2
KeyError – Missing keys3
KeyError – Missing keys4
- ConfProj.update_namelist(nml)[source]¶
Update namelist.
- Parameters:
nml (f90nml.Namelist) – Namelist object.
- Returns:
Namelist object.
- Return type:
nml (f90nml.Namelist)
- ConfProj.subset(geo)[source]¶
Find subset of geo.
- Parameters:
geo (surfex.Geo) – Geometry to check.
- Returns:
lons, lats
- Return type:
(list, list)
- LonLatVal.__init__(from_json)[source]¶
Construct a LonLatVal geometry.
Used also for points/observations.
- Parameters:
from_json (dict) – Domain description,
- Raises:
KeyError – Missing key
KeyError – Missing keys
- LonLatVal.update_namelist(nml)[source]¶
Update namelist.
- Parameters:
nml (f90nml.Namelist) – Namelist object.
- Returns:
Namelist object.
- Return type:
nml (f90nml.Namelist)
- LonLatVal.subset(geo)[source]¶
Find subset of geo.
- Parameters:
geo (surfex.Geo) – Geometry to check.
- Returns:
lons, lats
- Return type:
tuple
- Cartesian.__init__(from_json)[source]¶
Construct Cartesian geometry.
- Parameters:
from_json (_type_) – _description_
- Raises:
KeyError – Missing key
KeyError – Missing keys
- Cartesian.update_namelist(nml)[source]¶
Update namelist.
- Parameters:
nml (f90nml.Namelist) – Namelist object.
- Returns:
Namelist object.
- Return type:
nml (f90nml.Namelist)
- Cartesian.subset(geo)[source]¶
Find subset of geo.
- Parameters:
geo (surfex.Geo) – Geometry to check.
- Returns:
lons, lats
- Return type:
tuple
- LonLatReg.__init__(from_json)[source]¶
Construct the LonLatReg geometry.
- Parameters:
from_json (dict) – Domain definition.
- Raises:
KeyError – Missing key
KeyError – Missing keys
ZeroDivisionError – nlon and/or nlat is 0
- LonLatReg.update_namelist(nml)[source]¶
Update namelist.
- Parameters:
nml (f90nml.Namelist) – Namelist object.
- Returns:
Namelist object.
- Return type:
nml (f90nml.Namelist)
- LonLatReg.subset(geo)[source]¶
Find subset of geo.
- Parameters:
geo (surfex.Geo) – Geometry to check.
- Returns:
lons, lats
- Return type:
tuple
- IGN.__init__(from_json, recreate=False)[source]¶
Construct a IGN geometry.
- Parameters:
from_json (dict) – Domain definition.
recreate (bool, optional) – Recreate the cached mask. Defaults to False.
- Raises:
NotImplementedError – Projection not implemented
KeyError – Missing key
KeyError – Missing keys
- static IGN.get_coord(pin, pdin, coord, recreate=False)[source]¶
Get the IGN coordinates.
- Parameters:
pin (list) – _description_
pdin (list) – _description_
coord (list) – _description_
recreate (bool, optional) – _description_. Defaults to False.
- Returns:
Output coordinates
- Return type:
list
- static IGN.ign_mask(pxall, pyall, xxx, yyy, recreate)[source]¶
Create the IGN mask.
- Parameters:
pxall (_type_) – _description_
pyall (_type_) – _description_
xxx (_type_) – _description_
yyy (_type_) – _description_
recreate (_type_) – _description_
- Raises:
Exception – _description_
- Returns:
_description_
- Return type:
_type_
- IGN.update_namelist(nml)[source]¶
Update namelist.
- Parameters:
nml (f90nml.Namelist) – Namelist object.
- Returns:
Namelist object.
- Return type:
nml (f90nml.Namelist)
- IGN.subset(geo)[source]¶
Find subset of geo.
- Parameters:
geo (surfex.Geo) – Geometry to check.
- Returns:
lons, lats
- Return type:
tuple
- static Observation.vectors2obs(obstime, lon, lat, stid, elev, value, varname, sigmao)[source]¶
Convert vectors to observations.
- Parameters:
obstime (_type_) – _description_
lon (_type_) – _description_
lat (_type_) – _description_
stid (_type_) – _description_
elev (_type_) – _description_
value (_type_) – _description_
varname (_type_) – _description_
sigmao (float) – Observation error
- Returns:
Observation object.
- Return type:
- static Observation.obs2vectors(my_obs)[source]¶
Convert observations to vectors.
- Parameters:
my_obs (Observation) – Observation object
- Returns:
_description_
- Return type:
tuple
- static Observation.get_pos_from_stid(filename, stids)[source]¶
Get pos from station ID.
- Parameters:
filename (_type_) – _description_
stids (_type_) – _description_
- Raises:
Exception – _description_
- Returns:
_description_
- Return type:
_type_
- static Observation.get_stid_from_stationlist(stationlist, lons, lats)[source]¶
Get station ID from station list.
- Parameters:
stationlist (str) – Filename of station list
lons (list) – Longitudes
lats (list) – Latitudes
- Returns:
Station IDs
- Return type:
list
- BatchJob.__init__(rte, wrapper='')[source]¶
Construct batch job.
- Parameters:
rte (dict) – Run time environment.
wrapper (str, optional) – Wrapper around command. Defaults to “”.
- BatchJob.run(cmd)[source]¶
Run command.
- Parameters:
cmd (str) – Command to run.
- Raises:
CalledProcessError – Command failed.
RuntimeError – No command provided!
- SURFEXBinary.__init__(binary, batch, iofile, settings, input_data, **kwargs)[source]¶
Surfex binary task.
- Parameters:
binary (str) – Binary to run
batch (surfex.Batch) – Batch object to run command in
iofile (surfex.SurfexIO) – Input file to command.
settings (f90nml.Namelist) – Fortran namelist namelist
input_data (surfex.InputDataToSurfexBinaries) – Input to binary
kwargs (dict) – Key word arguments.
- Raises:
FileNotFoundError – Input file not found
RuntimeError – Execution failed
- Fa.field(varname, validtime)[source]¶
Read a field.
- Parameters:
varname (_type_) – _description_
validtime (_type_) – _description_
- Raises:
ModuleNotFoundError – You need epygram to read FA files
NotImplementedError – Geometry not implemented
- Returns:
np.field, surfex.Geometry
- Return type:
tuple
- Fa.points(varname, geo, validtime=None, interpolation='nearest')[source]¶
Read a 2-D field and interpolates it to requested positions.
- Parameters:
varname (str) – Variable name
geo (surfex.geo.Geo) – Geometry
validtime (as_datetime) – Validtime
interpolation (str, optional) – Interpoaltion method. Defaults to “nearest”.
- Returns:
field, interpolator
- Return type:
tuple
- SurfexOutputForcing.__init__(base_time, geo, ntimes, var_objs, time_step_intervall)[source]¶
Construct output forcing.
- Parameters:
base_time (_type_) – _description_
geo (_type_) – _description_
ntimes (_type_) – _description_
var_objs (_type_) – _description_
time_step_intervall (_type_) – _description_
- NetCDFOutput.write_forcing(var_objs, this_time, cache)[source]¶
Write forcing.
- Parameters:
var_objs (_type_) – _description_
this_time (_type_) – _description_
cache (_type_) – _description_
- AsciiOutput.write_forcing(var_objs, this_time, cache)[source]¶
Write forcing.
- Parameters:
var_objs (_type_) – _description_
this_time (_type_) – _description_
cache (_type_) – _description_
- JsonOutputData.__init__(data)[source]¶
Output data from dict.
- Parameters:
data (dict) – Output data.
- JsonInputDataFromFile.__init__(file)[source]¶
Construct JSON input data.
- Parameters:
file (str) – JSON file name
- InputDataFromNamelist.__init__(nml, input_data, program, platform, basetime=None, validtime=None)[source]¶
Construct InputDataFromNamelist.
- Parameters:
nml (f90nml.Namelist) – Namelist
input_data (dict) – Input data mapping
program (str) – Kind of program
platform (SystemFilePaths) – Platform settings
basetime (as_datetime, optional) – Baseetime. Defaults to None.
validtime (as_datetime, optional) – Validtime. Defaults to None.
- Raises:
RuntimeError – Program not defined
- static InputDataFromNamelist.get_nml_value2(nml, block, key, indices=None)[source]¶
Get namelist value.
- Parameters:
nml (nmlf90.Namelist) – Namelist
block (str) – Namelist block
key (str) – Namelist key
indices (list, optional) – Indices to read. Defaults to None.
- Returns:
Namelist setting
- Return type:
setting (any)
- static InputDataFromNamelist.get_nml_value(nml, block, key, indices=None)[source]¶
Get namelist value.
- Parameters:
nml (nmlf90.Namelist) – Namelist
block (str) – Namelist block
key (str) – Namelist key
indices (list, optional) – Indices to read. Defaults to None.
- Returns:
Namelist setting
- Return type:
setting (any)
- static InputDataFromNamelist.get_nml_value_from_string(nml, string, sep='#', indices=None)[source]¶
Get namelist value from a string.
- Parameters:
nml (nmlf90.Namelist) – Namelist
string (str) – Namelist identifier
sep (str, optional) – _description_. Defaults to “#”.
indices (list, optional) – Indices to read. Defaults to None.
- Returns:
Namelist setting
- Return type:
setting (any)
- InputDataFromNamelist.substitute(key, val, macros=None, micro='@', check_parsing=False)[source]¶
Substitute patterns.
- Parameters:
key (str) – _description_
val (str) – _description_
macros (dict, optional) – Macros. Defaults to None.
micro (str, optional) – Micro character. Defaults to “@”.
check_parsing (bool, optional) – Caheck if values were substituted.
- Returns:
Substituted key=value
- Return type:
dict
- InputDataFromNamelist.read_macro_setting(macro_defs, key, default=None, sep='#')[source]¶
Read a macro setting.
- Parameters:
macro_defs (dict) – Macro definition
key (str) – Macro setting to get.
default (str, optional) – Default value. Defaults to None.
sep (str, optional) – Namelist key separator. Defaults to “#”.
- Returns:
setting (any)
- InputDataFromNamelist.extend_macro(key, val, macros, sep='#')[source]¶
Extend entries from macro.
- Parameters:
key (_type_) – _description_
val (_type_) – _description_
macros (dict) – Macros
sep (str, optional) – Namelist key separator. Defaults to “#”.
- Raises:
NotImplementedError – _description_
NotImplementedError – _description_
- Returns:
Key, value dictionary
- Return type:
dict
- InputDataFromNamelist.process_macro(key, val, macros, sep='#', indices=None)[source]¶
Process macro.
- Parameters:
key (str) – Key
val (str) – Value
macros (dict) – Macros
sep (str, optional) – Namelist key separator. Defaults to “#”.
indices (list, optional) – Process macro from namelist indices.
- Raises:
NotImplementedError – Only 2 dimensions are implemented
- Returns:
Key, value dictionary
- Return type:
dict
- InputDataFromNamelist.matching_value(data, val, sep='#', indices=None)[source]¶
Match the value. Possibly also read namelist value.
- Parameters:
data (dict) – Data to check keys for
val (str) – Key to find
sep (str, optional) – Namelist separator. Defaults to “#”.
indices (list, optional) – Indices in namelist
- Raises:
RuntimeError – “Malformed input data”
- Returns:
Matching entry in data.
- Return type:
dict
- InputDataFromNamelist.process_data(sep='#')[source]¶
Process input definitions on files to map.
- Parameters:
sep (str, optional) – Namelist separator. Defaults to “#”.
- Returns:
A dict with mapped local names and target files.
- Return type:
mapped_data (dict)
- Netcdf.field(var_name, level=None, member=None, validtime=None, units=None)[source]¶
Read field.
- Parameters:
var_name (str) – Variable name
level (int, optional) – Level. Defaults to None.
member (int, optional) – Realization. Defaults to None.
validtime (surfex.datetime_utils.as_datetime, optional) – Validtime. Defaults to None.
units (str, optional) – Units. Defaults to None.
- Returns:
Field, Geo
- Return type:
tuple
- Netcdf.points(var, geo, validtime=None, interpolation='bilinear')[source]¶
Read a field and interpolate it to requested positions.
- Parameters:
var (NetCDFReadVariable) – NetCDF variable
geo (surfx.geo.Geo) – Geometry
validtime (surfex.datetime_utils.as_datetime, optional) – Validtime. Defaults to None.
interpolation (str, optional) – Interpolation. Defaults to “bilinear”.
- Returns:
Field, Interpolator
- Return type:
tuple
- NetCDFReadVariable.__init__(name, level=None, units=None, member=None)[source]¶
Construct object.
- Parameters:
name (_type_) – _description_
level (_type_, optional) – _description_. Defaults to None.
units (_type_, optional) – _description_. Defaults to None.
member (_type_, optional) – _description_. Defaults to None.
- NetCDFFileVariable.__init__(file_handler, var)[source]¶
Construct object.
- Parameters:
file_handler (_type_) – _description_
var (_type_) – _description_
- NetCDFFileVariable.axis_types()¶
Get axis_types.
- NetCDFFileVariable.dim_names()¶
Get dim_names.
- NetCDFFileVariable.units()¶
Get units.
- NetCDFFileVariable.lats()¶
Get lats.
- Raises:
RuntimeError – No latitude found
- Returns:
2D array of latitudes
- Return type:
np.array
- NetCDFFileVariable.lons()¶
Get lons.
- Raises:
RuntimeError – No longitude found
- Returns:
2D array of longitudes
- Return type:
np.array
- NetCDFFileVariable.datetimes()¶
Get datetimes.
- Raises:
RuntimeError – cfunits not loaded!
- Returns:
list()
- NetCDFFileVariable.times()¶
Get times.
- Returns:
1D array of times
- Return type:
np.array
- NetCDFFileVariable.members()¶
Get members.
- Returns:
1D array of ensemble members
- Return type:
np.array
- NetCDFFileVariable.levels()¶
Get levels.
- Returns:
1D array of levels
- Return type:
np.array
- static NetCDFFileVariable.is_level(axis_type)[source]¶
Check if is level.
- Parameters:
axis_type (Axis) – Acis type
- Returns:
If axis is a level type
- Return type:
bool
- NamelistGenerator.__init__(program, config, definitions, assemble=None, consistency=True)[source]¶
Construct a base namelists class.
- Parameters:
program (str) – Which surfex binary you want to run [“pgd”, “prep”, “offline”, “soda”]
config (surfex.Configuration) – A SURFEX configuration object
definitions (dict) – Namelist definitions
assemble (dict, optional) – Assembly order. Default to None.
consistency (bool, optional) – Check configuration consistency. Defaults to True.
- NamelistGenerator.flatten_config()[source]¶
Flatten dictionary.
- Returns:
Flat dict with settings
- Return type:
source(dict)
- static NamelistGenerator.check_nml_setting(problems, nml, block, key, value)[source]¶
Check namelist settings.
- Parameters:
problems (dict) – Problems
nml (f90nml.Namelist) – Namelist
block (str) – Block
key (str) – Key
value (any) – Value
- Returns:
Problems
- Return type:
problems (dict)
- NamelistGenerator.concistency(nml)[source]¶
Check if namelist is consistent with config.
- Parameters:
nml (f90nml.Namelist) – A parsed f90nml namelist
- Raises:
NotImplementedError – Mode is not implemented
- Returns:
Problems.
- Return type:
problems (dict)
- static NamelistGenerator.get_filetype_from_suffix(fname)[source]¶
Get the file type from suffix.
- Parameters:
fname (str) – File name
- Returns:
fname, format
- Return type:
tuple
- NamelistGenerator.assemble_namelist()[source]¶
Generate the namelists for ‘target’.
- Raises:
KeyError – Key not found
- Returns:
Assembled namelist
- Return type:
nlres (dict)
- NamelistGenerator.write(output_file)[source]¶
Generate the namelists for ‘target’.
- Parameters:
output_file (str) – where to write the result (OPTIONS.nam, fort.4 or EXSEG1.nam typically)
- ConvertedInput.__init__(geo, var_name, converter)[source]¶
Construct converted input.
- Parameters:
geo (_type_) – _description_
var_name (_type_) – _description_
converter (_type_) – _description_
- ConvertedInput.read_time_step(validtime, cache)[source]¶
Read time step.
- Parameters:
validtime (_type_) – _description_
cache (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- ConstantValue.__init__(geo, var_name, var_dict)[source]¶
Set a field to a constant value.
- Parameters:
geo (surfex.Geo) – Geometry object
var_name (str) – Variable name
var_dict (dict) – Variable definition
- Raises:
RuntimeError – Constant value must have a value!
- ConstantValue.read_time_step(validtime, cache)[source]¶
Read time step.
- Parameters:
validtime (_type_) – _description_
cache (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- Converter.__init__(name, initial_time, defs, conf, fileformat)[source]¶
Initialize the converter.
- Parameters:
name (str) – Converter name
initial_time (as_datetime) – The valid time you want to read
defs (dict) – A dictionary defining the variables
conf (dict) – A dictionary defining the converter
fileformat (str) – File format
- Raises:
KeyError – Missing definitions
NotImplementedError – Converter not implemented
- Converter.create_variable(fileformat, defs, var_dict)[source]¶
Create a variable.
- Parameters:
fileformat (str) – Fileformat
defs (dict) – defs
var_dict (dict) – Variable dictionary
- Raises:
RuntimeError – Variable is not set
- Returns:
The read field
- Return type:
field
- static Converter.mslp2ps(mslp, altitude, temp)[source]¶
Calcaulate ps from mslp.
- Parameters:
mslp (np.ndarray) – Mean sea level pressure
altitude (np.ndarray) – Altitude
temp (np.ndarray) – Temperature
- Returns:
Surface pressure
- Return type:
np.ndarray
- Interpolation.__init__(operator, geo_in, geo_out)[source]¶
Construct an intrpolation object.
- Parameters:
operator (str) – Operator
geo_in (surfex.geo.Geo) – Input geometry
geo_out (surfex.geo.Geo) – Output geometry
- Raises:
RuntimeError – You can not interpolate without specifying an output geometry
- Interpolation.interpolate(field2d, undefined=None)[source]¶
Do interpolation.
- Parameters:
field2d (np.ndarray) – Two dimensional field to interpolate
undefined (float, optional) – Undefined value if field2d is None. Defaults to None.
- Raises:
RuntimeError – Input domain and ouput domain differ.
RuntimeError – You try to interpolate a missing field!
NotImplementedError – Interpolation method not implemented
- Returns:
interpolated_field
- Return type:
np.array
- static Interpolation.distance(lon1, lat1, lon2, lat2)[source]¶
Compute distance.
Computes the great circle distance between two points using the haversine formula. Values can be vectors.
- Parameters:
lon1 (float) – lon1
lat1 (float) – lat1
lon2 (float) – lon2
lat2 (float) – lat2
- Returns:
Circle distance
- Return type:
cval(float)
- ObsOperator.__init__(operator, geo, dataset, grid_values, max_distance=5000)[source]¶
Construct the observation operator.
- Parameters:
operator (str) – Interpolation operator.
geo (surfex.Geo) – Surfex geometry.
dataset (QCDataSet) – QC data set.
grid_values (np.darray) – Values in the grid.
max_distance (int, optional) – Max allowed deviation in meters from grid borders. Defaults to 5000.
- ObsOperator.get_obs_value(pos=None)[source]¶
Get the observed value.
- Parameters:
pos (int, optional) – Position. Defaults to None.
- Raises:
NotImplementedError – Specific position not implemented yet!
- Returns:
Observation value for index.
- Return type:
float
- ObsOperator.is_in_grid(index)[source]¶
Check if index is in grid.
- Parameters:
index (int) – Index to check.
- Returns:
True if inside
- Return type:
bool
- SystemFilePaths.__init__(system_file_paths)[source]¶
Construct SystemFilePaths.
- Parameters:
system_file_paths (_type_) – _description_
- static SystemFilePaths.substitute_string(setting, system_variables=None, micro='@')[source]¶
Substitute setting if string with OS values of values from system_variables.
- Parameters:
setting (str) – if setting is string it can be subst
system_variables (dict) – Arbitrary settings to substitute @NAME@ = system_variables={“NAME”: “Value”}
micro (str, optional) – Micro character. Default to “@”
- Returns:
A setting possibly substituted if type is str
- Return type:
setting
- SystemFilePathsFromFile.__init__(system_file_paths)[source]¶
System file path from a file.
- Parameters:
system_file_paths (_type_) – _description_
- LoadFromFile.__call__(parser, namespace, values, option_string=None)[source]¶
Override __call__ method.
- TimeSeries.__init__(times, values, lons, lats, stids, stids_file=None, varname='NA')[source]¶
Construct time series.
- Parameters:
times (_type_) – _description_
values (_type_) – _description_
lons (_type_) – _description_
lats (_type_) – _description_
stids (_type_) – _description_
stids_file (_type_, optional) – _description_. Defaults to None.
varname (str, optional) – _description_. Defaults to “NA”.
- TimeSeries.write_json(filename, indent=None)[source]¶
Write json file.
- Parameters:
filename (_type_) – _description_
indent (_type_, optional) – _description_. Defaults to None.
- PgdInputData.__init__(config, system_file_paths, check_existence=True)[source]¶
Construct PD input.
- Parameters:
config (Configuration) – Surfex configuration
system_file_paths (SystemFilePaths) – System file paths
check_existence (bool, optional) – Check if input files exist. Defaults to True.
- OfflineInputData.__init__(config, system_file_paths, check_existence=True)[source]¶
Construct input data for offline.
- Parameters:
config (Configuration) – Surfex configuration
system_file_paths (SystemFilePaths) – System file paths
check_existence (bool, optional) – Check if input files exist. Defaults to True.
- Raises:
NotImplementedError – Filetype not implemented
- InlineForecastInputData.__init__(config, system_file_paths, check_existence=True)[source]¶
Construct input data for inline forecast.
- Parameters:
config (Configuration) – Surfex configuration
system_file_paths (SystemFilePaths) – System file paths
check_existence (bool, optional) – Check if input files exist. Defaults to True.
- SodaInputData.set_input_observations(check_existence=True)[source]¶
Input data for observations.
- Parameters:
check_existence (bool, optional) – Check if input files exist. Defaults to True.
- Raises:
NotImplementedError – File format not implemented
RuntimeError – Obs ASCII file needs DTG information
- Returns:
Input observations.
- Return type:
obssettings
- SodaInputData.set_input_sea_assimilation(check_existence=True)[source]¶
Input data for sea assimilation.
- Parameters:
check_existence (bool, optional) – Check if input files are existing. Defaults to True.
- Raises:
NotImplementedError – File format not implemented
- Returns:
Input filed for sea assimilation
- Return type:
sea_settings(dict)
Methods¶
- pysurfex.titan.define_quality_control(test_list, settings, an_time, domain_geo=None, blacklist=None)[source]¶
Define different QC test from a dict.
- Parameters:
test_list (list) – List of tests
settings (dict) – Test settings
an_time (datetime.datetime) – Analysis time
domain_geo (surfex.Geo) – Geo object
blacklist (dict) – Optional blacklist. Needd for blacklist test
- Raises:
NotImplementedError – Test not implemented
RuntimeError – You must set the name of fg file and variable
RuntimeError – You must set the name of fraction file and variable
RuntimeError – You must set both fraction_field and fraction_geo
RuntimeError – You must set both fg_field and fg_geo
- Returns:
List of QualityControl objects
- Return type:
tests(list)
- pysurfex.titan.merge_json_qc_data_sets(an_time, filenames, qc_flag=None, skip_flags=None)[source]¶
Merge QC data sets from json files.
- Parameters:
an_time (datetime.datetime) – Analysis time.
filenames (list) – List of filenames.
qc_flag (int, optional) – QC code to merge. Defaults to None.
skip_flags (list, optional) – List of QC flags to skip. Defaults to None.
- Returns:
QCDataSet
- Return type:
- pysurfex.file.guess_file_format(fname, ftype=None)[source]¶
Guess the file format.
- Parameters:
fname (str) – Filename
ftype (str, optional) – Filetype if known/wished. Defaults to None.
- Raises:
RuntimeError – Can not-auto decide filetype for files
RuntimeError – Filetype and/or format not set
- Returns:
fileformat, filetype
- Return type:
tuple
- pysurfex.datetime_utils.as_datetime_args(year=None, month=None, day=None, hour=0, minute=0, second=0)[source]¶
Set datetime object from args.
- pysurfex.geo.get_geo_object(from_json)[source]¶
Get a surfex geometry object from a dictionary.
- Parameters:
from_json (dict) – Domain definition.
- Raises:
NotImplementedError – Grid not implemented
KeyError – Missing grid information cgrid
KeyError – nam_pgd_grid not set!
- Returns:
Surfex geometry.
- Return type:
surfex.Geo
- pysurfex.geo.get_geo_object_from_json_file(fname)[source]¶
Get a surfex geometry object from a dictionary.
- Parameters:
fname (str) – Domain definition file.
- Returns:
Surfex geometry.
- Return type:
surfex.Geo
- pysurfex.geo.set_domain(settings, domain, hm_mode=False)[source]¶
Set domain.
- Parameters:
settings (dict) – Domain definitions
domain (str) – Domain name
hm_mode (bool, optional) – Harmonie definition. Defaults to False.
- Raises:
KeyError – Domain not found
ValueError – Settings should be a dict
- Returns:
Domain dictionary
- Return type:
dict
- pysurfex.geo.shape2ign(catchment, infile, output, ref_proj, indent=None)[source]¶
Read a shape file and convert to IGN geo.
- Parameters:
catchment (_type_) – _description_
infile (_type_) – _description_
output (_type_) – _description_
ref_proj (_type_) – _description_
indent (_type_, optional) – _description_. Defaults to None.
- pysurfex.forcing.write_formatted_array(file, array, columns, fileformat)[source]¶
Write a formatted array.
- pysurfex.util.deep_update(source, overrides)[source]¶
Update a nested dictionary or similar mapping.
Modify
source
in place.- Parameters:
source (dict) – Source data
overrides (dict) – Delta data to override
- Returns:
Updated dict
- Return type:
source(dict)
- pysurfex.util.remove_existing_file(f_in, f_out)[source]¶
Remove existing file.
- Parameters:
f_in (_type_) – _description_
f_out (_type_) – _description_
- Raises:
FileNotFoundError – _description_
IsADirectoryError – _description_
- pysurfex.util.parse_filepattern(file_pattern, basetime, validtime)[source]¶
Parse the file pattern.
- Parameters:
file_pattern (str) – File pattern.
basetime (datetime.datetime) – Base time.
validtime (datetime.datetime) – Valid time.
- Returns:
File name
- Return type:
str
- pysurfex.input_methods.get_datasources(obs_time, settings)[source]¶
Get data sources.
Main data source interface setting data ObservationSet objects based on settings dictionary
- Parameters:
obs_time (datetime.datetime) – Observation time
settings (dict) – Settings
- Raises:
NotImplementedError – Unknown observation file format
NotImplementedError – Only one file reading implemented
RuntimeError – No filenames or filepattern found
RuntimeError – You must set variable name
RuntimeError – You must set varname to read NETATMO JSON files
RuntimeError – You must set variable name
- Returns:
List of observation data sets
- Return type:
datasources(list)
- pysurfex.netcdf.read_first_guess_netcdf_file(input_file, var)[source]¶
Read netCDF first guess file.
- Parameters:
input_file (_type_) – _description_
var (_type_) – _description_
- Raises:
NotImplementedError – Only conf proj implemented when reading geo from file
RuntimeError – cfunits not loaded!
- Returns:
geo, validtime, background, glafs, gelevs
- Return type:
tuple
- pysurfex.netcdf.oi2soda(dtg, t2m=None, rh2m=None, s_d=None, s_m=None, output=None)[source]¶
Convert analysis to ASCII obs file for SODA.
- Parameters:
dtg (surfex.datetime_utils) – Analysis time
t2m (dict, optional) – Screen level temperature var and file name. Defaults to None.
rh2m (dict, optional) – Screen level relative humidiy var and file name. Defaults to None.
s_d (dict, optional) – Snow depth var and file name. Defaults to None.
s_m (dict, optional) – Soil moisture var and file name. Defaults to None.
output (str, optional) – Output file name. Defaults to None.
- Raises:
RuntimeError – You must specify at least one file to read from
RuntimeError – Mismatch in ?? dimension
- pysurfex.netcdf.read_cryoclim_nc(infiles, cryo_varname='classed_value_c')[source]¶
Read crycoclim netCDF file.
- Parameters:
infiles (list) – Input files.
cryo_varname (str, optional) – Variable name in cryo file. Defaults to “classed_value_c”
- Raises:
RuntimeError – “No files were read properly”
- Returns:
grid_lons, grid_lats, grid_snow_class
- Return type:
tuple
- pysurfex.netcdf.read_sentinel_nc(infiles)[source]¶
Read sentinel nc files.
- Parameters:
infiles (list) – Input files.
- Raises:
RuntimeError – “No files were read properly”
- Returns:
longitudes, latitudes, soil moisture
- Return type:
tuple
- pysurfex.obsmon.open_db(dbname)[source]¶
Open database.
- Parameters:
dbname (str) – File name.
- Raises:
RuntimeError – Need SQLite
- Returns:
A connection
- Return type:
sqlite3.connect
- pysurfex.obsmon.close_db(conn)[source]¶
Close data base connection.
- Parameters:
conn (sqlite3.connect) – Data base connection.
- pysurfex.obsmon.create_db(conn, modes, stat_cols)[source]¶
Create data base.
- Parameters:
conn (sqlite3.connect) – Data base connection.
modes (_type_) – _description_
stat_cols (_type_) – _description_
- pysurfex.obsmon.populate_usage_db(conn, dtg, varname, observations)[source]¶
Populate usage.
- Parameters:
conn (_type_) – _description_
dtg (_type_) – _description_
varname (_type_) – _description_
observations (_type_) – _description_
- pysurfex.obsmon.rmse(predictions, targets)[source]¶
Root mean square error.
- Parameters:
predictions (_type_) – _description_
targets (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- pysurfex.obsmon.absbias(predictions)[source]¶
Absolute bias.
- Parameters:
predictions (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- pysurfex.obsmon.mean(predictions)[source]¶
Mean.
- Parameters:
predictions (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- pysurfex.obsmon.calculate_statistics(observations, modes, stat_cols)[source]¶
Statistics.
- Parameters:
observations (_type_) – _description_
modes (_type_) – _description_
stat_cols (_type_) – _description_
- Raises:
NotImplementedError – _description_
- Returns:
_description_
- Return type:
_type_
- pysurfex.obsmon.populate_obsmon_db(conn, dtg, statistics, modes, stat_cols, varname)[source]¶
Populate obsmon.
- Parameters:
conn (_type_) – _description_
dtg (_type_) – _description_
statistics (_type_) – _description_
modes (_type_) – _description_
stat_cols (_type_) – _description_
varname (_type_) – _description_
- Raises:
Exception – _description_
- pysurfex.cli.sentinel_obs(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.qc2obsmon(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.prep(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.plot_points(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- Raises:
NotImplementedError – “Inputype is not implemented”
RuntimeError – “No geo is set”
RuntimeError – “No field read”
ModuleNotFoundError – “Matplotlib is needed to plot”
- pysurfex.cli.plot_field(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- Raises:
NotImplementedError – “Inputype is not implemented”
RuntimeError – “No geo is set”
RuntimeError – “No field read”
ModuleNotFoundError – “Matplotlib is needed to plot”
- pysurfex.cli.pgd(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.perturbed_offline(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.offline(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.cli_oi2soda(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.cli_modify_forcing(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.cli_merge_qc_data(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.masterodb(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.hm2pysurfex(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.gridpp(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.dump_environ(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.first_guess_for_oi(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.cryoclim_pseudoobs(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.create_namelist(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- Raises:
FileNotFoundError – “File not found:”
- pysurfex.cli.create_lsm_file_assim(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- Raises:
FileNotFoundError – Domain file not found
- pysurfex.cli.create_forcing(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.bufr2json(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.obs2json(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.cli_set_domain(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- Raises:
FileNotFoundError – File not found
RuntimeError – Domain not provided
- pysurfex.cli.cli_set_geo_from_obs_set(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.cli_set_geo_from_stationlist(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.cli_shape2ign(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.soda(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.cli.titan(argv=None)[source]¶
Command line interface.
- Parameters:
argv (list, optional) – Arguments. Defaults to None.
- pysurfex.interpolation.fill_field(field_tmp, geo, radius=1)[source]¶
Fill field.
- Parameters:
field_tmp (np.ndarray) – Field
geo (surfex.geo.Geo) – Geometry
radius (int, optional) – Radius. Defaults to 1.
- Returns:
field, nans
- Return type:
tuple
- Raises:
RuntimeError – You need gridpp for fill_field
- pysurfex.interpolation.grid2points(grid, points, grid_values, operator='bilinear', elev_gradient=None)[source]¶
Convert a grid to points.
- Parameters:
grid (Grid) – Grid object
points (Points) – Points object
grid_values (np.ndarray) – Grid values
operator (str, optional) – Interpolation operator. Defaults to “bilinear”.
elev_gradient (float, optional) – Elevation gradient for downscaler
- Raises:
NotImplementedError – Operator not implemented
RuntimeError – You need gridpp for interpolation
- Returns:
Interpolated values
- Return type:
np.ndarray
- pysurfex.interpolation.inside_grid(grid_lons, grid_lats, p_lons, p_lats, distance=2500.0)[source]¶
Get number of neighbours.
- Parameters:
grid_lons (np.ndarray) – Grid longitudes
grid_lats (np.ndarray) – Grid latitudes
p_lons (np.array) – Point longitudes
p_lats (np.array) – Point latitudes
distance (float, optional) – Max distance from points. Defaults to 2500.0.
- Returns:
Boolean mask
- Return type:
inside_grid(list)
- pysurfex.interpolation.sum_neighbour_points(twodfield, radius)[source]¶
Sum up points in neighbourhood.
- Parameters:
twodfield (np.ndarray) – Field to sum
radius (int) – Radius
- Returns:
Array with neighbourhood sums.
- Return type:
np.ndarray
- pysurfex.cmd_parsing.parse_args_create_forcing(argv)[source]¶
Parse arguments to create forcing.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_modify_forcing(argv)[source]¶
Parse arguments to modify forcing.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_qc2obsmon(argv)[source]¶
Parse arguments for qc2obsmon.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_dump_environ(argv)[source]¶
Parse arguments for dum environ.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_first_guess_for_oi(argv)[source]¶
Parse arguments for firstguess4oi.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_masterodb(argv)[source]¶
Parse the command line input arguments for masterodb.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_surfex_binary(argv, mode)[source]¶
Parse the command line input arguments for surfex binary.
- Parameters:
argv (list) – List with arguments.
mode (str) – Type of surfex binary
- Raises:
NotImplementedError – Mode not implemented
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_create_namelist(argv)[source]¶
Parse the command line input arguments for creating a namelist.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_gridpp(argv)[source]¶
Parse the command line input arguments for gridpp.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_titan(argv)[source]¶
Parse the command line input arguments for titan.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_oi2soda(argv)[source]¶
Parse the command line input arguments for oi2soda.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_lsm_file_assim(argv)[source]¶
Parse the command line input arguments for land-sea-mask for assimilation.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_hm2pysurfex(argv)[source]¶
Parse the command line input arguments for hm2pysurfex.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_bufr2json(argv)[source]¶
Parse the command line input arguments for bufr2json.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_obs2json(argv)[source]¶
Parse the command line input arguments for obs2json.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_plot_points(argv)[source]¶
Parse the command line input arguments for plotting points.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_plot_field(argv)[source]¶
Parse the command line input arguments for plotting a field.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.get_variables_from_args(parser, argv, variables)[source]¶
Get the variables from user arguments.
- Parameters:
parser (ArgumentParser) – The existing parser.
argv (list) – User arguments.
variables (list) – Variables to get setttings for.
- Returns:
Parsed keyword arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_set_geo_from_obs_set(argv)[source]¶
Parse the command line input arguments for setting geo from obs set.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_set_geo_from_stationlist(argv)[source]¶
Parse the command line input arguments for setting geo from station list.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_merge_qc_data(argv)[source]¶
Parse the command line input arguments for merge of qc data.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_timeseries2json(argv)[source]¶
Parse the command line input arguments for time series to json.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_cryoclim_pseudoobs(argv)[source]¶
Parse the command line input arguments for cryoclim pseudo obs.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.variable_parser(needles, argv, parser)[source]¶
Create parser entries for a variable.
- Parameters:
needles (list) – The variables to create.
argv (list) – User arguments.
parser (ArgumentParser) – The existing parser object.
- Returns:
Parser keyword arguments
- Return type:
dict
- pysurfex.cmd_parsing.parse_sentinel_obs(argv)[source]¶
Parse the command line input arguments for sentinel observations.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- pysurfex.cmd_parsing.parse_args_shape2ign(argv)[source]¶
Parse the command line input arguments for shape fiel to ign.
- Parameters:
argv (list) – List with arguments.
- Returns:
Parsed arguments.
- Return type:
dict
- ref:
README