How read Common Data Format (CDF) in Python

前端 未结 4 1561
Happy的楠姐
Happy的楠姐 2021-01-02 20:39

I need to read CDF file with using python. I have found libraries but i did not understand how use it. For example at this(Python lib), i need to download CDF lib, i don\'t

4条回答
  •  孤独总比滥情好
    2021-01-02 21:17

    While ago I had same problem. I assume, you work on Windows...

    According to Spacepy documentation you need several dependencies to use its's cdf module.

    First of all it SpacePy officially supports only 32-bit python version, therefore you have to have python in 323bit.

    Second, it requires NASA CDF library installed in you system (also 32 bit version). You can grab it from here.

    Third proceed with Spacepy dependencies:

    • numpy
    • scipy
    • matplotlib
    • h5py
    • networkx
    • ffnet

    Most of them are part of Anaconda bundle. If they are not and you have to install them simply pip install .

    If you have problems with compiling from the sources, I advice to go to Christoph Gohlke web site and grab pre-built binaries for Windows matching your python version. http://www.lfd.uci.edu/~gohlke/pythonlibs/

    This should get you going with Spacepy CDF module.

    You can also try another approach. Download CDF-to-netCDF converter from NASA page and run it on your CDF file.

    Python has nice netCDF module, which can be installed from GitHub, or python repo. In this case you also need several dependencies like HDF5, netCDF-4, numpy, cython.

    Once you have netCDF file, you can access it with netCDF module or scipy.io module.

提交回复
热议问题