Questions tagged [netcdf]

NetCDF (Network Common Data Form) is a binary file format for storing array-oriented scientific data. Use this tag for questions about programmatically encoding and/or decoding data to/from NetCDF files.

NetCDF (Network Common Data Form) is a binary file format for storing array-oriented scientific data.

From version 4, NetCDF files use the HDF5 format as container, and therefore can be read by HDF5 readers. Reliance on the HDF5 format also enabled easy parallel I/O and efficient compression.

References

2306 questions
14
votes
3 answers

Read .nc (netcdf) files using python

I am trying to learn how to read netcdf files using Python in the most easiest/fastest way. I heard that it can be done with 3 lines of code but I really don't know how. I am running the MITgcm numerical model. I'm trying to get an easy way to…
14
votes
3 answers

Is there a way to crop a NETCDF file?

Imagine that you have a file example.nc, that has wind data defined in 90N, 90S, 180E, 180W region. Is there anyway I could in linux, with a simple nc-type command (without extracting the data in matlab/python to rewrite), crop this file to include…
jhc
  • 1,739
  • 3
  • 21
  • 46
14
votes
2 answers

Handling very large netCDF files in python

I am trying to work with data from very large netCDF files (~400 Gb each). Each file has a few variables, all much larger than the system memory (e.g. 180 Gb vs 32 Gb RAM). I am trying to use numpy and netCDF4-python do some operations on these…
tiago
  • 22,602
  • 12
  • 72
  • 88
13
votes
5 answers

Install ncdf4 package: Error, nc-config not found or not executable

I have tried to install ncdf4 package. I have R version 3.1.1. The problem seems to be finding the nc-config. If I Google for this specific problem, then I find people with the same problem, who solved it by installing the Debian package…
Santiago I. Hurtado
  • 1,113
  • 1
  • 10
  • 23
13
votes
1 answer

Plotting a smooth curve in matplotlib graphs

I am reading a netcdf file using python and need to plot a graphs using matplotlib library in python. The netcdf file is containing 3 variables: u v and w components. I have to draw these 3 components on a vertical scale. Since these data is going…
user2028750
12
votes
7 answers

netcdf4 extract for subset of lat lon

I would like to extract a spatial subset of a rather large netcdf file. From Loop through netcdf files and run calculations - Python or R from pylab import * import netCDF4 f =…
user308827
  • 21,227
  • 87
  • 254
  • 417
11
votes
3 answers

HDF5 Warnings When Accessing Xarray DataSet

I'd like to understand what is causing the warning messages that I'm getting in the following scenario: In an earlier operation I've created some NetCDF files and saved them to disk using xarray.to_netcdf(). Lazy evaluation of these datasets is…
jpolly
  • 141
  • 9
11
votes
1 answer

Xarray combine_by_coords return the monotonic global index error

I am trying to combine two spatial xarray datasets using combine_by_coords. These two datasets are two tiles next to each other. So there are overlapping coordinates. In the overlapping regions, the variable values of one of the datasets is nan. I…
Ress
  • 667
  • 1
  • 7
  • 24
11
votes
1 answer

Reading file opened with Python Paramiko SFTPClient.open method is slow

I am trying to remote read a netcdf file. I used Paramiko package to read my file, like this: import paramiko from netCDF4 import Dataset client =…
Chun-Ye Lu
  • 343
  • 1
  • 2
  • 10
11
votes
5 answers

Get hourly average for each month from a netcdf file

I have a netCDF file with the time dimension containing data by the hour for 2 years. I want to average it to get an hourly average for each hour of the day for each month. I tried this: import xarray as xr ds =…
user308827
  • 21,227
  • 87
  • 254
  • 417
11
votes
1 answer

Extend dimensions in netCDF file using R

I would like to write a netCDF file using R with 'unlimited' dimensions that I can later extend. This is what I have tried: Create a netcdf file library(ncdf4) ## define lat, lon time dimensions lat <- ncdim_def("latitude", "degrees_east", vals = …
David LeBauer
  • 31,011
  • 31
  • 115
  • 189
10
votes
3 answers

How to join data from multiple netCDF files with xarray in Python?

I'm trying to open multiple netCDF files with xarray in Python. The files have data with same shape and I want to join them, creating a new dimension. I tried to use concat_dim argument for xarray.open_mfdataset(), but it doesn't work as expected.…
10
votes
2 answers

Drop duplicate times in xarray

I'm reading NetCDF files with open_mfdataset, which contain duplicate times. For each duplicate time I only want to keep the first occurrence, and drop the second (it will never occur more often). The problem is quite similar to this Pandas…
Bart
  • 9,825
  • 5
  • 47
  • 73
10
votes
1 answer

Efficient way to plot data on an irregular grid

I work with satellite data organized on an irregular two-dimensional grid whose dimensions are scanline (along track dimension) and ground pixel (across track dimension). Latitude and longitude information for each centre pixel are stored in…
stm4tt
  • 755
  • 1
  • 5
  • 22
9
votes
1 answer

Convert NetCDF (.nc) to GEOTIFF

I have .nc file sizing around 300MB with a couple of datasets (TEMP, DEWPOINT) forecast data. I need to convert (TEMP) dataset to multiple GEOTIFF (one .tif for each time slice). Here is how the .nc file looks like. Looked into this answer but it…
johnny
  • 2,032
  • 1
  • 25
  • 45