twpasolver.frequency module#

Definition of class for frequency span.

This module defines the Frequencies class for representing a span of frequencies with a variable unit of measure. The span can be provided either as a list or as a tuple that will be passed to numpy.arange.

pydantic model twpasolver.frequency.Frequencies[source]#

Bases: BaseModel

Frequency span with variable unit.

Show JSON schema
{
   "title": "Frequencies",
   "description": "Frequency span with variable unit.",
   "type": "object",
   "properties": {
      "f_list": {
         "anyOf": [
            {
               "items": {
                  "minimum": 0,
                  "type": "number"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "List of frequencies",
         "title": "F List"
      },
      "f_arange": {
         "anyOf": [
            {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "minimum": 0,
                     "type": "number"
                  },
                  {
                     "minimum": 0,
                     "type": "number"
                  },
                  {
                     "minimum": 0,
                     "type": "number"
                  }
               ],
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Tuple passed to numpy.arange to construct frequency span.",
         "title": "F Arange"
      },
      "unit": {
         "default": "GHz",
         "enum": [
            "Hz",
            "kHz",
            "MHz",
            "GHz",
            "THz"
         ],
         "title": "Unit",
         "type": "string"
      }
   }
}

Fields:
field f_list: list[typing.Annotated[float, Ge(ge=0)]] | None = None#

List of frequencies

field f_arange: tuple[typing.Annotated[float, Ge(ge=0)], typing.Annotated[float, Ge(ge=0)], typing.Annotated[float, Ge(ge=0)]] | None = None#

Tuple passed to numpy.arange to construct frequency span.

field unit: Literal['Hz', 'kHz', 'MHz', 'GHz', 'THz'] = 'GHz'#
property f: ndarray#

Computed frequencies array.

Returns:

Array of computed frequencies.

Return type:

numpy.ndarray

property omega: ndarray#

Computed angular frequencies array.

Returns:

Array of computed angular frequencies.

Return type:

numpy.ndarray

property unit_multiplier: float#

Get multiplier of chosen unit of measure.

Returns:

Multiplier corresponding to the unit of measure.

Return type:

float

model_post_init(context: Any, /) None#

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.