Attribute Error while converting cdf file to xarray dataset

20 Views Asked by At

I want to convert cdf file to xarray dataset in order to plot. I have downloaded the cdf file from this link -- https://maser.obspm.fr/repository/juno/waves/data/l3a_v02/data/cdf/2020/11/jno_wav_cdr_lesia_20201108_v02.cdf and am using the following code:

import cdflib
import xarray as xr
import os
import urllib.request

# Download a CDF file
fname = 'WAV08_11_20.cdf'
url = ("https://maser.obspm.fr/repository/juno/waves/data/l3a_v02/data/cdf/2020/11/jno_wav_cdr_lesia_20201108_v02.cdf")
if not os.path.exists(fname):
  urllib.request.urlretrieve(url, fname)

juno_data = cdflib.cdf_to_xarray("WAV08_11_20.cdf", to_unixtime=True, fillval_to_nan=True)

I receive the following error:

AttributeError                            Traceback (most recent call last)
Cell In[10], line 2
      1 # Load in and display the CDF file
----> 2 juno_data = cdflib.cdf_to_xarray("WAV08_11_20.cdf", to_unixtime=True, fillval_to_nan=True)

AttributeError: module 'cdflib' has no attribute 'cdf_to_xarray'

I used the code found in the documentation -- https://cdflib.readthedocs.io/en/stable/api/cdflib.xarray.cdf_to_xarray.html#cdflib.xarray.cdf_to_xarray

What can I try next?

0

There are 0 best solutions below