netcdf

xarray slow to save netCDF

扶醉桌前 提交于 2019-12-11 15:39:49
问题 I find xarray to be very slow to save a dataset to netCDF. I suspect the reason for this is that the .to_netcdf() command first has to load the data before saving it. For an example I get the following timings: Example a) ds.to_netcdf(file_path) # ~6 minutes Example b) ds.load() # ~6 minutes ds.to_netcdf(file_path) # <1 second It would seem the slow down comes from loading. Is there any way circumventing this load or speeding this process up? An explicit example of (a) that I am working with

Error plotting data from netcdf file “increasing x y values expected”

ぐ巨炮叔叔 提交于 2019-12-11 12:38:36
问题 I want to plot sea surface temperature data from a regular grid but can't find the proper way to do it. My data comes in nc format and can be downloaded from http://www.nodc.noaa.gov/SatelliteData/pathfinder4km/ I use this R code to access data but the problem appears when trying to plot library("ncdf") download.file("ftp://ftp.nodc.noaa.gov/pub/data.nodc/pathfinder/Version5.2/2003/20030715000715-NODC-L3C_GHRSST-SSTskin-AVHRR_Pathfinder-PFV5.2_NOAA17_G_2003196_night-v02.0-fv02.0.nc", destfile

Creating a new NetCDF from existing NetCDF file while preserving the compression of the original file

我只是一个虾纸丫 提交于 2019-12-11 09:53:07
问题 I am trying to create a new NetCDF file from an existing NetCDF file. I am only interested in using 12 variables from a list of 177 variables. You can find the sample NetCDF file from this ftp site here. I used the following code from a previous SO answer. You can find it here. import netCDF4 as nc file1 = '/media/sf_jason2/cycle_001/JA2_GPN_2PdP001_140_20080717_113355_20080717_123008.nc' file2 = '/home/sandbox/test.nc' toinclude = ['lat_20hz', 'lon_20hz', 'time_20hz', 'alt_20hz', 'ice_range

Multidimensional array into data frame

孤者浪人 提交于 2019-12-11 08:17:05
问题 The following issue in R might seem easy to many of you, but since I am relatively new to this, it would be extremely helpful if you could help me. I want to essentially write a multidimensional (3 dims) array as data frame that I can more easily manipulate. I am working with a NetCDF file of monthly Sea Surface Temperature (SST) data for the period of 01/01/1891-01/12/2015. Extracting the SST variable from the file (using the ncdf4 package) results in a multidimensional array (longitude =

converting float to byte in netcdf file

狂风中的少年 提交于 2019-12-11 06:17:18
问题 I have a large netcdf file with a standard float field which consists of only 0.0 or 1.0. I would like to convert it to a byte type from the command line to save some space and also make it easier to read in the array to a byte type in fortran. I tried to use ncap ncap -s 'fire=byte(fire)' CAMS_2003-2017_frp_mask2_africa_zip.nc test.nc but it just seems to zero all the fields. I was using zip_6 netcdf4 compression on the source file, I'm not sure if that complicates matters? UPDATE: I found

How to convert daily to monthly netcdf files

狂风中的少年 提交于 2019-12-11 06:16:21
问题 I have downloaded climate model output in the form of netcdf files with one variable (pr) for the whole world with a daily time-step. My final goal is to have monthly data for Europe. I have never used netcdf files before and all the specific software for netcdf I could find doesn't seems to work in windows. Since I programme in R, I tried using the ncdf4 package but run into memory size problems (my files are around 2Gb)... I am now trying the netCDF4 module in python (first time I am using

How to match netCDF variables' values in an array in MATLAB

时光怂恿深爱的人放手 提交于 2019-12-11 04:30:03
问题 I'm new to MATLAB and netCDF files and I think that I got stuck in an easy issue. I have a netCDF file with 5 variables: latitude, longitude, time, wind, mp2 I want to extract data in a txt file with the following format: latitude longitude time wind mp2 value value value value value value value value value value ''' value value value value value Until now I have stored the netCDF variables using ncread MATLAB command like the following: wind = ncread(filename, 'wind') long = ncread(filename,

setting values below a threshold to the threshold in a netcdf file

戏子无情 提交于 2019-12-10 23:05:43
问题 I want to set all values below a constant c to c itself in a netcdf file: file.nc A solution using climate data operators (CDO) would be cdo mul -gec,$c file.nc file.nc t1.nc cdo add -mulc,$c -ltc,$c file.nc t1.nc output.nc rm -f t1.nc But is there a neater/shorter way to do this? 回答1: You can use NCO's ncap2 to do this easily. For example, set all values of x below 100 to 100 in file.nc and output in file2.nc : >>> ncap2 -s 'where(x<100.) x=100;' file.nc -O file2.nc 回答2: ncap2's clipping

Python - Use list of points to extract data from gridded NetCDF without for loops

隐身守侯 提交于 2019-12-10 21:47:22
问题 The following example uses the "Unidata" sample netCDF dataset of eastward wind which can be downloaded from here (2.8 MB) I have two lists of integers that correspond to the x and y index of a gridded array in a netCDF file. I want to extract the data and save it to a 1 dimensional array or list for each of the point combinations (e.g. points: [(x[0],y[0]), (x[1],y[1]), (x[2],y[2]), ... , (x[n],y[n])] ). I can do this quite easily using this method... from netCDF4 import Dataset # grid point

Convert grib to netcdf file

爷,独闯天下 提交于 2019-12-10 21:27:50
问题 Is there a way to convert a grib file into a NetCDF format on Windows? I use a software named tkdegrib but it catches one argument by one argument whereas I want all my grib's arguments in the same file. Unfortunately, I can't use Linux. 回答1: I would use Unidata's NetCDF-Java library. It reads GRIB and GRIB2 files (as well as many others), and can write NetCDF files. And since it's Java, you don't have to build anything, and it works on all platforms. There is a ToolsUI application that you