Skip to content

Commit

Permalink
some convertion to cartopy and site details
Browse files Browse the repository at this point in the history
  • Loading branch information
hagne committed Oct 1, 2024
1 parent c182510 commit 2843086
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 453 deletions.
81 changes: 69 additions & 12 deletions atmPy/data_archives/NOAA_ESRL_GMD_GRAD/aero/aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
'abbreviation': 'BRW',
'alt': 11.0,
'operation_period': '1976-present'},
{'name': 'Cape Grim',
'state': 'Australia',
'lat': -40.68,
'lon': 144.69,
'abbreviation': 'CGO',
'alt': 94.0,
'operation_period': '2015-present'},
# {'name': 'Cape Grim',
# 'state': 'Australia',
# 'lat': -40.68,
# 'lon': 144.69,
# 'abbreviation': 'CGO',
# 'alt': 94.0,
# 'operation_period': '2015-present'},
{'name': 'Cape San Juan',
'state': 'Puerto Rico',
'lat': 18.48,
Expand All @@ -72,7 +72,7 @@
'lon': 18.49,
'abbreviation': 'CPT',
'alt': 230.0,
'operation_period': '2004-present'},
'operation_period': '2004-2005'},
{'name': 'Egbert',
'state': 'Canada',
'lat': 44.23,
Expand Down Expand Up @@ -107,7 +107,7 @@
'lon': 126.17,
'abbreviation': 'GSN',
'alt': 72.0,
'operation_period': '2001, 2009-present'},
'operation_period': '2009-present'},
{'name': 'AMF Shouxian',
'state': 'China',
'lat': 32.56,
Expand Down Expand Up @@ -156,14 +156,14 @@
'lon': 0.73,
'abbreviation': 'MSA',
'alt': 3397.0,
'operation_period': '2017-present'},
'operation_period': '2000-2021'},
{'name': 'Montseny',
'state': 'Spain',
'lat': 41.78,
'lon': 2.36,
'abbreviation': 'MSY',
'alt': 3397.0,
'operation_period': '2017-present'},
'operation_period': '2009-2021'},
{'name': 'AMF Niamey',
'state': 'Niger',
'lat': 13.48,
Expand Down Expand Up @@ -303,7 +303,64 @@
'lon': 10.98,
'abbreviation': 'ZSF',
'alt': 2671.0,
'operation_period': '2018-present'}]
'operation_period': '2018-present'},
{'name': 'Helmos Mountain',
'state': 'Greece',
'lat': 37.984265,
'lon': 22.196262,
'abbreviation': 'HAC',
'alt': 2314.0,
'operation_period': '2018-present'},
{'name': 'Table Mountain',
'state': 'Colorado',
'lat': 40.1250,
'lon': -105.2369995117,
'abbreviation': 'BOS',
'alt': 1689,
'operation_period': '2019-present'},
{'name': 'Ragged Point',
'state': '',
'lat': 13.1650,
'lon': -59.432,
'abbreviation': 'RPB',
'alt': 15,
'operation_period': '2023-present'},
{'name': 'University of Granada',
'state': 'Spain',
'lat': 37.1640,
'lon': -3.605,
'abbreviation': 'UGR',
'alt': 680.00,
'operation_period': '2013-present'},
{'name': 'Varrio',
'state': 'Finland',
'lat': 67.7550,
'lon': 29.6090,
'abbreviation': 'VAR',
'alt': 400.00,
'operation_period': '2018-present'},
{'name': 'Wright Patterson Air Force Base',
'state': 'Ohio',
'lat': 39.82306,
'lon': -84.04944,
'abbreviation': 'WPB',
'alt': 250.8,
'operation_period': '2022-present'},
{'name': 'Pond Inlet',
'state': 'Canada',
'lat': 72.699,
'lon': -77.959,
'abbreviation': 'PON',
'alt': 55,
'operation_period': '2018-2020'},
# {'name': '',
# 'state': '',
# 'lat': ,
# 'lon': ,
# 'abbreviation': '',
# 'alt': ,
# 'operation_period': ''},
]

network = _measurement_site.Network(_stations)
network.name = 'aero'
154 changes: 88 additions & 66 deletions atmPy/general/measurement_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ def add_subnetwork(self, network_instance):
setattr(self.subnetworks, network_instance.name, network_instance)
self.subnetworks._network_list.append(network_instance)

def plot(self, zoom = 1.1, network_label_format = '{abbr}', network_label_kwargs = False, **kwargs):
def plot(self, #ax = None,
zoom = 1.1,
network_label_format = '{abbr}',
network_label_kwargs = False,
**kwargs):
"""Plots all station in network on map
Parameters
Expand All @@ -213,72 +217,90 @@ def plot(self, zoom = 1.1, network_label_format = '{abbr}', network_label_kwargs
kwargs: dictionary with arguments that are passed to station.plot
"""
stl = self.stations._stations_list
# a, bmap = stl[0].plot(plot_only_if_on_map = True, **kwargs)
# kwargs['bmap'] = bmap

if 'center' not in kwargs.keys():
kwargs['center'] = 'auto'
if kwargs['center'] == 'auto':
# st = self.stations._stations_list[0]
# lat_max, lat_min = max([st.lat for st in self.stations._stations_list]), min(
# [st.lat for st in self.stations._stations_list])
# lon_max, lon_min = max([st.lon for st in self.stations._stations_list]), min(
# [st.lon for st in self.stations._stations_list])
# kwargs['center'] = ((lat_max+lat_min)/2, (lon_max+lon_min)/2)
kwargs['center'] = self.extend['center']

