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
1
vote
0 answers

compiling and installing with pip install vs python3 -m build

I have a package that is giving me trouble (netCDF4). I found out that if I download and build the source code myself, it works fine. There are two ways to install this package from source. For the examples below, the source code is at…
bluppfisk
  • 2,538
  • 3
  • 27
  • 56
1
vote
0 answers

How can I fix "Filter error: bad id or parameters or duplicate filter" in NetCDF?

I have been working on a project that uses NetCDF to store the trajectory of a simulation. However, when I try to run the simulation, I get this error: RuntimeError: NetCDF: Filter error: bad id or parameters or duplicate filter and I have been…
Dan
  • 35
  • 4
1
vote
1 answer

Time missmatch when using NetCDF4

I have a netcdf file with a time variable time. When I print this variable I get this: float32 time(time) long_name: time units: hours since 1900-01-01 00:00:00.0 calendar: gregorian unlimited…
jei L
  • 33
  • 6
1
vote
0 answers

Clipping multiple NETcDF4 files

I am trying to crop a bunch of netCDF4 files and then combine them into one CSV file. I have tried using the code below but can't seem to get the for loop to work. import os import xarray as xr import netCDF4 import pandas as pd import…
1
vote
2 answers

How to remove dimension from netCDF4 file, downloaded from ECMWF portal, using Python

I have download wind data in .nc format from ECMWF portal. I want to remove one dimension ('expver'). Reading that nc file gives the following output. I wish to copy this nc file to a new nc file by excluding one dimension ('expver'). But I expect…
Mahesh R
  • 21
  • 3
1
vote
0 answers

Unable to manipulate netCDF4 files using xarray

I am following a particular Machine Learning exercise using jupyter notebooks. The link to the exercise is here. I have managed to install all the necessary packages such as netCDF4, rioxarray, xarray and tensorflow. However, I am having trouble…
1
vote
1 answer

NetCDF4 file with Python - Filter before dataframing

Due to a large NetCDF4 file, I get a MemoryError when I want to transform it into Pandas dataframe. But I don't need everything from the netCDF4 file, so I wanted to know if I could cut the file priorly, and after transforming into dataframe My file…
ImFabien75
  • 157
  • 1
  • 9
1
vote
2 answers

Accessing NetCDF values within a bounding polygon

I'm trying to access daily temperature values from a NetCDF for analysis but want to create summaries of temps (i.e. total number of days within a temperature range) within different administrative units. I have a global nc file and a shapefile with…
1
vote
1 answer

Combining .nc files and extracting selected variables

I have a similar question to u/Ananas here: Sentinel3 OLCI (chl) Average of netcdf files on Python I am running into similar problems, in so much that I cannot seem to extract the necessary information from the .nc-files and then merge them to…
Ian
  • 13
  • 2
1
vote
1 answer

Calculating the size (bytes) of subset large netCDF file from a THREDDS Data Server before reading the file using ncvar_get?

I'm using nc_open to get a DatasetNode from a THREDDS Data Server, and reading a subset of the data in ncvar_get by specifying start and count. Reproducible example below: library(thredds) library(ncdf4) Top <-…
1
vote
1 answer

Combine mutiple variables within netCDF file

Apologies if this is a basic question, I'm new to these tools. I have a netcdf file with with eight variables containing data from the same source, but in different time periods. There is no overlap between the variables across the time dimension.…
1
vote
1 answer

how to change the unit of time variable in NetCdf files using python

I want the unit of time to be "hours since" like other which have unit is "day since"
sonal
  • 11
  • 1
1
vote
0 answers

How can I mask a chosen spatial area in a ncdf4 file with a 'fill value' in R?

I have a Netcdf4 file with three dimensions illustrating five global climate variables: 3 dimensions: lon Size:2160 units: degrees_east long_name: longitude standard_name: longitude lat Size:1080 units:…
matlabcat
  • 172
  • 2
  • 12
1
vote
1 answer

Trouble with dimensions in netcdf : index exceeds dimension bounds

I want to extract monthly temperature data from several netCDF files in different locations. Files are built as follows: > print(data.variables.keys()) dict_keys(['lon', 'lat', 'time', 'tmp','stn']) Files hold names like "tmp_1901_1910." Here is…
ele_al_12
  • 23
  • 6
1
vote
0 answers

Is there a way to use NetCDF4's num2date with an xarray .nc file?

I was instructed to use xarray rather than netCDF4 with this code, however, when importing with xarray, time doesn't have units and calendar to input into the num2date function (3rd line). I tried giving the units and calendar manually, but it…
Francisco
  • 11
  • 2