stella icon indicating copy to clipboard operation
stella copied to clipboard

post_processing/stella_data.py: *.out.nc is not a valid NetCDF 3 file

Open mrhardman opened this issue 2 years ago • 3 comments

Executing

$ python3 kspectra_plots.py

On my favourite stella *.out.nc file leads to the following error

Traceback (most recent call last): File "kspectra_plots.py", line 3, in from stella_data import time, ntime, outdir, nakx, naky, kx, ky TypeError: Error: *.out.nc is not a valid NetCDF 3 file

This can be fixed by replacing the scipy netcdf module with

from NETCDF4 import dataset ncfile = Dataset(infile,'r', format='NETCDF4')

and remembering to add '.size' the the end of a dimension enquiry

mrhardman avatar Aug 10 '22 15:08 mrhardman

The code changes to fix the issue raised here are in branch

https://github.com/stellaGK/stella/tree/bugfix/pythontools_netcdf4_compatibility

mrhardman avatar Aug 15 '22 18:08 mrhardman

I have previously made a start converting some of these post-processing scripts to xarray, and to make them a bit more flexible, allowing them to be used from the command line with arguments, or importing them to use in other scripts.

Are there particular scripts that are used more than others?

ZedThree avatar Aug 17 '22 10:08 ZedThree

I have now taken to using https://github.com/jfparisi/stella_tools/tree/master, a tool developed by jfparisi for stella, based on my original scripts for GS2. The main benefit of this script is speed: only data actually used for plotting is loaded. I found the scriptsi here to be too slow for the multiscale simulation that I wanted to inspect.

mrhardman avatar Aug 17 '22 12:08 mrhardman