#!/usr/bin/env python # -*- coding: utf-8 -*- """ # *.result: g = 0.0310978 +/- 0.004522 (14.54%) # fabry.v: 0.001067 \le n \le 0.001127 """ from __future__ import division import sys Hz = 1.0 MHz = 1E6 from intervals import Interval with open("fabry.v") as f: n = f.read() parts = n.split(r"\le n \le", 1) assert(len(parts) == 2) nmin, nmax = parts nmin = float(nmin.strip()) nmax = float(nmax.strip()) ng = Interval(nmin, nmax) ref_mode_spacing = 100E6 def interval_from_gnuplot_pm(line): line = line.split("(")[0].strip() vname, rest = line.split("=", 1) vname = vname.strip() rest = rest.strip() a,da = map(float, rest.split("+/-")) vvalue = Interval(a - da, a + da) #print(vname, vvalue, line) return vname, vvalue params = {} for line in sys.stdin.readlines(): parts = line.split("=", 1) if len(parts) == 2 and line.find("+/-") != -1: n, vvalue = interval_from_gnuplot_pm(line) assert(n not in params) params[n] = vvalue with file("ν_FSR.v") as f: nu_FSR = float(f.read().strip())*Hz with file("ν_0.v") as f: nu_0 = float(f.read().strip())*Hz g = params["g"] x0 = params["x0"] a = ref_mode_spacing*(g/ng)*Hz print("\\\\\n $ \\Delta ν := 100\\,\\unit{MHz}\\,g/n = (%.3g \\pm %.2g)\\,\\unit{MHz} $" % ((a[0] + a[1])/(2*MHz), (a[1] - a[0])/(2*MHz))) #Q_load = (x0/g) Q_load = nu_0/a print("\\\\\n $ Q_{load} := \\frac{ν_0}{Δν} = %.3g \\pm %.2g $" % ((Q_load[0] + Q_load[1])/2, (Q_load[1] - Q_load[0])/2)) F = nu_FSR/a print("\\\\\n $ \\mathcal{F} := \\frac{Δν_{FSR}}{Δν} = %.3g \\pm %.2g $" % ((F[0] + F[1])/2, (F[1] - F[0])/2)) # FIXME Q_0 # FIXME photon lifetime τ