Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion awot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:toctree: generated/

"""
from __future__ import absolute_import


# import subpackages
from . import io
Expand Down
84 changes: 42 additions & 42 deletions awot/display/rtd.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
"""

# Load the needed packages
from __future__ import print_function

from mpl_toolkits.basemap import Basemap, cm
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
from matplotlib import ticker
import numpy as np

import awot.graph.common as common
import awot.graph.common as gp


def polar_sweep(Var, rot, range, nlevs=30,
def polar_sweep(data, rot, ranges, nlevs=30,
vmin=None, vmax=None, cmap=None, mask_outside=True,
rng_rings=None, rot_angs=None,
title=None, cb_flag=True, cb_orient='horizontal', cb_lab=None):
Expand All @@ -38,9 +38,9 @@ def polar_sweep(Var, rot, range, nlevs=30,

Parameters
----------
Var : float array
data : float array
Data values to plot.
range : float array
ranges : float array
Range along ray.
rot : float array
Rotation angle with respect to instrument [degrees].
Expand Down Expand Up @@ -74,11 +74,11 @@ def polar_sweep(Var, rot, range, nlevs=30,
"""
# Plot the polar coordinate radar data
fig, ax, p = gp.plot_polar_contour(
Var, rot, range, nlevs=nlevs,
vmin=vmin, vmax=vmax, cmap=cmap, mask_outside=True)
data, rot, ranges, nlevs=nlevs,
vmin=vmin, vmax=vmax, cmap=cmap)

# Set the range and turn grid on
ax.set_rmax(1.05 * range.max())
ax.set_rmax(1.05 * ranges.max())
ax.grid(True)

# Set the title
Expand Down Expand Up @@ -206,7 +206,7 @@ def plot_sweep_grid(Xcoord, Ycoord, Values, ax=None, title=None,
return p


def sweep_to_Cart(Var, range, rot, tilt, ax=None, data_proj='fore',
def sweep_to_Cart(Var, ranges, rot, tilt, ax=None, data_proj='fore',
title=None, vmin=-24., vmax=64., cmap=None,
mask_outside=True, grid_on=True, xlims=None, ylims=None,
xlab=None, ylab=None, cb_flag=True, cb_orient='horizontal',
Expand All @@ -222,7 +222,7 @@ def sweep_to_Cart(Var, range, rot, tilt, ax=None, data_proj='fore',
----------
Var : float array
Data values to plot.
range : float array
ranges : float array
Range along ray.
rot : float array
Rotation angle with respect to instrument [degrees].
Expand Down Expand Up @@ -280,26 +280,26 @@ def sweep_to_Cart(Var, range, rot, tilt, ax=None, data_proj='fore',
"either 'fore' or 'aft', assuming 'fore'")
Fact = 1.

range = np.array(range) # Make sure that the data is numpy array
ranges = np.array(ranges) # Make sure that the data is numpy array

values = np.array(Var) # Make sure that the data is numpy array
values = values.reshape(len(rot), len(range)) # Resize it to work
values = values.reshape(len(rot), len(ranges)) # Resize it to work

# mask the data where outside the limits
if mask_outside:
Var = np.ma.masked_outside(Var, vmin, vmax)

# Create 2D variables to plot contour against
r, Rot = np.meshgrid(range, np.radians(rot))
r2, Tilt = np.meshgrid(range, np.radians(tilt))
r, Rot = np.meshgrid(ranges, np.radians(rot))
r2, Tilt = np.meshgrid(ranges, np.radians(tilt))

# Convert r, Rot to Cartesian (x,z)
X = Fact * r * np.sin(Rot) * np.sin(Tilt)
Z = r * np.cos(Rot) * np.cos(Tilt)

# Set axis limits if passed
if xlims is None:
xlims = (-1.05 * range.max(), 1.05 * range.max())
xlims = (-1.05 * ranges.max(), 1.05 * ranges.max())
else:
xlims = xlims
if ylims is None:
Expand All @@ -316,7 +316,7 @@ def sweep_to_Cart(Var, range, rot, tilt, ax=None, data_proj='fore',
return p


def sweep_aircraft_relative(Var, range, tilt, rot, ax=None, title=None,
def sweep_aircraft_relative(Var, ranges, tilt, rot, ax=None, title=None,
vmin=-24., vmax=64., cmap=None, mask_outside=True,
grid_on=True, xlims=None, ylims=None, xlab=None,
ylab=None, cb_flag=True, cb_orient='horizontal',
Expand All @@ -332,7 +332,7 @@ def sweep_aircraft_relative(Var, range, tilt, rot, ax=None, title=None,
----------
Var : float array
Data values to plot.
range : float array
ranges : float array
Range along ray.
tilt : float array
Radar ray Tilt angle with respect to platform [degrees].
Expand Down Expand Up @@ -377,18 +377,18 @@ def sweep_aircraft_relative(Var, range, tilt, rot, ax=None, title=None,
This mapping does NOT take into account corrections for roll,
pitch, or drift of the aircraft.
"""
range = np.array(range) # Make sure that the data is numpy array
ranges = np.array(ranges) # Make sure that the data is numpy array

values = np.array(Var) # Make sure that the data is numpy array
values = values.reshape(len(rot), len(range)) # Resize it to work
values = values.reshape(len(rot), len(ranges)) # Resize it to work

# mask the data where outside the limits
if mask_outside:
Var = np.ma.masked_outside(Var, vmin, vmax)

# Create 2D variables to plot contour against
r, Rot = np.meshgrid(range, np.radians(rot))
r2, Tilt = np.meshgrid(range, np.radians(tilt))
r, Rot = np.meshgrid(ranges, np.radians(rot))
r2, Tilt = np.meshgrid(ranges, np.radians(tilt))

# Convert polar (r,Rot,Tilt) to Cartesian (x,y,z)
X = r * np.cos(Tilt) * np.sin(Rot)
Expand All @@ -397,7 +397,7 @@ def sweep_aircraft_relative(Var, range, tilt, rot, ax=None, title=None,

# Set axis limits if passed
if xlims is None:
xlims = (-1.05 * range.max(), 1.05 * range.max())
xlims = (-1.05 * ranges.max(), 1.05 * ranges.max())
else:
xlims = xlims
if ylims is None:
Expand All @@ -415,7 +415,7 @@ def sweep_aircraft_relative(Var, range, tilt, rot, ax=None, title=None,


def sweep_track_relative(
Var, range, tilt, rot, roll, drift, pitch, ax=None, title=None,
Var, ranges, tilt, rot, roll, drift, pitch, ax=None, title=None,
vmin=-24., vmax=64., cmap=None, mask_outside=True, grid_on=True,
xlims=None, ylims=None, xlab=None, ylab=None,
cb_flag=True, cb_orient='horizontal', cb_lab=None):
Expand All @@ -428,7 +428,7 @@ def sweep_track_relative(
----------
Var : float array
Data values to plot.
range : float array
ranges : float array
Range along ray.
tilt : float array
Radar ray Tilt angle with respect to platform [degrees].
Expand Down Expand Up @@ -480,21 +480,21 @@ def sweep_track_relative(
This mapping corrects for roll, pitch, and drift of the aircraft.
This is considered a leveled, heading-relative coordinate system.
"""
range = np.array(range) # Make sure that the data is numpy array
ranges = np.array(ranges) # Make sure that the data is numpy array

values = np.array(Var) # Make sure that the data is numpy array
values = values.reshape(len(rot), len(range)) # Resize it to work
values = values.reshape(len(rot), len(ranges)) # Resize it to work

# mask the data where outside the limits
if mask_outside:
Var = np.ma.masked_outside(Var, vmin, vmax)

# Create 2D variables to plot contour against
r, Rot = np.meshgrid(range, np.radians(rot))
r2, Tilt = np.meshgrid(range, np.radians(tilt))
r3, Roll = np.meshgrid(range, np.radians(roll))
r4, Pitch = np.meshgrid(range, np.radians(pitch))
r5, Drift = np.meshgrid(range, np.radians(drift))
r, Rot = np.meshgrid(ranges, np.radians(rot))
r2, Tilt = np.meshgrid(ranges, np.radians(tilt))
r3, Roll = np.meshgrid(ranges, np.radians(roll))
r4, Pitch = np.meshgrid(ranges, np.radians(pitch))
r5, Drift = np.meshgrid(ranges, np.radians(drift))
del r2, r3, r4, r5

# Convert r, Rot to Cartesian (x,y)
Expand All @@ -509,7 +509,7 @@ def sweep_track_relative(

# Set axis limits if passed
if xlims is None:
xlims = (-1.05 * range.max(), 1.05 * range.max())
xlims = (-1.05 * ranges.max(), 1.05 * ranges.max())
else:
xlims = xlims
if ylims is None:
Expand All @@ -526,7 +526,7 @@ def sweep_track_relative(
return p


def sweep_earth_relative(Var, range, tilt, rot, roll, heading, pitch,
def sweep_earth_relative(Var, ranges, tilt, rot, roll, heading, pitch,
ax=None, title=None, vmin=-24., vmax=64.,
cmap=None, mask_outside=True, grid_on=True,
xlims=None, ylims=None, xlab=None, ylab=None,
Expand All @@ -542,7 +542,7 @@ def sweep_earth_relative(Var, range, tilt, rot, roll, heading, pitch,
----------
Var : float array
Data values to plot.
range : float array
ranges : float array
Range along ray.
tilt : float array
Radar ray Tilt angle with respect to platform [degrees].
Expand Down Expand Up @@ -595,21 +595,21 @@ def sweep_earth_relative(Var, range, tilt, rot, roll, heading, pitch,

This is considered a leveled, heading-relative coordinate system.
"""
range = np.array(range) # Make sure that the data is numpy array
ranges = np.array(ranges) # Make sure that the data is numpy array

values = np.array(Var) # Make sure that the data is numpy array
values = values.reshape(len(rot), len(range)) # Resize it to work
values = values.reshape(len(rot), len(ranges)) # Resize it to work

# mask the data where outside the limits
if mask_outside:
Var = np.ma.masked_outside(Var, vmin, vmax)

# Create 2D variables to plot contour against
r, Rot = np.meshgrid(range, np.radians(rot))
r2, Tilt = np.meshgrid(range, np.radians(tilt))
r3, Roll = np.meshgrid(range, np.radians(roll))
r4, Pitch = np.meshgrid(range, np.radians(pitch))
r5, Heading = np.meshgrid(range, np.radians(heading))
r, Rot = np.meshgrid(ranges, np.radians(rot))
r2, Tilt = np.meshgrid(ranges, np.radians(tilt))
r3, Roll = np.meshgrid(ranges, np.radians(roll))
r4, Pitch = np.meshgrid(ranges, np.radians(pitch))
r5, Heading = np.meshgrid(ranges, np.radians(heading))
del r2, r3, r4, r5

# Convert r, Rot to Cartesian (x,y)
Expand All @@ -624,7 +624,7 @@ def sweep_earth_relative(Var, range, tilt, rot, roll, heading, pitch,

# Set axis limits if passed
if xlims is None:
xlims = (-1.05 * range.max(), 1.05 * range.max())
xlims = (-1.05 * ranges.max(), 1.05 * ranges.max())
else:
xlims = xlims
if ylims is None:
Expand Down
19 changes: 9 additions & 10 deletions awot/graph/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

"""

from __future__ import print_function

import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -909,19 +909,19 @@ def create_polar_fig_ax(nrows=1, ncols=1, figsize=(5, 5)):
##################


def save_figure(name='awot_plot', type="png", dpi=300):
def save_figure(name='awot_plot', fig_type="png", dpi=300):
'''Save the current plot.

Parameters
------------
name : str
Figure name.
type : str
fig_type : str
Figure format, default to .png file type.
dpi : int
Resolution in dots per inch.
'''
plt.savefig(name+'.'+type, format=figType, dpi=dpi)
plt.savefig(f"{name}.{fig_type}", format=fig_type, dpi=dpi)

#################
# Get methods #
Expand Down Expand Up @@ -954,7 +954,7 @@ def get_masked_data(data, mask_procedure, mask_tuple):
vmax = mask_tuple[2]
data = np.ma.masked_outside(data, vmin, vmax)
else:
print("Check the mask_procedure operation string!")
print("--> Check the mask_procedure operation string!")
return data


Expand All @@ -974,7 +974,7 @@ def _get_start_datetime(time, start_time):
startInt[4], startInt[5], startInt[6])
except:
import warnings
warnings.warn(common.DATE_STRING_FORMAT)
warnings.warn(DATE_STRING_FORMAT)
return

# Check to see if date time specified is beyond start
Expand All @@ -1000,7 +1000,7 @@ def _get_end_datetime(time, end_time):
endInt[4], endInt[5], endInt[6])
except:
import warnings
warnings.warn(common.DATE_STRING_FORMAT)
warnings.warn(DATE_STRING_FORMAT)
return

# Check to see if date time specified is beyond start
Expand Down Expand Up @@ -1072,9 +1072,8 @@ def _check_basemap(instance, strong=True):
if instance.basemap is None:
if strong:
raise ValueError('Please supply basemap instance')
return None
else:
print("WARNING: A basemap instance may be required for some plots")
print("--> WARNING: A basemap instance may be required for some plots")
return False


Expand All @@ -1089,5 +1088,5 @@ def _check_field(instance, field):
The key name of the field to check
"""
if instance[field] is None:
print("This field has no value!!")
print(f"--> {field} field has no value!!")
return
4 changes: 2 additions & 2 deletions awot/graph/flight_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Improve time series variable plotting?
"""

from __future__ import print_function

import numpy as np
import os
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -507,7 +507,7 @@ def plot_radar_cross_section(
# Return masked or unmasked variable
var, data = self._get_radar_variable_dict_data(radar, field)
if mask_procedure is not None:
data = get_masked_data(data, mask_procedure, mask_tuple)
data = common.get_masked_data(data, mask_procedure, mask_tuple)

# Create contour level array
clevels = np.linspace(cminmax[0], cminmax[1], clevs)
Expand Down
Loading