-
Dear xarray community, I tried to set the fill_value argument in xarray.merge(), see the minimal example below. The first merge() call works as I would expect it, the second call throws a MergeError for me (xarray Version 0.18.2): "conflicting values for variable 'var1' on objects to be combined. ...". Is this intended behaviour? I expected fill_value to be a value which is inserted in case the merge creates missing values in the new DataArray/Dataset. Providing it, especially in a case where no voids are created, should not affect the result. Please correct me if I understand something wrong! import xarray as xr
da=xr.DataArray([1,2],dims=("x"), coords={"x":[1,2]})
da.name="var1"
db=xr.DataArray([3],dims=("x"), coords={"x":[3]})
db.name="var1"
test1=xr.merge([da, db])#Succeeds as expected
test2=xr.merge([da, db], fill_value=0.0)#Throws a MergeError Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Internally,
while interpreting
with this, the default You can get the second call to work by specifying a different |
Beta Was this translation helpful? Give feedback.
Internally,
merge
will first align both objects and then "join" variables with the same name together using the method specified bycompat
. For the first call, that will be:while interpreting
nan
as missing. However, with the fill value, this becomes:with this, the default
compat
method ("no_conflicts"
) will detect conflicting values for both arrays and thus raise.You can get the second call to work by specifying a different
compat
method, e.g."override"
, or by using a different function …