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

time and geographical subset of netcdf raster stack or raster brick using R

For the following netcdf file with daily global sea surface temperatures for 2016, I'm trying to (i) subset temporally, (ii) subset geographically, (iii) then take long-term means for each pixel and create a basic plot. Link to file:…
Peter Houk
  • 107
  • 1
  • 2
  • 6
9
votes
1 answer

Assign class PCICt to dataframe r

I have a large set of NetCDF files with historical weather data averaged by month. The time dimension unit is "Days since 1600-01-01" and uses a 360-day calendar. I used the PCICt package to correctly format the time dimension according to the…
jls
  • 224
  • 2
  • 13
9
votes
4 answers

Python : Replacing Values in netcdf file using netCDF4

I have a netcdf file with several values < 0. I would like to replace all of them with a single value (say -1). How do I do that using netCDF4? I am reading in the file like this: import netCDF4 dset =…
user308827
  • 21,227
  • 87
  • 254
  • 417
9
votes
3 answers

How to read a gzip netcdf file in python?

I have a working python program that reads in a number of large netCDF files using the Dataset command from the netCDF4 module. Here is a snippet of the relevant parts: from netCDF4 import Dataset import glob infile_root =…
eclark
  • 481
  • 5
  • 14
9
votes
1 answer

Delete a dimension in a NetCDF file

I have a netCDF file with 8 variables and 4 dimensions: latitude (dim: 26), longitude (dim:17), time (dim: a lot) and level (dim:1, pressure level). In order to use it in a specific program I need to have only 3 dimensions: latitude, longitude and…
Douie
  • 201
  • 4
  • 11
9
votes
1 answer

netcdf4-python: memory increasing with numerous calls to slice data from netcdf object

I'm trying to read data slices from a netcdf4 file using netcdf4-python. This is the first time using python and I am running into memory issues. Below is a simplified version of the code. On each iteration of the loop memory jumps by the equivalent…
user2870145
  • 126
  • 5
9
votes
4 answers

Converting NetCDF to GRIB2

I know there is software like wgrib2 that will convert files in grib and grib2 format to NetCDF files, but I need to go the other way: from NetCDF to grib2, because the local weather offices here can only consume gridded data in grib2 format. It…
Rich Signell
  • 14,842
  • 4
  • 49
  • 77
9
votes
4 answers

how to install R packages "RNetCDF" and "ncdf" on Ubuntu?

I would like to use the R packages RNetCDF and ncdf in Ubuntu. When I try install.packages('RNetCDF') or install.packages('ncdf'), I get similar errors: ... ncdf.c:3:20: fatal error: netcdf.h: No such file or directory compilation terminated. make:…
Abe
  • 12,956
  • 12
  • 51
  • 72
8
votes
1 answer

Is there a way to release the file lock for a xarray.Dataset?

I have a process that grows a NetCDF file fn every 5 minutes using netcdf4.Dataset(fn, mode=a). I also have a bokeh server visualization of that NetCDF file using a xarray.Dataset (which I want to keep, because it is so convenient). The problem is…
cchwala
  • 530
  • 4
  • 14
8
votes
2 answers

NCO: Extract a variable from NetCDF file using NCO ncks

I am trying to extract a variable from a multi-variable netcdf file, by entering the command: ncks -v ta temp1.nc out.nc However then I look at the out.nc header, all the variables are still there. The headers of both temp1.nc and out.nc are…
F. Brazil
  • 199
  • 1
  • 1
  • 10
8
votes
3 answers

convert a netcdf time variable to an R date object

I have a netcdf file with a timeseries and the time variable has the following typical metadata: double time(time) ; time:standard_name = "time" ; time:bounds = "time_bnds" ; time:units = "days since 1979-1-1…
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
8
votes
1 answer

xarray automatically applying _FillValue to coordinates on netCDF output

I'm trying to create a cf compliant netcdf file. I can get it about 98% cf compliant with xarray but there is one issue that I am running into. When I do an ncdump on the file that I am creating, I see the following: float lon(lon) ; …
naja
  • 361
  • 1
  • 3
  • 10
8
votes
0 answers

How do I disable caching when opening a netcdf file with xarray?

I am trying to set up a performance test to perform a repetitive reading of a netcdf file with different chunking configuration to finally determine the best chunk size for a certain use case. One issue that I encounter is that when reading the file…
8
votes
4 answers

Convert NetCDF file to CSV or text using Python

I'm trying to convert a netCDF file to either a CSV or text file using Python. I have read this post but I am still missing a step (I'm new to Python). It's a dataset including latitude, longitude, time and precipitation data. This is my code so…
aliki43
  • 161
  • 1
  • 2
  • 5
8
votes
1 answer

Extracting nearest lat-lon and time value from netcdf using xarray

I have a netCDF file with foll. structure: Dimensions: (latitude: 94, longitude: 192, time: 366) Coordinates: * longitude (longitude) float32 -180.0 -178.125 -176.25 -174.375 -172.5 ... * latitude (latitude) float32…
user308827
  • 21,227
  • 87
  • 254
  • 417