TUW-GEO / ascat

Read and visualize data from the Advanced Scatterometer (ASCAT) on-board the series of Metop satellites
https://ascat.readthedocs.io/
MIT License
25 stars 16 forks source link

TypeError: 'NoneType' object does not support item assignment #42

Closed xushanthu-2014 closed 3 years ago

xushanthu-2014 commented 4 years ago

To whom it may concern I am a student who is using ASCAT data and trying to read it by ASCAT package. Here is my code:

import os import numpy as np import ascat.tuw as tuw import ascat.h_saf as h_saf from netCDF4 import Dataset

ASCAT_test_path = '/Users/xushan/research/TUD/ASCAT/' testdata_folder = '/Users/xushan/research/TUD/ASCAT' os.chdir(ASCAT_test_path)

ascat_data_folder = os.path.join(testdata_folder,'pytesmo-test-data-master/sat/ascat/netcdf/55R22') static_layers_folder = os.path.join(testdata_folder,'spytesmo-test-data-master/at/h_saf/static_layer') ascat_grid_folder = os.path.join(testdata_folder,'pytesmo-test-data-master/sat/ascat/netcdf/grid/TUW_WARP5_grid_info_2_1.nc')

ascat_reader = h_saf.AscatNc(ascat_data_folder, '.nc', grid_filename = ascat_grid_folder)#+'/grid.nc')

lat_test, lon_test = -17.375, -178.875 ascat_reader.read_ts(lat_test, lon_test)

But I got one error which says that:

/Users/xushan/opt/anaconda3/lib/python3.7/site-packages/ascat/read_native/cdr.py:130: UserWarning: WARNING: valid_range not used since it cannot be safely cast to variable data type land_gp = np.where(grid_nc.variables['land_flag'][:] == 1)[0] /Users/xushan/opt/anaconda3/lib/python3.7/site-packages/pynetcf/time_series.py:1301: RuntimeWarning: I/O error /Users/xushan/research/TUD/ASCAT/pytesmo-test-data-master/sat/ascat/netcdf/55R22/,nc.nc warnings.warn(msg, RuntimeWarning) Traceback (most recent call last):

File "", line 50, in ascat_reader.read_ts(lat_test, lon_test)

File "/Users/xushan/opt/anaconda3/lib/python3.7/site-packages/pygeobase/io_base.py", line 691, in read_ts return self.read(*args, **kwargs)

File "/Users/xushan/opt/anaconda3/lib/python3.7/site-packages/pygeobase/io_base.py", line 469, in read data = self._read_lonlat(args[0], args[1], **kwargs)

File "/Users/xushan/opt/anaconda3/lib/python3.7/site-packages/pygeobase/io_base.py", line 434, in _read_lonlat return self._read_gp(gp, **kwargs)

File "/Users/xushan/opt/anaconda3/lib/python3.7/site-packages/ascat/read_native/cdr.py", line 359, in _read_gp data['snow_prob'] = np.nan

TypeError: 'NoneType' object does not support item assignment

So could you please help me with this issue? Thanks!

sebhahn commented 4 years ago

I saw you wrote that the error was related to a typo?

xushanthu-2014 commented 4 years ago

I saw you wrote that the error was related to a typo?

Then I found it was not related to that typo...actually the error is caused by running:

lat_test, lon_test = -17.375, -178.875 ascat_reader.read_ts(lat_test, lon_test)

There is no error until these two lines...

sebhahn commented 4 years ago

There seems to be a problem with the file name:

/Users/xushan/opt/anaconda3/lib/python3.7/site-packages/pynetcf/time_series.py:1301: RuntimeWarning: I/O error /Users/xushan/research/TUD/ASCAT/pytesmo-test-data-master/sat/ascat/netcdf/55R22/,nc.nc

',nc.nc'?

xushanthu-2014 commented 4 years ago

Thanks and I solved that! By the way, do you have any documents or examples for reading ASCAT data of .dat and .idx format? Or basically the structure of the .dat file?