-
Notifications
You must be signed in to change notification settings - Fork 11
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
BUG: Corrections converting gate to geographic location #353
Conversation
pydarn/utils/coordinates.py
Outdated
beam_sep = np.radians(abs(SuperDARNRadars. | ||
radars[stid].hardware_info.beam_separation)) | ||
beam_sep = np.radians(SuperDARNRadars. | ||
radars[stid].hardware_info.beam_separation) | ||
rxrise = SuperDARNRadars.radars[stid].hardware_info.rx_rise_time | ||
|
||
# TODO: fix after slant range change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement doesn't appear correct (which may explain the "TODO" note) - the beam_edge
value should be zero if center
is True (ie the current logic should be swapped).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Evan, I'll work through this and figure out what the proper logic we should be doing, there was a very long discussion about this two years ago, and I believe that it centred around what actually the definition of frang
was (was it to the inner edge, or center of the first range gate) and the conclusion was essentially that no one actually had this definition set, different PIs thought it was different and it wasn't for us to define it at the time - as far as I remember, the outcome for us was that the logic for center
was backwards from davitpy/rst but it made sense at the time. I'll link the main PR here, but there was a couple going on at the same time to figure this out: #134
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carleyjmartin yes, there still tends to be a lot of confusion around whether frang
corresponds to the front edge or center of the first range gate (I think it's the latter). The convention for center vs edge of a beam in terms of azimuth should be more straightforward though: the center = True
case should return the azimuth to the center of the beam. At least in the northern hemisphere, when center = False
it should return the azimuth to the "left" / western" beam edge. Currently, it appears the logic in the python code is reversed from what it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay, yep. We have an issue here where we're using the variable name center
in two similar but related ways. In range_separation
the center value is in the direction from the radar outwards (which I assumed was the same thing in here!) and in coordinates
is across the fov. I get it! I believe we may have flipped this one assuming the same definition of center being the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so this is kinda confusing but, I think if we change the logic in the if statement around, we will then want to give center=False
to the method from our plotting methods, as the plotting itself requires the values of the range gate corners.
So I think we also need to change the default to False. (EDIT: changing this in means we wont have to go and add the kw to the plotting methods that use this)
This makes more logical sense though, as if the user wants the central value they say center=True
, otherwise we use False in general for plotting, and center
retains the definition of giving the value at the center of the range gate.
I think we originally had it so that center was defined as True 'if the value we are given is the central value' which would cause the logic all to swap around and we had to then adjust the values to give us the edges to use for plotting. (if that makes sense, thinking of it from the 'what does the plot need' view rather than what logically does center mean)
EDIT: I've updated with this logic in the newest commit, I'll give it a proper test in the coming weeks. I just had a few hours free whilst it was raining at the site this morning!
pydarn/utils/coordinates.py
Outdated
@@ -172,7 +174,7 @@ def gate2geographic_location(stid: int, beam: int, height: float = None, | |||
beam_edge = 0 | |||
|
|||
# psi [rad] in the angle from the boresight | |||
psi = beam_sep * (beam - offset) + beam_edge | |||
psi = beam_sep * (beam - offset) - beam_edge + bmoff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the sign changed from + beam_edge
to - beam_edge
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sign change was suggested by Colin in this comment:
#351 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carleyjmartin oh ok thanks, now I see that suggested change. This has the practical effect of shifting all of the beams eastward by one, eg printing out the psi
values for the CVW radar for each beam:
0 -37.260000 -38.880000 -35.640000
1 -34.020000 -35.640000 -32.400000
2 -30.780000 -32.400000 -29.160000
3 -27.540000 -29.160000 -25.920000
4 -24.300000 -25.920000 -22.680000
5 -21.060000 -22.680000 -19.440000
6 -17.820000 -19.440000 -16.200000
7 -14.580000 -16.200000 -12.960000
8 -11.340000 -12.960000 -9.7200000
9 -8.1000000 -9.7200000 -6.4800000
10 -4.8600000 -6.4800000 -3.2400000
11 -1.6200000 -3.2400000 0.0000000
12 1.6200000 0.0000000 3.2400000
13 4.8600000 3.2400000 6.4800000
14 8.1000000 6.4800000 9.7200000
15 11.340000 9.7200000 12.960000
16 14.580000 12.960000 16.200000
17 17.820000 16.200000 19.440000
18 21.060000 19.440000 22.680000
19 24.300000 22.680000 25.920000
20 27.540000 25.920000 29.160000
21 30.780000 29.160000 32.400000
22 34.020000 32.400000 35.640000
23 37.260000 35.640000 38.880000
where the first column is beam number, the second column is for the beam center, the third column is using +beam_edge
, and the fourth column is -beam_edge
. You can see that the beam edges in the last column no longer correspond to the "left" beam edge, which is the standard convention. Maybe this is hemisphere specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooo okay, It could possibly be a fix for the -ve beam_sep valued radars, I think they're all in the southern hemisphere.
I'll figure it out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carleyjmartin I just did some tests in IDL, and I think it should still be + beam_edge
for both Northern and Southern Hemisphere radars (as long as the beam_sep
value retains the correct sign, which this pull request now ensures).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Evan, I've switched it back around in the latest commit.
@carleyjmartin thanks for making those changes - hopefully @Prof-CW agrees / can confirm! |
Scope
This PR changes the calculation for geographic coordinates of the location of each range gate to include the 'offset' value of boresight from hdw files, and removes the abs() function from bmsep calculation to allow for the correct beam numbers.
As the abs() was originally a bug fix for a colouring-in issue with cartopy plots, this is now taken care of inside the fov method rather than in the position calculation using an if statement.
issue: #351
Approval
Number of approvals: 2 with a quick code review if possible
Test
matplotlib version: 3.7.1
Note testers: please indicate what version of matplotlib you are using
You can plot all the FOV in geographic coordinates, this should colour in the FOv in grey, anything outside should not be shaded:
To check on the direction of beams, you can use the following code:
This code checks the first and 15th beam (red and blue) for a -ve and +ve bmsep value:
These all require Cartopy to be installed - you can remove the projs, coords and coastline keywords to test in magnetic coordinates without cartopy.
Please check out the associated issue for further discussion!