load_cube() and circular longitude?

32 views
Skip to first unread message

Phil Morefield

unread,
Mar 31, 2017, 9:39:51 AM3/31/17
to Iris
I'm trying to concatenate cubes from two netCDF files, but the call to load_cube() is failing:

climate_cube_list = iris.load([historical_file, future_file], 'pr')


File "D:\projects\local\make_map_bcsd.py", line 108, in <module>
 
BCSDMapGenerator(**keywords)
File "D:\projects\local\make_map_bcsd.py", line 32, in __init__
 
self.create_iris_cube()
File "D:\projects\local\make_map_bcsd.py", line 48, in create_iris_cube
  climate_cube_list
= iris.load([historical_file, future_file], self.climate_variable_short)
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\__init__.py", line 341, in load
 
return _load_collection(uris, constraints, callback).merged().cubes()
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\__init__.py", line 311, in _load_collection
  result
= iris.cube._CubeFilterCollection.from_cubes(cubes, constraints)
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\cube.py", line 144, in from_cubes
 
for cube in cubes:
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\__init__.py", line 298, in _generate_cubes
 
for cube in iris.io.load_files(part_names, callback, constraints):
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\io\__init__.py", line 201, in load_files
 
for cube in handling_format_spec.handler(fnames, callback):
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\fileformats\netcdf.py", line 693, in load_cubes
  cube
= _load_cube(engine, cf, cf_var, filename)
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\fileformats\netcdf.py", line 525, in _load_cube
  engine
.activate(_PYKE_RULE_BASE)
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\pyke\knowledge_engine.py", line 296, in activate
 
for rb_name in rb_names: self.get_rb(rb_name).activate()
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\pyke\rule_base.py", line 159, in activate
 
self.run_fc_rules(current_rb)
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\pyke\rule_base.py", line 147, in run_fc_rules
 
for fc_rule in rb.fc_rules: fc_rule.run()
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\pyke\fc_rule.py", line 90, in run
 
self.rule_fn(self)
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\fileformats\_pyke_rules\compiled_krb\fc_rules_cf_fc.py", line 602, in fc_build_coordinate_longitude_nocs
  coord_system
=None)
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\fileformats\_pyke_rules\compiled_krb\fc_rules_cf_fc.py", line 1923, in build_dimension_coordinate
  circular
= iris.util._is_circular(points_data, modulus_value, bounds=bounds_data)
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\iris\util.py", line 1418, in _is_circular
  significant
=4)
File "C:\Users\pmorefi\Anaconda2\Lib\site-packages\numpy\testing\utils.py", line 637, in assert_approx_equal
 
raise AssertionError(msg)

AssertionError:
Items are not equal to 4 significant digits:
ACTUAL
: 235.3125
DESIRED
: 293.0625

It's pretty clear that this has something to do with Iris assuming the longitude values are circular; the longitude values in the netCDF file have a min/max of 235.3125 and 292.9375 respectively. And I'm able to create cubes from the netCDF files independently. 

Any insights, suggestions, or work-arounds would be appreciated. All of the load functions (i.e., even load_raw()) give me the same error.

Phil Morefield

unread,
Mar 31, 2017, 4:05:08 PM3/31/17
to Iris
Disregard this question. It turns out the default behavior for the IDE I'm using (WingIDE) is to instantly exit when an AssertionError is raised, even if it's appropriately trapped by a try/except block. I turned that setting off and the code executed as expected.
Reply all
Reply to author
Forward
0 new messages