Skip to content

Expand deferred data relative paths to absolute #1508

@niallrobinson

Description

@niallrobinson

If you do this, biggus fails

d = iris.load_cube('./some_cube.nc')
os.chdir('some_other_dir')
d.data

iris will throw this error

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-9-1780462823f7> in <module>()
----> 1 d[0][0,0,0,0].data

/home/niall/anaconda/lib/python2.7/site-packages/iris/cube.pyc in data(self)
   1448         if not isinstance(data, np.ndarray):
   1449             try:
-> 1450                 data = data.masked_array()
   1451             except MemoryError:
   1452                 msg = "Failed to create the cube's data as there was not" \

/home/niall/anaconda/lib/python2.7/site-packages/biggus/__init__.pyc in masked_array(self)
    814 
    815     def masked_array(self):
--> 816         array = self._apply_keys()
    817         # We want the shape of the result to match the shape of the
    818         # Array, so where we've ended up with an array-scalar,

/home/niall/anaconda/lib/python2.7/site-packages/biggus/__init__.pyc in _apply_keys(self)
    872                 array = np.take(array, key, axis=dimensions[i])
    873         else:
--> 874             array = self.concrete.__getitem__(keys)
    875         return array
    876 

/home/niall/anaconda/lib/python2.7/site-packages/iris/fileformats/pp.pyc in __getitem__(self, keys)
    662 
    663     def __getitem__(self, keys):
--> 664         with open(self.path, 'rb') as pp_file:
    665             pp_file.seek(self.offset, os.SEEK_SET)
    666             data_bytes = pp_file.read(self.data_len)

seems like this could be easily sorted if biggus converted relative paths to absolute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions