Using Iris to read MODIS data

47 views
Skip to first unread message

V V

unread,
Mar 17, 2021, 11:35:12 PM3/17/21
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
Hi all, 
I was wondering if anyone has experience in reading netcdf files downloaded from the MODIS archive in Iris?

I have added a sample nc file here:

The nc files are netcdf4 and for some reason it returns the cube as empty when trying to open in Iris (as below)

In [1]: import iris

In [2]: print(iris.__version__)
2.4.0


In [4]: print (cube)
< No cubes >

I don't see any errors/warnings. 
The file can be read in Python of course but would be good to know if Iris could be used. 
The ncdump output is attached. 

Thanks!
Vidya

The nc file is originally downloaded from 





ncinfo.txt

Simon Peatman

unread,
Mar 18, 2021, 8:02:00 AM3/18/21
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
Dear Vidya,

The variables in your file are all stored within groups, but as far as I know Iris will load only those variables found in the root (i.e., top-level) group.  I'm not aware of any solution to this I'm afraid, other than editing the file using other software to move all the variables into the root group (e.g., using ncks) before loading it with Iris.  Note that, in this case, you would have to rename the variables first to avoid name clashes.

Simon

Tony Phillips - UKRI BAS

unread,
Mar 18, 2021, 8:11:11 AM3/18/21
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools

Hi

 

I didn’t have any previous experience in reading MODIS netCDF files, but do have a bit now. I suspect that Iris is only looking for data variables in the root netCDF group – the MODIS files put their spatial dimensions in the root group but all the data variables in their own groups “Cloud_Retrieval_Fraction_Total” etc. with each group containing variables “Mean”, “Standard_Deviation”, “Sum”, “Pixel_Counts” and “Sum_Squares”. So Iris doesn’t see any data variables to read.

 

Unless anyone else has a better way, I suggest that you will need to read what need from the file (variable data, coordinates, attributes etc.) using something like netcdf4 or xarray, then build your cube out of what you’ve read.

 

I have attached a simple definition that does this using xarray, preserving as much of the metadata as possible. I hope this is useful.

 

Tony

--
You received this message because you are subscribed to the Google Groups "SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scitools-iri...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scitools-iris/7f308b05-e693-451e-ac29-0fdc90b8e098n%40googlegroups.com.

This email and any attachments are intended solely for the use of the named recipients. If you are not the intended recipient you must not use, disclose, copy or distribute this email or any of its attachments and should notify the sender immediately and delete this email from your system. UK Research and Innovation (UKRI) has taken every reasonable precaution to minimise risk of this email or any attachments containing viruses or malware but the recipient should carry out its own virus and malware checks before opening the attachments. UKRI does not accept any liability for any losses or damages which the recipient may sustain due to presence of any viruses. Opinions, conclusions or other information in this message and attachments that are not related directly to UKRI business are solely those of the author and do not represent the views of UKRI.
read_modis_data.py

V V

unread,
Mar 18, 2021, 7:07:20 PM3/18/21
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
Thank you very much @Simon and @Tony. Very helpful to have these replies.
I tried the code snippet Tony sent to convert to cubes from selecting the desired data from groups and it works.  Its good to know about the xarray utility to convert arrays to iris cubes! 
Much appreciate the help.

Regards
Vidya

Reply all
Reply to author
Forward
0 new messages