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
2 answers

Netcdf averages time varable when averaging multiple .nc files

I have averaged a bunch of hourly netCDF files (for one year) to create one large netCDF file that contains an average daily value. The time variable represents hours since 2005-1-1 00:00:00 and looks like this: time = 11.5, 35.5, 59.5, 83.5, 107.5,…
elyssac
  • 51
  • 3
3
votes
1 answer

How to add time dimension when concatenating daily TRMM netCDF files using NCO?

I downloaded daily TRMM 3B42 data for a few days from https://disc.gsfc.nasa.gov/datasets. The filenames are of the form 3B42_Daily.yyyymmdd.7.nc4.nc4 but the files do not contain any time dimension. Hence when I use ncecat to concatenate various…
A.Apte
  • 105
  • 5
3
votes
0 answers

ProjError: x, y, z, and time must be same size

How can I fix *ProjError: x, y, z, and time must be same size+ error? I was loading an .nc-file and view dataset. lat, lon are of data exchanging Basemap type. But the error message call three valuation. x, y, z. XU_OCEAN_uv =…
bigdata
  • 31
  • 1
  • 2
3
votes
0 answers

PyInstaller cftime module not found

I am beginning to work with PyInstaller to create exe file from my Python scripts, but i have problem with netCDF4 module. I am working on windows 7. The code is really simple: from netCDF4 import Dataset out = Dataset("file.nc", "w") out.GA =…
Ezecamele
  • 31
  • 4
3
votes
1 answer

matplotlib.pyplot plot_date function breaks on cftime.datetime objects

Trying to plot data using the matplotlib.pyplot.plot_date function with datetime objects originating from the netCDF4.num2date function I get the following error: In [1]: from netCDF4 import num2date In [2]: from matplotlib.pyplot import…
momme
  • 141
  • 9
3
votes
1 answer

Save np.array to netCDF4 files with Python

I am trying to save np.array outputs to netCDF4 format with Python. For example, the 2 dimensions are: longitude = [0,25,50,75], latitude = [0,15,30,45]. The variable is: Data = np.arange(16).reshape(4,4) How can I save them into a netCDF4 file,…
Jeremy
  • 849
  • 6
  • 15
3
votes
2 answers

Plotting netCDF with xarray, data not showing but legend is

I am trying to use the simple .plot() function from xarray on a netCDF file from the atmospheric composition analysis group. Say I want to plot the PM2.5 concentration from North America in 2000 available here. When I try to plot the dataset I get…
forgef
  • 41
  • 1
  • 5
3
votes
1 answer

How do I get the default fill values?

How can I get the default fill values using netcdf4-python? According to this issue one can get it via netCDF4._default_fillvals, but this gives AttributeError: module 'netCDF4' has no attribute '_default_fillvals' 1.5.0.1. The information is…
gerrit
  • 24,025
  • 17
  • 97
  • 170
3
votes
1 answer

How should I use CDO selyear? I get an output file four times larger

CDO seems to work fine for me, until I met this. I have a netcdf of daily data from year 2101 to 2228, and I want to obtain a file with only years from 2101 to 2227, so I run: cdo selyear,2101/2227 in.nc out.nc But the output file is more than four…
Pauli
  • 170
  • 3
  • 9
3
votes
3 answers

Split single monthly NetCDF file into daily averaged NetCDF multiple files using xarray

I have 1 NetCDF file for the month of September 2007. It contains 6 hourly data for certain lat/long with wind and humidity variables. Each variable is in a shape of (120, 45, 93): 120 times (4 times a day), 45 latitudes and 93 longitudes. With the…
Pramod
  • 89
  • 2
  • 7
3
votes
0 answers

Writing Dask/XArray to NetCDF - Parallel IO

I am using Dask/Xarray with a ~150 GB dataset on a distributed cluster on a HPC system. I have the computation component complete, which takes about ~30 minutes. I want to save the final result to a NETCDF4 file, but writing the data to a NETCDF…
Rowan_Gaffney
  • 452
  • 5
  • 17
3
votes
1 answer

num2date does not support 'months since...'

Hello i have a neetcdf4 file with monthly precipitation data for over 10 years. what i am trying to do is : read the file select a subset area based on longitude latitude i need to calculate the moving average per 3 years plot the…
luna
  • 31
  • 7
3
votes
1 answer

Aggregating seasonal means with the raster package in r

I am attempting to aggregate daily data (35 years) to monthly then calculate seasonal mean using the raster package in R (I know how to do it with CDO). Below is my code, which outputs 4 seasonal means for all years (140 layers). How can I loop to…
Fredrick
  • 37
  • 6
3
votes
1 answer

xarray: mean of data stored via OPeNDAP

I'm using xarray's very cool pydap back-end (http://xarray.pydata.org/en/stable/io.html#opendap) to read data stored via OPenDAP at IRI: import xarray as xr remote_data =…
Ray Bell
  • 1,508
  • 4
  • 18
  • 45
3
votes
1 answer

Writing R raster stack to NetCDF

I've got an R grid file containing monthly temperature data for the year 1981 which I read in and tried to write to NetCDF using the following code: library(raster) library(ncdf4) library(RNetCDF) test <- raster('.../TavgM_1981.gri', package =…
Pad
  • 841
  • 2
  • 17
  • 45
1 2
3
43 44