How read Common Data Format (CDF) in Python

前端 未结 4 1557
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:25

    If you have Python's package tool, pip installed, you can get the spacepy cdf library as follows:

    $ pip install git+https://github.com/spacepy/spacepy.git
    

    Note this will install a lot of dependencies, including numpy and scipy. These can be a bit difficult to install from scratch. You might want to install a ready-made package first, e.g. anaconda. Once that's done, just use the above command and spacepy should install like a breeze.

    Once the installation of spacepy was successful, according to this example it should work something like this:

    from spacepy import pycdf
    cdf = pycdf.CDF('/path/to/file.cdf')
    print(cdf)
    

提交回复
热议问题