-
Notifications
You must be signed in to change notification settings - Fork 0
/
sig_to_idl.py
29 lines (26 loc) · 1000 Bytes
/
sig_to_idl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import copy
from attune._transition import Transition
from attune._tune import Tune
def sig_to_idl(instrument, arrangement, tune, amount, amount_units=None): # MUST PASS SIG AS TUNE AND DEGENERACY AS AMOUNT. #amount in nm
md = {
"arrangement": arrangement,
"tune": tune,
"amount": amount,
"amount_units": amount_units,
}
sig_tune = instrument[arrangement][tune]
idler = attune.Arrangement("idler", dict(bbo=sig_tune))
def _get_sig_offset(sig_tune, amount):
sigs = sig_tune.independent
return [sig - 2*(sig-amount) for sig in sigs]
if amount_units is not None:
amount = wt.units.convert(amount, amount_units, sig_tune.dep_units)
instr = copy.deepcopy(instrument)
instr["idler"]._tunes[tune] = Tune(
_get_sig_offset,
sig_tune.dependent,
dep_units=sig_tune.dep_units,
)
instr._transition = Transition("offset_by", instrument, metadata=md)
instr._load = None
return instr