From 12ff2916c9a1bb7b7a0c42482425e86757bbab5a Mon Sep 17 00:00:00 2001
From: Jameson Graef Rollins <jrollins@finestructure.net>
Date: Tue, 22 May 2018 17:33:46 -0700
Subject: [PATCH] move Constants.Temp to be part of Infrastructure

Infrastructure is obviously where it really belongs.  This also allows us
to almost eliminate the need for the Constants struct on our side.
---
 gwinc/gwinc_matlab.py      | 6 +++++-
 gwinc/ifo/A+.yaml          | 5 +----
 gwinc/ifo/Voyager.yaml     | 4 +---
 gwinc/ifo/aLIGO.yaml       | 5 +----
 gwinc/noise/residualgas.py | 2 +-
 gwinc/precomp.py           | 9 ++++++---
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/gwinc/gwinc_matlab.py b/gwinc/gwinc_matlab.py
index a315bbf..c5e815e 100644
--- a/gwinc/gwinc_matlab.py
+++ b/gwinc/gwinc_matlab.py
@@ -111,12 +111,16 @@ NOISE_NAME_MAP = {
 def ifo_matlab_transform(ifo):
     """Prep the ifo structure for use with MATLAB gwinc
 
-    * add "constants" sub-Struct
+    * add "Constants" sub-Struct
+    * copy Temp to Constants
 
     """
     # add constants
     ifo.Constants = Struct.from_dict(const.CONSTANTS)
 
+    # copy tempurature into Constants
+    ifo.Constants.Temp = ifo.Infrastructure.Temp
+
     return ifo
 
 
diff --git a/gwinc/ifo/A+.yaml b/gwinc/ifo/A+.yaml
index 8dc1cef..3e4604a 100644
--- a/gwinc/ifo/A+.yaml
+++ b/gwinc/ifo/A+.yaml
@@ -29,12 +29,9 @@
 #
 # Updated numbers March 2018: LIGO-T1800044
 
-Constants:
-  # Temperature of the Vacuum
-  Temp: 290                       # K
-
 Infrastructure:
   Length: 3995                    # m
+  Temp: 290                       # K
   ResidualGas:
     pressure: 4.0e-7              # Pa
     mass: 3.35e-27                # kg; Mass of H_2 (ref. 10)
diff --git a/gwinc/ifo/Voyager.yaml b/gwinc/ifo/Voyager.yaml
index 6b06478..8ee8c12 100644
--- a/gwinc/ifo/Voyager.yaml
+++ b/gwinc/ifo/Voyager.yaml
@@ -27,11 +27,9 @@
 # * 13. Fejer
 # * 14. Braginsky
 
-Constants:
-  Temp: 295 # K; Temperature of the Vacuum
-  
 Infrastructure:
   Length: 3995 # m
+  Temp: 295 # K; Temperature of the Vacuum
   ResidualGas:
     pressure: 4.0e-7         # Pa
     mass: 3.35e-27           # kg,   Mass of H_2 (ref. 10)
diff --git a/gwinc/ifo/aLIGO.yaml b/gwinc/ifo/aLIGO.yaml
index 68014c4..f35ad5c 100644
--- a/gwinc/ifo/aLIGO.yaml
+++ b/gwinc/ifo/aLIGO.yaml
@@ -29,12 +29,9 @@
 #
 # Updated numbers March 2018: LIGO-T1800044
 
-Constants:
-  # Temperature of the Vacuum
-  Temp: 290                       # K
-
 Infrastructure:
   Length: 3995                    # m
+  Temp: 290                       # K
   ResidualGas:
     pressure: 4.0e-7              # Pa
     mass: 3.35e-27                # kg; Mass of H_2 (ref. 10)
diff --git a/gwinc/noise/residualgas.py b/gwinc/noise/residualgas.py
index 4a5d3e0..27994e1 100644
--- a/gwinc/noise/residualgas.py
+++ b/gwinc/noise/residualgas.py
@@ -16,7 +16,7 @@ def gas(f, ifo):
     L      = ifo.Infrastructure.Length
     Lambda = ifo.Laser.Wavelength
     k      = scipy.constants.k
-    T      = ifo.Constants.Temp
+    T      = ifo.Infrastructure.Temp
     P      = ifo.Infrastructure.ResidualGas.pressure            # Pressure inside the vacuum
     M      = ifo.Infrastructure.ResidualGas.mass
     R1     = ifo.Optics.Curvature.ITM                           # Radius of curvature of ITM
diff --git a/gwinc/precomp.py b/gwinc/precomp.py
index fae365d..7e044e1 100644
--- a/gwinc/precomp.py
+++ b/gwinc/precomp.py
@@ -27,7 +27,7 @@ def precompIFO(ifo, PRfixed=True):
     # derived temp
 
     if 'Temp' not in ifo.Materials.Substrate:
-        ifo.Materials.Substrate.Temp = ifo.Constants.Temp
+        ifo.Materials.Substrate.Temp = ifo.Infrastructure.Temp
 
     ##############################
     # suspension vertical-horizontal coupling
@@ -114,9 +114,12 @@ def precompIFO(ifo, PRfixed=True):
 
     ##############################
     # precompute bessels zeros, needed in coat and substrate thermal
+    # FIXME: can we move this into const and just compute at load
+    # time?
 
-    besselzeros = scipy.special.jn_zeros(1, 300)
-    ifo.Constants.BesselZeros = besselzeros
+    if 'Constants' not in ifo:
+        ifo.Constants = Struct()
+    ifo.Constants.BesselZeros = scipy.special.jn_zeros(1, 300)
 
     ##############################
     # saved seismic spectrum
-- 
GitLab