cavcalc


Namecavcalc JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://cavcalc.readthedocs.io/en/latest/
SummaryA program for computing Fabry-Perot optical cavity parameters.
upload_time2023-04-12 16:38:42
maintainer
docs_urlNone
authorSamuel Rowlinson
requires_python>=3.9,<4.0
licenseGPL-3.0-or-later
keywords physics optics interferometry
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/docs/source/_static/logo.svg)

A command line program and Python module for computing parameters associated with linear, Fabry-Perot optical cavities.

- Find the documentation at: https://cavcalc.readthedocs.io/en/latest/
- Follow the latest changes: https://gitlab.com/sjrowlinson/cavcalc
- See the entry on PyPI: https://pypi.org/project/cavcalc/

## Installation
To install `cavcalc`, simply run:

```
pip install cavcalc
```

Check that the installation was successful with:

```bash
cavcalc --version
```

if you see something along the lines of

```
cavcalc v1.1.0
```

then you should be ready to start using `cavcalc`!

**Note**: As is often recommended with the installation of Python packages (especially those with dependencies
on packages such as `numpy` and `matplotlib`, as is the case here), you should prefer to install `cavcalc` in
a suitable virtual environment. See [the official documentation on Python virtual environments](https://docs.python.org/3/tutorial/venv.html)
for details on how to set up these if you are unfamiliar with the topic.

## Example usage via the CLI

For details on available arguments run `cavcalc -h` on the command line.

Some examples follow on how to use `cavcalc`. See [the documentation on using cavcalc](https://cavcalc.readthedocs.io/en/latest/using/index.html)
for more in-depth examples and guides.

### Computing single parameters

You can ask for, e.g., the beam size on the mirrors of a symmetric cavity given its length and stability factor of the mirrors (gs) with:

```bash
cavcalc w -L 4000 -gs 0.91
```

This would result in an output of:

```
Given:
	Cavity length = 4000 m

	Stability g-factor of both mirrors = 0.91

	Wavelength of beam = 1064 nm

Computed:
	Radius of beam at mirrors = 57.16193267930482 mm
```

Units for both inputs and outputs can also be specified:

```bash
cavcalc w -u mm -L 10km -gouy 145deg
```

This requests the beam radius (in mm) on the mirrors of a symmetric cavity of length 10km given that the
round-trip Gouy phase is 145 degrees; resulting in the following output:

```
Given:
	Cavity length = 10 km

	Round-trip Gouy phase = 145 deg

	Wavelength of beam = 1064 nm

Computed:
	Radius of beam at mirrors = 59.59174828941794 mm
```

Support for units is provided via the package [Pint](https://pint.readthedocs.io/en/stable/index.html), so any units
defined in the Pint unit-registry can be used in cavcalc.

### Computing all available parameters

A compute target of `all` is the default choice which is used to calculate all parameters which can be determined
from the arguments specified. For example, using approximate values of the Advanced LIGO arm cavity parameters,

```bash
cavcalc -L 4km -Rc1 1934 -Rc2 2245 -T1 0.014 -L1 37.5e-6 -T2 5e-6 -L2 37.5e-6
```

gives the following output:

```
Given:
	Loss of first mirror = 3.75e-05
	Loss of second mirror = 3.75e-05
	Transmission of first mirror = 0.014
	Transmission of second mirror = 5e-06

	Cavity length = 4 km

	Radius of curvature of first mirror = 1934 m
	Radius of curvature of second mirror = 2245 m

	Wavelength of beam = 1064 nm

Computed:
	FSR = 37474.05725 Hz
	FWHM = 84.56921734107604 Hz
	Mode separation frequency = 4988.072188176178 Hz
	Pole frequency = 42.28460867053802 Hz

	Finesse = 443.11699254426594
	Reflectivity of first mirror = 0.9859625
	Reflectivity of second mirror = 0.9999574999999999

	Position of beam waist (from first mirror) = 1837.2153886417168 m

	Radius of beam at first mirror = 53.421066433049255 mm
	Radius of beam at second mirror = 62.448079883230896 mm
	Radius of beam at waist = 11.950538458990879 mm

	Stability g-factor of cavity = 0.8350925761717987
	Stability g-factor of first mirror = -1.0682523267838677
	Stability g-factor of second mirror = -0.7817371937639199

	Round-trip Gouy phase = 312.0813565565169 deg

	Divergence angle = 0.0016237789746943276 deg
```

### Units of output

The default behaviour for the output parameter units is to grab the relevant parameter type option under the `[units]` header
of the `cavcalc.ini` configuration file. When installing `cavcalc`, this file is written to a new `cavcalc/` directory within
your config directory (i.e. typically `~/.config/cavcalc/cavcalc.ini` under Unix systems). See the comments in this file for
details on the options available for the output units of each parameter type.

`cavcalc` attempts to read a `cavcalc.ini` config file from several locations in this fixed order:

- Firstly from the current working directory, then
- from `$XDG_CONFIG_HOME/cavcalc/` (or `%APPDATA%/cavcalc/` on Windows), then
- the final read attempt is from the within the source of the package directory itself.

The config options from these read attempts are loaded in a standard way; that is, any options appearing
first in the sequence defined above will take priority. If any of the above read attempts fails, then this
will be a silent failure; the only situation where an error could occur would be when *all* of the above
read attempts fail (which is very unlikely to happen).

Note that if you specify a `-u` argument when running `cavcalc` from the CLI, then this takes priority over
the options in the config file (as we saw in an example above).

### Evaluating, and plotting, parameters over data ranges

Parameters can be computed over ranges of data using:

* the data range syntax: `-<param_name> "start stop num [<units>]"`,
* or data from an input file with `-<param_name> <file>`.

We can use data-ranges to compute, and plot, arrays of target values, e.g:

```bash
cavcalc w -L "1 10 100 km" -Rc 5.1km --plot
```

This results in a plot (see below) showing how the beam radius at the mirrors of a symmetric cavity varies from
a cavity length of 1 km to 10 km with 100 data points, with the radii of curvature of both mirrors fixed at 5.1 km.

![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/images/symmcav_ws_vs_lengths.png)


Alternatively one could use a file of data, e.g:

```bash
cavcalc gouy -L 5cm -w beam_radii.txt --plot --saveplot symmcav_gouy_vs_ws.png
```

This then computes the round-trip Gouy phase (in degrees) of a symmetric cavity of length 5cm
using beam radii data stored in a file `beam_radii.txt`, and plots the results (see below). Note also that
you can save the resulting figure using the `--saveplot <filename>` syntax as seen in the above command.

![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/images/symmcav_gouy_vs_ws.png)

From the plot above you can also see that cavcalc supports automatically plotting of quantities which can be
dual-valued. In this case, the Gouy phase can be one of two values for each beam radius; this is due to the
nature of the equations which govern the Fabry-Perot cavity dynamics.

### Image / density plots via `--mesh`

When multiple arguments are given as data-ranges, one can use the `--mesh` option to construct mesh-grids
of these parameters. This allows cavcalc to automatically produce image plots. For example:

```bash
cavcalc w -L "1 10 100 km" -gouy "20 120 100 deg" --mesh true --plot
```

computes the radius of the beam on the mirrors of a symmetric cavity, against both the cavity length and
round-trip Gouy phase on a grid. This results in the plot shown below. Note that we simply used `--mesh true`
here, which automatically determines the ordering of the mesh-grid parameters based on the order in which
these parameters were given. One could replace the above with, e.g., `--mesh "gouy,L"` to reverse the order
of the mesh-grid; and thereby flip the parameter axes on any automated plots.

![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/images/symmcav_w_vs_L_gouy.png)

A matplotlib compliant colour-map can be specified when making an image plot using the `--cmap <name>` option. For example,
the following command gives the plot shown below.

```bash
cavcalc gouy -L 12um -g1 "-2 2 499" -g2 "-2 2 499" --mesh true --plot --cmap Spectral_r
```

![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/images/asymmcav_w0_vs_g1g2.png)

## A note on g-factors

Stability (g) factors are split into four different parameters for implementation purposes and to
hopefully make it clearer as to which argument is being used and whether the resulting cavity
computations are for a symmetric or asymmetric cavity. These arguments are detailed here:

- `-gs` : The symmetric, singular stability factor. This represents the individual g-factors of **both**
          cavity mirrors. Use this to define a *symmetric* cavity where the overall cavity g-factor is
		  then simply `g = gs * gs`.
- `-g` : The overall cavity stability factor. This is the product of the individual g-factors of the
         cavity mirrors. Use this to define a *symmetric* cavity where the individual g-factors of **both**
		 mirrors are then `gs = +/- sqrt(g)`.
- `-g1` : The stability factor of the first cavity mirror. Use this to define an *asymmetric* cavity
          along with the argument `-g2` such that the overall cavity g-factor is then `g = g1 * g2`.
- `-g2` : The stability factor of the second cavity mirror. Use this to define an *asymmetric* cavity
          along with the argument `-g1` such that the overall cavity g-factor is then `g = g1 * g2`.

---

## Using `cavcalc` programmatically

As well as providing a CLI, cavcalc has a full API which allows users to interact with this tool
via Python. The recommended method for doing this is to use the single-function interface via
[`cavcalc.calculate`](https://cavcalc.readthedocs.io/en/latest/api/generated/cavcalc.calculate.calculate.html#cavcalc.calculate.calculate). This
function works similarly to the CLI, where a target can be specified along with a variable number of keyword
arguments corresponding to the physical parameters. This function then returns one of two output objects (`SingleOutput`
if a target was given, `MultiOutput` otherwise); see [`cavcalc.output`](https://cavcalc.readthedocs.io/en/latest/api/cavcalc.output.html#module-cavcalc.output)
for details.

For example, the following script will compute all available targets from the cavity length and mirror radii
of curvature provided:

```python
import cavcalc as cc

# Specifying no target means all possible targets are computed
out = cc.calculate(L="4km", Rc1=1934, Rc2=2245)

# Printing the output object results in the same output as
# you would see when running via the CLI
print(out)
```

producing:

```
Given:
	Cavity length = 4 km

	Radius of curvature of first mirror = 1934 m
	Radius of curvature of second mirror = 2245 m

	Wavelength of beam = 1064 nm

Computed:
	FSR = 37474.05725 Hz
	Mode separation frequency = 4988.072188176178 Hz

	Position of beam waist (from first mirror) = 1837.2153886417168 m

	Radius of beam at first mirror = 53.421066433049255 mm
	Radius of beam at second mirror = 62.448079883230896 mm
	Radius of beam at waist = 11.950538458990879 mm

	Stability g-factor of cavity = 0.8350925761717987
	Stability g-factor of first mirror = -1.0682523267838677
	Stability g-factor of second mirror = -0.7817371937639199

	Round-trip Gouy phase = 312.0813565565169 deg

	Divergence angle = 0.0016237789746943276 deg
```

An extra feature of the API is the ability to use the `cavcalc.configure` function for overriding
default behaviour. For example, in the script below we use this in a context-managed scope to
temporarily use microns for any beam radius parameters, mm for distances, and GHz for any frequencies:

```python
import cavcalc as cc

# Temporarily override units...
with cc.configure(beamsizes="um", distances="mm", frequencies="GHz"):
    out = cc.calculate(L=8, gouy=121)
    print(out)

# ... previous state (using loaded config options) will
# be restored on exit from the with block above
```

resulting in:

```
Given:
    Cavity length = 8 mm

    Round-trip Gouy phase = 121 deg

    Wavelength of beam = 1064 nm

Computed:
    FSR = 18.737028625 GHz
    Mode separation frequency = 6.297723510069445 GHz

    Position of beam waist (from first mirror) = 4.0 mm

    Radius of curvature of both mirrors = 0.01576117284251957 m

    Radius of beam at mirrors = 55.79464044247193 µm
    Radius of beam at waist = 48.19739141432035 µm

    Stability g-factor of cavity = 0.2424809625449729
    Stability g-factor of both mirrors = 0.4924235601034671

    Divergence angle = 0.40260921048107506 deg
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://cavcalc.readthedocs.io/en/latest/",
    "name": "cavcalc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "physics,optics,interferometry",
    "author": "Samuel Rowlinson",
    "author_email": "samueljrowlinson@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8f/2a/5687f58475d816137f9dc0c5c538d0d5374ea9d24893cb4a4b90d921dace/cavcalc-1.1.0.tar.gz",
    "platform": null,
    "description": "![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/docs/source/_static/logo.svg)\n\nA command line program and Python module for computing parameters associated with linear, Fabry-Perot optical cavities.\n\n- Find the documentation at: https://cavcalc.readthedocs.io/en/latest/\n- Follow the latest changes: https://gitlab.com/sjrowlinson/cavcalc\n- See the entry on PyPI: https://pypi.org/project/cavcalc/\n\n## Installation\nTo install `cavcalc`, simply run:\n\n```\npip install cavcalc\n```\n\nCheck that the installation was successful with:\n\n```bash\ncavcalc --version\n```\n\nif you see something along the lines of\n\n```\ncavcalc v1.1.0\n```\n\nthen you should be ready to start using `cavcalc`!\n\n**Note**: As is often recommended with the installation of Python packages (especially those with dependencies\non packages such as `numpy` and `matplotlib`, as is the case here), you should prefer to install `cavcalc` in\na suitable virtual environment. See [the official documentation on Python virtual environments](https://docs.python.org/3/tutorial/venv.html)\nfor details on how to set up these if you are unfamiliar with the topic.\n\n## Example usage via the CLI\n\nFor details on available arguments run `cavcalc -h` on the command line.\n\nSome examples follow on how to use `cavcalc`. See [the documentation on using cavcalc](https://cavcalc.readthedocs.io/en/latest/using/index.html)\nfor more in-depth examples and guides.\n\n### Computing single parameters\n\nYou can ask for, e.g., the beam size on the mirrors of a symmetric cavity given its length and stability factor of the mirrors (gs) with:\n\n```bash\ncavcalc w -L 4000 -gs 0.91\n```\n\nThis would result in an output of:\n\n```\nGiven:\n\tCavity length = 4000 m\n\n\tStability g-factor of both mirrors = 0.91\n\n\tWavelength of beam = 1064 nm\n\nComputed:\n\tRadius of beam at mirrors = 57.16193267930482 mm\n```\n\nUnits for both inputs and outputs can also be specified:\n\n```bash\ncavcalc w -u mm -L 10km -gouy 145deg\n```\n\nThis requests the beam radius (in mm) on the mirrors of a symmetric cavity of length 10km given that the\nround-trip Gouy phase is 145 degrees; resulting in the following output:\n\n```\nGiven:\n\tCavity length = 10 km\n\n\tRound-trip Gouy phase = 145 deg\n\n\tWavelength of beam = 1064 nm\n\nComputed:\n\tRadius of beam at mirrors = 59.59174828941794 mm\n```\n\nSupport for units is provided via the package [Pint](https://pint.readthedocs.io/en/stable/index.html), so any units\ndefined in the Pint unit-registry can be used in cavcalc.\n\n### Computing all available parameters\n\nA compute target of `all` is the default choice which is used to calculate all parameters which can be determined\nfrom the arguments specified. For example, using approximate values of the Advanced LIGO arm cavity parameters,\n\n```bash\ncavcalc -L 4km -Rc1 1934 -Rc2 2245 -T1 0.014 -L1 37.5e-6 -T2 5e-6 -L2 37.5e-6\n```\n\ngives the following output:\n\n```\nGiven:\n\tLoss of first mirror = 3.75e-05\n\tLoss of second mirror = 3.75e-05\n\tTransmission of first mirror = 0.014\n\tTransmission of second mirror = 5e-06\n\n\tCavity length = 4 km\n\n\tRadius of curvature of first mirror = 1934 m\n\tRadius of curvature of second mirror = 2245 m\n\n\tWavelength of beam = 1064 nm\n\nComputed:\n\tFSR = 37474.05725 Hz\n\tFWHM = 84.56921734107604 Hz\n\tMode separation frequency = 4988.072188176178 Hz\n\tPole frequency = 42.28460867053802 Hz\n\n\tFinesse = 443.11699254426594\n\tReflectivity of first mirror = 0.9859625\n\tReflectivity of second mirror = 0.9999574999999999\n\n\tPosition of beam waist (from first mirror) = 1837.2153886417168 m\n\n\tRadius of beam at first mirror = 53.421066433049255 mm\n\tRadius of beam at second mirror = 62.448079883230896 mm\n\tRadius of beam at waist = 11.950538458990879 mm\n\n\tStability g-factor of cavity = 0.8350925761717987\n\tStability g-factor of first mirror = -1.0682523267838677\n\tStability g-factor of second mirror = -0.7817371937639199\n\n\tRound-trip Gouy phase = 312.0813565565169 deg\n\n\tDivergence angle = 0.0016237789746943276 deg\n```\n\n### Units of output\n\nThe default behaviour for the output parameter units is to grab the relevant parameter type option under the `[units]` header\nof the `cavcalc.ini` configuration file. When installing `cavcalc`, this file is written to a new `cavcalc/` directory within\nyour config directory (i.e. typically `~/.config/cavcalc/cavcalc.ini` under Unix systems). See the comments in this file for\ndetails on the options available for the output units of each parameter type.\n\n`cavcalc` attempts to read a `cavcalc.ini` config file from several locations in this fixed order:\n\n- Firstly from the current working directory, then\n- from `$XDG_CONFIG_HOME/cavcalc/` (or `%APPDATA%/cavcalc/` on Windows), then\n- the final read attempt is from the within the source of the package directory itself.\n\nThe config options from these read attempts are loaded in a standard way; that is, any options appearing\nfirst in the sequence defined above will take priority. If any of the above read attempts fails, then this\nwill be a silent failure; the only situation where an error could occur would be when *all* of the above\nread attempts fail (which is very unlikely to happen).\n\nNote that if you specify a `-u` argument when running `cavcalc` from the CLI, then this takes priority over\nthe options in the config file (as we saw in an example above).\n\n### Evaluating, and plotting, parameters over data ranges\n\nParameters can be computed over ranges of data using:\n\n* the data range syntax: `-<param_name> \"start stop num [<units>]\"`,\n* or data from an input file with `-<param_name> <file>`.\n\nWe can use data-ranges to compute, and plot, arrays of target values, e.g:\n\n```bash\ncavcalc w -L \"1 10 100 km\" -Rc 5.1km --plot\n```\n\nThis results in a plot (see below) showing how the beam radius at the mirrors of a symmetric cavity varies from\na cavity length of 1 km to 10 km with 100 data points, with the radii of curvature of both mirrors fixed at 5.1 km.\n\n![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/images/symmcav_ws_vs_lengths.png)\n\n\nAlternatively one could use a file of data, e.g:\n\n```bash\ncavcalc gouy -L 5cm -w beam_radii.txt --plot --saveplot symmcav_gouy_vs_ws.png\n```\n\nThis then computes the round-trip Gouy phase (in degrees) of a symmetric cavity of length 5cm\nusing beam radii data stored in a file `beam_radii.txt`, and plots the results (see below). Note also that\nyou can save the resulting figure using the `--saveplot <filename>` syntax as seen in the above command.\n\n![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/images/symmcav_gouy_vs_ws.png)\n\nFrom the plot above you can also see that cavcalc supports automatically plotting of quantities which can be\ndual-valued. In this case, the Gouy phase can be one of two values for each beam radius; this is due to the\nnature of the equations which govern the Fabry-Perot cavity dynamics.\n\n### Image / density plots via `--mesh`\n\nWhen multiple arguments are given as data-ranges, one can use the `--mesh` option to construct mesh-grids\nof these parameters. This allows cavcalc to automatically produce image plots. For example:\n\n```bash\ncavcalc w -L \"1 10 100 km\" -gouy \"20 120 100 deg\" --mesh true --plot\n```\n\ncomputes the radius of the beam on the mirrors of a symmetric cavity, against both the cavity length and\nround-trip Gouy phase on a grid. This results in the plot shown below. Note that we simply used `--mesh true`\nhere, which automatically determines the ordering of the mesh-grid parameters based on the order in which\nthese parameters were given. One could replace the above with, e.g., `--mesh \"gouy,L\"` to reverse the order\nof the mesh-grid; and thereby flip the parameter axes on any automated plots.\n\n![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/images/symmcav_w_vs_L_gouy.png)\n\nA matplotlib compliant colour-map can be specified when making an image plot using the `--cmap <name>` option. For example,\nthe following command gives the plot shown below.\n\n```bash\ncavcalc gouy -L 12um -g1 \"-2 2 499\" -g2 \"-2 2 499\" --mesh true --plot --cmap Spectral_r\n```\n\n![](https://gitlab.com/sjrowlinson/cavcalc/raw/master/images/asymmcav_w0_vs_g1g2.png)\n\n## A note on g-factors\n\nStability (g) factors are split into four different parameters for implementation purposes and to\nhopefully make it clearer as to which argument is being used and whether the resulting cavity\ncomputations are for a symmetric or asymmetric cavity. These arguments are detailed here:\n\n- `-gs` : The symmetric, singular stability factor. This represents the individual g-factors of **both**\n          cavity mirrors. Use this to define a *symmetric* cavity where the overall cavity g-factor is\n\t\t  then simply `g = gs * gs`.\n- `-g` : The overall cavity stability factor. This is the product of the individual g-factors of the\n         cavity mirrors. Use this to define a *symmetric* cavity where the individual g-factors of **both**\n\t\t mirrors are then `gs = +/- sqrt(g)`.\n- `-g1` : The stability factor of the first cavity mirror. Use this to define an *asymmetric* cavity\n          along with the argument `-g2` such that the overall cavity g-factor is then `g = g1 * g2`.\n- `-g2` : The stability factor of the second cavity mirror. Use this to define an *asymmetric* cavity\n          along with the argument `-g1` such that the overall cavity g-factor is then `g = g1 * g2`.\n\n---\n\n## Using `cavcalc` programmatically\n\nAs well as providing a CLI, cavcalc has a full API which allows users to interact with this tool\nvia Python. The recommended method for doing this is to use the single-function interface via\n[`cavcalc.calculate`](https://cavcalc.readthedocs.io/en/latest/api/generated/cavcalc.calculate.calculate.html#cavcalc.calculate.calculate). This\nfunction works similarly to the CLI, where a target can be specified along with a variable number of keyword\narguments corresponding to the physical parameters. This function then returns one of two output objects (`SingleOutput`\nif a target was given, `MultiOutput` otherwise); see [`cavcalc.output`](https://cavcalc.readthedocs.io/en/latest/api/cavcalc.output.html#module-cavcalc.output)\nfor details.\n\nFor example, the following script will compute all available targets from the cavity length and mirror radii\nof curvature provided:\n\n```python\nimport cavcalc as cc\n\n# Specifying no target means all possible targets are computed\nout = cc.calculate(L=\"4km\", Rc1=1934, Rc2=2245)\n\n# Printing the output object results in the same output as\n# you would see when running via the CLI\nprint(out)\n```\n\nproducing:\n\n```\nGiven:\n\tCavity length = 4 km\n\n\tRadius of curvature of first mirror = 1934 m\n\tRadius of curvature of second mirror = 2245 m\n\n\tWavelength of beam = 1064 nm\n\nComputed:\n\tFSR = 37474.05725 Hz\n\tMode separation frequency = 4988.072188176178 Hz\n\n\tPosition of beam waist (from first mirror) = 1837.2153886417168 m\n\n\tRadius of beam at first mirror = 53.421066433049255 mm\n\tRadius of beam at second mirror = 62.448079883230896 mm\n\tRadius of beam at waist = 11.950538458990879 mm\n\n\tStability g-factor of cavity = 0.8350925761717987\n\tStability g-factor of first mirror = -1.0682523267838677\n\tStability g-factor of second mirror = -0.7817371937639199\n\n\tRound-trip Gouy phase = 312.0813565565169 deg\n\n\tDivergence angle = 0.0016237789746943276 deg\n```\n\nAn extra feature of the API is the ability to use the `cavcalc.configure` function for overriding\ndefault behaviour. For example, in the script below we use this in a context-managed scope to\ntemporarily use microns for any beam radius parameters, mm for distances, and GHz for any frequencies:\n\n```python\nimport cavcalc as cc\n\n# Temporarily override units...\nwith cc.configure(beamsizes=\"um\", distances=\"mm\", frequencies=\"GHz\"):\n    out = cc.calculate(L=8, gouy=121)\n    print(out)\n\n# ... previous state (using loaded config options) will\n# be restored on exit from the with block above\n```\n\nresulting in:\n\n```\nGiven:\n    Cavity length = 8 mm\n\n    Round-trip Gouy phase = 121 deg\n\n    Wavelength of beam = 1064 nm\n\nComputed:\n    FSR = 18.737028625 GHz\n    Mode separation frequency = 6.297723510069445 GHz\n\n    Position of beam waist (from first mirror) = 4.0 mm\n\n    Radius of curvature of both mirrors = 0.01576117284251957 m\n\n    Radius of beam at mirrors = 55.79464044247193 \u00b5m\n    Radius of beam at waist = 48.19739141432035 \u00b5m\n\n    Stability g-factor of cavity = 0.2424809625449729\n    Stability g-factor of both mirrors = 0.4924235601034671\n\n    Divergence angle = 0.40260921048107506 deg\n```\n\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "A program for computing Fabry-Perot optical cavity parameters.",
    "version": "1.1.0",
    "split_keywords": [
        "physics",
        "optics",
        "interferometry"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c928582efac51e8bca665b7ac9a0172400c689167d0a9dedc422af93d3106b8",
                "md5": "8e63e5f9082cfffab308901ebe4df9af",
                "sha256": "3898fad088154828ebdc6939f0b8443c810834e9b2281be721eae134b8b2f6d4"
            },
            "downloads": -1,
            "filename": "cavcalc-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8e63e5f9082cfffab308901ebe4df9af",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 57728,
            "upload_time": "2023-04-12T16:38:40",
            "upload_time_iso_8601": "2023-04-12T16:38:40.120637Z",
            "url": "https://files.pythonhosted.org/packages/1c/92/8582efac51e8bca665b7ac9a0172400c689167d0a9dedc422af93d3106b8/cavcalc-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8f2a5687f58475d816137f9dc0c5c538d0d5374ea9d24893cb4a4b90d921dace",
                "md5": "f7248eafe1bc4edea0e68f652c99d5dd",
                "sha256": "900629b925d924aa8a152ff4608fc5b2502e83dbfb3eb332b427e58c6c725905"
            },
            "downloads": -1,
            "filename": "cavcalc-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f7248eafe1bc4edea0e68f652c99d5dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 51865,
            "upload_time": "2023-04-12T16:38:42",
            "upload_time_iso_8601": "2023-04-12T16:38:42.106557Z",
            "url": "https://files.pythonhosted.org/packages/8f/2a/5687f58475d816137f9dc0c5c538d0d5374ea9d24893cb4a4b90d921dace/cavcalc-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-12 16:38:42",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "cavcalc"
}
        
Elapsed time: 0.05516s