SciTools / iris

A powerful, format-agnostic, and community-driven Python package for analysing and visualising Earth science data
https://scitools-iris.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
635 stars 284 forks source link

Nimrod file type - TranslationWarning: Vertical coord 5 not yet handled "".format(v_type), TranslationWarning) #2149

Closed gac55 closed 8 years ago

gac55 commented 8 years ago

I am attempting to load a nimrod .dat file using the following:

file_location = "dir/file" cube = iris.load_cube(file_location) print cube

Resulting in the vertical coord 5 wanring and the following print out: /usr/local/lib/python2.7/site-packages/Iris-1.10.0.dev0-py2.7.egg/iris/fileformats/nimrod_load_rules.py:246: TranslationWarning: Vertical coord 5 not yet handled "".format(v_type), TranslationWarning)

screen shot 2016-09-20 at 11 41 28

I believe this is resulting in the incorrect projection_y_coordinate and projection_x_coordinate fields.

For those with access to CEDA, a sample file may be found here http://browse.ceda.ac.uk/browse/badc/ukmo-nimrod/data/composite/uk-1km/2016

Can anyone point me in the right direction with this issue? I don't believe there has been a change in the nimrod format since the last update to nimrod_load_rules.py for converting Nimrod fields into cubes. If this is a misunderstanding of my part on the nimrod file type my apologies!

ajdawson commented 8 years ago

The warning you are receiving only affects the interpretation of the vertical coordinate, not horizontal coordinates.

Could you explain why you think the horizontal coordinates are incorrect? Currently the only horizontal grid that is supported is the British national grid, which uses the coordinate system iris.coord_systems.OSGB and it looks like this is what you are getting. If you try and plot this using iris I suspect it will correctly plot over an OSGB projection.

gac55 commented 8 years ago

Thanks @ajdawson. I misunderstood vertical coordinates as the y component of horizontal coordinates.

You are correct. The coordinates are fine. However, I'm struggling to see the actual precipitation data in the array... The field_code of 213 indicates the correct type (precipitation rate). Feel free to close this issue (although any pointers if you've experience with nimrod would be gratefully received).

ajdawson commented 8 years ago

However, I'm struggling to see the actual precipitation data in the array

I'm not quite sure what you mean by that. Do you mean plot on a graphic, or see the values printed out?

gac55 commented 8 years ago

The values themselves. My desired output is the precipitation value and its geographic bounds (for a given datetime .dat file). The file I am using is of the form metoffice-c-band-rain-radar_uk_$timedatestamp_1km-composite.dat and thus contains a range of 1km sections for the UK and not just one precipitation value.

ajdawson commented 8 years ago

OK, in general the data values contained in a cube can be accessed via the .data attribute, so in your case print(cube.data) would print the array of values.

I know almost nothing about the Nimrod file format and the data they contain, so I can't answer any tricky questions about the file format itself, only the iris questions. A Nimrod expert may be on hand to help you. Recent contributors to this code were @cpelley and @pelson, any input on this one?

gac55 commented 8 years ago

Thank you @ajdawson! I have aready tried the .data attribute. In the case of nimrod data it returns an array of bytes like this:

[-1 -1 -1 ..., -1 -1 -1] [-1 -1 -1 ..., -1 -1 -1] [-1 -1 -1 ..., -1 -1 -1] ..., [-1 -1 -1 ..., -1 -1 -1] [-1 -1 -1 ..., -1 -1 -1] [-1 -1 -1 ..., -1 -1 -1]

I confess, I'm finding it hard to get my head around the nimrod data. Before Iris I was using the scripts from here which manipulates the raw bytes. However, I was unable to find the actual precipitation data and bounds despite combing the file format doc.

Apologies for turning this into a nimrod discussion, any help would save me another few days of head scratching!

ajdawson commented 8 years ago

Can you try plotting it just to see what it looks like (Python isn't showing you every value, just a sample from the start and end of the array), quickest way would be:

import iris.quickplot as qplt

qplt.pcolormesh(cube)
qplt.show()
gac55 commented 8 years ago

Wow, this looks promising. I confess I don't understand what is happening under the hood. Outputted the following:

figure_1

If you look closely (bottom right) you can see some subtle differences indicating that qplot is accessing the precipitation data and its geographic bounds somehow.

ajdawson commented 8 years ago

OK, well perhaps getting somewhere then. I think I've reached the end of my usefulness since I have no idea what this should look like, hopefully someone else can help you out from here. If nothing is forthcoming you can also try a post to the user list: https://groups.google.com/forum/?fromgroups#!forum/scitools-iris. Someone there may have experience with Nimrod files.

gac55 commented 8 years ago

Thank your for your help @ajdawson!