@@ -488,6 +488,10 @@ def xr(self, bold=False):
488
488
:param bold: if True, will load and return only BOLD output
489
489
:type bold: bool
490
490
"""
491
+
492
+ def _sanitize_nc_key (k ):
493
+ return k .replace ("*" , "_" ).replace ("." , "_" ).replace ("|" , "_" )
494
+
491
495
assert self .results is not None , "Run `loadResults()` first to populate the results"
492
496
assert len (self .results ) == len (self .dfResults )
493
497
# create intrisinsic dims for one run
@@ -510,6 +514,8 @@ def xr(self, bold=False):
510
514
expand_coords = {}
511
515
# iterate exploration coordinates
512
516
for k , v in expl_coords .items ():
517
+ # sanitize keys in the case of stars etc
518
+ k = _sanitize_nc_key (k )
513
519
# if single values, just assing
514
520
if isinstance (v , (str , float , int )):
515
521
expand_coords [k ] = [v ]
@@ -525,10 +531,14 @@ def xr(self, bold=False):
525
531
dataarrays .append (data_temp .expand_dims (expand_coords ))
526
532
527
533
# finally, combine all arrays into one
528
- combined = xr .combine_by_coords (dataarrays )["exploration" ]
534
+ # sometimes combining xr.DataArrays does not work, see https://github.com/pydata/xarray/issues/3248#issuecomment-531511177
535
+ # resolved by casting them explicitely to xr.Dataset
536
+ combined = xr .combine_by_coords ([da .to_dataset () for da in dataarrays ])["exploration" ]
529
537
if self .parameterSpace .star :
530
- combined .attrs = {k : list (self .model .params [k ].keys ()) for k in orig_search_coords .keys ()}
531
-
538
+ # if we explored over star params, unwrap them into attributes
539
+ combined .attrs = {
540
+ _sanitize_nc_key (k ): list (self .model .params [k ].keys ()) for k in orig_search_coords .keys () if "*" in k
541
+ }
532
542
return combined
533
543
534
544
def getRun (self , runId , filename = None , trajectoryName = None , pypetShortNames = True ):
0 commit comments