Questions tagged [netcdf4]

Questions related to NetCDF (Network Common Data Form) format and corresponding libraries/implementations may have this tag.

In 2008, the netCDF4 format was added to support per-variable compression, multiple unlimited dimensions, more complex data types, and better performance, by layering an enhanced netCDF access interface on top of the HDF5 format.

At the same time, a fourth format variant, netCDF-4 classic model format, was added for users who needed the performance benefits of the new format (such as compression) without the complexity of a new programming interface or enhanced data mode.

Every netCDF-4 or netCDF-4 classic model file can be read or written by the HDF5 library version 1.8 or later, so in that respect netCDF-4 files are already HDF5 files and need no conversion.

According to netCDF FAQ installing the netCDF4 is required for any of the following situations:

  • you need to access netCDF data that makes use of netCDF-4 compression or chunking
  • you need to access data in all netCDF formats including netCDF-4 or netCDF-4 classic model formats
  • you need to write non-record variables larger than 4GiB or record variables with more than 4GiB per record
  • you are installing netCDF to support other software packages that require netCDF-4 features
  • you want to write data that takes advantage of compression, chunking, or other netCDF-4 features
  • you want to be able to read netCDF-4 classic model data with no changes to your current software except relinking with the new library
  • you want to benchmark your current applications with the new libraries to determine whether the benefits are significant enough to justify the upgrade
  • you need to use parallel I/O with netCDF-4 or netCDF-4 classic files
651 questions
3
votes
1 answer

Python - Use list of points to extract data from gridded NetCDF without for loops

The following example uses the "Unidata" sample netCDF dataset of eastward wind which can be downloaded from here (2.8 MB) I have two lists of integers that correspond to the x and y index of a gridded array in a netCDF file. I want to extract the…
Muon
  • 1,294
  • 1
  • 9
  • 31
3
votes
3 answers

Convert hdf5 to netcdf4 in bash, R, python or NCL?

Is there a quick and simple way to convert HDF5 files to netcdf(4) from the command line in bash? Alternatively a simple script that handle such a conversion automatically in R, NCL or python ?
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
3
votes
2 answers

NCO cropping a netcdf file using dimension values rather than indices

CDO can crop a netcdf file in terms of latitude and longitude as long as they are defined in a standard way, and I know that NCO can cut out a subset of a netcdf file along any dimension if you know the range of indices that you want, as stated in…
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
3
votes
1 answer

h5netcdf as default xarray engine

The default backend engine for xarray is set to netcdf4 in this function What is the best way to make h5netcdf the default engine in xarray?
Ted Habermann
  • 321
  • 2
  • 9
3
votes
1 answer

Compression level of netCDF4 variable

How do you determine the compression level of a netCDF4 variable (preferably in Python)?
sfinkens
  • 1,210
  • 12
  • 15
3
votes
1 answer

Subsetting xarray.Dataset with respect to multiple coordinates

Say I have an xarray.Dataset object loaded in using xarray.open_dataset(..., decode_times=False) that looks like this when printed: Dimensions: (bnds: 2, lat: 15, lon: 34, plev: 8, time: 3650) Coordinates: * time (time)…
pbreach
  • 16,049
  • 27
  • 82
  • 120
3
votes
1 answer

NetCDF4 python create numpy multi-dimension arrays

With the python netcdf4 library I want to write a test dataset for my netcdf4 read script. However, I am not able to generate the desired output. This is currently my write script: # write file varlist = ['ABC123', 'DEF456', 'GHI789'] varlist =…
Joost Döbken
  • 3,450
  • 2
  • 35
  • 79
3
votes
2 answers

Error on using xarray open_mfdataset function

I am trying to combine multiple netCDF files with the same dimensions, their dimensions are as follows: OrderedDict([(u'lat', : name = 'lat', size = 720 ), (u'lon', : name =…
user308827
  • 21,227
  • 87
  • 254
  • 417
3
votes
1 answer

understanding pyresample to regrid irregular grid data to a regular grid

I need to regrid data on a irregular grid (lambert conical) to a regular grid. I think pyresample is my best bet. Infact my original lat,lon are not 1D (which seems to be needed to use basemap.interp or scipy.interpolate.griddata). I found this SO's…
claude
  • 549
  • 8
  • 25
3
votes
2 answers

Replace values in netCDF file using python

I would like to replace all the -999.0 values in the foll. netCDF file by 0.0. The file is here: https://www.dropbox.com/s/ohh7tntzm2pj1uw/all_SSP3_BaU_NoCC.nc?dl=0 here's my function: def modify_nc_value(path_inp, name_var, val_to_modify,…
user308827
  • 21,227
  • 87
  • 254
  • 417
2
votes
0 answers

How to install ncview package for cywgin?

I'm trying to download the ncview package by cygwin from the installer but whenever I type the command ncview it's not identified by the terminal.. I downloaded all the pre-required packages and still no clue why it's not working. Any help will be…
2
votes
1 answer

change chunk block shape in netCDF file

I have several ~100 GB NetCDF files. Within each NetCDF file, there is a variable a, from which I have to extract several data series The dimension is (1440,721,6,8760). I need to extract ~20k slices of dimension (1,1,1,8760) from each NetCDF…
user7431005
  • 3,899
  • 4
  • 22
  • 49
2
votes
1 answer

convert csv to netcdf in Python

Hi I have a CSV file that is for several monitoring stations that have measured isotope data repeatedly over a period of time. Country Latitude Longitude Altitude Sample Name Date Begin of Period End of Period H2 Precipitation …
Weiss
  • 176
  • 2
  • 16
2
votes
0 answers

python netcdf on M1

I am trying to install netcdf4-python on a MacOSX Monterey with M1 processor. I installed without problems hdf5 and netcdf using brew. However, after cloning the netcfd4 python repo at https://github.com/Unidata/netcdf4-python, when I then try to…
Marco
  • 21
  • 2
2
votes
1 answer

NETCDF4 file doesn't grow beyond 2GB

I have a NETCDF4 file which doesn't grow beyond 2GB. I am using the following sample data - I am converting over 200 txt files to netcdf4 file STATIONS_ID;MESS_DATUM; QN;FF_10;DD_10;eor 3660;201912150000; 3; 4.6; 170;eor …
super
  • 23
  • 3