Why does iris create cubes with a time dimension of only one point?

881 views
Skip to first unread message

LeonH

unread,
Jan 28, 2014, 5:50:35 AM1/28/14
to scitoo...@googlegroups.com
I am a little perplexed as to why iris sometimes creates cubes with a time dimcoord despite the fact that there is only one time point. Shouldn't it be a scalar coordinate in that case?
Python 2.7.2 (default, Oct  1 2012, 15:56:20)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import iris
>>> iris.__version__
'1.6.0'
>>> a = iris.load('ancxco_1s_20111201_20120230_grid_U.nc', 'surface_downward_x_stress')
>>> print a[0]
surface_downward_x_stress
/ (Pa)    (time: 1; -- : 292; -- : 362)
     
Dimension coordinates:
          time                           x      
-         -
     
Auxiliary coordinates:
          latitude                      
-       x         x
          longitude                      
-       x         x
     
Attributes:
         
Conventions: CF-1.1
          NCO
: 4.2.0
          interval_operation
: 3600.0
          interval_write
: 2.592e+06
          nco_openmp_thread_number
: 1
          production
: An IPSL model
     
Cell methods:
          mean
: time_counter
>>> print a[0].coord('time')
DimCoord([2012-01-16 00:00:00], standard_name=u'time', calendar=u'360_day', long_name=u'Time axis', var_name='time_counter', attributes={'time_origin': ' 2011-NOV-01 00:00:00', 'title': 'Time'})




Carwyn Pelley

unread,
Jan 28, 2014, 6:23:17 AM1/28/14
to
In the original netcdf file, there will be a time netcdf variable associated with a dimension of length 1 or "UNLIMITED".  If this netcdf variable had no associated dimension, then you would have a resulting scalar coordinate in your cube in iris.  Automatically making this a scalar coordinate in the resulting cube for your case, would mean reshaping the data and not preserving its shape from the netcdf file.  This would also offer problems for those who expect the data to be of the same shape on saving, especially for those tools which for example concatenate netcdf files using dimensions marked as UNLIMITED.

LeonH

unread,
Jan 28, 2014, 6:41:11 AM1/28/14
to scitoo...@googlegroups.com
OK, thanks. Any idea why this cube won't concatenate with other cubes that are the same except for the time value? I have checked the cube and its coordinates with their respective is_compatible() function and get 'True' in all cases. I have also caused the data to be loaded in, but it doesn't help.

Carwyn Pelley

unread,
Jan 28, 2014, 7:56:31 AM1/28/14
to
No problem.  is_compatible has nothing to do with merge or concatenate, it only looks at comparing certain aspects which has its uses with interpolation and regridding (I don't think it should live where it is but that's for a different conversation).  Its documentation has now been updated to reflect this (available only within iris master as of yet).

Instead, I might suggest looking at equality between objects.

cubea.attributes == cubeb.attributes

And checking that the coordinates that you expect to be common, truly are:
cubea.coords('latitude') == cubeb.coords('latitude')

If it's a problem with the attributes, you can make use of the following function:
http://scitools.org.uk/iris/docs/latest/iris/iris/experimental/equalise_cubes.html#iris.experimental.equalise_cubes.equalise_attributes

Perhaps they don't occupy different regions entirely as there is an overlap?

Can you send us the troublesome cubes in question?

Regards,

@cpelley

LeonH

unread,
Jan 28, 2014, 8:26:36 AM1/28/14
to scitoo...@googlegroups.com
Thanks, Carwyn. That's very interesting. In fact, I have asked before what is 'is_compatible()' supposed to be used for. I got a functional answer (to determine if two cubes share meta data), but I didn't know what that could be used for practically.

I would be grateful if you could look at the two cubes that are not concatenating. They are unfortunately too large to attach, but those at the Met Office can look here:
/data/cr1/hadlh/tmp/cubeOne.nc
/data/cr1/hadlh/tmp/cubeTwo.nc


ScottHosking

unread,
Apr 8, 2014, 6:28:59 AM4/8/14
to scitoo...@googlegroups.com
LeanH, I would be interested to know if you now have some code to concatenate your two cubes.

Thanks,
    Scott

LeonH

unread,
Apr 25, 2014, 11:01:50 AM4/25/14
to scitoo...@googlegroups.com
Hi Scott

Sorry it has taken ages to get back to you. I am now running iris 1.7.0-dev. The cubes still do not concatenate, there is a workaround though. Bizarrely, if I slice my cube so the time dimension becomes a scalar coordinate, the cube will merge! You'd think that two cubes that merge when time is a scalar coordinate, would concatenate when time is a dim_coord, but that is not true. Perhaps development of merge() has got further than that of concatenate()?

I hope that helps.
Reply all
Reply to author
Forward
0 new messages