Unstructured grid NetCDF surface flux gridded_netcdf/unstructured

Unstructured grid NetCDF surface flux gridded_netcdf/unstructured#

Description#

Reads surface flux from a 1+2D (time x latitude x longitude) gridded NetCDF files

The provided NetCDF files should all have the exact same latitude x longitude grid. The latitude x longitude grid will only be read from the NetCDF file corresponding to the first simulation sub-period.

The time coordinate should be named 'time' in the NetCDF files.

Either file_freq or is_climatology argument is required.

See Gridded NetCDF domain plugin for information about the required coordinates format in the NetCDF file.

YAML arguments#

The following arguments are used to configure the plugin. pyCIF will return an exception at the initialization if mandatory arguments are not specified, or if any argument does not fit accepted values or type:

Optional arguments#

dir : str, optional, default “”

Path to the corresponding component. This value is used if not provided in parameters

file : str, optional, default “”

File format in the given directory. This value is used if not provided in parameters

varname : str, optional, default “”

Variable name to use to read data filesinstead of the parameter name if different to the parameter name

file_freq : str, optional, default “”

The time frequency at which data files are available. Should be a multiple of one of Pandas’ offset aliases which will be passed to the pandas.date_range method, ex: ‘1MS’ for every first day of the month

split_freq : str, optional

Force splitting the processing at a given frequency different to file_freq

is_climatology : bool, optional, default False

Set this argument to True for climatological data (i.e. year-independent data)

var_freq : str, optional

The time frequency of the flux variable within the NetCDF files. Should be one of Pandas’ offset aliases which will be passed to the pandas.DatetimeIndex.to_period method. This argument may not be needed is the time frequency in the NetCDF files is regular, ex: ‘D’ for daily values

force_var_freq : bool, optional, default False

Force using var_freq instead of the time dimension.

remove_duplicates : bool, optional, default True

Remove duplicate files matching the prescribed pattern

time_varname : str, optional

Time coordinate variable name in file. If this argument is not provided, the time coordinate is found by its standard_name or long_name (which should be 'time'). If the time coordinate cannot be found by its attributes, the variable named 'time' will be used if it exists.

period_varname : str, optional

Period variable, used to define time intervals valid for each value in the dataset

time_coordinate : str, optional

Name of the time coordinate if different from the time variable

time_dimname : str, optional, default “time”

Time dimension name in file.

time_midpoint : bool, optional, default False

Whether the time variable defines the beginning of each period of validity of the data, or the midpoint. True for midpoint.

time_endpoint : bool, optional, default False

Whether the time variable defines the beginning of each period of validity of the data, or the endpoint. True for endpoint.

time_unit : str, optional

