netcdf

HDF5 headers missing in installation of netCDF4 module for Python

对着背影说爱祢 提交于 2019-12-13 20:09:09
问题 I have attempted to install the netCDF4 module several times now and I keep getting the same error: Traceback (most recent call last): File "<string>", line 17, in <module> File "C:\Users\User\AppData\Local\Temp\pycharm-packaging0.tmp\netCDF4\setup.py", line 219, in <module> raise ValueError('did not find HDF5 headers') ValueError: did not find HDF5 headers I tried using the official HDF installer from their website and I am still getting the same error (though during the installation the

count number of missing values in netcdf file - R

主宰稳场 提交于 2019-12-13 18:15:50
问题 Is there a quick way to know how many missing values are in a netcdf file? Possibly using R. Currently I have to hum<-nc_open("rhum.sig995.2008.nc") rhum<-ncvar_get(hum, "rhum") then manually look up the missing value by typing 'hum' and copy it into this operation sum(abs(rhum - 9.96920996838687e+36) < -9.96920996838687e+36) Is there a more direct way, especially if I have to work with hundreds of files? I would like to avoid copying and pasting the missing value, and also I am not sure with

python load OpenDap to NetcdfFile

↘锁芯ラ 提交于 2019-12-13 18:02:28
问题 I am opening netcdf data from an opendap server (a subset of the data) using an URL. When I open it the data is (as far as I can see) not actually loaded until the variable is requested. I would like to save the data to a file on disk, how would I do this? I currently have: import numpy as np import netCDF4 as NC url = u'http://etc/etc/hourly?varname[0:1:10][0:1:30]' set = NC.Dataset(url) # I think data is not yet loaded here, only the "layout" varData = set.variables['varname'][:,:] # I

Drop duplicate times in xarray

左心房为你撑大大i 提交于 2019-12-13 16:31:52
问题 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 question, but none of the solutions provided there seem to work with Xarray. To reproduce the problem: import numpy as np import netCDF4 as nc4 import xarray as xr # Create example NetCDF files for t in range(2): nc = nc4.Dataset('test{}.nc'.format(t), 'w

Aggregating seasonal means with the raster package in r

给你一囗甜甜゛ 提交于 2019-12-13 14:05:24
问题 I am attempting to aggregate daily data (35 years) to monthly then calculate seasonal mean using the raster package in R (I know how to do it with CDO). Below is my code, which outputs 4 seasonal means for all years (140 layers). How can I loop to output only 4 layers ( for the 4 seasons)?. I appreciate your help. dailydata <- brick ("dailyrain.nc") dates <- seq(as.Date("1981-01-01"), as.Date("2015-12-31"), by="day") months <- format(dates, "%Y-%m") Aggregate2Monthly <- function(x) { agg <-

Get hourly average for each month from a netcdf file

五迷三道 提交于 2019-12-13 12:57:10
问题 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 = xr.open_mfdataset('ecmwf_usa_2015.nc') ds.groupby(['time.month', 'time.hour']).mean('time') but I get this error: *** TypeError: `group` must be an xarray.DataArray or the name of an xarray variable or dimension How can I fix this? If I do this: ds.groupby('time.month', 'time.hour')

Problems plotting Netcdf files in Panoply

雨燕双飞 提交于 2019-12-13 08:38:27
问题 I can't create plot from .nc files using Panoply. The error message reads: "Axis contains NaN". Is there a workaround ? 回答1: Change the NaNs to normal "missing values", then use Panoply. The netCDF Operator (NCO) command ncatted works with NaNs. First set the missing value (i.e., the value of the _FillValue attribute) for the variable(s) in question to the IEEE NaN value: ncatted -a _FillValue,,o,f,NaN in.nc Then change the missing value from the IEEE NaN value to a normal IEEE number, like 1

\[Errno -101\] NetCDF: HDF error when opening netcdf file

狂风中的少年 提交于 2019-12-13 02:00:48
问题 I have this error when opening my netcdf file. The code was working before. How do I fix this ? Traceback (most recent call last): File "", line 1, in ... File "file.py", line 71, in gather_vgt return xr.open_dataset(filename) File "/.../lib/python3.6/site-packages/xarray/backends/api.py", line 286, in open_dataset autoclose=autoclose) File "/.../lib/python3.6/site-packages/xarray/backends/netCDF4_.py", line 275, in open ds = opener() File "/.../lib/python3.6/site-packages/xarray/backends

editing a netcdf variable

浪子不回头ぞ 提交于 2019-12-13 00:48:19
问题 I have a 3 dimensional variable my_var within a netcdf (original.nc) file (150x100x20000). I want to convert all of the elements within this variable from Celsius to Kelvin and then rewrite the variable's new values in a copy (test.nc) of the original file. %make a copy of the file I’m editing (so I can write the new values to it later copyfile('original.nc','test.nc'); %gets the attributes of the file fileattrib('test.nc','+w'); %get id and opens the file for editing ncid=netcdf.open('test

NCO: Extract a variable from NetCDF file using NCO ncks

坚强是说给别人听的谎言 提交于 2019-12-12 14:06:36
问题 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 below: --- temp1.nc header --- dimensions: time = UNLIMITED ; // (124 currently) lon = 256 ; bnds = 2 ; lat = 128 ; lev = 40 ; variables: double time(time) ; time:standard_name = "time" ; time:long_name = "time" ; time:units = "days since 1850-1-1" ; time