Skip to content

Commit

Permalink
Fixed bug with terminator plotting behind background pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
RemingtonRohel committed Oct 10, 2024
1 parent 7bbae76 commit 94e9ca4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
29 changes: 15 additions & 14 deletions docs/user/range_time.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,21 @@ plt.show()
### Additional options
To see all the customisation options, check out all the parameters listed in 'rtp.py'. A few useful ones:

| Parameter | Action |
|------------------------------|-------------------------------------------------------------|
| start_time=(datetime object) | Control the start time of the plot |
| end_time=(datetime object) | Control the end time of the plot |
| channel=(int or string) | Choose which channel to plot. Default is 'all'. |
| groundscatter=(bool) | True or false to showing ground scatter as grey |
| date_fmt=(string) | How the x-tick labels look. Default is ('%y/%m/%d\n %H:%M') |
| zmin=(int) | Minimum data value to be plotted |
| zmax=(int) | Maximum data value to be plotted |
| range_estimation=(RangeEstimation) | Estaimtion of the distance for the radar to use for the y-axis (See [Ranges, Coords and Projs](coordinates.md)) |
| coords=(Coords) | Used in conjunction with range_estimation, converts the y-axis to a coordinate |
| lat_or_lon=(str) | In conjunction with coords, choose if you would like the latitude ('lat') or longitude ('lon') |
| colorbar=(plt.colorbar) | If you would like a different colorbar than the default |
| colorbar_label=(str) | Set the label fo the colorbar |
| Parameter | Action |
|------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| start_time=(datetime object) | Control the start time of the plot |
| end_time=(datetime object) | Control the end time of the plot |
| channel=(int or string) | Choose which channel to plot. Default is 'all'. |
| groundscatter=(bool) | True or false to showing ground scatter as grey |
| date_fmt=(string) | How the x-tick labels look. Default is ('%y/%m/%d\n %H:%M') |
| zmin=(int) | Minimum data value to be plotted |
| zmax=(int) | Maximum data value to be plotted |
| range_estimation=(RangeEstimation) | Estaimtion of the distance for the radar to use for the y-axis (See [Ranges, Coords and Projs](coordinates.md)) |
| coords=(Coords) | Used in conjunction with range_estimation, converts the y-axis to a coordinate |
| lat_or_lon=(str) | In conjunction with coords, choose if you would like the latitude ('lat') or longitude ('lon') |
| colorbar=(plt.colorbar) | If you would like a different colorbar than the default |
| colorbar_label=(str) | Set the label fo the colorbar |
| terminator=(bool) | Turn on shading of the day-night terminator |

For instance, code for a velocity RTP showing the same beam of Clyde river radar as above, but with ground scatter plotted in grey, date format as `hh:mm`, custom min and max values and a colour bar label could look something like:
```python
Expand Down
18 changes: 13 additions & 5 deletions pydarn/plotting/rtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __str__(self):
@classmethod
def plot_range_time(cls, dmap_data: List[dict], parameter: str = 'v',
beam_num: int = 0, channel: int = 'all', ax=None,
background: str = 'w', background_alpha: float = 1.0,
background: str = 'w', background_alpha: float = 0.0,
groundscatter: bool = False,
zmin: int = None, zmax: int = None,
start_time: datetime = None, end_time: datetime = None,
Expand Down Expand Up @@ -130,7 +130,7 @@ def plot_range_time(cls, dmap_data: List[dict], parameter: str = 'v',
default: white
background_alpha : float
alpha (transparency) of the background in the plot
default: 1.0 (opaque)
default: 0.0 (transparent)
zmin: int
Minimum normalized value
Default: minimum parameter value in the data set
Expand Down Expand Up @@ -467,14 +467,18 @@ def plot_range_time(cls, dmap_data: List[dict], parameter: str = 'v',
geographic_points = np.flip(geographic_points, axis=1)

# [num_times, num_ranges] indicating if the cell is in darkness at that time
is_night = np.zeros((y.shape[0], len(x)), dtype=bool)
is_night = np.zeros_like(time_axis, dtype=np.int8)
geodesic = cartopy.geodesic.Geodesic()
for i, t in enumerate(x):
anti_point, arc_ang, _ = calc_terminator(t, height)
distance_to_antisolar_point = geodesic.inverse(anti_point, geographic_points)[:, 0] / 1000.0 # convert to km
is_night[:, i] = distance_to_antisolar_point < arc_ang

ax.pcolormesh(time_axis, y_axis, is_night, cmap=matplotlib.cm.get_cmap('binary'), zorder=0, alpha=0.5)
ax.pcolormesh(time_axis, y_axis, is_night,
cmap=colors.ListedColormap(['white', 'gray']),
zorder=0.5,
vmin=0,
vmax=1,
alpha=0.7)

# setup some standard axis information
if ymax is None:
Expand Down Expand Up @@ -903,6 +907,7 @@ def plot_summary(cls, dmap_data: List[dict],
latlon: str = None, coords: object = Coords.AACGM,
vector_parameters: list = [('p_l'), ('v'),
('w_l'), ('elv')],
terminator: bool = False,
**kwargs):
"""
Plots the summary of several SuperDARN parameters using time-series and
Expand Down Expand Up @@ -991,6 +996,8 @@ def plot_summary(cls, dmap_data: List[dict],
Required parameters for plotting in the summary plot
Must be a subset of the default list below
default:[('p_l'), ('v'), ('w_l'), ('elv')]
terminator: bool=False
Flag to include the terminator (day/night boundary) and shade the night-side
kwargs:
reflection_height for ground_scatter_mapped method
background
Expand Down Expand Up @@ -1294,6 +1301,7 @@ def plot_summary(cls, dmap_data: List[dict],
yspacing=500,
background=background,
range_estimation=range_estimation,
terminator=terminator,
**kwargs)
else:
rt_rtn =\
Expand Down

0 comments on commit 94e9ca4

Please sign in to comment.