Skip to content

Commit dc85aa5

Browse files
committed
Merge branch 'fixes-0.9.1' into staging
2 parents acdb27c + 62d496a commit dc85aa5

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

viresclient/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@
3636
from ._api.token import TokenManager
3737
from . import _data
3838

39-
__version__ = "0.9.1-dev-conjunctions"
39+
40+
__version__ = "0.9.1"

viresclient/_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ class ClientRequest(object):
247247
"""Base class handling the requests to and downloads from the server.
248248
"""
249249

250-
def __init__(self, url=None, username=None, password=None, token=None,
250+
def __init__(self, url=None, token=None,
251251
config=None, logging_level="NO_LOGGING", server_type=None):
252252

253253
# Check and prompt for token if not already set, then store in config
254254
# Try to only do this if running in a notebook
255255
if IN_JUPYTER:
256-
if not ((username and password) or token or config):
256+
if not (token or config):
257257
cc = ClientConfig()
258258
# Use production url if none chosen
259259
url = url or cc.default_url or "https://vires.services/ows"
@@ -275,7 +275,7 @@ def __init__(self, url=None, username=None, password=None, token=None,
275275
set_stream_handler(self._logger, logging_level)
276276

277277
self._wps_service = self._create_service_proxy_(
278-
config, url, username, password, token
278+
config, url, None, None, token
279279
)
280280
# Test if the token is working; re-enter if not
281281
if IN_JUPYTER:
@@ -292,7 +292,7 @@ def __init__(self, url=None, username=None, password=None, token=None,
292292
raise AuthenticationError(AUTH_ERROR_TEXT)
293293
set_token(url)
294294
self._wps_service = self._create_service_proxy_(
295-
config, url, username, password, token
295+
config, url, None, None, token
296296
)
297297

298298
def _create_service_proxy_(self, config, url, username, password, token):

viresclient/_client_swarm.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,6 @@ class SwarmRequest(ClientRequest):
402402
403403
Args:
404404
url (str):
405-
username (str):
406-
password (str):
407405
token (str):
408406
config (str or ClientConfig):
409407
logging_level (str):
@@ -733,7 +731,7 @@ class SwarmRequest(ClientRequest):
733731
"B_FGM1", "B_FGM2", "B_FGM3", "q_NEC_CRF", "q_error",
734732
],
735733
"MAG_GRACE": [
736-
"F", "B_NEC", "B_NEC_raw", "B_FGM", "B_mod_NEC",
734+
"F", "B_NEC", "B_NEC_raw", "B_FGM",
737735
"q_NEC_CRF", "q_error",
738736
],
739737
"MAG_GFO": [
@@ -775,10 +773,10 @@ class SwarmRequest(ClientRequest):
775773
"MCO_SHA_2X", "CHAOS", "CHAOS-MMA", "MMA_SHA_2C", "MMA_SHA_2F", "MIO_SHA_2C", "MIO_SHA_2D", "SwarmCI",
776774
]
777775

778-
def __init__(self, url=None, username=None, password=None, token=None,
776+
def __init__(self, url=None, token=None,
779777
config=None, logging_level="NO_LOGGING"):
780778
super().__init__(
781-
url, username, password, token, config, logging_level,
779+
url, token, config, logging_level,
782780
server_type="Swarm"
783781
)
784782

viresclient/_data_handling.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -296,40 +296,45 @@ def reshape_dataset(ds):
296296
# Create integer "Site" identifier based on SiteCode / IAGA_code
297297
sites = dict(enumerate(sorted(set(ds[codevar].values))))
298298
sites_inv = {v: k for k, v in sites.items()}
299-
# Identify (V)OBS locations and mapping from integer "Site" identifier
300-
pos_vars = ["Longitude", "Latitude", "Radius", codevar]
301-
_ds_locs = next(iter(ds[pos_vars].groupby("Timestamp")))[1]
302-
if len(sites) > 1:
303-
_ds_locs = _ds_locs.drop(("Timestamp")).rename({"Timestamp": "Site"})
299+
if len(sites) == 0:
300+
_ds_locs = ds
304301
else:
305-
_ds_locs = _ds_locs.drop(("Timestamp")).expand_dims("Site")
306-
_ds_locs["Site"] = [sites_inv.get(code) for code in _ds_locs[codevar].values]
307-
_ds_locs = _ds_locs.sortby("Site")
302+
# Identify (V)OBS locations and mapping from integer "Site" identifier
303+
pos_vars = ["Longitude", "Latitude", "Radius", codevar]
304+
_ds_locs = next(iter(ds[pos_vars].groupby("Timestamp")))[1]
305+
if len(sites) > 1:
306+
_ds_locs = _ds_locs.drop(("Timestamp")).rename({"Timestamp": "Site"})
307+
else:
308+
_ds_locs = _ds_locs.drop(("Timestamp")).expand_dims("Site")
309+
_ds_locs["Site"] = [sites_inv.get(code) for code in _ds_locs[codevar].values]
310+
_ds_locs = _ds_locs.sortby("Site")
308311
# Create dataset initialised with the (V)OBS positional info as coords
309312
# and datavars (empty) reshaped to (Site, Timestamp, ...)
310313
t = numpy.unique(ds["Timestamp"])
311314
ds2 = xarray.Dataset(
312315
coords={
313316
"Timestamp": t,
314-
codevar: (("Site"), _ds_locs[codevar]),
315-
"Latitude": ("Site", _ds_locs["Latitude"]),
316-
"Longitude": ("Site", _ds_locs["Longitude"]),
317-
"Radius": ("Site", _ds_locs["Radius"]),
317+
codevar: (("Site"), _ds_locs[codevar].data),
318+
"Latitude": ("Site", _ds_locs["Latitude"].data),
319+
"Longitude": ("Site", _ds_locs["Longitude"].data),
320+
"Radius": ("Site", _ds_locs["Radius"].data),
318321
"NEC": ["N", "E", "C"]
319322
},
320323
)
321324
# (Dropping unused Spacecraft var)
322325
data_vars = set(ds.data_vars) - {"Latitude", "Longitude", "Radius", codevar, "Spacecraft"}
323326
N_sites = len(_ds_locs[codevar])
327+
# Create empty data variables to be infilled
324328
for var in data_vars:
325329
shape = [N_sites, len(t), *ds[var].shape[1:]]
326330
ds2[var] = ("Site", *ds[var].dims), numpy.empty(shape, dtype=ds[var].dtype)
327331
ds2[var][...] = None
328-
# Loop through each (V)OBS site to insert the datavars into ds2
329-
for k, _ds in dict(ds.groupby(codevar)).items():
330-
site = sites_inv.get(k)
331-
for var in data_vars:
332-
ds2[var][site, ...] = _ds[var].values
332+
# Loop through each (V)OBS site to infill the data
333+
if N_sites != 0:
334+
for k, _ds in dict(ds.groupby(codevar)).items():
335+
site = sites_inv.get(k)
336+
for var in data_vars:
337+
ds2[var][site, ...] = _ds[var].values
333338
# Revert to using only the "SiteCode"/"IAGA_code" identifier
334339
ds2 = ds2.set_index({"Site": codevar})
335340
ds2 = ds2.rename({"Site": codevar})

0 commit comments

Comments
 (0)