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

converting datetime.datetime object to datetime64[ns] in python for an netcdf file read with xarray module

I have an netcdf file,I read it with xarray module.I want to make a plot from it. But the problem is the datatype of my time is datetime.datetime object and I am having problem with plotting. I want to change the datatype to datetime64. I tried…
Sreeshma
  • 5
  • 2
0
votes
0 answers

Assign coordinates to Xarray dataset with no coordinates

I have a netcdf that I want to slice by coordinates, but when I open it, the dataset appears not to have any coordinates associated. It has dimmensions and lat/lon variables, but any coordinates, so it looks like this: Dimensions: …
OlegRuskiy
  • 173
  • 2
  • 12
0
votes
2 answers

Is there a way to merge 41 nc files into one file?

I have 41 nc files, all containing climate data for 41 separate years. Is there a way to merge these files together on r?
javzam
  • 1
0
votes
3 answers

xarray assign_coords does not work to set new coordinates

I have a NetCDF file and trying to use xarray to read a variable (with no attributes and coordinates) then assign new attributes and coordinates to that. Here is my python code: #--- Import packages: import numpy as np import xarray as xr #--- Read…
Soroush
  • 3
  • 3
0
votes
0 answers

Finding the average of data storage in a list of masked array

I need to take an average of a bunch of data in different netcdf files, that contain the following dimensions: TOTAL(TSTEP, LAY, ROW, COL) TSTEP is the number of days in a year. So basically i took the average of the data in a year and for each…
0
votes
1 answer

How can I make a new netcdf file in a loop in bash?

I am trying to loop over all the netcdf files in a certain directory with bash, manipulate them with NCO, and then write the result to new files, all with different names. I am thinking of something like this: for f in *.nc do ncap2 -s "vt =…
0
votes
1 answer

Merge nc files with different longitude and latitude but same timestamps

I have downloaded some ERA5 data for eastern North America at noon (12:00). This means I had to download nc-files separately to match 12:00 noon for different longitudes. Hence, between longitude -52.5 and -67.5, the timestamp is 16.00, while it is…
Thomas
  • 441
  • 3
  • 16
0
votes
0 answers

How to find nearest gridded latitude and longitude given a list of values?

I have a csv of weather stations and their corresponding latitudes and longitudes. I also have a gridded dataset of temperature trends. I want to find and create an array of the temperature trends of the grid points that most closely match the…
Megan Martin
  • 221
  • 1
  • 9
0
votes
1 answer

Not able to open netcdf file(.nc) using nc_open() function in c++

nc_open(input_file.c_str(), NC_NOWRITE , &ncid) Here the input_file is the file path. The file is opening only when the netcdf file is placed in the bin folder where the executable is present. When the netcdf file(.nc) is not placed in the bin…
0
votes
1 answer

Lat/Lon coordinate point data extraction failing to run in xarray

I have large NetCDF files (~23GB) which I extract point data from and load in as numpy arrays via xarray. In a loop, this process works perfectly - however when I try do it with a smaller single file (3.8GB), the code never finishes running. I…
Ndharwood
  • 123
  • 3
  • 11
0
votes
1 answer

How to combine more than 300 NetCDF files?

i tried combine more than 300 NetCDF files into one with Xarray. But it is running over three days and the final NetCDF file has about 5 GB. All single NetCDF files have about 1.5 GB. Can you help me how combine these NetCDF files into one with this…
0
votes
0 answers

Masking netCDF with np.where

I am not too experienced with programming and completely new to working with netCDF files and xarray. I am trying to apply a mask to some precipitation data to split it into 7 regions. Here is what the mask looks like: enter image description…
0
votes
1 answer

Empty strings created by netCDF4.stringtochar()

I am using the netCDF4.stringtochar() function before saving an N-D array of strings before exporting to a netCDF file; however, the function adds empty strings between each character. Is this a bug in the function and/or am I missing a simple fix…
BenT
  • 3,172
  • 3
  • 18
  • 38
0
votes
0 answers

Python netCDF: I accidentally wrote a unwanted variable in a netcdf file. Now a simple ds. var doesn't work anymore. What should I do?

I open the netCDF file by xarray. ds = xr.open_dataset(filename) But there's an extra variable 「u」exsited already which I think I accidentally wrote in the file.I can't remember how I did it. When I run newname = ds. var in the file, it doesn't…
0
votes
1 answer

Xarray: Dimensions or multi-index levels ['lon', 'lat'] do not exist

I'm trying to extract some climate data from a netcdf file, but I'm getting an error saying the dimensions do not exist. I've sliced netcdf files before from different model and never run into this error. The output for the dataset looks like…
Hamza Waheed
  • 139
  • 2
  • 10