zxdawn / S5P-LNO2

Core code for the TROPOMI lightning NO2 retrievals
GNU General Public License v3.0
2 stars 1 forks source link

Empty S5P-LNO2 product #38

Closed zxdawn closed 2 years ago

zxdawn commented 2 years ago

I got this error when extract TM5 profiles to products generated by s5p_lnox_main.py

Adding NO2 and Temperature profiles to  /student/zhangxin/papers/Arctic/S5P_LNOx/main/output_gld360/clean_lightning/202107/S5P_PAL__L2__NO2____20210712T000148_20210712T014317_19403_02_020301.nc
Traceback (most recent call last):
  File "/public/home/zhangxin/new/miniconda3/envs/knmi_arctic/lib/python3.9/site-packages/xarray/backends/netCDF4_.py", line 180, in _nc4_require_group
    ds = ds.groups[key]
KeyError: 'S5P'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/student/zhangxin/papers/Arctic/S5P_LNOx/main/s5p_lnox_tm5_extract.py", line 48, in <module>
    with xr.open_dataset(file, group='S5P') as ds:
  File "/public/home/zhangxin/new/miniconda3/envs/knmi_arctic/lib/python3.9/site-packages/xarray/backends/api.py", line 495, in open_dataset
    backend_ds = backend.open_dataset(
  File "/public/home/zhangxin/new/miniconda3/envs/knmi_arctic/lib/python3.9/site-packages/xarray/backends/netCDF4_.py", line 553, in open_dataset
    store = NetCDF4DataStore.open(
  File "/public/home/zhangxin/new/miniconda3/envs/knmi_arctic/lib/python3.9/site-packages/xarray/backends/netCDF4_.py", line 382, in open
    return cls(manager, group=group, mode=mode, lock=lock, autoclose=autoclose)
  File "/public/home/zhangxin/new/miniconda3/envs/knmi_arctic/lib/python3.9/site-packages/xarray/backends/netCDF4_.py", line 330, in __init__
    self.format = self.ds.data_model
  File "/public/home/zhangxin/new/miniconda3/envs/knmi_arctic/lib/python3.9/site-packages/xarray/backends/netCDF4_.py", line 391, in ds
    return self._acquire()
  File "/public/home/zhangxin/new/miniconda3/envs/knmi_arctic/lib/python3.9/site-packages/xarray/backends/netCDF4_.py", line 386, in _acquire
    ds = _nc4_require_group(root, self._group, self._mode)
  File "/public/home/zhangxin/new/miniconda3/envs/knmi_arctic/lib/python3.9/site-packages/xarray/backends/netCDF4_.py", line 186, in _nc4_require_group
    raise OSError(f"group not found: {key}", e)
OSError: [Errno group not found: S5P] 'S5P'

Two solutions:

  1. Skip saving the product if it's empty
  2. Skip extracting if it's empty
zxdawn commented 2 years ago

I suppose #33 is caused by the same problem