0

I tried the solutions from Numpy: Creating a complex array from 2 real ones? but can't seem to get them to work for an array with more than 2 columns.

I have code that works but is very inefficient. I couldn't imagine if the column numbers were much higher.

reTrc1_S22_thrutest = thrutest[:,0]
imTrc1_S22_thrutest = 1j*thrutest[:,1]

Trc1_S22_thrutest = reTrc1_S22_thrutest + imTrc1_S22_thrutest

1 Answers1

0

To get even columns or odd columns from a numpy array, you can use slicing syntax.

reTrc1_S22_thrutest = thrutest[:,0::2]
imTrc1_S22_thrutest = 1j*thrutest[:,1::2]

Trc1_S22_thrutest = reTrc1_S22_thrutest + imTrc1_S22_thrutest
Nick ODell
  • 15,465
  • 3
  • 32
  • 66