Category : netcdf

Given two nc files here: data/CMIP6_UKESM1-0-LL_Lmon_piControl_r1i1p1f2_gpp_1960-3059.nc data/CMIP6_UKESM1-0-LL_Amon_piControl_r1i1p1f2_tas_1960-3059.nc Read the first file: from netCDF4 import Dataset import numpy as np ds1 = Dataset(‘data/CMIP6_UKESM1-0-LL_Lmon_piControl_r1i1p1f2_gpp_1960-3059.nc’) print(ds1.variables.keys()) # get all variable names Out: odict_keys([‘gpp’, ‘time’, ‘time_bnds’, ‘lat’, ‘lat_bnds’, ‘lon’, ‘lon_bnds’, ‘clim_season’, ‘season_year’]) Read the second file: ds2 = Dataset(‘data/CMIP6_UKESM1-0-LL_Amon_piControl_r1i1p1f2_tas_1960-3059.nc’) print(ds2.variables.keys()) Out: odict_keys([‘tas’, ‘time’, ‘time_bnds’, ‘lat’, ‘lat_bnds’, ‘lon’, ‘lon_bnds’, ‘clim_season’, ..

Read more

Given two nc files here: data/CMIP6_UKESM1-0-LL_Lmon_piControl_r1i1p1f2_gpp_1960-3059.nc data/CMIP6_UKESM1-0-LL_Amon_piControl_r1i1p1f2_tas_1960-3059.nc Read the first file: from netCDF4 import Dataset import numpy as np ds1 = Dataset(‘data/CMIP6_UKESM1-0-LL_Lmon_piControl_r1i1p1f2_gpp_1960-3059.nc’) print(ds1.variables.keys()) # get all variable names Out: odict_keys([‘gpp’, ‘time’, ‘time_bnds’, ‘lat’, ‘lat_bnds’, ‘lon’, ‘lon_bnds’, ‘clim_season’, ‘season_year’]) Read the second file: ds2 = Dataset(‘data/CMIP6_UKESM1-0-LL_Amon_piControl_r1i1p1f2_tas_1960-3059.nc’) print(ds2.variables.keys()) Out: odict_keys([‘tas’, ‘time’, ‘time_bnds’, ‘lat’, ‘lat_bnds’, ‘lon’, ‘lon_bnds’, ‘clim_season’, ..

Read more

Given a point (latitude and longitude) I would like to calculate the distance between the given point and the longitudes and latitudes in my file, and filter all the information based on that distance. This is my file. <xarray.Dataset> Dimensions: (height: 1, heightv: 1, ff: 3, time: 49, x: 70, y: 61) Coordinates: Lambert_Conformal |S1 ..

Read more

I need help using xarray. I have a list of points (longitudes, latitudes and dates) for which I need to extract weather data. So far, I have weather_by_loc_time = pd.DataFrame([]) for i,j in zip(latitude,longitude): dsloc = ds.sel(latitude=i,longitude=j, method=’nearest’) dot = dsloc.to_dataframe() weather_by_loc_time = weather_by_loc_time.append(dot) which gives me data for the entire time series. If I ..

Read more

I have a set of points defined by longitude, latitude and date (YY.MM.DD.HH). I had the idea to use xarray to extract values from netcdf file at each point. Using following… target_lon = xr.DataArray(longitude, dims="points") target_lat = xr.DataArray(latitude, dims="points") db = ds.sel(longitude=target_lon, latitude=target_lat, method="nearest") …I can collect the entire timeseries for each of the points. ..

Read more

Basically, this is a repost or follow-up from How to calculate daily average from ERA5 hourly netCDF data? I have four atmospheric variables, viz. dew point temperature, longwave radiation, shortwave radiation, and wind speed (calculated from u10 and v10 wind components). All are on an hourly scale and I need to convert them into the ..

Read more