Invalid Input Error message

Hi all, I am having some serious issues when using pyGMT.

I have previously ran my script with no issues and have generated some maps, but for some reason it at times decides it doesnt want to run and I get the error message ‘GMTInvalidInput: Unrecognized data type: <class ‘xarray.core.dataset.Dataset’>’. My data type is a netcdf and as i said above, ran smoothly a week ago and I havent changed anything or moved any data around in the files.

Does anyone have any ideas why this now wont run?

Are you able to share a minimal, reproducible example for your issue?

If you could also share a more complete traceback that would be helpful for us to know which method produces the error message.

I am pretty new at this, and it is a script written by a thesis supervisor. But here are the screen shots of the section that is not running, let me know if you need anymore info. Everything before this section of code worked perfectly

It’s a bit surprising that it previously worked. The problem is that erode is a xarray.Dataset and raster based functions/methods in PyGMT expect an xarray.Dataarray.

If the netcdf file contains only one variable, you could use xarray.load_dataarray rather than xarray.load_dataset. If it contains more than one variable, you would need to select the variable within the erode dataset that you want to plot (similar to how you’ve selected to pass scotese.Band1 to grdcontour).

As an aside, it looks like you are using an old version of PyGMT. PyGMT is being quickly developed, meaning that we are regularly adding new features and fixing bugs. If you expect to ever want to use those features, it could be helpful to regularly update your anaconda environment. We issue deprecation warnings anytime we change the API. Regular updates would help make sure that you see those warnings.

Thanks for the reply! I have tried this and still get errors. There is a chance I have selected the variables incorrectly. How would this be executed correctly if the variable I need is called Band1?

fig.grdimage(erode.Band1, shading='+a345+nt1+m0', frame=True)