Dear All,
Using geemap and google colab I successfully exported ERA5_L data to Netcdf format.
I used the exported Netcdf data for further ingestion like seasonal mean etc , it works great.
When I tried to save the data as netcdf , I got the following error :
Xarray to netcdf (ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all())
Even when I tried to export the original data to netcdf, it gives the same error.
I checked the encoding, Fillvalue etc , everything is fine. But still i am getting the same error.
Here are the code snapshots:
import xarray as xr
#Reading Data
fn="ISB_ERA5.nc"
ISB=xr.open_dataset(fn,engine="netcdf4")
<xarray.Dataset>
Dimensions: (time: 24, lon: 56, lat: 31)
Coordinates:
* time (time) datetime64[ns] 2010-01-01 ... 2011-12-01
* lon (lon) float64 72.78 72.79 72.8 ... 73.32 73.33
* lat (lat) float64 33.5 33.51 33.52 ... 33.78 33.79 33.8
Data variables:
total_precipitation_sum (time, lon, lat) float32 ...
Attributes:
crs: EPSG:4326
Checking the encoding
ISB.total_precipitation_sum.encoding
{'zlib': False,
'szip': False,
'zstd': False,
'bzip2': False,
'blosc': False,
'shuffle': False,
'complevel': 0,
'fletcher32': False,
'contiguous': True,
'chunksizes': None,
'source': '/Users/macbookpro/Documents/0_PM10_PM25/DATA_Scripts/ERA5L_DATA/ISB_ERA5.nc',
'original_shape': (24, 56, 31),
'dtype': dtype('float32'),
'_FillValue': nan,
'scale_factor': 0.01}
selecting by indexing and saving to .nc formate file
import netCDF4
single_timestep_data = ISB.isel(time=0)
ISB.to_netcdf("single_timestep_data.nc", mode='w', format='NETCDF4', engine='netcdf4')
Your suggestion/response to resolve this issue would be greatly appreciated.
Kind Regards
Toqeer