You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error occurs from projectField when data was opened using xr.open_mfdataset and solver was using weights. I have doubled check there was no error with the input data, which has no missing value at all.
importxarrayasxrfromeofs.xarrayimportEofdemo_file="ts_Amon_ACCESS1-0_historical_r1i1p1_185001-200512.nc"data_var="ts"## test 1: open dataset using 'open_dataset'#ds=xr.open_dataset(demo_file)
ds=ds.isel(time=slice(0,20))
da=ds[data_var]
wtarray=xr.ones_like(da)
# test 1a: working okaysolver=Eof(da)
pseudo_pcs=solver.projectField(da)
# test 1b: weights used for solver, working okaysolver=Eof(da, weights=wtarray)
pseudo_pcs=solver.projectField(da)
## test 2: open dataset using 'open_mfdataset'#ds=xr.open_mfdataset(demo_file)
ds=ds.isel(time=slice(0,20))
da=ds[data_var]
wtarray=xr.ones_like(da)
# test 2a: working okaysolver=Eof(da)
pseudo_pcs=solver.projectField(da)
# test 2b: errorsolver=Eof(da, weights=wtarray)
pseudo_pcs=solver.projectField(da)
Error message:
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
CellIn[10], line21solver=Eof(da, weights=wtarray)
---->2pseudo_pcs=solver.projectField(da)
File~/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/eofs/xarray.py:618, inEof.projectField(self, array, neofs, eofscaling, weighted)
616else:
617has_time=False-->618pcs=self._solver.projectField(array.values,
619neofs=neofs,
620eofscaling=eofscaling,
621weighted=weighted)
622# Create the PCs DataArray.623ifpcs.ndim==2:
File~/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/eofs/standard.py:752, inEof.projectField(self, field, neofs, eofscaling, weighted)
748eofNonMissingIndex=np.where(
749np.logical_not(np.isnan(self._flatE[0])))[0]
750ifeofNonMissingIndex.shape!=nonMissingIndex.shapeor \
751 (eofNonMissingIndex!=nonMissingIndex).any():
-->752raiseValueError('field and EOFs have different '753'missing value locations')
754eofs_flat=self._flatE[slicer, eofNonMissingIndex]
755ifeofscaling==1:
ValueError: fieldandEOFshavedifferentmissingvaluelocations
I suspect this might be somewhat related to #122. Does anyone have any idea?
The text was updated successfully, but these errors were encountered:
Thank you, @ajdawson, for providing and sharing this amazing package. It has been very helpful for my project, developing a tool to collectively evaluate climate models, named PCMDI Metrics Package. In my recent work to convert the code that used to be cdms based to use xarray, because the lifespan of the cdms is sunsetting, I have encountered the above issue. I wonder if you have any clue on this.
I just found the the fix suggested by @lfery resolves my issue, and it passes all 4 tests above. I will write open a pull request for that. -- Thank you, @lfery!
Error occurs from
projectField
when data was opened usingxr.open_mfdataset
andsolver
was usingweights
. I have doubled check there was no error with the input data, which has no missing value at all.Error message:
I suspect this might be somewhat related to #122. Does anyone have any idea?
The text was updated successfully, but these errors were encountered: