Open tsarkany opened 5 years ago
Could you let me know which version of CIS and the other libraries you are using? Feel free to attach a print out of your environment.
Dear Duncan, I am not sure whether this is what you are looking for but I have attached the output of the printenv command on Linux. When I type in cis version it outputs Using CIS version: 1.7.1 (Stable)
If this is not the right information then let me know! Best wishes, Tasmin
From: Duncan Watson-Parris notifications@github.com Sent: 09 August 2019 17:49:56 To: cedadev/cis cis@noreply.github.com Cc: Tasmin Sarkany tasmin.sarkany@lincoln.ox.ac.uk; Author author@noreply.github.com Subject: Re: [cedadev/cis] Plugin not working for .hdf MODIS data (#22)
Could you let me know which version of CIS and the other libraries you are using? Feel free to attach a print out of your environment.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/cedadev/cis/issues/22?email_source=notifications&email_token=AM3S3X3NNSQK4W5A6QY37ODQDWN3JA5CNFSM4IKVVOEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD37GINA#issuecomment-519988276, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AM3S3X5FYNMZMRJNLJQRFRTQDWN3JANCNFSM4IKVVOEA.
OK, that's a nice recent version of CIS. To get the versions of the other Python packages could you send the output of running the command: conda list
. Thanks!
Created a new python 3 environment with cis to test this, getting the same error. The problem is in MODIS_L2.__field_interpolate on line 247 of cis/data_io/products/MODIS.py. I believe that all the slice indices now need to be specifically int type due to changes in numpy. The full error output is as follows:
Traceback (most recent call last): File "/home/users/wkjones/miniconda2/envs/cis_test/lib/python3.7/site-packages/cis/data_io/products/AProduct.py", line 197, in get_data data = product_cls().create_data_object(filenames, variable) File "/home/users/wkjones/miniconda2/envs/cis_test/lib/python3.7/site-packages/cis/data_io/products/MODIS.py", line 299, in create_data_object coords = self._create_coord_list(filenames, variable) File "/home/users/wkjones/miniconda2/envs/cis_test/lib/python3.7/site-packages/cis/data_io/products/MODIS.py", line 269, in _create_coord_list lat_data = self.field_interpolate(sd_lat) if apply_interpolation else sd_lat File "/home/users/wkjones/miniconda2/envs/cis_test/lib/python3.7/site-packages/cis/data_io/products/MODIS.py", line 247, in field_interpolate float(factor)) + output[int(factor / 2):(-1 * factor):factor, :] TypeError: slice indices must be integers or None or have an index method
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
Ah yeah, more specifically it's because this value in the slicing [(-1 * factor / 2 + 1)] isn't converted to int type
This is the output of conda list
#
_libgcc_mutex 0.1 main
antlr-python-runtime 4.7.2 py37_1000 conda-forge
asn1crypto 0.24.0 py37_0
attrs 19.1.0 py37_1
backcall 0.1.0 py37_0
basemap 1.2.0 py37h705c2d8_0 anaconda
blas 1.0 mkl
bleach 3.1.0 py37_0
bokeh 1.3.4 py37_0
bzip2 1.0.8 h7b6447c_0
ca-certificates 2019.5.15 0
cartopy 0.16.0 py37hfa13621_0 anaconda
certifi 2019.6.16 py37_1
cf-units 2.1.2 py37hc1659b7_0 conda-forge
cffi 1.12.3 py37h2e261b9_0
cftime 1.0.3.4 py37hdd07704_1001
chardet 3.0.4 py37_1003
cis 1.7.1 py37_0 conda-forge
click 7.0 py37_0
cloudpickle 1.2.1 py_0
conda 4.7.11 py37_0
conda-package-handling 1.3.11 py37_0
cryptography 2.7 py37h1ba5d50_0
curl 7.65.2 hbc83047_0
cycler 0.10.0 py37_0
cytoolz 0.10.0 py37h7b6447c_0
dask 2.2.0 py_0
dask-core 2.2.0 py_0
dbus 1.13.6 h746ee38_0
decorator 4.4.0 py37_1
defusedxml 0.6.0 py_0
distributed 2.2.0 py_1
entrypoints 0.3 py37_0
expat 2.2.6 he6710b0_0
fontconfig 2.13.0 h9420a91_0
freetype 2.9.1 h8a8886c_1
fsspec 0.4.0 py_0
geos 3.6.2 heeff764_2
glib 2.56.2 hd408876_0
gmp 6.1.2 h6c8ec71_1
gst-plugins-base 1.14.0 hbbd80ab_1
gstreamer 1.14.0 hb453b48_1
hdf4 4.2.13 h3ca952b_2
hdf5 1.10.4 hb1b8bf9_0
heapdict 1.0.0 py37_2
icu 58.2 h9c2bf20_1
idna 2.8 py37_0
intel-openmp 2019.4 243
ipykernel 5.1.1 py37h39e3cac_0
ipython 7.7.0 py37h39e3cac_0
ipython_genutils 0.2.0 py37_0
iris 2.2.1 py37_0 conda-forge
jedi 0.13.3 py37_0
jinja2 2.10.1 py37_0
jpeg 9b h024ee3a_2
json5 0.8.5 py_0
jsonschema 3.0.1 py37_0
jupyter_client 5.3.1 py_0
jupyter_core 4.5.0 py_0
jupyterlab 1.0.4 py37_0 conda-forge
jupyterlab_server 1.0.0 py_1
kiwisolver 1.1.0 py37he6710b0_0
krb5 1.16.1 h173b8e3_7
libarchive 3.3.3 h5d8350f_5
libcurl 7.65.2 h20c2e04_0
libedit 3.1.20181209 hc058e9b_0
libffi 3.2.1 hd88cf55_4
libgcc-ng 9.1.0 hdf63c60_0
libgfortran-ng 7.3.0 hdf63c60_0
libnetcdf 4.6.1 h11d0813_2
libpng 1.6.37 hbc83047_0
libsodium 1.0.16 h1bed415_0
libssh2 1.8.2 h1ba5d50_0
libstdcxx-ng 9.1.0 hdf63c60_0
libtiff 4.0.10 h2733197_2
libuuid 1.0.3 h1bed415_2
libxcb 1.13 h1bed415_1
libxml2 2.9.9 hea5a465_1
libxslt 1.1.33 h7d1a2b0_0
locket 0.2.0 py37_1
lxml 4.3.4 py37hefd8a0e_0
lz4-c 1.8.1.2 h14c3975_0
lzo 2.10 h49e0be7_2
markupsafe 1.1.1 py37h7b6447c_0
matplotlib 2.2.3 py37hb69df0a_0
mistune 0.8.4 py37h7b6447c_0
mkl 2019.4 243
mkl-service 2.0.2 py37h7b6447c_0
mkl_fft 1.0.12 py37ha843d7b_0
mkl_random 1.0.2 py37hd81dba3_0
msgpack-python 0.6.1 py37hfd86e86_1
nbconvert 5.5.0 py_0
nbformat 4.4.0 py37_0
ncurses 6.1 he6710b0_1
netcdf4 1.4.2 py37h808af73_0
notebook 6.0.0 py37_0
numpy 1.16.4 py37h7e9f1db_0
numpy-base 1.16.4 py37hde5b4d6_0
olefile 0.46 py37_0
openssl 1.1.1c h7b6447c_1
owslib 0.18.0 py_0
packaging 19.0 py37_0
pandas 0.25.0 py37he6710b0_0
pandoc 2.2.3.2 0
pandocfilters 1.4.2 py37_1
parso 0.5.0 py_0
partd 1.0.0 py_0
pcre 8.43 he6710b0_0
pexpect 4.7.0 py37_0
pickleshare 0.7.5 py37_0
pillow 6.1.0 py37h34e0f95_0
pip 19.1.1 py37_0
proj4 5.0.1 h14c3975_0
prometheus_client 0.7.1 py_0
prompt_toolkit 2.0.9 py37_0
psutil 5.6.3 py37h7b6447c_0
ptyprocess 0.6.0 py37_0
pycosat 0.6.3 py37h14c3975_0
pycparser 2.19 py37_0
pyepsg 0.4.0 py37_0
pygments 2.4.2 py_0
pyhdf 0.10.1 py37h3a4e923_1 conda-forge
pyke 1.1.1 py37_1000 conda-forge
pyopenssl 19.0.0 py37_0
pyparsing 2.4.0 py_0
pyproj 1.9.5.1 py37h7b21b82_1 anaconda
pyqt 5.9.2 py37h05f1152_2
pyrsistent 0.14.11 py37h7b6447c_0
pyshp 2.1.0 py_0
pysocks 1.7.0 py37_0
python 3.7.3 h0371630_0
python-dateutil 2.8.0 py37_0
python-libarchive-c 2.8 py37_13
pytz 2019.1 py_0
pyyaml 5.1.1 py37h7b6447c_0
pyzmq 18.0.0 py37he6710b0_0
qt 5.9.7 h5867ecd_1
readline 7.0 h7b6447c_5
requests 2.22.0 py37_0
ruamel_yaml 0.15.46 py37h14c3975_0
scipy 1.3.0 py37h7c811a0_0
send2trash 1.5.0 py37_0
setuptools 41.0.1 py37_0
shapely 1.6.4 py37h7ef4460_0
sip 4.19.8 py37hf484d3e_0
six 1.12.0 py37_0
sortedcontainers 2.1.0 py37_0
sqlite 3.29.0 h7b6447c_0
tblib 1.4.0 py_0
terminado 0.8.2 py37_0
testpath 0.4.2 py37_0
tk 8.6.8 hbc83047_0
toolz 0.10.0 py_0
tornado 6.0.3 py37h7b6447c_0
tqdm 4.32.1 py_0
traitlets 4.3.2 py37_0
udunits2 2.2.27.6 h4e0c4b3_1001 conda-forge
urllib3 1.24.2 py37_0
wcwidth 0.1.7 py37_0
webencodings 0.5.1 py37_1
wheel 0.33.4 py37_0
xz 5.2.4 h14c3975_4
yaml 0.1.7 had09818_2
zeromq 4.3.1 he6710b0_3
zict 1.0.0 py_0
zlib 1.2.11 h7b6447c_3
zstd 1.3.7 h0b5b093_0
It looks like the easiest fix is to replace float division / with integer division // in those lines. Any obvious reason why that wouldn't work?
That floors the number, doesn't it? If so, would that break compatibility with the previous functionality?
i.e: If (-1 * factor / 2 + 1) = 0.5
then was the 0th or 1st element of the array selected?
Doing (-1 * factor // 2 + 1)
will always select the lower element.
numpy would previously select index 0 for 0.5. The only problem is trying to find out if the value was floored or cast as int when indexing, as that changes the behaviour for negative values
Trying it in my own code doesn't work as you end up with a 2030x1350 coordinate and a 2030x1354 data field. It appears some rounding was being done somewhere.
To be honest, I'm keen to remove this code entirely since there are a few nasty cases which I'm not convinced it's properly dealing with, this issue of the 4 'missing' coordinates being one of them.
This is a first go at making this work with the python-geotiepoints package, which is probably the best way to tackle this: https://github.com/duncanwp/cis_plugins/blob/master/modis_fixed.py
The MOD06 and MOD04 products seem to have slightly different structures though so it still isn't working as generally as I'd like.
I am trying to read a HDF file using the cis.read_data() function in Python.
import cis
import iris
from cis import read_data
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
a=cis.read_data('MOD06_L2.A2008001.0000.061.2017287164540.hdf','Cloud_Effective_Radius_16')
When I run this an error comes up:
ProductPluginException: An error occurred retrieving data using the product MODIS_L2. Check that this is the correct product plugin for your chosen data. Exception was TypeError: slice indices must be integers or None or have an __index__ method.
The same thing happens when I put in 'MODIS_L2' explicity as the plugin in the cis.read_data() function.
Am I using the wrong plugin? If not, then I can't work out how to read the file.