Skip to content

Commit 42953f7

Browse files
committed
Merge branch 'dev'
2 parents 00c6a5a + 0b21aed commit 42953f7

File tree

9 files changed

+363
-502
lines changed

9 files changed

+363
-502
lines changed

src/pyrad_proc/pyrad/flow/flow_aux.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
_MPROFILE_AVAILABLE = False
5757

5858
from pyrad import proc
59-
from ..io.config import read_config, DEFAULT_CONFIG
59+
from ..io.config import read_config
60+
from ..io.default_config import DEFAULT_CONFIG
6061
from ..io.read_data_radar import get_data
6162
from ..io.write_data import write_to_s3
6263
from ..io.io_aux import get_datetime, get_file_list, get_scan_list
@@ -1079,7 +1080,6 @@ def _create_cfg_dict(cfgfile):
10791080
try:
10801081
print("- Main config file : {}".format(cfgfile))
10811082
cfg = read_config(cfg["configFile"], cfg=cfg, defaults=DEFAULT_CONFIG["main"])
1082-
10831083
# Convert loc and prod config files to absolute paths if needed
10841084
filenames = [
10851085
"locationConfigFile",
@@ -1088,7 +1088,6 @@ def _create_cfg_dict(cfgfile):
10881088
for fname in filenames:
10891089
if not os.path.isabs(cfg[fname]):
10901090
cfg[fname] = os.path.join(cfg["configpath"], cfg[fname])
1091-
10921091
print("- Location config file : {}".format(cfg["locationConfigFile"]))
10931092
cfg = read_config(
10941093
cfg["locationConfigFile"], cfg=cfg, defaults=DEFAULT_CONFIG["loc"]

src/pyrad_proc/pyrad/graph/plots_aux.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,38 @@
3434
mpl.rcParams.update({"font.size": 16})
3535
mpl.rcParams.update({"font.family": "sans-serif"})
3636

37+
_CARTOPY_AVAILABLE = False
38+
try:
39+
from cartopy.io.img_tiles import GoogleTiles
40+
41+
# Define ESRI terrain tiles
42+
class ShadedReliefESRI(GoogleTiles):
43+
def __init__(self, cache):
44+
super().__init__(self, cache=cache)
45+
self.desired_tile_form = "RGB"
46+
47+
# shaded relief
48+
def _image_url(self, tile):
49+
x, y, z = tile
50+
return (
51+
f"https://server.arcgisonline.com/ArcGIS/rest/services/Elevation/"
52+
f"World_Hillshade/MapServer/tile/{z}/{y}/{x}"
53+
)
54+
55+
class OTM(GoogleTiles):
56+
def __init__(self, cache):
57+
super().__init__(self, cache=cache)
58+
self.desired_tile_form = "RGB"
59+
60+
# OpenTopoMap
61+
def _image_url(self, tile):
62+
x, y, z = tile
63+
return f"https://a.tile.opentopomap.org/{z}/{x}/{y}.png"
64+
65+
_CARTOPY_AVAILABLE = True
66+
except ImportError:
67+
pass
68+
3769

3870
def generate_complex_range_Doppler_title(radar, field, ray, datetime_format=None):
3971
"""

src/pyrad_proc/pyrad/graph/plots_grid.py

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,11 @@
2929
import pyart
3030

3131
from .plots_aux import get_norm
32+
from .plots_aux import _CARTOPY_AVAILABLE
3233

33-
try:
34+
if _CARTOPY_AVAILABLE:
3435
import cartopy
35-
from cartopy.io.img_tiles import GoogleTiles
36-
37-
# Define ESRI terrain tiles
38-
class ShadedReliefESRI(GoogleTiles):
39-
def __init__(self, cache):
40-
super().__init__(self, cache=cache)
41-
self.desired_tile_form = "RGB"
42-
43-
# shaded relief
44-
def _image_url(self, tile):
45-
x, y, z = tile
46-
return (
47-
f"https://server.arcgisonline.com/ArcGIS/rest/services/Elevation/"
48-
f"World_Hillshade/MapServer/tile/{z}/{y}/{x}"
49-
)
50-
51-
class OTM(GoogleTiles):
52-
def __init__(self, cache):
53-
super().__init__(self, cache=cache)
54-
self.desired_tile_form = "RGB"
55-
56-
# OpenTopoMap
57-
def _image_url(self, tile):
58-
x, y, z = tile
59-
return f"https://a.tile.opentopomap.org/{z}/{x}/{y}.png"
60-
61-
_CARTOPY_AVAILABLE = True
62-
except ImportError:
63-
_CARTOPY_AVAILABLE = False
64-
36+
from .plots_aux import ShadedReliefESRI, OTM
6537

6638
try:
6739
import pydda

src/pyrad_proc/pyrad/graph/plots_vol.py

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
plot_field_coverage
2828
2929
"""
30+
from copy import deepcopy
31+
import numpy as np
32+
import os
33+
from netCDF4 import num2date
34+
import pyart
35+
import matplotlib.pyplot as plt
3036

3137
from ..io.write_data import write_histogram
3238
from ..util.radar_utils import compute_histogram_sweep
@@ -36,47 +42,12 @@
3642
from .plots_aux import generate_complex_range_Doppler_title
3743
from .plots_aux import generate_fixed_rng_span_title
3844
from .plots_aux import get_colobar_label, get_norm, generate_fixed_rng_title
39-
import pyart
40-
import matplotlib.pyplot as plt
4145
from ..util import warn
42-
from copy import deepcopy
43-
44-
import numpy as np
45-
import os
46+
from .plots_aux import _CARTOPY_AVAILABLE
4647

47-
from netCDF4 import num2date
48-
49-
try:
48+
if _CARTOPY_AVAILABLE:
5049
import cartopy
51-
from cartopy.io.img_tiles import GoogleTiles
52-
53-
# Define ESRI terrain tiles
54-
class ShadedReliefESRI(GoogleTiles):
55-
def __init__(self):
56-
super().__init__(self, cache=True)
57-
self.desired_tile_form = "RGB"
58-
59-
# shaded relief
60-
def _image_url(self, tile):
61-
x, y, z = tile
62-
return (
63-
f"https://server.arcgisonline.com/ArcGIS/rest/services/Elevation/"
64-
f"World_Hillshade/MapServer/tile/{z}/{y}/{x}"
65-
)
66-
67-
class OTM(GoogleTiles):
68-
def __init__(self):
69-
super().__init__(self, cache=True)
70-
self.desired_tile_form = "RGB"
71-
72-
# OpenTopoMap
73-
def _image_url(self, tile):
74-
x, y, z = tile
75-
return f"https://a.tile.opentopomap.org/{z}/{x}/{y}.png"
76-
77-
_CARTOPY_AVAILABLE = True
78-
except ImportError:
79-
_CARTOPY_AVAILABLE = False
50+
from .plots_aux import ShadedReliefESRI, OTM
8051

8152
try:
8253
import shapely

src/pyrad_proc/pyrad/io/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
"""
214214

215215
from .config import read_config # noqa
216-
216+
from .default_config import DEFAULT_CONFIG # noqa
217217
from .read_data_radar import get_data, add_field, interpol_field # noqa
218218

219219
from .read_data_icon import read_icon_data, read_icon_coord # noqa

0 commit comments

Comments
 (0)