if 'width' not in kwargs.keys():
kwargs['width'] = 'auto'
if kwargs['width'] == 'auto':
kwargs['width'] = self.extend['width_m'] * zoom

if 'height' not in kwargs.keys():
kwargs['height'] = 'auto'
if kwargs['height'] == 'auto':
kwargs['height'] = self.extend['height_m'] * zoom

if 'station_symbol_kwargs' not in kwargs.keys():
kwargs['station_symbol_kwargs'] = {}

for e, station in enumerate(stl):
if 'color' not in kwargs['station_symbol_kwargs']:
kwargs['station_symbol_kwargs']['color'] = default_colors[1]
a, bmap = station.plot(plot_only_if_on_map = True, **kwargs)
kwargs['bmap'] = bmap

if network_label_kwargs != False:
annodefaults = dict(xytext=(0, 0),
size=12,
ha="center",
va='center',
textcoords='offset points',
bbox=dict(boxstyle="round", fc=[1, 1, 1, 0.5], ec='black'),
)
if isinstance(network_label_kwargs, type(None)):
network_label_kwargs = {}

for ak in annodefaults:
if ak not in network_label_kwargs:
network_label_kwargs[ak] = annodefaults[ak]

label = network_label_format.format(abbr=self.abbr, name=self.name)
center_lat = sum([station.lat for station in stl]) / len(stl)
center_lon = sum([station.lon for station in stl]) / len(stl)
xpt, ypt = bmap(center_lon, center_lat)
a.annotate(label, xy=(xpt, ypt), **network_label_kwargs
# xycoords='data',
# xytext=(10 ,-10),
# size = station_annotation_kwargs['size'],
# ha="left",
# va = 'top',
# textcoords='offset points',
# bbox=dict(boxstyle="round", fc=[1 ,1 ,1 ,0.5], ec='black'),
)


stl = self.stations.list
rescale = True
if 'ax' in kwargs:
rescale = False

for site in stl:
f,a = site.plot(#ax = a,
**kwargs)
kwargs['ax'] = a

if rescale:
latmin = _np.min([s.lat for s in stl])
latmax = _np.max([s.lat for s in stl])
lonmin = _np.min([s.lon for s in stl])
lonmax = _np.max([s.lon for s in stl])
a.set_extent([lonmin-zoom, lonmax+zoom, latmin-zoom, latmax+zoom])

if 0:

# a, bmap = stl[0].plot(plot_only_if_on_map = True, **kwargs)
# kwargs['bmap'] = bmap

if 'center' not in kwargs.keys():
kwargs['center'] = 'auto'
if kwargs['center'] == 'auto':
# st = self.stations._stations_list[0]
# lat_max, lat_min = max([st.lat for st in self.stations._stations_list]), min(
# [st.lat for st in self.stations._stations_list])
# lon_max, lon_min = max([st.lon for st in self.stations._stations_list]), min(
# [st.lon for st in self.stations._stations_list])
# kwargs['center'] = ((lat_max+lat_min)/2, (lon_max+lon_min)/2)
kwargs['center'] = self.extend['center']

if 'width' not in kwargs.keys():
kwargs['width'] = 'auto'
if kwargs['width'] == 'auto':
kwargs['width'] = self.extend['width_m'] * zoom

if 'height' not in kwargs.keys():
kwargs['height'] = 'auto'
if kwargs['height'] == 'auto':
kwargs['height'] = self.extend['height_m'] * zoom

if 'station_symbol_kwargs' not in kwargs.keys():
kwargs['station_symbol_kwargs'] = {}

for e, station in enumerate(stl):
if 'color' not in kwargs['station_symbol_kwargs']:
kwargs['station_symbol_kwargs']['color'] = default_colors[1]
a, bmap = station.plot(plot_only_if_on_map = True, **kwargs)
kwargs['bmap'] = bmap

if network_label_kwargs != False:
annodefaults = dict(xytext=(0, 0),
size=12,
ha="center",
va='center',
textcoords='offset points',
bbox=dict(boxstyle="round", fc=[1, 1, 1, 0.5], ec='black'),
)
if isinstance(network_label_kwargs, type(None)):
network_label_kwargs = {}

for ak in annodefaults:
if ak not in network_label_kwargs:
network_label_kwargs[ak] = annodefaults[ak]

label = network_label_format.format(abbr=self.abbr, name=self.name)
center_lat = sum([station.lat for station in stl]) / len(stl)
center_lon = sum([station.lon for station in stl]) / len(stl)
xpt, ypt = bmap(center_lon, center_lat)
a.annotate(label, xy=(xpt, ypt), **network_label_kwargs
# xycoords='data',
# xytext=(10 ,-10),
# size = station_annotation_kwargs['size'],
# ha="left",
# va = 'top',
# textcoords='offset points',
# bbox=dict(boxstyle="round", fc=[1 ,1 ,1 ,0.5], ec='black'),
)



return a,bmap
return f,a

def _operation_period2sub_network_active(self):
has_operation_period = _np.array([hasattr(sta, 'operation_period') for sta in self.stations._stations_list])
Expand Down
Loading

0 comments on commit 2843086

Please sign in to comment.