Skip to content

Commit

Permalink
Added enum for station ID of radars, called RadarID.
Browse files Browse the repository at this point in the history
  • Loading branch information
RemingtonRohel committed Oct 9, 2024
1 parent 851f173 commit 599fe19
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 205 deletions.
10 changes: 5 additions & 5 deletions docs/user/axis.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import pydarn
import datetime as dt
import matplotlib.pyplot as plt

pydarn.Fan.plot_fov(stid=65, date=dt.datetime(2024,7,23,0,0),
pydarn.Fan.plot_fov(stid=pydarn.RadarID.RKN, date=dt.datetime(2024,7,23,0,0),
radar_label=True, fov_color='green',
line_color='green', alpha=0.8, lowlat=60, coastline=True,
projs=pydarn.Projs.POLAR, coords=pydarn.Coords.AACGM_MLT)
Expand Down Expand Up @@ -60,7 +60,7 @@ import pydarn
import datetime as dt
import matplotlib.pyplot as plt

pydarn.Fan.plot_fov(stid=65, date=dt.datetime(2024,7,23,0,0),
pydarn.Fan.plot_fov(stid=pydarn.RadarID.RKN, date=dt.datetime(2024,7,23,0,0),
radar_label=True, fov_color='green',
line_color='green', alpha=0.8, plot_extent=[80,50],
coastline=True, projs=pydarn.Projs.GEO,
Expand Down Expand Up @@ -96,7 +96,7 @@ import pydarn
import datetime as dt
import matplotlib.pyplot as plt

pydarn.Fan.plot_fov(stid=65, date=dt.datetime(2024,7,23,0,0),
pydarn.Fan.plot_fov(stid=pydarn.RadarID.RKN, date=dt.datetime(2024,7,23,0,0),
radar_label=True, fov_color='green',
line_color='green', alpha=0.8, plot_extent=[80,50],
coastline=True, projs=pydarn.Projs.MAG,
Expand Down Expand Up @@ -132,7 +132,7 @@ ax1.set_xticks([0, np.radians(45), np.radians(90), np.radians(135),
np.radians(315)])
ax1.set_xticklabels(['00', '', '06', '', '12', '', '18', ''])
ax1.set_theta_zero_location("S")
pydarn.Fan.plot_fov(stid=65, date=date, ax=ax1)
pydarn.Fan.plot_fov(stid=pydarn.RadarID.RKN, date=date, ax=ax1)

# Geo plot
deg_from_midnight = (date.hour + date.minute / 60) / 24 * 360
Expand All @@ -144,7 +144,7 @@ ax2 = fig.add_subplot(122, projection=proj, aspect='auto')
ax2.gridlines(draw_labels=True)
extent = min(45e5,(abs(proj.transform_point(noon, 30, ccrs.PlateCarree())[1])))
ax2.set_extent(extents=(-extent, extent, -extent, extent), crs=proj)
pydarn.Fan.plot_fov(stid=65, date=date, ax=ax2, ccrs=ccrs, coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO)
pydarn.Fan.plot_fov(stid=pydarn.RadarID.RKN, date=date, ax=ax2, ccrs=ccrs, coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO)
plt.tight_layout()
plt.show()
```
Expand Down
2 changes: 1 addition & 1 deletion docs/user/coordinates.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ import matplotlib.pyplot as plt
import numpy as np

# North Winter
pydarn.Fan.plot_fov(66, dt.datetime(2023, 12, 21, 0, 0),
pydarn.Fan.plot_fov(pydarn.RadarID.CLY, dt.datetime(2023, 12, 21, 0, 0),
lowlat= 5, boundary=True, line_color='red', coastline=True)

# Test to plot terminator if ever required - plot line not fill!
Expand Down
3 changes: 1 addition & 2 deletions docs/user/fan.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,11 @@ data_groundscatter = [(np.zeros(16)).tolist() for x in range(75)]
for i in range(30,40):
data_groundscatter[i] = (np.ones(16)).tolist()

stid = 5
data_datetime = dt.datetime(2024,1,1,0,0)

pydarn.Fan.plot_fan_input(data_array=data_array,
data_datetime=data_datetime,
stid=stid,
stid=pydarn.RadarID.SAS,
data_groundscatter = data_groundscatter,
data_parameter='v',
zmin=-400,zmax=400, lowlat=50, coastline=True)
Expand Down
64 changes: 35 additions & 29 deletions docs/user/fov.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import pydarn
from datetime import datetime
import matplotlib.pyplot as plt

pydarn.Fan.plot_fov(66, datetime(2015, 3, 8, 15, 0), radar_label=True)
pydarn.Fan.plot_fov(pydarn.RadarID.CLY, datetime(2015, 3, 8, 15, 0), radar_label=True)
plt.show()
```

Expand All @@ -37,8 +37,8 @@ A `datetime` object of the date is required to convert to `Coords.AACGM_MLT` (de
Here is a list of all the current options than can be used with `plot_fov`

| Option | Action |
| ----------------------- | ------------------------------------------------------------------------------------------------------- |
| stid=(int) | Station id of the radar. Can be found using [SuperDARNRadars](hardware.md) |
|-------------------------|---------------------------------------------------------------------------------------------------------|
| stid=pydarn.RadarID | Station id of the radar. |
| date=(datetime) | `datetime` object to determine the position the radar fov AACGM or AACGM MLT coordinates |
| ranges=(list) | Two element list giving the lower and upper ranges to plot, grabs ranges from hardware file (default [] |
| ax=(Axes Object) | Matplotlib axes object than can be used for cartopy additions |
Expand Down Expand Up @@ -70,22 +70,28 @@ To plot based on hemisphere or selection of radars, here is an example plotting
```python
import pydarn
from datetime import datetime
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt

fov_rtn={}
fov_rtn = {}
fov_rtn['ax'] = None
for stid in pydarn.SuperDARNRadars.radars.keys():
for stid in pydarn.RadarID:
if pydarn.SuperDARNRadars.radars[stid].hemisphere == pydarn.Hemisphere.North:
if stid != 2:
if stid in [66, 65, 6, 65, 5]:
fov_rtn = pydarn.Fan.plot_fov(stid, datetime(2021, 2, 5, 12, 5),
radar_label=True, fov_color='green',
line_color='green', alpha=0.8, ax=fov_rtn['ax'])

fov_rtn = pydarn.Fan.plot_fov(stid, datetime(2021, 2, 5, 12, 5),
radar_label=True, fov_color='blue',
line_color='blue', alpha=0.2, lowlat=10,
ax=fov_rtn['ax'])
if stid != pydarn.RadarID.SCH:
if stid in [
pydarn.RadarID.SAS,
pydarn.RadarID.PGR,
pydarn.RadarID.CLY,
pydarn.RadarID.RKN,
pydarn.RadarID.INV
]:
fov_rtn = pydarn.Fan.plot_fov(stid, datetime(2021, 2, 5, 12, 5),
radar_label=True, fov_color='green',
line_color='green', alpha=0.8, ax=fov_rtn['ax'])
else:
fov_rtn = pydarn.Fan.plot_fov(stid, datetime(2021, 2, 5, 12, 5),
radar_label=True, fov_color='blue',
line_color='blue', alpha=0.2, lowlat=10,
ax=fov_rtn['ax'])

plt.show()
```
Expand All @@ -97,16 +103,16 @@ This example will plot all radars in the southern hemisphere FOV in red:
```python
import pydarn
from datetime import datetime
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt

fov_rtn={}
fov_rtn = {}
fov_rtn['ax'] = None
for stid in pydarn.SuperDARNRadars.radars.keys():
for stid in pydarn.RadarID:
if pydarn.SuperDARNRadars.radars[stid].hemisphere == pydarn.Hemisphere.South:
if stid != 2:
if stid != pydarn.RadarID.SCH:
fov_rtn = pydarn.Fan.plot_fov(stid, datetime(2021, 2, 5, 12, 5),
radar_label=True, fov_color='red',
line_color='red', alpha=0.2, ax=fov_rtn['ax'])
radar_label=True, fov_color='red',
line_color='red', alpha=0.2, ax=fov_rtn['ax'])
plt.show()
```

Expand All @@ -120,7 +126,7 @@ import pydarn
from datetime import datetime
import matplotlib.pyplot as plt

pydarn.Fan.plot_fov(stid=65, date=datetime(2022, 1, 8, 14, 5),
pydarn.Fan.plot_fov(stid=pydarn.RadarID.RKN, date=datetime(2022, 1, 8, 14, 5),
fov_color='red', coords=pydarn.Coords.GEOGRAPHIC,
projs=pydarn.Projs.GEO, coastline=True)
plt.show()
Expand All @@ -138,27 +144,27 @@ import pydarn
from datetime import datetime
import matplotlib.pyplot as plt

fov_rtn = pydarn.Fan.plot_fov(66, datetime(2021, 6, 21, 6, 0),
fov_rtn = pydarn.Fan.plot_fov(pydarn.RadarID.CLY, datetime(2021, 6, 21, 6, 0),
lowlat= 50, boundary=True, radar_label=True,
line_color='red', grid = True,
coords=pydarn.Coords.GEOGRAPHIC,
projs=pydarn.Projs.GEO, coastline=True)
pydarn.Fan.plot_fov(5, datetime(2021, 2, 5, 12, 5), radar_label=True,
pydarn.Fan.plot_fov(pydarn.RadarID.SAS, datetime(2021, 2, 5, 12, 5), radar_label=True,
ax=fov_rtn['ax'], ccrs=fov_rtn['ccrs'], boundary=True,
line_color='blue', grid = True,
coords=pydarn.Coords.GEOGRAPHIC,
projs=pydarn.Projs.GEO)
pydarn.Fan.plot_fov(64, datetime(2021, 2, 5, 12, 5), radar_label=True,
pydarn.Fan.plot_fov(pydarn.RadarID.INV, datetime(2021, 2, 5, 12, 5), radar_label=True,
ax=fov_rtn['ax'], ccrs=fov_rtn['ccrs'],
boundary=True, line_color='green',
grid = True, coords=pydarn.Coords.GEOGRAPHIC,
projs=pydarn.Projs.GEO)
pydarn.Fan.plot_fov(65, datetime(2021, 2, 5, 12, 5), radar_label=True,
pydarn.Fan.plot_fov(pydarn.RadarID.RKN, datetime(2021, 2, 5, 12, 5), radar_label=True,
ax=fov_rtn['ax'], ccrs=fov_rtn['ccrs'],
boundary=True, line_color='orange',
grid = True, coords=pydarn.Coords.GEOGRAPHIC,
projs=pydarn.Projs.GEO)
pydarn.Fan.plot_fov(6, datetime(2021, 2, 5, 12, 5), radar_label=True,
pydarn.Fan.plot_fov(pydarn.RadarID.PGR, datetime(2021, 2, 5, 12, 5), radar_label=True,
ax=fov_rtn['ax'], ccrs=fov_rtn['ccrs'],
boundary=True, grid = True,
coords=pydarn.Coords.GEOGRAPHIC, projs=pydarn.Projs.GEO)
Expand All @@ -175,7 +181,7 @@ import pydarn
from datetime import datetime
import matplotlib.pyplot as plt

pydarn.Fan.plot_fov(66, datetime(2021, 2, 5, 12, 5), boundary=False,
pydarn.Fan.plot_fov(pydarn.RadarID.CLY, datetime(2021, 2, 5, 12, 5), boundary=False,
radar_label=True)
plt.show()
```
Expand Down
12 changes: 6 additions & 6 deletions docs/user/grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ In addition to the gridded line-of-sight velocity, you can choose one of two oth
Here is a list of all the current options than can be used with `plot_grid`

| Option | Action |
| ------------------------------ | ------------------------------------------------------------------------------------- |
|--------------------------------| ------------------------------------------------------------------------------------- |
| record=(int) | Record number to plot |
| start_time=(datetime.datetime) | The start time of the record to plot |
| time_delta=(int) | How close to the start time to be to the start time of the record |
Expand All @@ -77,12 +77,12 @@ Here is a list of all the current options than can be used with `plot_grid`
| colorbar=(bool) | Set true to plot a colorbar (default: True) |
| colorbar_label=(string) | Label for the colour bar (requires colorbar to be true) |
| title=(str) | To add a title to the plot |
| radar_label=(str) | To include a dot at radar location and label of 3 letter code |
| fov_color=(str) | Fill color of fov |
| line_color=(str) | Fill color of fov lines |
| radar_label=(str) | To include a dot at radar location and label of 3 letter code |
| fov_color=(str) | Fill color of fov |
| line_color=(str) | Fill color of fov lines |
| coastline=(bool) | Plots outlines of coastlines below grid data |
| coords=(Coords) | [Coordinates](coordinates.md) for the data to be plotted in |
| projs=(Projs) | Projections to plot the data on top of |
| coords=(Coords) | [Coordinates](coordinates.md) for the data to be plotted in |
| projs=(Projs) | Projections to plot the data on top of |

As an example, the following code plots multiple radar Grid plot:
```python
Expand Down
12 changes: 6 additions & 6 deletions docs/user/hardware.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ This class contains a dictionary of all currently accepted SuperDARN radars (inc
``` python
import pydarn

# Access Prince Georges Radar information
radar_info = pydarn.SuperDARNRadars.radars[6]
# Access Prince George Radar information
radar_info = pydarn.SuperDARNRadars.radars[pydarn.RadarID.PGR]
print(radar_info)
```

Expand All @@ -101,17 +101,17 @@ Example code:
```python
import pydarn

# Geographic coordinates for Clyde River (STID: 66) FOV
geo_lats, geo_lons=pydarn.Coords.GEOGRAPHIC(66)
# Geographic coordinates for Clyde River FOV
geo_lats, geo_lons=pydarn.Coords.GEOGRAPHIC(pydarn.RadarID.CLY)
```

You also have the option to set the `coords` keyword to `aacgm`. In this case, [Altitude adjusted corrected geomagnetic](http://superdarn.thayer.dartmouth.edu/aacgm.html) latitude and longitude are returned instead of geographic. Because AACGM requires a date to convert coordinates accurately, a python datetime object is also required to be passed in to `coords` under this circumstance:
```python
import pydarn
import datetime as dt

# AACGMv2 coordinates for Dome C (STID: 96), valid for November 26th, 2005
aacgm_lats, aacgm_lons=pydarn.Coords.AACGM(96, date=dt.datetime(2005, 11, 26))
# AACGMv2 coordinates for Dome C East, valid for November 26th, 2005
aacgm_lats, aacgm_lons=pydarn.Coords.AACGM(pydarn.RadarID.DCE, date=dt.datetime(2005, 11, 26))
```
The `Coords` keyword points to the function to convert the radar's Field-of-View to the designed coordinate system. The outputs are two numpy arrays of latitude and longitude coordinates with dimensions (number_of_beams+1 x number_of_gates+1). They correspond to the corners of each range gate.

Expand Down
2 changes: 1 addition & 1 deletion docs/user/range_time.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ plt.show()

Range-time plots also allow users to plot `pwr0` parameters in RAWACF files:

``` python
```python
import pydarn
import matplotlib.pyplot as plt
from matplotlib import colors
Expand Down
2 changes: 1 addition & 1 deletion pydarn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from .utils.plotting import (MapParams, TimeSeriesParams, check_data_type,
time2datetime, find_record, determine_embargo, add_embargo)
from .utils.general_utils import GeneralUtils
from .utils.superdarn_radars import SuperDARNRadars
from .utils.superdarn_radars import RadarID, SuperDARNRadars
from .utils.superdarn_cpid import SuperDARNCpids
from .utils.superdarn_radars import Hemisphere, read_hdw_file, get_hdw_files
from .utils.scan import find_records_by_datetime, find_records_by_scan
Expand Down
Loading

0 comments on commit 599fe19

Please sign in to comment.