precomp.py assumes recycling; should be able to define precomp method/class per IFO
See #39 (closed) for context.
precomp.py requires recycling cavities to be defined in the parameter file, i.e. ifo.Optics.PRM
.
The AEI prototype doesn't have recycling cavities, yet precomp.py
requires ifo.Optics.PRM.Transmittance
to be specified so I can't use pygwinc without a hack. I'd rather not monkey patch precomp.py
to get rid of the PRM stuff, since it's doing a lot of other useful stuff.
Idea: make precomp.py
contain a class (e.g. BasePrecomp
) that implements the various tools in the existing precomp module. Allow this to be overridden so that particular precomputations can be changed or switched off, and new ones added. Have pygwinc look for a Precomp[IFO]
class on the system path and if it finds it, use that instead of BasePrecomp
.
Alternatively, since some of precomp is interferometer-specific (e.g. recycling cavity finesses etc.) and some of it is not (e.g. mirror masses), split these into some core precomp functions/class and some inside the gwinc.ifo
subpackages.
Another idea: to define a class to represent the parameter file, and allow this class to be subclassed and have properties with decorators applied to provide derived parameters:
class MyIFOParams(BaseParams):
@derives('Materials.MirrorVolume', 'Materials.MirrorMass')
@classmethod
def _compute_mirror_mass(cls, ifo):
volume = pi*ifo.Materials.MassRadius**2 * \
ifo.Materials.MassThickness
mass = volume * ifo.Materials.Substrate.MassDensity
return volume, mass
(come on, let's make use of the stuff that makes Python so much better than MATLAB!)
The constructor would then pass the loaded YAML file into each of these methods to compute derived parameters. Then e.g. ifo.Materials.MirrorVolume
could be called as usual.
It would actually be pretty nice if the parameter file could be defined programmatically using a class like above, rather than via YAML. I expect most people including me would still use YAML to define most of the parameters, but for some more complicated ones, or where something might need to be defined by an external calculation (e.g. Finesse), it would be nice to have an API.