Convert binary punch file to netCDF
iriadigos opened this issue · 8 comments
I am trying to convert a punch file to netCDF using the "AC_tools" but it shows me the following error when I use the "convert_to_netCDF" function:
_File "/home/i/irs11/miniconda3/lib/python3.7/site-packages/AC_tools/bpch2netCDF.py", line 209, in bpch_to_netCDF
bpch_data = datasets.load(bpch_files)
NameError: name 'datasets' is not defined_
I'm using the following packages: python 3.7, iris 2.2.0, numpy 1.17.2, netcdf4 1.5.3 .....
I don't have the pygchem package because I am not able to install it in python 3.7. Consequently, I've tried to use an environment with python 2.7, but in such case AC_tools needs python=>3.5 to be installed. So I got stuck.
Any suggestion?
Hello @iriadigos,
Thanks for writing.
Yes. To use the iris backend via PyGChem in AC_tools, you need to run in a python 2 environment. This is due to PyGChem. AC_tools should install fine in Python 2 environment. Is your install of AC_tools not successful in a python2 environment?
When using the convert_to_netCDF function, you need to be in a Python2 environment. For doing anything else using AC_tools, I would recommend using a python3 environment.
No, I am not able to install AC_tools in a python2 environment. This is the error:
ERROR: Package 'AC-tools' requires a different Python: 2.7.17 not in '>=3.5'
OK. You are installing via the pip method listed on the README, correct?
I've not re-installed a AC_tools in python2 since switching to the pip method. I think the second approach listed on the wiki should work. Would be able to give that a go?
I am assuming you have successfully installed PyGChem and iris in your Python2 environment already?
I have successfully installed AC_tools with the second approach.
PyGChem 0.3.0 and iris 2.2.1 are also installed in the environment.
But again, I have the same error when executing "convert_to_netCDF" function:
Creating a netCDF from 1 file(s). This can take some time...
Traceback (most recent call last):
File "", line 1, in
ds=AC.convert_to_netCDF(folder=folder,bpch_file_type='trac_avg.*')
File "/home/i/irs11/miniconda3/envs/py27/lib/python2.7/site-packages/AC_tools-0.1.1-py2.7.egg/AC_tools/bpch2netCDF.py", line 62, in convert_to_netCDF
file_type=bpch_file_type, verbose=verbose)
File "/home/i/irs11/miniconda3/envs/py27/lib/python2.7/site-packages/AC_tools-0.1.1-py2.7.egg/AC_tools/bpch2netCDF.py", line 209, in bpch_to_netCDF
bpch_data = datasets.load(bpch_files)
NameError: global name 'datasets' is not defined
Please could I check what (if any) error messages you get when you paste in the following lines?
import pygchem
from pygchem import datasets
import pygchem.datafields as datasets
I just checked and PyChem version I have from running the same process is '0.3.0dev' and the iris version is '1.13.0'. You may need to force the iris version to be the same, as I think some large happened at v2.
Importing pygchem does not show any error. However, the other two lines show these errors:
`from pygchem import datasets
Traceback (most recent call last):
File "", line 1, in
from pygchem import datasets
File "/home/i/irs11/miniconda3/envs/py27/lib/python2.7/site-packages/PyGChem-0.3.0.dev0-py2.7.egg/pygchem/datasets.py", line 97, in
_load_backend(DEFAULT_BACKEND)
File "/home/i/irs11/miniconda3/envs/py27/lib/python2.7/site-packages/PyGChem-0.3.0.dev0-py2.7.egg/pygchem/datasets.py", line 41, in _load_backend
.format(backend_name))
File "/home/i/irs11/miniconda3/envs/py27/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/i/irs11/miniconda3/envs/py27/lib/python2.7/site-packages/PyGChem-0.3.0.dev0-py2.7.egg/pygchem/dataset_backends/backend_iris.py", line 27, in
import iris.unit
ImportError: No module named unit
import pygchem.datafields as datasets
Traceback (most recent call last):
File "", line 1, in
import pygchem.datafields as datasets
ImportError: No module named datafields`
Finally, it works with the iris version '1.13.0'.
Thank you very much.
Good to hear!
I will add some information on this to the README to help others who encounter this in the future.