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
2
votes
1 answer

Unable to import module 'lambda_function': No module named 'netCDF4'

I am trying to create a lambda function that uses netCDF4. Unfortunately it seems netCDF4 is not supported in AWS. Is there a way to use netCDF4 in AWS? Update: I created the zip file, however another module is missing (netCDF4._netCDF4) within the…
Arec
  • 33
  • 4
2
votes
1 answer

How can I convert my text file into netcdf file. I have observation datasets of simply one meteorological station between 1980 and 2018

I tried to convert my text file into NetCDF (nc) file with the help of the youtube link I shared here. I cannot open this nc file in GrADS. I guess the reason is that I cannot add metadata or something into nc file with these lines of codes. I…
2
votes
1 answer

MemoryError during the NetCDF4 saving via xarray

I would like to load my 499 NetCDF files by xarray and concatenate them however, it seems that I am stuck up at saving the file. Here's my code snippet: import pandas as pd import numpy as np import xarray as xr import os files_xr = [f for f in…
Lukáš Tůma
  • 350
  • 2
  • 15
2
votes
2 answers

converting Grib to netcdf4

I downloaded data from ECMWF for Era interim in grib format. Is there a way to convert a grib file with multiple bands to netCDF4, keeping the bands in the NETCDF format? I tried using the cdo operations, but the output will be only the first band…
2
votes
1 answer

Combining NetCDF files using Xarray

I am trying to combine multiple NetCDF files using xarray. Here are my dimensions: Dimensions: (Time: 1, XCells: 2000, YCells: 1000) Coordinates: longitude (YCells, XCells) float32 latitude (YCells, XCells) float32 *…
Jeanne Lane
  • 495
  • 1
  • 9
  • 26
2
votes
0 answers

Module 'netCDF4' has no 'Dataset' member

Recently I'm trying to study about netCDF4 in Python to deal with climate na data file, however, weather I tried import netCDF4 as nc or from netCDF4 import Dataframe, it just can't read the nc file I was trying to open, also the problem said module…
landy
  • 21
  • 2
2
votes
2 answers

Reading netCDF file from google cloud bucket directly into python

I have a bucket on the Google cloud that contains multiple netcdf files. Normally, when the files are stored locally, I would perform: import netCDF4 nc = netCDF4.Dataset('path/to/netcdf.nc') Is it possible to do this in python straight from the…
2
votes
5 answers

Regrid Netcdf file in python

I'm trying to regrid a NetCDF file from 0.125 degrees to 0.083-degree spatial scale. The netcdf contains 224 latitudes and 464 longitudes and it has daily data for one year. I tried xarray for it but it produces this memory error: MemoryError:…
lsr729
  • 752
  • 2
  • 11
  • 25
2
votes
1 answer

difference between netcdf4 _FillValue, missing_value, and python masked array fill_value

I have netcdf files where _FillValue and/or missing value are set in various combinations (e.g. as float, string, or not at all, and generally as -999./'-999' ). I am manipulating these files and saving them again and want to set the fill value…
Therese
  • 63
  • 1
  • 2
  • 6
2
votes
0 answers

How to read a multiple raster files from web in R?

I wanted to display in R (without downloading to my computer) .nc files from a server with free access on the internet. I used this code below, but I can't find a good command to read all the files. Can someone help me to improve my code please! url…
tazrart
  • 167
  • 1
  • 15
2
votes
0 answers

netCDF4ninstall not working with python3.8

I am trying to install the netCDF4 module to a conda environment that's using python3.8 using conda install netCDF4 but am receiving the following error: UnsatisfiableError: The following specifications were found …
reaves
  • 21
  • 3
2
votes
1 answer

Extracting values for specific lat long from netcdf

I'm trying to read into R a netCDF file. The netcdf chirps-v2.0.1981.days_p05.nc is downloaded from here: ftp://ftp.chg.ucsb.edu/pub/org/chg/products/CHIRPS-2.0/global_daily/netcdf/p05/ This netCDF file describes daily rainfall globally as a…
89_Simple
  • 3,393
  • 3
  • 39
  • 94
2
votes
1 answer

ncvar_get "cannot allocate vector of size" for netcdf4 subset no matter how small

I'm trying to extract a subset of depth data from GEBCO's global ocean bathymetry dataset, which is a 10.9gb .nc file, netcdf4 (direct link). I open a connection to the file, which doesn't load it into memory: library(ncdf4) GEBCO <-…
dez93_2000
  • 1,730
  • 2
  • 23
  • 34
2
votes
2 answers

Convert days since start of the gregorian calender to date

I am working with netCDF4 files which contain a time dimension. Values of this time dimension are doubles representing days since 1582-10-15 00:00. To allow users to interact with the data, I need to convert these timestamps into actual dates (like…
A. Osterthun
  • 175
  • 1
  • 3
  • 18
2
votes
1 answer

Compression of arrays in netcdf file

I want to be able to compress arrays stored inside a netcdf file via manipulation of the scale factor and add offsets to be applied to arrays via conversion of array data types (i.e float32 to int16) I want to make raster data which would normally…
Krios101
  • 43
  • 4