Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YvZheng committed Jan 9, 2020
1 parent ef0dc2f commit 151d6a0
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 174 deletions.
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: pycwr
version: 0.2.10
version: 0.2.13

build:
skip: True # [py<35]
Expand Down
373 changes: 212 additions & 161 deletions notebooks/pycwr_example.ipynb

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions pycwr/draw/SingleRadarPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pandas as pd
from ..configure.default_config import CINRAD_COLORMAP, CINRAD_field_bins, \
CINRAD_field_normvar, CINRAD_field_mapping, DEFAULT_METADATA
from ..core.transforms import antenna_vectors_to_cartesian
from ..core.transforms import antenna_vectors_to_cartesian_cwr

class RadarGraph(object):
"""雷达绘图显示部分"""
Expand Down Expand Up @@ -50,7 +50,7 @@ def plot(self, sweep, field_name, normvar=None, title=None, clabel=None, dark=Fa
if clabel is None:
clabel = CINRAD_field_mapping[field_name] + " (%s)"%DEFAULT_METADATA[CINRAD_field_mapping[field_name]]['units']
field = self.NRadar.fields[sweep][field_name]
RadarGraph.simple_plot_ppi(field, normvar=(vmin, vmax),
RadarGraph.simple_plot_ppi(radar_data=field, normvar=(vmin, vmax),
title=title, cmap=cmap, cmap_bins=cmap_bins,
clabel=clabel, dark=dark, continuously=continuously)
@staticmethod
Expand Down Expand Up @@ -119,7 +119,7 @@ def simple_plot_ppi_xy(x, y, radar_data, normvar=None, cmap=None,
cmap_bins, orient, label, clabel, continuously)

@staticmethod
def simple_plot_ppi(_range=None, azimuth=None, elevation=None, radar_data=None, normvar=None, cmap=None,
def simple_plot_ppi(radar_data, _range=None, azimuth=None, elevation=None, normvar=None, cmap=None,
max_range=None, title=None, cmap_bins=16, orient="vertical",
label=None, clabel=None, dark=False, continuously=False):
"""
Expand All @@ -139,11 +139,17 @@ def simple_plot_ppi(_range=None, azimuth=None, elevation=None, radar_data=None,
:param dark: 是否使用黑色背景
:return:
"""
if hasattr(elevation, "values"):
elevation = elevation.values
if hasattr(azimuth, "values"):
azimuth = azimuth.values
if hasattr(_range, "values"):
_range = _range.values
assert radar_data is not None, "radar_data should not be None!"
if hasattr(radar_data, "x") and hasattr(radar_data, "y"):
x, y = radar_data.x, radar_data.y
else:
x, y, z = antenna_vectors_to_cartesian(_range, azimuth, elevation, edges=True)
x, y, z = antenna_vectors_to_cartesian_cwr(_range, azimuth, elevation, h=0)
if dark:
plt.style.use('dark_background')
fig = plt.figure()
Expand Down
14 changes: 10 additions & 4 deletions pycwr/draw/SingleRadarPlotMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import cartopy.crs as ccrs
import numpy as np
import pandas as pd
from ..core.transforms import cartesian_to_geographic_aeqd, antenna_vectors_to_cartesian
from ..core.transforms import cartesian_to_geographic_aeqd, antenna_vectors_to_cartesian_cwr
from ..configure.default_config import CINRAD_COLORMAP, CINRAD_field_bins, \
CINRAD_field_normvar, CINRAD_field_mapping, DEFAULT_METADATA

Expand Down Expand Up @@ -59,7 +59,7 @@ def plot(self, sweep, field_name, normvar=None, title=None, clabel=None, continu
" (%s)"%DEFAULT_METADATA[CINRAD_field_mapping[field_name]]['units']
field = self.NRadar.fields[sweep][field_name]

RadarGraphMap.simple_plot_ppi_map(field, title, (vmin, vmax), cmap, cmap_bins,\
RadarGraphMap.simple_plot_ppi_map(radar_data=field, title=title, normvar=(vmin, vmax), cmap=cmap, cmap_bins=cmap_bins,\
clabel=clabel, continuously=continuously)

@staticmethod
Expand Down Expand Up @@ -104,7 +104,7 @@ def GUI_plot(NRadar, fig, ax, cax, sweep, field_name,\
clabel=clabel, continuously=continuously)

@staticmethod
def simple_plot_ppi_map(_range=None, azimuth=None, elevation=None, radar_data=None, main_piont=None,\
def simple_plot_ppi_map(radar_data, _range=None, azimuth=None, elevation=None, main_piont=None,\
title=None, normvar=None, cmap=None, cmap_bins=16, extend=None, \
projection=ccrs.PlateCarree(), orient="vertical", \
clabel=None, continuously=False):
Expand All @@ -126,13 +126,19 @@ def simple_plot_ppi_map(_range=None, azimuth=None, elevation=None, radar_data=No
:param continuously: 是否使用连续的cmaps
:return:
"""
if hasattr(elevation, "values"):
elevation = elevation.values
if hasattr(azimuth, "values"):
azimuth = azimuth.values
if hasattr(_range, "values"):
_range = _range.values
assert radar_data is not None, "radar_data should not be None!"
if hasattr(radar_data, 'lat') and hasattr(radar_data, 'lon'):
lon, lat = radar_data.lon, radar_data.lat
else:
assert main_piont is not None, "should input (station_lon, station_lat) as main_point!"
main_lon, main_lat = main_piont
x, y, z = antenna_vectors_to_cartesian(_range, azimuth, elevation, edges=True)
x, y, z = antenna_vectors_to_cartesian_cwr(_range, azimuth, elevation, h=0)
lon, lat = cartesian_to_geographic_aeqd(x, y, main_lon, main_lat)
fig = plt.figure()
ax = fig.add_axes([0.04, 0.1, 0.82, 0.82], projection=projection)
Expand Down
2 changes: 1 addition & 1 deletion pycwr/io/SABFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def _get_instrument_parameters(self):

# pulse width
pulse_width = get_metadata('pulse_width')
pulse_width['data'] = self.radial[0]["GateSizeOfDoppler"] / _LIGHT_SPEED # m->sec
pulse_width['data'] = np.array([self.radial[0]["GateSizeOfDoppler"] / _LIGHT_SPEED,], dtype='float32') # m->sec

# assume that the parameters in the first ray represent the beam widths,
# bandwidth and frequency in the entire volume
Expand Down
2 changes: 1 addition & 1 deletion pycwr/io/SCFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def _get_instrument_parameters(self):

# pulse width
pulse_width = get_metadata('pulse_width')
pulse_width['data'] = self.range[0] / _LIGHT_SPEED # nanosec->sec
pulse_width['data'] = np.array([self.range[0] / _LIGHT_SPEED,], dtype='float32') # nanosec->sec
# assume that the parameters in the first ray represent the beam widths,
# bandwidth and frequency in the entire volume
wavelength_hz = self.frequency * 10 ** 9
Expand Down
2 changes: 1 addition & 1 deletion pycwr/io/WSR98DFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def _get_instrument_parameters(self):

# pulse width
pulse_width = get_metadata('pulse_width')
pulse_width['data'] = self.header["TaskConfig"]['PulseWidth']/10**9 # nanosec->sec
pulse_width['data'] = np.array([self.header["TaskConfig"]['PulseWidth']/10**9,], dtype='float32') # nanosec->sec
# assume that the parameters in the first ray represent the beam widths,
# bandwidth and frequency in the entire volume
wavelength_hz = self.frequency * 10 ** 9
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'Operating System :: Microsoft :: Windows']
setup(
name=DISTNAME,
version="0.2.10",
version="0.2.13",
author=AUTHOR,
license=LICENSE,
author_email=AUTHOR_EMAIL,
Expand Down
Empty file added test/test_xband.py
Empty file.

0 comments on commit 151d6a0

Please sign in to comment.