File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,12 @@ def asdataarray(
116
116
dataarray = dataoptions .factory (model .data [0 ](reference ))
117
117
118
118
for coord in model .coord :
119
- dataarray .coords .update ({coord .name : coord (dataarray )})
119
+ if coord .name in dataarray .dims :
120
+ dataarray .coords .update ({coord .name : coord (dataarray )})
121
+
122
+ for coord in model .coord :
123
+ if coord .name not in dataarray .dims :
124
+ dataarray .coords .update ({coord .name : coord (dataarray )})
120
125
121
126
for attr in model .attr :
122
127
dataarray .attrs .update ({attr .name : attr ()})
Original file line number Diff line number Diff line change @@ -119,7 +119,12 @@ def asdataset(
119
119
dataset .update ({data .name : data (reference )})
120
120
121
121
for coord in model .coord :
122
- dataset .coords .update ({coord .name : coord (dataset )})
122
+ if coord .name in dataset .dims :
123
+ dataset .coords .update ({coord .name : coord (dataset )})
124
+
125
+ for coord in model .coord :
126
+ if coord .name not in dataset .dims :
127
+ dataset .coords .update ({coord .name : coord (dataset )})
123
128
124
129
for attr in model .attr :
125
130
dataset .attrs .update ({attr .name : attr ()})
You can’t perform that action at this time.
0 commit comments