Skip to content

FIX/NEW: plot_center bug fix and new plot_tight option#437

Open
carleyjmartin wants to merge 5 commits intodevelopfrom
fix/plot-center
Open

FIX/NEW: plot_center bug fix and new plot_tight option#437
carleyjmartin wants to merge 5 commits intodevelopfrom
fix/plot-center

Conversation

@carleyjmartin
Copy link
Collaborator

Scope

This PR fixes the plot_center option for MAG projections, and includes new plot_tight which will calculate the plot_center and plot_extent to center the FOV in the middle of the plot zoomed in.

Docs amended to include changes. This can be properly formatted during a release.

Note that the plot_center now used MLT when using the magnetic projection, as that it what is plotted so makes more sense.
Plot tight requires information about the FOV so has to be in the fan module to get that information. Tight plotting is only available for FOV and FAN methods for individual radar plots... doesn't make sense to have the option for grid or maps. You can over plot extra fans from other radars, but plot_tight will use whatever radar you have plotted first with that option as True.

issue: to close #430 and #433

Approval

Number of approvals: 2, code review and testing

Test

matplotlib version: 3.10.8
python version: 3.11
Note testers: please indicate what version of matplotlib you are using

  • Please test with north and south data, and use various combinations of projections, plot_center and plot_extent.
  • The three keywords do not work with the POLAR projection, plot_tight will override any plot_center and plot_extent inputs.
  • plot_center uses the plot coordinates, i.e. geographic longitude for GEO proj and MLT for MAG proj
import pydarn
import matplotlib.pyplot as plt
import datetime as dt

# Fitacf data
file1 = '/home/carleyjm/data/fitacf/20250101.0600.00.sas.a.fitacf'
file2 = '/home/carleyjm/data/fitacf/2024/01/20240101.0000.29.rkn.a.fitacf.bz2'
file3 = '/home/carleyjm/data/fitacf/2025/01/20250131.2200.22.lyr.fitacf.bz2'
file4 = '/home/carleyjm/data/fitacf/2026/02/20260201.0000.00.sps.a.fitacf.bz2'


for i, file in enumerate([file1 ,file2 ,file3 , file4]):
    data, _ = pydarn.read_fitacf(file)
    pydarn.Fan.plot_fan(data,scan_index=1,groundscatter=True,coastline=True,
                    projs=pydarn.Projs.MAG, plot_tight=True)
    plt.savefig('/home/carleyjm/projects/plot_tight/fan_mag_' + str(i) + '.png')
    plt.close()


    pydarn.Fan.plot_fan(data,scan_index=1,groundscatter=True,coastline=True, 
                    projs=pydarn.Projs.GEO, coords=pydarn.Coords.GEOGRAPHIC,
                    plot_tight=True)
    plt.savefig('/home/carleyjm/projects/plot_tight/fan_geo_' + str(i) + '.png')
    plt.close()

pydarn.Fan.plot_fov(pydarn.RadarID.INV, dt.datetime(2020,1,1,4,30), plot_tight=True,
                    projs=pydarn.Projs.MAG,coastline=True, fov_color='r')
plt.savefig('/home/carleyjm/projects/plot_tight/fov_mag.png')
plt.close()


pydarn.Fan.plot_fov(pydarn.RadarID.SPS, dt.datetime(2020,1,1,4,30), plot_tight=True,
                    projs=pydarn.Projs.GEO, coords=pydarn.Coords.GEOGRAPHIC,
                    coastline=True, fov_color='b')
plt.savefig('/home/carleyjm/projects/plot_tight/fov_geo.png')
plt.close()

Whole bunch of plots this made for testing:

fan_mag_0 fan_mag_1 fan_mag_2 fan_mag_3 fan_geo_0 fan_geo_1 fan_geo_2 fan_geo_3 fov_mag fov_geo

@carleyjmartin carleyjmartin changed the title Fix/plot center FIX/NEW: plot_center bug fix and new plot_tight option Feb 24, 2026
@carleyjmartin carleyjmartin self-assigned this Feb 24, 2026
@carleyjmartin carleyjmartin requested review from RemingtonRohel and billetd and removed request for billetd February 24, 2026 19:18
@carleyjmartin carleyjmartin added enhancement New feature or request FIX fix for a bug labels Feb 24, 2026
@carleyjmartin carleyjmartin linked an issue Feb 24, 2026 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request FIX fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: plot center only works accurately at 0 LT New: Quick and Easy FOV centered fan plots

1 participant