rads.config.builders module

Builders for configuration dataclasses in rads.config.tree.

class rads.config.builders.SatelliteBuilder(*, id: str = REQUIRED, id3: str = REQUIRED, name: str = REQUIRED, names: Sequence[str] = REQUIRED, dt1hz: float = REQUIRED, inclination: float = REQUIRED, frequency: Sequence[float] = REQUIRED, phases: Sequence[rads.config.tree.Phase] = OPTIONAL, aliases: Mapping[str, Sequence[str]] = OPTIONAL, variables: Mapping[str, rads.config.tree.Variable[float][float]] = OPTIONAL)

Bases: object

Builder for the rads.config.tree.Satellite dataclass.

This class allows the rads.config.tree.Satellite dataclass to be constructed with the builder pattern. Once an instance is constructed simply assign to it’s attributes, which are identical to the rads.config.tree.Satellite dataclass. When done use it’s build method, or the build() function if one of the fields is build, to make an instance of the rads.config.tree.Satellite dataclass using the field values set on this builder.

Warning

Because this class overrides attribute assignment, care must be taken when extending to only use private and/or “dunder” attributes and methods.

See rads.config.tree.Satellite for further information on each filed.

Parameters
  • id – Optionally initialize id field.

  • id3 – Optionally initialize id3 field.

  • name – Optionally initialize name field.

  • names – Optionally initialize names field.

  • dt1hz – Optionally initialize dt1hz field.

  • inclination – Optionally initialize inclination field.

  • frequency – Optionally initialize frequency field.

  • phases – Optionally initialize phases field.

  • aliases – Optionally initialize aliases field.

  • variables – Optionally initialize variables field.

Raises
  • dataclass_builder.exceptions.UndefinedFieldError – If you try to assign to a field that is not part of rads.config.tree.Satellite’s __init__ method.

  • dataclass_builder.exceptions.MissingFieldError – If build() is called on this builder before all non default fields of the dataclass are assigned.

build() → rads.config.tree.Satellite

Build a rads.config.tree.Satellite dataclass using the fields from this builder.

Returns

An instance of the rads.config.tree.Satellite dataclass using the fields set on this builder instance.

Raises

dataclass_builder.exceptions.MissingFieldError – If not all of the required fields have been assigned to this builder instance.

fields(required: bool = True, optional: bool = True) → Mapping[str, Field[Any]]

Get a dictionary of the builder’s fields.

Parameters
  • required – Set to False to not report required fields.

  • optional – Set to False to not report optional fields.

Returns

A mapping from field names to actual dataclasses.Field’s in the same order as in the rads.config.tree.Satellite dataclass.

class rads.config.builders.PhaseBuilder(*, id: str = REQUIRED, mission: str = REQUIRED, cycles: rads.config.tree.Cycles = REQUIRED, repeat: rads.config.tree.Repeat = REQUIRED, reference_pass: rads.config.tree.ReferencePass = REQUIRED, start_time: datetime.datetime = REQUIRED, end_time: Optional[datetime.datetime] = OPTIONAL, subcycles: Optional[rads.config.tree.SubCycles] = OPTIONAL)

Bases: object

Builder for the rads.config.tree.Phase dataclass.

This class allows the rads.config.tree.Phase dataclass to be constructed with the builder pattern. Once an instance is constructed simply assign to it’s attributes, which are identical to the rads.config.tree.Phase dataclass. When done use it’s build method, or the build() function if one of the fields is build, to make an instance of the rads.config.tree.Phase dataclass using the field values set on this builder.

Warning

Because this class overrides attribute assignment, care must be taken when extending to only use private and/or “dunder” attributes and methods.

See rads.config.tree.Phase for further information on each filed.

Parameters
  • id – Optionally initialize id field.

  • mission – Optionally initialize mission field.

  • cycles – Optionally initialize cycles field.

  • repeat – Optionally initialize repeat field.

  • reference_pass – Optionally initialize reference_pass field.

  • start_time – Optionally initialize start_time field.

  • end_time – Optionally initialize end_time field.

  • subcycles – Optionally initialize subcycles field.

Raises
  • dataclass_builder.exceptions.UndefinedFieldError – If you try to assign to a field that is not part of rads.config.tree.Phase’s __init__ method.

  • dataclass_builder.exceptions.MissingFieldError – If build() is called on this builder before all non default fields of the dataclass are assigned.

build() → rads.config.tree.Phase

Build a rads.config.tree.Phase dataclass using the fields from this builder.

Returns

An instance of the rads.config.tree.Phase dataclass using the fields set on this builder instance.

Raises

dataclass_builder.exceptions.MissingFieldError – If not all of the required fields have been assigned to this builder instance.

fields(required: bool = True, optional: bool = True) → Mapping[str, Field[Any]]

Get a dictionary of the builder’s fields.

Parameters
  • required – Set to False to not report required fields.

  • optional – Set to False to not report optional fields.

Returns

A mapping from field names to actual dataclasses.Field’s in the same order as in the rads.config.tree.Phase dataclass.

