pythonpython-xarraysatellite

netCDF files has no variables in python when importing with xarray


I'm VERY new to xarray, and I tried to import a satellite netcdf files into python using xarray using this file: https://tropomi.gesdisc.eosdis.nasa.gov/data//S5P_TROPOMI_Level2/S5P_L2__NO2____HiR.1/2020/003/S5P_OFFL_L2__NO2____20200103T170946_20200103T185116_11525_01_010302_20200105T100506.nc

This is the code I used:

import xarray as xr
import numpy as np
import pandas as pd

tropomi = xr.open_dataset('test2.nc', engine = 'netcdf4')
tropomi 

Output: enter image description here

But the output does not present any variables, and has 53 attributes - why is this happening?

Thanks!


Solution

  • I figured it out. When you open the file without a group defined, you get the global attributes with no variables. You need to include a group='PRODUCT' to get the data products, like this:

    
    tropomi = xr.open_dataset('test2.nc', group='PRODUCT')