diff --git a/gwinc/noise/newtonian.py b/gwinc/noise/newtonian.py index a8a6054f191fa0087a4e18cbea6722227d4211aa..15026d5304c579e10e549f2f19d6366b15242164 100644 --- a/gwinc/noise/newtonian.py +++ b/gwinc/noise/newtonian.py @@ -86,7 +86,7 @@ def ground(Seismic, f): coeff = 1/(1 + 3**(gamma*(f-fk))) # modelization of seismic noise (velocity) - if 'Site' not in Seismic.__dict__: + if 'Site' not in Seismic: print('defaulting to Livingston site') Seismic.Site = 'LLO' diff --git a/gwinc/noise/quantum.py b/gwinc/noise/quantum.py index 883635c75e07cc0c80e04a1719a47e06853baba0..5d8324c4f39ea0ba94e182d32388be98f21606d4 100644 --- a/gwinc/noise/quantum.py +++ b/gwinc/noise/quantum.py @@ -12,7 +12,7 @@ def shotrad(f, ifo, verbose=False): # deal with multiple bounces, required for resonant delay lines # Stefan Ballmer 2012 - if 'NFolded' in ifo.Infrastructure.__dict__: + if 'NFolded' in ifo.Infrastructure: if ifo.Infrastructure.travellingWave: ifo.Materials.MirrorMass=ifo.Materials.MirrorMass/ifo.Infrastructure.NFolded**2 else: @@ -24,7 +24,7 @@ def shotrad(f, ifo, verbose=False): # Call IFO Quantum Model ##################################################### - if 'Type' not in ifo.Optics.__dict__: + if 'Type' not in ifo.Optics: fname = shotradSignalRecycled else: namespace = globals() @@ -66,10 +66,10 @@ def shotrad(f, ifo, verbose=False): # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # determine squeezer type, if any # and extract common parameters - if 'Squeezer' not in ifo.__dict__: + if 'Squeezer' not in ifo: sqzType = 'None' else: - if 'Type' not in ifo.Squeezer.__dict__: + if 'Type' not in ifo.Squeezer: sqzType = 'Freq Independent' else: sqzType = ifo.Squeezer.Type @@ -84,7 +84,7 @@ def shotrad(f, ifo, verbose=False): SQZ_DB = ifo.Squeezer.AmplitudedB # Squeeing in dB lambda_in = ifo.Squeezer.InjectionLoss # Loss to squeezing before injection [Power] alpha = ifo.Squeezer.SQZAngle # Freq Indep Squeeze angle - if 'AntiAmplitudedB' in ifo.Squeezer.__dict__: + if 'AntiAmplitudedB' in ifo.Squeezer: ANTISQZ_DB = ifo.Squeezer.AntiAmplitudedB # Anti squeezing in db else: ANTISQZ_DB = SQZ_DB @@ -146,7 +146,7 @@ def shotrad(f, ifo, verbose=False): # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Inject squeezed field into the IFO via some filter cavities - if sqzType == 'Freq Dependent' and 'FilterCavity' in ifo.Squeezer.__dict__: + if sqzType == 'Freq Dependent' and 'FilterCavity' in ifo.Squeezer: if verbose: print(' Applying %d input filter cavities' % np.atleast_1d(ifo.Squeezer.FilterCavity).size) Mr, Msqz = sqzFilterCavityChain(f, np.atleast_1d(ifo.Squeezer.FilterCavity), Msqz) @@ -164,7 +164,7 @@ def shotrad(f, ifo, verbose=False): # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # pass IFO output through some filter cavities - if 'OutputFilter' in ifo.__dict__: + if 'OutputFilter' in ifo: if ifo.OutputFilter.Type == 'None': # do nothing, say nothing pass diff --git a/gwinc/noise/substratethermal.py b/gwinc/noise/substratethermal.py index ad9592a7d1fcc8190fe5a3a8f21af8ad15af20e9..ba02e3f687f318b0deafb52cc81cc2abf7cfaf86 100644 --- a/gwinc/noise/substratethermal.py +++ b/gwinc/noise/substratethermal.py @@ -146,7 +146,7 @@ def subbrownianFiniteCorr(ifo, opticName): # get some numbers a = ifo.Materials.MassRadius h = ifo.Materials.MassThickness - w = ifo.Optics.__dict__[opticName].BeamRadius + w = ifo.Optics[opticName].BeamRadius Y = ifo.Materials.Substrate.MirrorY sigma = ifo.Materials.Substrate.MirrorSigma zeta = ifo.Constants.BesselZeros @@ -226,7 +226,7 @@ def subthermFiniteCorr(ifo, opticName): # extract some numbers a = ifo.Materials.MassRadius h = ifo.Materials.MassThickness - w = ifo.Optics.__dict__[opticName].BeamRadius + w = ifo.Optics[opticName].BeamRadius sigma = ifo.Materials.Substrate.MirrorSigma zeta = ifo.Constants.BesselZeros diff --git a/gwinc/struct.py b/gwinc/struct.py index deb8a4223a186c6915141876f12d895f721257fb..04f1a513b574d18ed071cd767c35b727d8b62f6c 100644 --- a/gwinc/struct.py +++ b/gwinc/struct.py @@ -75,6 +75,9 @@ class Struct(object): ########## + def __getitem__(self, item): + return self.__dict__[item] + def __contains__(self, item): return item in self.__dict__ diff --git a/gwinc/util.py b/gwinc/util.py index 7a49cec924764929690d72a16ddf3c3da46aae17..f21f0d52492277145a3759b76c0e006c1eb83b9c 100644 --- a/gwinc/util.py +++ b/gwinc/util.py @@ -26,7 +26,7 @@ def precompIFO(ifo, PRfixed=0): ################################# DERIVED TEMP - if 'Temp' not in ifo.Materials.Substrate.__dict__: + if 'Temp' not in ifo.Materials.Substrate: ifo.Materials.Substrate.Temp = ifo.Constants.Temp ################################# DERIVED OPTICS VALES @@ -38,7 +38,7 @@ def precompIFO(ifo, PRfixed=0): ifo.Optics.ITM.Thickness = ifo.Materials.MassThickness # coating layer optical thicknesses - mevans 2 May 2008 - if 'CoatLayerOpticalThickness' not in ifo.Optics.ITM.__dict__: + if 'CoatLayerOpticalThickness' not in ifo.Optics.ITM: T = ifo.Optics.ITM.Transmittance dL = ifo.Optics.ITM.CoatingThicknessLown dCap = ifo.Optics.ITM.CoatingThicknessCap @@ -74,7 +74,7 @@ def precompIFO(ifo, PRfixed=0): # Seismic noise term is saved in a .mat file defined in your respective IFOModel.m # It is loaded here and put into the ifo structure. - if 'darmSeiSusFile' in ifo.Seismic.__dict__: + if 'darmSeiSusFile' in ifo.Seismic and ifo.Seismic.darmSeiSusFile: darmsei = loadmat(ifo.Seismic.darmSeiSusFile) ifo.Seismic.darmseis_f = darmsei['darmseis_f'][0] ifo.Seismic.darmseis_x = darmsei['darmseis_x'][0]