fibermodes.fiber.factory¶
A FiberFactory is used to build
Fiber objects.
-
class
fibermodes.fiber.factory.FiberFactory(filename=None)[source]¶ Bases:
objectFiberFactory is used to instantiate a
Fiberor a series of Fiber objects.It can read fiber definition from json file, and write it back. Convenient functions are available to set fiber parameters, and to iterate through fiber objects.
All fibers build from a given factory share the same number of layers, the same kind of geometries, and the same materials. However, parameters can vary.
Parameters: filename – Name of fiber file to load, or None to construct empty Fiberfactory object. -
addLayer(pos=None, name='', radius=0, material='Fixed', geometry='StepIndex', **kwargs)[source]¶ Insert a new layer in the factory.
Parameters: - pos (int or None) – Position the the inserted layer. By default, new layer is inserted at the end.
- name (string) – Layer name.
- radius (float) – Radius of the layer (in meters).
- material (string) – Name of the Material (default: Fixed)
- geometry (string) – Name of the Geometry (default: StepIndex)
- tparams (list) – Parameters for the Geometry
- mparams (list) – Parameters for the Material
- index (float) – Index of the layer (for Fixed Material, otherwise parameters are calculated to give this index)
- x (float) – Molar concentration for the Material
- wl (float) – Wavelength (in m) used for calculating parameters (when index is given)
Please note that some parameters are specific to some
materialorgeometry:Fixedmaterial- index is required. mparams is ignored.
CompMaterial(SiO2GeO2)- You can specify either x or index and wl. mparams is ignored.
Author of the fiber definition.
Used as a reference.
-
crdate¶ Creation date of this factory.
-
description¶ Description of the fiber build form this factory.
-
dump(fp, **kwargs)[source]¶ Dumps fiber factory to a file.
Parameters: - fp – File pointer.
- **kwargs – See json.dumps
-
dumps(**kwargs)[source]¶ Dumps fiber factory to a string.
Parameters: **kwargs – See json.dumps. Returns: JSON string.
-
layers¶ List of layers.
-
load(fp, **kwargs)[source]¶ Loads fiber factory from file.
File contents is validated when loaded, and version is upgraded is needed.
Parameters: - fp – File pointer.
- **kwargs – See json.loads
-
loads(s, **kwargs)[source]¶ Loads fiber factory from JSON string.
String contents is validated when loaded, and version is upgraded is needed.
Parameters: - s (string) – JSON string
- **kwargs – See json.loads
-
name¶ Name of the fiber.
The name simply is a string identifier.
-
removeLayer(pos=-1)[source]¶ Remore layer at given position (default: last layer)
Parameters: pos (int) – Index of the layer to remove.
-
tstamp¶ Timestamp (modification date).
This is automatically updated when the fiber factory is saved.
-
validate(obj)[source]¶ Validates that obj is a valid fiber factory.
Parameters: obj (dict) – Dict of fiber factory parameters. Raises: FiberFactoryValidationError– Object does not validate.
-