SuperDARN / pydarn

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

EHN: Adding more keywords to allow customization #383

Closed carleyjmartin closed 1 month ago

carleyjmartin commented 3 months ago

Scope

This PR adds some new keywords for plots that have multiple plots inside, or need a specific key word to set a marker or a color as there a multiple uses of color. Otherwise, kwargs can be used in other plotting methods. Also streamlined some plot calls for ax calls instead.

issue: to close #361

Approval

Number of approvals: 2

Test

Please plot grid, fan, and ACF plots. For grid and fan try using the new cartopy keywords to customize the coastlines, for ACF you can use the marker and color key words to customize the colors. You can see all the new key words in the changes.

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

carleyjmartin commented 1 month ago

Testing codes:

Cartopy stuff:

import matplotlib.pyplot as plt
import pydarn
files = ['/Users/carley/Documents/data/20200101.0001.00.inv.fitacf', '/Users/carley/Documents/data/20220108.0801.00.dcn.fitacf']
for file in files:
    SDarn_read = pydarn.SuperDARNRead(file)
    fitacf_data = SDarn_read.read_fitacf()

    rtn = pydarn.Fan.plot_fan(fitacf_data, scan_index=4,
                              coastline=True, lowlat=30,
                              coords=pydarn.Coords.AACGM_MLT,
                              projs=pydarn.Projs.POLAR,
                              cartopy_scale='50m',
                              coastline_color='y',
                              coastline_linewidth=2.0)

    plt.show()

    rtn = pydarn.Fan.plot_fan(fitacf_data, scan_index=4,
                              coastline=True, lowlat=30,
                              coords=pydarn.Coords.AACGM_MLT,
                              projs=pydarn.Projs.MAG,
                              cartopy_scale='50m',
                              coastline_color='g',
                              coastline_linewidth=2.0)

    plt.show()

    rtn = pydarn.Fan.plot_fan(fitacf_data, scan_index=4,
                              coastline=True, lowlat=30,
                              coords=pydarn.Coords.GEOGRAPHIC,
                              projs=pydarn.Projs.GEO,
                              cartopy_scale='50m',
                              coastline_color='m',
                              coastline_linewidth=2.0)

    plt.show()

ACF plots

import pydarn
#import pydarnio
import matplotlib.pyplot as plt 
from datetime import datetime

#reader = pydarn.SuperDARNRead("/Users/carley/Documents/data/20140105.1208.03.rkn.rawacf")
reader = pydarn.SuperDARNRead("/Users/carley/Documents/data/20180520.0801.00.lyr.rawacf")
data = reader.read_rawacf()
plt.figure(figsize=(12, 7))
rtn = pydarn.ACF.plot_acfs(data, beam_num=5, gate_num=12, normalized=True,
                start_time=datetime(2018, 5, 20, 9, 0), pwr_and_phs=True,
                plot_blank=True, real_color='green', imaginary_color='yellow',
                phs_color='pink', pwr_color='red', real_marker='+',
                imaginary_marker='v', phs_marker='s', pwr_marker='H')
#print(rtn)
plt.show()

plt.figure(figsize=(12, 7))
rtn = pydarn.ACF.plot_acfs(data, beam_num=5, gate_num=12, normalized=True,
                start_time=datetime(2018, 5, 20, 9, 0), pwr_and_phs=False,
                plot_blank=False, real_color='green', imaginary_color='yellow',
                phs_color='pink', pwr_color='red', real_marker='+',
                imaginary_marker='v', phs_marker='s', pwr_marker='H')
plt.show()

plt.figure(figsize=(12, 7))
rtn = pydarn.ACF.plot_acfs(data, beam_num=5, gate_num=12, normalized=False,
                start_time=datetime(2018, 5, 20, 9, 0), pwr_and_phs=True,
                plot_blank=False, real_color='green', imaginary_color='yellow',
                phs_color='pink', pwr_color='red', real_marker='+',
                imaginary_marker='v', phs_marker='s', pwr_marker='H')
plt.show()

RTP and Grid plots are minor changes, any testing that doesnt break them will do.