0
$\begingroup$

This question is a follow up on previous. As I am analyzing the sampled data I need to know if it is complex or real. This is important for me since I want to transform my two-sided to a one-sided PSD. Then I have to either divide the spectrum by $N/2$ (for real-valued signals) or $N$ (for complex-valued signals).

So far I executed both np.angle(x.MIC, deg=True) and np.iscomplexobj(x.MIC) with the returned value of array([180., 180., 180., ..., 180., 180., 0.]) and False respectively.

Why do I keep getting this inconsistency in my results? Am I missing something important here?

$\endgroup$
3
  • $\begingroup$ ??? You have the time data… Does x.MIC have real or complex values?! $\endgroup$
    – Jdip
    Oct 30, 2023 at 16:21
  • $\begingroup$ @Jdip complex values are not present, but angles are. How can it be real if there are angles? $\endgroup$
    – Tom
    Oct 30, 2023 at 16:28
  • $\begingroup$ Ok, I agree it’s a little confusing. I wrote an answer explaining the behavior. $\endgroup$
    – Jdip
    Oct 30, 2023 at 17:36

1 Answer 1

2
$\begingroup$

np.angle(z) with z = a + bi uses arctan2(a,b),

which returns the signed angle in radians between the ray ending at the origin and passing through the point (1,0), and the ray ending at the origin and passing through the point (b, a).

In your case, b = 0 so np.angle() is returning arctan2(a,0).

  • If a > 0, that means a lies on the positive x-axis of the unit circle, and the angle between the positive x-axis and the line connecting a and the origin $(0,0)$ is 0.

  • If a < 0, that means a lies on the negative x-axis of the unit circle, and the angle between the positive x-axis and the line connecting a and the origin $(0,0)$ is pi.

Since you're asking for degrees, it multiplies the values by 180/pi, so the final result is either 0 for positive real numbers or 180 for negative real numbers.

$\endgroup$
1
  • $\begingroup$ That solves my question. Thank you! $\endgroup$
    – Tom
    Oct 31, 2023 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.