7
7
from c3 .signal .pulse import Carrier
8
8
from c3 .signal .gates import Instruction
9
9
from c3 .c3objs import Quantity , C3obj , hjson_encode
10
- from c3 .utils .tf_utils import tf_convolve
10
+ from c3 .utils .tf_utils import tf_convolve , tf_convolve_legacy
11
11
12
12
devices = dict ()
13
13
@@ -513,50 +513,6 @@ def __init__(self, **props):
513
513
super ().__init__ (** props )
514
514
self .inputs = props .pop ("inputs" , 1 )
515
515
self .outputs = props .pop ("outputs" , 1 )
516
- raise Exception ("use ResponseFFT for faster signal generation instead" )
517
-
518
- def convolve (self , signal : list , resp_shape : list ):
519
- """
520
- Compute the convolution with a function.
521
-
522
- Parameters
523
- ----------
524
- signal : list
525
- Potentially unlimited signal samples.
526
- resp_shape : list
527
- Samples of the function to model limited bandwidth.
528
-
529
- Returns
530
- -------
531
- tf.Tensor
532
- Processed signal.
533
-
534
- """
535
- convolution = tf .zeros (0 , dtype = tf .float64 )
536
- signal = tf .concat (
537
- [
538
- tf .zeros (len (resp_shape ), dtype = tf .float64 ),
539
- signal ,
540
- tf .zeros (len (resp_shape ), dtype = tf .float64 ),
541
- ],
542
- 0 ,
543
- )
544
- for p in range (len (signal ) - 2 * len (resp_shape )):
545
- convolution = tf .concat (
546
- [
547
- convolution ,
548
- tf .reshape (
549
- tf .math .reduce_sum (
550
- tf .math .multiply (
551
- signal [p : p + len (resp_shape )], resp_shape
552
- )
553
- ),
554
- shape = [1 ],
555
- ),
556
- ],
557
- 0 ,
558
- )
559
- return convolution
560
516
561
517
def process (self , instr , chan , iq_signal : List [Dict [str , Any ]]) -> Dict [str , Any ]:
562
518
"""
@@ -580,23 +536,26 @@ def process(self, instr, chan, iq_signal: List[Dict[str, Any]]) -> Dict[str, Any
580
536
tf .cast (n_ts , tf .int32 ),
581
537
)
582
538
cen = tf .cast (
583
- (self .params ["rise_time" ].get_value () - 1 / self .resolution ) / 2 , tf .float64
539
+ (self .params ["rise_time" ].get_value () + 1 / self .resolution ) / 2 , tf .float64
584
540
)
585
541
sigma = self .params ["rise_time" ].get_value () / 4
586
542
gauss = tf .exp (- ((ts - cen ) ** 2 ) / (2 * sigma * sigma ))
587
543
offset = tf .exp (- ((- 1 - cen ) ** 2 ) / (2 * sigma * sigma ))
588
- # TODO make sure ratio of risetime and resolution is an integer
544
+
589
545
risefun = gauss - offset
590
- inphase = self . convolve (
546
+ inphase = tf_convolve_legacy (
591
547
iq_signal [0 ]["inphase" ], risefun / tf .reduce_sum (risefun )
592
548
)
593
- quadrature = self . convolve (
549
+ quadrature = tf_convolve_legacy (
594
550
iq_signal [0 ]["quadrature" ], risefun / tf .reduce_sum (risefun )
595
551
)
552
+
553
+ inphase = tf .math .real (inphase )
554
+ quadrature = tf .math .real (quadrature )
596
555
self .signal = {
597
556
"inphase" : inphase ,
598
557
"quadrature" : quadrature ,
599
- "ts" : self . create_ts ( instr . t_start , instr . t_end , centered = True ) ,
558
+ "ts" : iq_signal [ 0 ][ "ts" ] ,
600
559
}
601
560
return self .signal
602
561
0 commit comments