class rads.config.builders.VariableBuilder(*, id: str = REQUIRED, name: str = REQUIRED, data: Union[rads.config.tree.Constant, rads.rpn.CompleteExpression, rads.config.tree.Flags, rads.config.tree.Grid, rads.config.tree.NetCDFAttribute, rads.config.tree.NetCDFVariable] = REQUIRED, units: Union[cf_units.Unit, str] = OPTIONAL, standard_name: Optional[str] = OPTIONAL, source: str = OPTIONAL, comment: str = OPTIONAL, flag_values: Optional[Sequence[str]] = OPTIONAL, flag_masks: Optional[Sequence[str]] = OPTIONAL, limits: Optional[rads.config.tree.Range[~N][N]] = OPTIONAL, plot_range: Optional[rads.config.tree.Range[~N][N]] = OPTIONAL, quality_flag: Optional[Sequence[str]] = OPTIONAL, dimensions: int = OPTIONAL, format: Optional[str] = OPTIONAL, compress: Optional[rads.config.tree.Compress] = OPTIONAL, default: Optional[float] = OPTIONAL)

Bases: object

Builder for the rads.config.tree.Variable dataclass.

This class allows the rads.config.tree.Variable dataclass to be constructed with the builder pattern. Once an instance is constructed simply assign to it’s attributes, which are identical to the rads.config.tree.Variable dataclass. When done use it’s build method, or the build() function if one of the fields is build, to make an instance of the rads.config.tree.Variable dataclass using the field values set on this builder.

Warning

Because this class overrides attribute assignment, care must be taken when extending to only use private and/or “dunder” attributes and methods.

See rads.config.tree.Variable for further information on each filed.

Parameters
  • id – Optionally initialize id field.

  • name – Optionally initialize name field.

  • data – Optionally initialize data field.

  • units – Optionally initialize units field.

  • standard_name – Optionally initialize standard_name field.

  • source – Optionally initialize source field.

  • comment – Optionally initialize comment field.

  • flag_values – Optionally initialize flag_values field.

  • flag_masks – Optionally initialize flag_masks field.

  • limits – Optionally initialize limits field.

  • plot_range – Optionally initialize plot_range field.

  • quality_flag – Optionally initialize quality_flag field.

  • dimensions – Optionally initialize dimensions field.

  • format – Optionally initialize format field.

  • compress – Optionally initialize compress field.

  • default – Optionally initialize default field.

Raises
  • dataclass_builder.exceptions.UndefinedFieldError – If you try to assign to a field that is not part of rads.config.tree.Variable’s __init__ method.

  • dataclass_builder.exceptions.MissingFieldError – If build() is called on this builder before all non default fields of the dataclass are assigned.

build() → rads.config.tree.Variable

Build a rads.config.tree.Variable dataclass using the fields from this builder.

Returns

An instance of the rads.config.tree.Variable dataclass using the fields set on this builder instance.

Raises

dataclass_builder.exceptions.MissingFieldError – If not all of the required fields have been assigned to this builder instance.

fields(required: bool = True, optional: bool = True) → Mapping[str, Field[Any]]

Get a dictionary of the builder’s fields.

Parameters
  • required – Set to False to not report required fields.

  • optional – Set to False to not report optional fields.

Returns

A mapping from field names to actual dataclasses.Field’s in the same order as in the rads.config.tree.Variable dataclass.

class rads.config.builders.PreConfigBuilder(*, dataroot: Union[str, os.PathLike] = REQUIRED, config_files: Sequence[Union[str, os.PathLike, IO[Any]]] = REQUIRED, satellites: Collection[str] = REQUIRED, blacklist: Collection[str] = OPTIONAL)

Bases: object

Builder for the rads.config.tree.PreConfig dataclass.

This class allows the rads.config.tree.PreConfig dataclass to be constructed with the builder pattern. Once an instance is constructed simply assign to it’s attributes, which are identical to the rads.config.tree.PreConfig dataclass. When done use it’s build method, or the build() function if one of the fields is build, to make an instance of the rads.config.tree.PreConfig dataclass using the field values set on this builder.

Warning

Because this class overrides attribute assignment, care must be taken when extending to only use private and/or “dunder” attributes and methods.

See rads.config.tree.PreConfig for further information on each filed.

Parameters
  • dataroot – Optionally initialize dataroot field.

  • config_files – Optionally initialize config_files field.

  • satellites – Optionally initialize satellites field.

  • blacklist – Optionally initialize blacklist field.

Raises
  • dataclass_builder.exceptions.UndefinedFieldError – If you try to assign to a field that is not part of rads.config.tree.PreConfig’s __init__ method.

  • dataclass_builder.exceptions.MissingFieldError – If build() is called on this builder before all non default fields of the dataclass are assigned.

build() → rads.config.tree.PreConfig

Build a rads.config.tree.PreConfig dataclass using the fields from this builder.

Returns

An instance of the rads.config.tree.PreConfig dataclass using the fields set on this builder instance.

Raises

dataclass_builder.exceptions.MissingFieldError – If not all of the required fields have been assigned to this builder instance.

fields(required: bool = True, optional: bool = True) → Mapping[str, Field[Any]]

Get a dictionary of the builder’s fields.

Parameters
  • required – Set to False to not report required fields.

  • optional – Set to False to not report optional fields.

Returns

A mapping from field names to actual dataclasses.Field’s in the same order as in the rads.config.tree.PreConfig dataclass.