From abaa3bd36f378f03c11d89eb0c9a7923132c3f7b Mon Sep 17 00:00:00 2001 From: Jameson Graef Rollins <jrollins@finestructure.net> Date: Fri, 11 May 2018 17:32:44 -0700 Subject: [PATCH] rename precomp module and cleanup clarify PRFixed to be bool and True by default --- gwinc/__init__.py | 2 +- gwinc/__main__.py | 1 + gwinc/gwinc.py | 6 +++--- gwinc/{util.py => precomp.py} | 21 +++++++++------------ 4 files changed, 14 insertions(+), 16 deletions(-) rename gwinc/{util.py => precomp.py} (94%) diff --git a/gwinc/__init__.py b/gwinc/__init__.py index e0b153a..12cd527 100644 --- a/gwinc/__init__.py +++ b/gwinc/__init__.py @@ -1,5 +1,5 @@ from .ifo import load_ifo -from .util import precompIFO +from .precomp import precompIFO from .gwinc import noise_calc from .gwinc import gwinc from .plot import plot_noise diff --git a/gwinc/__main__.py b/gwinc/__main__.py index a773c1c..0b5b13a 100644 --- a/gwinc/__main__.py +++ b/gwinc/__main__.py @@ -8,6 +8,7 @@ import logging logging.basicConfig(level=logging.INFO) from .ifo import available_ifos, load_ifo +from .precomp import precompIFO from . import plot_noise ################################################## diff --git a/gwinc/gwinc.py b/gwinc/gwinc.py index 206b85c..6dad140 100644 --- a/gwinc/gwinc.py +++ b/gwinc/gwinc.py @@ -3,7 +3,7 @@ import numpy as np from numpy import log10, pi, sqrt import copy -from .util import precompIFO +from .precomp import precompIFO from . import noise from . import plot @@ -115,8 +115,8 @@ def gwinc(freq, ifoin, source=None, fig=False): ifo = copy.deepcopy(ifoin) - modeSR = 0 - PRfixed = 0 + modeSR = False + PRfixed = True # stick it into the IFO so that it gets passed around ifo.modeSR = modeSR diff --git a/gwinc/util.py b/gwinc/precomp.py similarity index 94% rename from gwinc/util.py rename to gwinc/precomp.py index f21f0d5..a3c8b09 100644 --- a/gwinc/util.py +++ b/gwinc/precomp.py @@ -1,27 +1,24 @@ -from __future__ import division, print_function +from __future__ import division from numpy import pi, sqrt -from scipy.io.matlab.mio5_params import mat_struct from scipy.io import loadmat import scipy.special +import logging from .struct import Struct from .noise.coatingthermal import getCoatDopt -def precompIFO(ifo, PRfixed=0): +def precompIFO(ifo, PRfixed=True): """Add precomputed data to the IFO model. - + To prevent recomputation of these precomputed data, if the ifo argument contains ifo.gwinc.PRfixed, and this matches the argument PRfixed, no changes are made. """ - # check PRfixed - #if 'gwinc' in ifo.__dict__: - # && isfield(ifo.gwinc, 'PRfixed') && ifo.gwinc.PRfixed == PRfixed - #return - ifo.gwinc = mat_struct() + if 'gwinc' not in ifo: + ifo.gwinc = Struct() ifo.gwinc.PRfixed = PRfixed ################################# DERIVED TEMP @@ -47,7 +44,7 @@ def precompIFO(ifo, PRfixed=0): dL = ifo.Optics.ETM.CoatingThicknessLown dCap = ifo.Optics.ETM.CoatingThicknessCap ifo.Optics.ETM.CoatLayerOpticalThickness = getCoatDopt(ifo, T, dL, dCap=dCap) - + # compute power on BS pbs, parm, finesse, prfactor, Tpr = precompPower(ifo, PRfixed) ifo.gwinc.pbs = pbs @@ -82,7 +79,7 @@ def precompIFO(ifo, PRfixed=0): return ifo -def precompPower(ifo, PRfixed): +def precompPower(ifo, PRfixed=True): """Compute power on beamsplitter and finesse and power recycling factor. """ @@ -114,7 +111,7 @@ def precompPower(ifo, PRfixed): garm = t1 / (1 - r1*r2*sqrt(1-2*loss)) # amplitude gain wrt input field rarm = r1 - t1 * r2 * sqrt(1-2*loss) * garm - if (PRfixed == 1): + if PRfixed: Tpr = ifo.Optics.PRM.Transmittance # use given value else: #prfactor = 1/(2*loss * neff + bsloss); % power recycling factor -- GitLab