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

NetCDF: How to extract data which crosses a boundary?

I have a NetCDF file with 4 dimensions: time, level, latitude and longitude. The shape of the data is: 1, 60, 1440, 2880 This means that there is 1 timepoint, 60 levels, 1440 latitudes and 2880 longitudes. Latitudes range from -90 to 90 and…
pookie
  • 3,796
  • 6
  • 49
  • 105
0
votes
1 answer

How can I reduce the dimension of the netCDF file and change data?

dimensions: i1 = 3 ; x = 11 ; s1 = 1 ; mid1 = 8 ; mid2 = 8 ; variables: double Height(i1,x) ; double Temp(s1, x) ; short Soil(s1, x) ; double Liq(mid1, x) ; I have a netCDF file on which I want to reduce the size…
maximusdooku
  • 5,242
  • 10
  • 54
  • 94
0
votes
1 answer

Extracting temperature from Global Land Data Assimilation System (GLDAS) netcdf4 file using python?

I extract temperature data from the netcdf4 file using python I used these code but it returns only null values. from netCDF4 import Dataset nc = Dataset("GLDAS_NOAH025_3H.A20170102.0000.021.nc4","r") for temp in nc.variables['AvgSurfT_inst'] : …
Vipul Gangwar
  • 149
  • 1
  • 1
  • 10
0
votes
1 answer

How can I reduce the dimension size in a netCDF file?

I have a netCDF file dimensions: i1 = 3 ; x = 11 ; s1 = 1 ; mid1 = 8 ; mid2 = 8 ; variables: double Height(i1,x) ; double Temp(s1, x) ; short Soil(s1, x) ; double Liq(mid1, x) ; I want to reduce the mid1 size to…
maximusdooku
  • 5,242
  • 10
  • 54
  • 94
0
votes
0 answers

Problems installing netCDF4 with Ubuntu and running script Python

I am very new to Ubuntu and Python, but I need to run a script for modeling which involves netCDF4. I am using Ubuntu 16.04 and Python 2.7, I have followed this guide of how to install it, but when I try to run my script, it tells me 'No module…
flix
  • 13
  • 4
0
votes
2 answers

IndexError: size of data array does not conform to slice

Why would I get this error only on subsequent execution of a python function? I am running a python script that converts one kind of netCDF4 file to another and does this by calling a function in a module that I wrote. The script processes several…
Marinna Martini
  • 189
  • 1
  • 13
0
votes
1 answer

Mask raster with shapefile, error in colnames

In the R Raster package, when I load a netCDF file into a raster and attempt to mask or crop the raster with a shapefile, I am getting the error: "*Error in `colnames<-`(`*tmp*`, value = names(object)) : attempt to set 'colnames' on an object…
0
votes
0 answers

Permission denied: netcdf4 python module

I have got a big problem of using the netcdf4 python module. My error is this: Traceback (most recent call last): File "convert_lmkCosmoCols.py", line 264, in ncdf_file=…
Onyxelfe
  • 1
  • 1
0
votes
2 answers

Avoid a for() loop and if in R

I have a question about avoiding a for() loop in R. I have looked at all the posts on this topic and nothing answers my question. So here goes, I have two data files one file with latitude and longitude for 60 cities (see this CSV file) and one 2D…
Ashok
  • 67
  • 1
  • 2
  • 9
0
votes
0 answers

plotting netCDF file with python: why do not visualize the contour?

I'm trying to produce a temperature colormap of a netcdf file with python. This is the first part of the code: from netCDF4 import Dataset import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap my_path =…
Mal
  • 63
  • 1
  • 9
0
votes
2 answers

Read multiple .nc files into a 3D pandas dataframe python

I would like to read in multiple SST netcdf files and from each file extract the SST data in selected lat, lon range and then store this data in a three dimensional panda dataframe. Closing each netcdf after it has been read to save memory. I would…
holto1
  • 121
  • 4
  • 10
0
votes
1 answer

Installing Hdf4 conversion tool doesn't work

Im new here as well as to install software from the source. I want to install http://www.hdfeos.org/software/h4cflib.php to convert hdf --> netcdf files. External requirements are HDF4 HDF-EOS2 libraries. So I 1st checked with dpkg -l | grep…
petze
  • 1
  • 1
0
votes
0 answers

Random behaviour in Python netCDF4.date2num function

I am generating some netCDF datasets which contain daily variables over the 21st century, with each 5 years of data is stored in a separate file. Everything goes smoothly but when I checked the time values in each file I found out that for no…
Monobakht
  • 193
  • 1
  • 11
0
votes
1 answer

Extract netCDF4 data from inside a shapefile?

In python 3.6 I have imported a netCDF4 file containing global precipitation values. I have also imported a shapefile which contains the shape for the Colorado River basin. My goal is to be able to read/extract precipitation data only within my…
CPG
  • 97
  • 2
  • 15
0
votes
1 answer

Python changing units on a basemap

I am trying to plot precipitation data, from a netCDF4 file, on a basemap using python 3.6. The code that I am using has worked perfectly on a very similar data set. The only difference being that the previous precip data was in 'cm' while the data…
CPG
  • 97
  • 2
  • 15