Skip to content

PhfStream

PhfStream(filename, mode='r', set_config=True)

Create a PhfStream object for writing or loading phf files.

Args

  • filename (str): Phf file name.
  • mode (Literal[“r”, “w”]): Either "r" or "w" to open the file for reading or writing, respectively.
  • set_config (bool): If True and mode == 'r', set the configuration with values loaded from the file.
MethodDescription
closeClose the stream.
contentsIndex of the stream contents.
dataList of all objects stored in the phf stream file.
load_componentLoad components from this stream.
load_technologyLoad technologies from this stream.
writeWrite objects to this phf stream file.

close(self)

Close the stream.

contents(self, only_explicit=True)

Index of the stream contents.

Args

  • only_explicit (bool): If set, only explicitly written component and technology entries are returned (excludes automatically included dependencies).

Returns

dict[Literal[“components”, “technologies”], set[str] | set[tuple[str, str]]] Dictionary with keys "components" and "technologies". The former holds a set of Component names, and the latter a set of tuples with Technology names and versions.

data(self)

List of all objects stored in the phf stream file.

Returns

list[object]: Objects stored in the phf stream, in the order they were originally stored.

load_component(self, name=None, only_explicit=True)

Load components from this stream.

Args

  • name (str | None): If given, only the named component is returned, otherwise all components in the stream.
  • only_explicit (bool): If set, only explicitly stored components are returned. This argument is ignored if name is given.

Returns

list[Component]: Loaded components.

load_technology(self, name=None, version=None, only_explicit=True)

Load technologies from this stream.

Args

  • name (str | None): If given, only technologies with this name are returned, otherwise all technologies in the stream.
  • version (str | None): If given, only technologies with this version are returned, otherwise all technologies in the stream.
  • only_explicit (bool): If set, only explicitly stored technologies are returned. This argument is ignored if both name and version are given.

Returns

list[Technology]: Loaded technologies.

write(self, *args)

Write objects to this phf stream file.

Args

  • *args (object): All photonforge objects are supported. Serializable Tidy3D objects and many native python and numpy types are also supported.

Returns

PhfStream: This object.

AttributeDescription
configdict[str, object] | None: Configuration present in phf files (read only).
propertiesProperties: Object properties.

dict[str, object] | None: Configuration present in phf files (read only).

Properties: Object properties.