473,379 Members | 1,191 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

How do I handle atan() when calculating absolute phase? (Communication engineering)

I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian
noise. Thus, near pi/2, direct division of atan(Q/I) may yield outputs
either +pi/2 or
-pi/2. How do I handle this situation?

Thanks.
May 4 '06 #1
5 4140
BRG
Mr. Ken wrote:
I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian
noise. Thus, near pi/2, direct division of atan(Q/I) may yield outputs
either +pi/2 or
-pi/2. How do I handle this situation?


As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.

Brian Gladman
May 4 '06 #2
BRG wrote:
Mr. Ken wrote:
I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian noise.


As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.


atan2 avoids infinity, and I think gives a full +/-pi range, but there's
still a massive jump in the number that represents phase, so you can't
just average that number to remove noise. You can smooth x and y first,
or smooth a modified phase w/ 2pi added or subtracted to keep it near
the recent average, and jump the average when it goes out of range.
May 4 '06 #3
BRG
Robert Mabee wrote:
BRG wrote:
Mr. Ken wrote:
I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian noise.


As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.


atan2 avoids infinity, and I think gives a full +/-pi range, but there's
still a massive jump in the number that represents phase, so you can't
just average that number to remove noise.


[snip]
You can at +pi/2 and -pi/2, the points to which the original poster
specifically referred.

When two quadrature signals I and Q are available, atan2(Q, I) is better
than atan(Q/I) since it not only eliminates the division by zero problem
but also eliminates the artificial phase ambiguity _introduced_ by
atan(Q/I) at +pi/2 and -pi/2.

Noise will still be an issue at +pi and -pi but at least atan2(Q, I)
won't produce the incorrect results given by atan(Q/I) near +pi/2 and
-pi/2 caused by essentially ignoring a good sign on Q when I is small.

Brian Gladman
May 5 '06 #4

"BRG" <br*@nowhere.org> wrote in message
news:44**********************@ptn-nntp-reader01.plus.net...
Robert Mabee wrote:
BRG wrote:
Mr. Ken wrote:
I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian noise.

As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.


atan2 avoids infinity, and I think gives a full +/-pi range, but there's
still a massive jump in the number that represents phase, so you can't
just average that number to remove noise.


[snip]
You can at +pi/2 and -pi/2, the points to which the original poster
specifically referred.

When two quadrature signals I and Q are available, atan2(Q, I) is better
than atan(Q/I) since it not only eliminates the division by zero problem
but also eliminates the artificial phase ambiguity _introduced_ by
atan(Q/I) at +pi/2 and -pi/2.

Noise will still be an issue at +pi and -pi but at least atan2(Q, I)
won't produce the incorrect results given by atan(Q/I) near +pi/2 and
-pi/2 caused by essentially ignoring a good sign on Q when I is small.


Hmm... Let's see how much of this mess it cleans up:

float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
float Theta;
if ( Point2.x - Point1.x == 0 )
if ( Point2.y > Point1.y )
Theta = 0;
else
Theta = static_cast<float>( PI );
else
{
Theta = std::atan( (Point2.y - Point1.y) / (Point2.x - Point1.x) );
if ( Point2.x > Point1.x )
Theta = static_cast<float>( PI ) / 2.0f - Theta;
else
Theta = static_cast<float>( PI ) * 1.5f - Theta;
};

return Theta;
}

would become...

float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
float Theta;
Theta = std::atan2( (Point2.y - Point1.y) / (Point2.x - Point1.x) );
if ( Point2.x > Point1.x )
Theta = static_cast<float>( PI ) / 2.0f - Theta;
else
Theta = static_cast<float>( PI ) * 1.5f - Theta;
};

return Theta;
}

Is that all that can be simplified?


May 6 '06 #5
BRG
Jim Langston wrote:
"BRG" <br*@nowhere.org> wrote in message
news:44**********************@ptn-nntp-reader01.plus.net...
Robert Mabee wrote:
BRG wrote:
Mr. Ken wrote:
> I am calculating the phase of an IQ signal, which are polluted by AWGN
> gaussian noise.
As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.
atan2 avoids infinity, and I think gives a full +/-pi range, but there's
still a massive jump in the number that represents phase, so you can't
just average that number to remove noise.

[snip]
You can at +pi/2 and -pi/2, the points to which the original poster
specifically referred.

When two quadrature signals I and Q are available, atan2(Q, I) is better
than atan(Q/I) since it not only eliminates the division by zero problem
but also eliminates the artificial phase ambiguity _introduced_ by
atan(Q/I) at +pi/2 and -pi/2.

Noise will still be an issue at +pi and -pi but at least atan2(Q, I)
won't produce the incorrect results given by atan(Q/I) near +pi/2 and
-pi/2 caused by essentially ignoring a good sign on Q when I is small.


Hmm... Let's see how much of this mess it cleans up:

float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
float Theta;
if ( Point2.x - Point1.x == 0 )
if ( Point2.y > Point1.y )
Theta = 0;
else
Theta = static_cast<float>( PI );
else
{
Theta = std::atan( (Point2.y - Point1.y) / (Point2.x - Point1.x) );
if ( Point2.x > Point1.x )
Theta = static_cast<float>( PI ) / 2.0f - Theta;
else
Theta = static_cast<float>( PI ) * 1.5f - Theta;
};

return Theta;
}

would become...

float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
float Theta;
Theta = std::atan2( (Point2.y - Point1.y) / (Point2.x - Point1.x) );
if ( Point2.x > Point1.x )
Theta = static_cast<float>( PI ) / 2.0f - Theta;
else
Theta = static_cast<float>( PI ) * 1.5f - Theta;
};

return Theta;
}

Is that all that can be simplified?


float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
return std::atan2( Point2.x - Point1.x, Point2.y - Point1.y );
}

is an even simpler solution.

Brian Gladman
May 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Michael Winter | last post by:
In an attempt to answer another question in this group, I've had to resort to calling the DOM method, Node.removeChild(), using a reference to it (long story...). That is, passing Node.removeChild....
21
by: Protoman | last post by:
How do I calculate the log of a number? Don't tell me to use log in cmath; I'm trying to learn complex math in C++. Got any tips/ideas on how to do this? Thanks for the help!!!
6
by: Leandro Berti via DotNetMonster.com | last post by:
Hi All, I wrote a code to do serial communication with an equipament. When i use the code outside of threaded class it seens work properly, but when i put inside a class and execute a thread in...
1
by: Umut Tezduyar | last post by:
Because of the fact that, handling events method ( IPostBackEventHandler.RaisePorstBackEvent method) is prior to OnPreRender method, i cannot handle the events of the controls that i am adding on...
4
by: Niels Jensen | last post by:
Hi, I'm a bit of a newbie to VB.NET so please forgive me if I get the terminology incorrect... I'm still learning :) I have a form with five numUpDown controls representing different ratios...
39
by: tydbowl | last post by:
I have a problem where the below code chunk causes handle leaks on some machines. The leak APPEARS to be handles to the registry key: HKCU\Software\Microsoft\Windows\CurrentVersion\Internet...
4
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this...
6
by: Liming | last post by:
Hi, In a typical 3 tier model (view layer, busines layer and data access layer) where do you handle your exceptions? do you let it buble up all the way to the .aspx pages or do you handle it in...
13
by: Xah Lee | last post by:
Today, a motherfucker Christophe Rhodes (aka Xof in irc://chat.freenode.net/lisp ) kicked banned me. Here's the few relevant excerpt. (full, unedited excerpt will be published if there is a public...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.