UCL / pyCascadia

Implementation of GEBCO cookbook remove-restore and other cleaning of topography/bathymetry. Uses `pyGMT`.
Mozilla Public License 2.0
9 stars 0 forks source link

Error when one of the update grids have no data #66

Closed Devaraj-G closed 3 years ago

Devaraj-G commented 3 years ago

Hi @alessandrofelder I get the following error when one of the update grids has no valid data. Would it be possible to suppress it without halting the script?

Blockmedian update grid
Find z in base grid
Traceback (most recent call last):
  File "/home/devaraj/anaconda3/envs/cascadia/bin/remove-restore", line 8, in <module>
    sys.exit(main())
  File "/home/devaraj/anaconda3/envs/cascadia/lib/python3.9/site-packages/pycascadia/remove_restore.py", line 154, in main
    diff_grid = calc_diff_grid(base_grid, update_grid,
  File "/home/devaraj/anaconda3/envs/cascadia/lib/python3.9/site-packages/pycascadia/remove_restore.py", line 71, in calc_diff_grid
    base_pts = grdtrack(bmd, base_grid.grid, 'base_z', interpolation='l')
  File "/home/devaraj/anaconda3/envs/cascadia/lib/python3.9/site-packages/pygmt/helpers/decorators.py", line 288, in new_module
    return module_func(*args, **kwargs)
  File "/home/devaraj/anaconda3/envs/cascadia/lib/python3.9/site-packages/pygmt/src/grdtrack.py", line 91, in grdtrack
    with table_context as csvfile:
  File "/home/devaraj/anaconda3/envs/cascadia/lib/python3.9/contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "/home/devaraj/anaconda3/envs/cascadia/lib/python3.9/site-packages/pygmt/clib/session.py", line 1270, in virtualfile_from_matrix
    self.put_matrix(dataset, matrix)
  File "/home/devaraj/anaconda3/envs/cascadia/lib/python3.9/site-packages/pygmt/clib/session.py", line 908, in put_matrix
    raise GMTCLibError("Failed to put matrix of type {}.".format(matrix.dtype))
Devaraj-G commented 3 years ago

This happens when I chop a DEM. Even though the DEM contains valid data, the cut portion may contain only no_data values.

alessandrofelder commented 3 years ago

@Devaraj-G could you git checkout feature/ignore-fully-nodata-grids and check that it fixes this issue for you, when you get a chance, please?

Devaraj-G commented 3 years ago

Awesome and thanks @alessandrofelder. It doesn't give an error but says -

Blockmedian update grid
Update grid consists entirely of no_data_values. Skipping

Checking for the entire grid now.

JamieJQuinn commented 3 years ago

This has been fixed and merged.