Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeRate seems to be incorrect #25

Open
Magner18 opened this issue Jun 24, 2022 · 12 comments
Open

RangeRate seems to be incorrect #25

Magner18 opened this issue Jun 24, 2022 · 12 comments

Comments

@Magner18
Copy link

I Implemented a very basic application using SGP.NET and I think I am getting incorrect range rate values. my little test app is tracking STARLINK-3962, and I can watch the range change by something like .2 km/s or 1km/s depending on the satellites current position relative to the ground station. anyway the reported range rate is sometime 0km/s or 0.00000000000000002079601643302110 km/s. anyway that value I think is incorrect.

@parzivail
Copy link
Owner

Can you share the TLE and a timestamp where the issue occurs? I'll get it set up in a debugger and see where the issue is coming from. I'll also compare it to gpredict since the RR calculation is using the same formula.

@Magner18
Copy link
Author

1 52708U 22053BE 22175.16667824 -.00063401 00000-0 -45001-3 0 9990
2 52708 53.2156 116.0059 0002599 15.3214 275.1441 15.73231754 6108

10:15 am 6/24/2022

Ground station location lat 31.577255 long -110.36208 alt 3052

@parzivail
Copy link
Owner

Can you confirm that this snippet properly represents and reproduces the issue?

var tle = new []
{
	"1 52708U 22053BE  22175.16667824 -.00063401  00000-0 -45001-3 0  9990",
	"2 52708  53.2156 116.0059 0002599  15.3214 275.1441 15.73231754  6108"
};

var time = new DateTime(2022, 6, 24, 17, 15, 00, DateTimeKind.Utc);

var gs = new GroundStation(new GeodeticCoordinate(Angle.FromDegrees(31.577255), Angle.FromDegrees(-110.36208), 3052));

var sat = new Satellite(tle[0], tle[1]);
while (true)
{
	var o = gs.Observe(sat, time);
	Console.WriteLine(o.RangeRate);

	time += TimeSpan.FromSeconds(1);
	Thread.Sleep(100);
}

@Magner18
Copy link
Author

strangely it does not, however if you use DateTime.Now instead of the time i provided it does produce the issue I am seeing.

@parzivail
Copy link
Owner

Does it also break when using DateTime.UtcNow? All input times are in UTC.

@Magner18
Copy link
Author

that also breaks. I think the issue may be that by setting time to DateTime.Now or DateTime.UtcNow the value changes while it is doing the calculations.

@Magner18
Copy link
Author

Nope, thats not it, I think it just something to do with a time generated using DateTime.Now

@Magner18
Copy link
Author

ok I created the time var like this
var time = new DateTime(Datetime.Now.Year, Datetime.Now.Month, Datetime.Now.Day, Datetime.Now.Hour, Datetime.Now.Minute, Datetime.Now.Second, DateTimeKind.UTC);

and the problem went away.

@parzivail
Copy link
Owner

Changing the inner loop to directly use DateTime.UtcNow seems to produce similar output to the first snippet:

while (true)
{
	var o = gs.Observe(sat, DateTime.UtcNow);
	Console.WriteLine(o.RangeRate);
	Thread.Sleep(1000);
}

It's strange that directly using DateTime.UtcNow in your case was creating an issue (and be warned that DateTime.Now uses your local time, which will be incorrect in the ground station's time zone by 7 hours). What runtime are you using?

@Magner18
Copy link
Author

4.0.30319.42000

@Magner18
Copy link
Author

@parzivail so you are able to reproduce the issue I am seeing?

@parzivail
Copy link
Owner

Apologies for the delay -- No, I haven't been able to reproduce this issue, on .NET 4 or .NET 6. Can you put together a minimal repo that can demonstrate the issue so I can reproduce your setup exactly? I doubt this is a runtime issue but it's very strange that using the dynamic DateTime fields break but using a constructed DateTime works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants