Hi
I am writing a loop to upload every zdef in each step for using dset. But I recieved some error :
my code is:
for yy in range(1980,1981):
fileCtl=("IVT_",str(yy),".ctl")
file_name="".join(fileCtl)
path=os.path.join(path1+os.sep,file_name)
print(path)
dset1 = CtlDescriptor(file=os.path.join(path1+os.sep,file_name))
dset1 = open_CtlDataset(os.path.join(path1+os.sep,file_name))
#print(dset)
if(yy%4==0):
for tt in range(0,852):
dset1=dset1['IVT'][tt]
da1=dset1.to_numpy()
print(da1)
print("tt",tt)
Hi I am writing a loop to upload every zdef in each step for using dset. But I recieved some error : my code is:
for yy in range(1980,1981): fileCtl=("IVT_",str(yy),".ctl") file_name="".join(fileCtl)
path=os.path.join(path1+os.sep,file_name)
=============================================================================
I want to have da1 in every step, but I just have tt=1 and then there is an error:Traceback (most recent call last):
File ~\anaconda3\lib\site-packages\xarray\core\dataarray.py:731 in _getitem_coord var = self._coords[key]
KeyError: 'IVT'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File E:\dissertation\Code\code2\untitled8.py:37 in
dset1=dset1['IVT'][tt]
File ~\anaconda3\lib\site-packages\xarray\core\dataarray.py:742 in getitem return self._getitem_coord(key)
File ~\anaconda3\lib\site-packages\xarray\core\dataarray.py:734 in _getitemcoord , key, var = _get_virtual_variable(
File ~\anaconda3\lib\site-packages\xarray\core\dataset.py:170 in _get_virtual_variable ref_var = variables[ref_name]
KeyError: 'IVT'