NetCDF standard time unit, if not specified in the file. Can contain a date format (ex: "%Y-%m-%d) which will be decoded with the current file datetime. Cannot be used along side the time_format argument

time_calendar : “gregorian” or “noleap”, optional

Overwrite the calendar as specified in the files

  • “gregorian”: Standard Gregorian calendar

  • “noleap”: calendar with no leap years

time_format : str, optional

The strftime to parse the time coordinate values, e.g. "%Y%m%d". This argument is passed to the pandas.to_datetime method’s format keyword argument. Cannot be used along side the time_unit argument

add_time_coord : bool, optional, default False

Set this argument to True if there is no time coordinate. in the NetCDF file. Timestamps will be added acording to the var_freq or file_freq argument. Use the var_freq argument only if there is a single timestamp per file. When the var_freq argument is used the time dimension is found with the time_dimname argument. Cannot be used with the is_climatology argument.

sum_along_dim : str, optional

Sum the data along a given dimension (other than lon, lat, lev and time)

group_name : str, optional

Name of the NetCDF group to read in the NetCDF file

sum_variables : str, optional, default False

If several variables are specified in varname, force them to be summed

slice_dimension : optional

Keep only slices over some dimensions. This is useful when the data hqs more dimensions than ones corresponding to (time, level, lat, lon). It is possible to slice over given dimensions with the convention slice(slice_min, slice_max, slice_freq)

Argument structure:
any_key : optional

Name of a dimension.

Argument structure:
slice_min : int, optional

Start for the slice

slice_max : int, optional

End for the slice

slice_freq : int, optional

Frequency for the slice

method : “sum” or “avg”, optional, default “sum”

Method for the slicing

  • “sum”: sum over the slice

  • “avg”: average over the slice

latitude_varname : str, optional, default “latitude”

Latitude coordinate variable name in file. If this argument is not provided, the latitude coordinate is found by its standard_name or long_name attribute (which should be 'latitude').

longitude_varname : str, optional, default “longitude”

Longitude coordinate variable name in file. If this argument is not provided, the longitude coordinate is found by its standard_name or long_name attribute (which should be 'longitude').

latitude_bounds_varname : str, optional

Latitude bounds (vertices) coordinate variable name in file. If this argument is not provided, the latitude coordinate is found with the bounds attribute of the latitude variable.

longitude_bounds_varname : str, optional

longitude bounds (vertices) coordinate variable name in file. If this argument is not provided, the longitude coordinate is found with the bounds attribute of the longitude variable.

dir_vcoord : str, optional, default “”

Directory containing file_vcoord. Use this argument if the vertical coordinates are not in file

file_vcoord : str, optional

NetCDF file containing the vertical coordinates. Use this argument if the vertical coordinates are not in file

vertical_coord : “mids” or “bounds”, optional

Read the domain’s vertical levels if this parameter is used. Should be ‘mids’ if the vertical coordinate represents the levels mid-points or ‘bounds’ if the vertical coordinate represents the levels boundaries. If this parameter is not used a domain single vertical level is created

  • “mids”: levels mid-points

  • “bounds”: levels boundaries

vertical_dim_name : str, optional, default “lev”

Vertical dimension name in file or file_vcoord

vertical_dim_type : “sigma_pressure” or “heights”, optional, default “sigma_pressure”

Vertical dimension type

  • “sigma_pressure”: Levels defined with ap/bp sigma pressure coordinates, with p = psurf * bp + ap

  • “heights”: Levels in meters above ground

sigma_a_var_name : str, optional, default “ap”

‘sigma a’ variable name in file or file_vcoord

sigma_b_var_name : str, optional, default “bp”

‘sigma b’ variable name in file or file_vcoord

pressure_unit : “Pa” or “hPa”, optional

pressure units if different from units attributes in sigma `a` variable, should be ``'Pa' or 'hPa'

reverse_vcoord : bool, optional, default False

reverse the vertical coordinate or not

YAML template#

Please find below a template for a YAML configuration:

 1flux:
 2  plugin:
 3    name: gridded_netcdf
 4    version: unstructured
 5    type: flux
 6
 7  # Optional arguments
 8  dir: XXXXX  # str
 9  file: XXXXX  # str
10  varname: XXXXX  # str
11  file_freq: XXXXX  # str
12  split_freq: XXXXX  # str
13  is_climatology: XXXXX  # bool
14  var_freq: XXXXX  # str
15  force_var_freq: XXXXX  # bool
16  remove_duplicates: XXXXX  # bool
17  time_varname: XXXXX  # str
18  period_varname: XXXXX  # str
19  time_coordinate: XXXXX  # str
20  time_dimname: XXXXX  # str
21  time_midpoint: XXXXX  # bool
22  time_endpoint: XXXXX  # bool
23  time_unit: XXXXX  # str
24  time_calendar: XXXXX  # gregorian|noleap
25  time_format: XXXXX  # str
26  add_time_coord: XXXXX  # bool
27  sum_along_dim: XXXXX  # str
28  group_name: XXXXX  # str
29  sum_variables: XXXXX  # str
30  slice_dimension:
31    any_key:
32      slice_min: XXXXX  # int
33      slice_max: XXXXX  # int
34      slice_freq: XXXXX  # int
35      method: XXXXX  # sum|avg
36  latitude_varname: XXXXX  # str
37  longitude_varname: XXXXX  # str
38  latitude_bounds_varname: XXXXX  # str
39  longitude_bounds_varname: XXXXX  # str
40  dir_vcoord: XXXXX  # str
41  file_vcoord: XXXXX  # str
42  vertical_coord: XXXXX  # mids|bounds
43  vertical_dim_name: XXXXX  # str
44  vertical_dim_type: XXXXX  # sigma_pressure|heights
45  sigma_a_var_name: XXXXX  # str
46  sigma_b_var_name: XXXXX  # str
47  pressure_unit: XXXXX  # Pa|hPa
48  reverse_vcoord: XXXXX  # bool