Hello, I want to convert my netcdf file to CSV. For this, I reviewed the How to convert NetCDF to CSV page and tried the pyhton codes. But
time_dim, lat_dim, lon_dim = tcwv.get_dims ()
in this code i get the following error.
ValueError: too many values to unpack (expected 3).
How can I solve it, can you help me? It's really important. I also leave below how I use the codes. Thank you from now.
import cdsapi
import netCDF4
from netCDF4 import num2date
import numpy as np
import os
import pandas as pd
c = cdsapi.Client ()
file_location = r "C: \ Users \ A \ Desktop \ download.nc"
c.retrieve (
'reanalysis-era5-single-levels-monthly-means',
{
'product_type': 'monthly_averaged_reanalysis',
'variable': 'total_column_water_vapour',
'year': (
'2019', '2020',
],
'month': [
'01', '02', '03',
'04', '05', '06',
'07', '08', '09',
'10', '11', '12',
],
'time': '00: 00 ',
'area': (
41.15, 39.88, 38.94,
43,
],
'format': 'netcdf',
},
file_location)
f = netCDF4.Dataset (file_location)
tcwv = f.variables ('tcwv')
time_dim, lat_dim, lon_dim = tcwv.get_dims ()
time_var = f.variables [time_dim.name]
times = num2date (time_var [:], time_var.units)
latitudes = f.variables [lat_dim.name] [:]
longitudes = f.variables [lon_dim.name] [:]
output_dir = './'
1 Comment
Michela Giusti
Hi,
this is probably due to the extra dimension 'expver', please have a look at the following link for details:
ERA5 CDS requests which return a mixture of ERA5 and ERA5T data
Thanks
Michela