Closed carleyjmartin closed 1 month ago
Matplotlib version: 3.9.0 Hi, Things look good to me. I think in the magnetic coordinate system, it would be useful to have a selected MLT (e.g. 0 or 12) at the top center or the bottom center of the plot.
import matplotlib.pyplot as plt import pydarn import datetime as dt
SDarn_read = pydarn.SuperDARNRead('20210126.2000.00.pgr.a.fitacf') fitacf_data = SDarn_read.read_fitacf()
#Fan plot in geographic coordinate rtn = pydarn.Fan.plot_fan(fitacf_data, scan_index=50, coastline=True, radar_label=True, groundscatter=True, colorbar=False, coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO, plot_extent=[50,30], plot_center=[-120,65]) plt.title('Geographic plot-extent: 50,30 plot-center: -120,65') plt.show()
#Fan plot in geomagnetic coordinate rtn = pydarn.Fan.plot_fan(fitacf_data, scan_index=50, coastline=True, radar_label=True, groundscatter=True, colorbar=False, coords=pydarn.Coords.AACGM_MLT, projs=pydarn.Projs.MAG, plot_extent=[60,30], plot_center=[-120,85]) plt.title('Geographic plot-extent: 60,30 plot-center: -120,85') plt.show()
#FOV plot in geomagnetic coordinate from datetime import datetime stids = [53,54,55] cols = ['blue','red','green'] plt.figure(figsize=(8, 8)) rtn=pydarn.Fan.plot_fov(stids[0], datetime(2021, 2, 5, 18, 5), fov_color= cols[0],radar_location=True, radar_label=True, coastline=True, coords=pydarn.Coords.AACGM_MLT, projs=pydarn.Projs.MAG, plot_extent=[90,50], plot_center=[20,60]) for i, stid in enumerate(stids[1:]): rtn=pydarn.Fan.plot_fov(stid, datetime(2021, 2, 5, 18, 5), ax=rtn['ax'], ccrs=rtn['ccrs'], fov_color= cols[i+1], radar_location=True, radar_label=True, coastline=True, coords=pydarn.Coords.AACGM_MLT, projs=pydarn.Projs.MAG) plt.show()
#FOV plot in geographic coordinate from datetime import datetime stids = [53,54,55] cols = ['blue','red','green'] plt.figure(figsize=(8, 8)) rtn=pydarn.Fan.plot_fov(stids[0], datetime(2021, 2, 5, 18, 5), fov_color= cols[0],radar_location=True, radar_label=True, coastline=True, coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO, plot_extent=[90,90], plot_center=[80,70]) for i, stid in enumerate(stids[1:]): rtn=pydarn.Fan.plot_fov(stid, datetime(2021, 2, 5, 18, 5), ax=rtn['ax'], ccrs=rtn['ccrs'], fov_color= cols[i+1], radar_location=True, radar_label=True, coastline=True, coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO,) plt.show()
#FOV plotting in geographic coordinate on the southern hemisphere from datetime import datetime stids = [19,18] cols = ['blue','red'] plt.figure(figsize=(8, 8)) rtn=pydarn.Fan.plot_fov(stids[0], datetime(2020, 2, 5, 18, 5), fov_color= cols[0],radar_location=True, radar_label=True, coastline=True, coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO,plot_extent=[100,100], plot_center=[10,-90] ) for i, stid in enumerate(stids[1:]): rtn=pydarn.Fan.plot_fov(stid, datetime(2021, 2, 5, 18, 5), ax=rtn['ax'], ccrs=rtn['ccrs'], fov_color= cols[i+1], radar_location=True, radar_label=True, coastline=True, coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO) plt.show()
Excellent! Thanks @KhanalKrishna ! I'll have a look into how we can set an MLT in a fixed spot!
I am using matplotlib: 3.7.2.
The fist code I am getting the a
figure with following error:
File ~/.local/lib/python3.11/site-packages/pydarn/plotting/fan.py:198 in plot_fan
date = time2datetime(dmap_data[plot_beams[0][0]])
IndexError: index 0 is out of bounds for axis 0 with size 0.
For the second and third codes, I ma getting this error:
Cell In[7], line 10 coords=pydarn.Coords.AACGM_MLT, projs=pydarn.Projs.MAG,
File ~/anaconda3/lib/python3.11/enum.py:784 in getattr raise AttributeError(name) from None
AttributeError: MAG.
Thanks, @hiyadutuje !
The errors you're getting and the first plot not working correctly sounds like the correct branch might not be installed for testing?
You can install in a fresh environment using pip3 install git+https://github.com/superdarn/pydarn@ref/axes
Or git clone and checkout the ref/axes branch then pip3 install .
Suggestions have been implemented, if you are testing and come across the numpy error, please downgrade numpy and test, fixing that is out of scope for this PR and is a pyDARNio issue.
pip3 uninstall numpy
pip3 install numpy==1.26.4
I recommend doing this in a virtual environment, as always.
Here's the results of my test runs
OS: Win10, numpy version 1.25.0
I used the same code as the given tests, save for the decompression steps since my data is in .bz2
For the FOV plot
GRID plotting
Tested with Python=3.9.2
, Numpy=1.26.4
, and matplotlib=3.9.0
on Windows 10. Everything seems to work well. Figures can be interacted with in the live editor and the plot_center
and plot_extent
options seem to work for the different plot types.
My only comment is that I've noted that the MAG projection defaults to 12 MLT at the bottom of the figure and the POLAR projections defaults 12 MLT to the top of the figure for both Northern and Southern hemisphere data. It might be nice to have the MAG and POLAR projections default to the same orientation if plot_center
is not specified.
Fan plots and ball and stick plots:
FOV plots:
Lastly the grid plots:
I'm gonna merge this in now and sort out lots of merge conflicts. I have changed the default to be 0 MLT at bottom. We will also have some time before the release to test this within the release branch.
Thanks to all who tested! :D
Scope
This PR amends some details in the projections module, updates the geographic plotting to allow the user to zoom in on areas and move the focus of the plot. A new projection is also made for the same thing in geomagnetic/MLT coordinates. I was unable to allow subplot usage with these plots - the projections are very specific for use with SuperDARN data so I don't recommend making your own axes to put in, it would be nice to have the ability to plot multiple plots on one figure, but that will require a lot of work that I can't do right now.
Zoomable convection map plots will come eventually - they're just very hard and there are a few issues I haven't solved yet so that will all be in another PR at a later date!
Whats new:
issue: to close #357
Approval
Number of approvals: 2 at least please, lots of things to test
Test
matplotlib version: 3.8.2 Note testers: please indicate what version of matplotlib you are using
Also test with southern hemisphere data, different keyword combos etc...
FAN or BALL AND STICK Plot testing:
This tests the new geographic plotting and geomagnetic plotting defaults and zoom features
FOV plot testing:
This feature was specifically requested for plotting the new NSSC radars, so here is an example of doing jsut that in magnetic MLT coordinates.
GRID plotting:
Map plots only use the Polar projection.