SuperDARN / pydarn

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

FIX: Grid lines on Fan plots not showing #333

Closed carleyjmartin closed 1 year ago

carleyjmartin commented 1 year ago

Scope

This PR fixes a bug where the plot grid lines on fan plots were not showing up. I have removed duplicate code that seems to mess up the grid plotting and added a zorder to the ax.grid() to give it a position on the plot. Zordering was added with the map plots but not checked against the fan plots.

issue: No issue

Approval

Number of approvals: 1 quick fix

Test

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

import matplotlib.pyplot as plt 
import pydarn

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

ax, _,_,_,_ = pydarn.Fan.plot_fan(fitacf_data, parameter='elv', coastline=True, lowlat=60)
plt.show()
Screenshot 2023-06-14 at 8 19 49 AM

If you get a chance have a look at map plots to make sure the grid lines are where you expect.

PrestonXPitzer commented 1 year ago
import matplotlib.pyplot as plt #verified to 3.7.1
import pydarn

file = "test/data/20150317.0900.32.sas.fitacf.bz2"
SDarn_read = pydarn.SuperDARNRead().read_dmap(file)

ax, _,_,_,_ = pydarn.Fan.plot_fan(SDarn_read, parameter='elv', coastline=True, lowlat=60)
plt.show()

Figure_1 Here's the output that I got.

carleyjmartin commented 1 year ago

Thanks @PrestonXPitzer !

I just want to check that you installed this branch of pydarn using (apologies, I did not go over this in the tutorial and I should have): pip3 install git+https://github.com/superdarn/pydarn@fix/fan-plot-grid

or by cloning

git clone https://github.com/SuperDARN/pydarn.git checking out this branch cd pydarn git checkout fix/fan-plot-grid and then installing pip3 install .

I'm struggling to recreate the grid lines not showing up now.

PrestonXPitzer commented 1 year ago

I tried both of these methods a few times, and I'm getting the same output; No grid lines (Using the code I sent before). I have an example of grid lines working for me on main if that helps.


    #generate individual fan plots for each time period
    plot_output = pydarn.Fan.plot_fan(data_list[position], fov_color='grey', line_color='blue',
                                    radar_label=True, colorbar = False,
                                    coords=pydarn.Coords.AACGM_MLT, coastline=True)
    ax=plot_output[0]
    pydarn.Fan.plot_fan(rkn_data_list[position], fov_color='grey', line_color='red',radar_label=True, 
                    groundscatter=True, colorbar_label="Velocity (m/s)", ax=ax,
                    coords=pydarn.Coords.AACGM_MLT, coastline=True)
    plt.savefig('stpatricksday_fanplot_' + str(iter) + '.png', dpi = 300)
    iter+=1

nogrid

stpatricksday_fanplot_3

carleyjmartin commented 1 year ago

Awesome, thanks! I'll look into it more!

carleyjmartin commented 1 year ago

Okay, so if I just straight up remove the grid call in projections. It appears to still plot the grid lines for me so hopefully fixed?

hiyadutuje commented 1 year ago

It is working for me.

carleyjmartin commented 1 year ago

This was solved in #339