Datasets:
License:
Encountering some corrupt files
#2
by
nilsleh
- opened
Hi, thanks for this exciting dataset. I have downloaded and extracted the dataset with the extract_dataset.py file and it runs successfully. However, I am encountering some corrupted files from the CMIP outputs that cannot be opened by xarray
or netcdf4
. I have attempted this on two machines.
from glob import glob
import os
import xarray as xr
from tqdm import tqdm
from netCDF4 import Dataset
input_paths = glob(os.path.join("inputs", "**", "*.nc"), recursive=True)
output_paths = glob(os.path.join("outputs", "**", "*.nc"), recursive=True)
def find_files_with_errors(paths: list[str]):
"""Find files with errors."""
for path in tqdm(paths):
try:
xr.open_dataset(path)
except Exception as e:
print(f"Error in {path}: {e}")
try:
Dataset(path)
print(f"{path} is a valid NetCDF file.")
except Exception as e:
print(f"{path} is not a valid NetCDF file: {e}")
# find_files_with_errors(input_paths)
find_files_with_errors(output_paths)
This script yields the following files that cannot be opened:
outputs/CMIP6/CESM2-WACCM/r1i1p1f1/ssp245/tas/250_km/mon/2042/CMIP6_CESM2-WACCM_r1i1p1f1_ssp245_tas_250_km_mon_gn_2042.nc
outputs/CMIP6/CNRM-CM6-1-HR/r1i1p1f2/historical/tas/50_km/mon/2009/CMIP6_CNRM-CM6-1-HR_r1i1p1f2_historical_tas_50_km_mon_gr_2009.nc
outputs/CMIP6/GFDL-ESM4/r1i1p1f1/ssp370/pr/100_km/mon/2044/CMIP6_GFDL-ESM4_r1i1p1f1_ssp370_pr_100_km_mon_gr1_2044.nc
outputs/CMIP6/CMCC-ESM2/r1i1p1f1/ssp245/pr/250_km/mon/2066/CMIP6_CMCC-ESM2_r1i1p1f1_ssp245_pr_250_km_mon_gn_2066.nc
outputs/CMIP6/INM-CM4-8/r1i1p1f1/ssp585/tas/100_km/mon/2046/CMIP6_INM-CM4-8_r1i1p1f1_ssp585_tas_100_km_mon_gr1_2046.nc
outputs/CMIP6/MPI-ESM1-2-HR/r1i1p1f1/ssp126/pr/100_km/mon/2062/CMIP6_MPI-ESM1-2-HR_r1i1p1f1_ssp126_pr_100_km_mon_gn_2062.nc
outputs/CMIP6/TaiESM1/r1i1p1f1/ssp245/tas/100_km/mon/2054/CMIP6_TaiESM1_r1i1p1f1_ssp245_tas_100_km_mon_gn_2054.nc
outputs/CMIP6/EC-Earth3-Veg/r1i1p1f1/ssp585/pr/250_km/mon/2065/CMIP6_EC-Earth3-Veg_r1i1p1f1_ssp585_pr_250_km_mon_gr_2065.nc
outputs/CMIP6/CMCC-CM2-SR5/r1i1p1f1/ssp585/pr/250_km/mon/2025/CMIP6_CMCC-CM2-SR5_r1i1p1f1_ssp585_pr_250_km_mon_gn_2025.nc
outputs/CMIP6/NorESM2-MM/r1i1p1f1/ssp370/pr/100_km/mon/2089/CMIP6_NorESM2-MM_r1i1p1f1_ssp370_pr_100_km_mon_gn_2089.nc
outputs/CMIP6/CESM2/r4i1p1f1/ssp585/tas/250_km/mon/2015/CMIP6_CESM2_r4i1p1f1_ssp585_tas_250_km_mon_gn_2015.nc
outputs/CMIP6/MRI-ESM2-0/r1i1p1f1/ssp245/tas/100_km/mon/2028/CMIP6_MRI-ESM2-0_r1i1p1f1_ssp245_tas_100_km_mon_gn_2028.nc
Was wondering if you can confirm this, or have possible reasons for why I am encountering this. Thanks in advance!