SuperDARN / pydarn

Python library for visualizing SuperDARN Data
GNU Lesser General Public License v3.0
31 stars 11 forks source link

EHN: Ball and Stick Fan Plot Option #304

Closed carleyjmartin closed 1 year ago

carleyjmartin commented 1 year ago

Scope

This PR adds the option to plot ball and stick plots via fan plots using the new keyword ball_and_stick=True and len_factor=300. There is also some new code in geo.py that calculates the azimuth direction from Xueling and Shibaji (thank you!) from the radar to the gate position which calculates the stick part when plotting velocity. I have not used them to replace any current geo functions as they're slightly different and the module probably needs a nice tidy in it's own PR when we want to release this. I've also only used the code required, but we can add to and expand as we need it, rather than add it all in and then end up needing a whole rewrite down the line. Ran through flake8 and modification lines added.

I can never remember if blue (+ve) is towards or away from the radar, in this version it just works out that blue is towards, let me know if that is correct cause I always get it wrong.

issue: to close #144

Approval

Number of approvals: 2 including a look over the code

Test

matplotlib version: 3.6.3 Note testers: please indicate what version of matplotlib you are using

Following code tests the mag and geo plots, and then back to the normal fan plot to make sure nothing has changed.

import matplotlib.pyplot as plt
import pydarn

file = "/Users/carley/Documents/data/20180101.0000.01.rkn.fitacf"
SDarn_read = pydarn.SuperDARNRead(file)
fitacf_data = SDarn_read.read_fitacf()

# Fan plot with specific data in geo and mag
ax, _, _, _,_ = pydarn.Fan.plot_fan(fitacf_data,
                    scan_index=1, lowlat=60, zmin=-1000, zmax=1000,
                    boundary=True, radar_label=True,
                    groundscatter=True, ball_and_stick=True, len_factor=300,
                    coastline=True, parameter="v")
plt.show()

# Fan plot with specific data in geo and mag
ax, _, _, _,_ = pydarn.Fan.plot_fan(fitacf_data,
                    scan_index=1, lowlat=50, zmin=-1000, zmax=1000,
                    boundary=True, radar_label=True,
                    groundscatter=True, ball_and_stick=True, len_factor=300,
                    coastline=True, parameter="v", coords=pydarn.Coords.GEOGRAPHIC,
                    projs=pydarn.Projs.GEO)
plt.show()

ax, _, _, _,_ = pydarn.Fan.plot_fan(fitacf_data,
                    scan_index=1, lowlat=50, zmin=-1000, zmax=1000,
                    boundary=True, radar_label=True,
                    groundscatter=True, ball_and_stick=False,
                    coastline=True, parameter="v")
plt.show()

ax, _, _, _,_ = pydarn.Fan.plot_fan(fitacf_data,
                    scan_index=1, lowlat=50, zmin=-1000, zmax=1000,
                    boundary=True, radar_label=True,
                    coastline=True, parameter="v", coords=pydarn.Coords.GEOGRAPHIC,
                    projs=pydarn.Projs.GEO)
plt.show()

Top two make these plots:

Screenshot 2023-03-01 at 2 52 42 PM Screenshot 2023-03-01 at 2 52 56 PM
KhanalKrishna commented 1 year ago

Matplotlib version: 3.5.3

The red/blue representation is correct.

import matplotlib.pyplot as plt import pydarn

file = "20150308.1400.03.cly.fitacf"

SDarn_read = pydarn.SuperDARNRead(file) fitacf_data = SDarn_read.read_fitacf()

Fan plot with specific data in geo and mag

ax, , , , = pydarn.Fan.plot_fan(fitacf_data, scan_index=1, lowlat=60, zmin=-1000, zmax=1000, boundary=True, radar_label=True, groundscatter=True, ball_and_stick=True, len_factor=300, coastline=True, parameter="v") plt.show()

Fan plot with specific data in geo and mag

ax, , , , = pydarn.Fan.plot_fan(fitacf_data, scan_index=1, lowlat=50, zmin=-1000, zmax=1000, boundary=True, radar_label=True, groundscatter=True, ball_and_stick=True, len_factor=300, coastline=True, parameter="v", coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO) plt.show()

ax, , , , = pydarn.Fan.plot_fan(fitacf_data, scan_index=1, lowlat=50, zmin=-1000, zmax=1000, boundary=True, radar_label=True, groundscatter=True, ball_and_stick=False, coastline=True, parameter="v") plt.show()

ax, , , , = pydarn.Fan.plot_fan(fitacf_data, scan_index=1, lowlat=50, zmin=-1000, zmax=1000, boundary=True, radar_label=True, coastline=True, parameter="v", coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO) plt.show()

ax, , , , = pydarn.Fan.plot_fan(fitacf_data, scan_index=1, lowlat=50, zmin=-1000, zmax=1000, boundary=True, radar_label=True, coastline=True, parameter="v",ball_and_stick=True, len_factor=200, coords=pydarn.Coords.AACGM, projs=pydarn.Projs.POLAR) plt.show()

image image image image image
hiyadutuje commented 11 months ago

Figure_15 Figure_16 Figure_17 Figure_18 I was getting some errors, which are resolved by updating my matplotlib on Anaconda.