netcdf4

Extracting site-specific information from NetCDF file in R

99封情书 提交于 2019-12-12 03:37:31
问题 I got a NetCDF file from the German Meteorological Service concerning mean temperatures in Europe (CDC FDP SERVER). The only thing I want to extract is the daily mean temperature for Bornholm, which is an island in the central Baltic. I know how to extract information for certain coordinates (see code sample below). The only problem is that the file specific coordinates are 'rotated' which is why the geographic coordinates for Bornholm (extracted from GoogleMaps) are kind of useless. packages

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

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

Error on using xarray open_mfdataset function

爱⌒轻易说出口 提交于 2019-12-10 10:37:18
问题 I am trying to combine multiple netCDF files with the same dimensions, their dimensions are as follows: OrderedDict([(u'lat', <type 'netCDF4._netCDF4.Dimension'>: name = 'lat', size = 720 ), (u'lon', <type 'netCDF4._netCDF4.Dimension'>: name = 'lon', size = 1440 ), (u'time', <type 'netCDF4._netCDF4.Dimension'>: name = 'time', size = 96 ), (u'nv', <type 'netCDF4._netCDF4.Dimension'>: name = 'nv', size = 2 )]) OrderedDict([(u'lat', <type 'netCDF4._netCDF4.Dimension'>: name = 'lat', size = 720 )

Writing R raster stack to NetCDF

北城以北 提交于 2019-12-08 09:18:09
问题 I've got an R grid file containing monthly temperature data for the year 1981 which I read in and tried to write to NetCDF using the following code: library(raster) library(ncdf4) library(RNetCDF) test <- raster('.../TavgM_1981.gri', package = "raster") rstack = stack(test) writeRaster(rstack, "rstack.nc", overwrite=TRUE, format="CDF", varname="Temperature", varunit="degC", longname="Temperature -- raster stack to netCDF", xname="X", yname="Y",zname="nbands", zunit="numeric") This writes the

NetCDF: How to mask/filter out non-land values in global dataset, preferably using Python and/or NCO?

*爱你&永不变心* 提交于 2019-12-07 22:56:41
问题 I have a global data at 0.25 degree resolution that I'd like to mask so that it only contains data values over land. The data covers full 360 degrees in the lon dimension and from -60 to 60 degrees in the lat dimension. The file header, as well as summary lat and lon coordinate values, are listed below: netcdf cmorph_global_daily { dimensions: lat = UNLIMITED ; // (480 currently) lon = 1440 ; time = 7305 ; variables: float lat(lat) ; lat:units = "degrees_north" ; lat:long_name = "Latitude" ;

Only positive latitude and longitude when importing netcdf in R from paleoView probably wrong projection

不打扰是莪最后的温柔 提交于 2019-12-06 11:13:56
I used the paleoview software to download some variables from past climate, including the mean temperature from 15000BP-10000BP (I could upload a file on request but its a GB at least). The main problem is that when I read the raster, it contains only positive latitude and positive longitude. I know from the article that this has a 2.5*2.5 resolution. Using Raster I loaded both the raster and ncdf4 libraries to read it using raster library(raster) library(ncdf4) When I read it using the following code r <- raster("mean_temperature-15000BP-10000BP.nc", varname = "14000BP-13000BP/13300BP") I get

Error on using xarray open_mfdataset function

雨燕双飞 提交于 2019-12-06 09:23:06
I am trying to combine multiple netCDF files with the same dimensions, their dimensions are as follows: OrderedDict([(u'lat', <type 'netCDF4._netCDF4.Dimension'>: name = 'lat', size = 720 ), (u'lon', <type 'netCDF4._netCDF4.Dimension'>: name = 'lon', size = 1440 ), (u'time', <type 'netCDF4._netCDF4.Dimension'>: name = 'time', size = 96 ), (u'nv', <type 'netCDF4._netCDF4.Dimension'>: name = 'nv', size = 2 )]) OrderedDict([(u'lat', <type 'netCDF4._netCDF4.Dimension'>: name = 'lat', size = 720 ), (u'lon', <type 'netCDF4._netCDF4.Dimension'>: name = 'lon', size = 1440 ), (u'time', <type 'netCDF4.

NetCDF: How to mask/filter out non-land values in global dataset, preferably using Python and/or NCO?

陌路散爱 提交于 2019-12-06 08:02:33
I have a global data at 0.25 degree resolution that I'd like to mask so that it only contains data values over land. The data covers full 360 degrees in the lon dimension and from -60 to 60 degrees in the lat dimension. The file header, as well as summary lat and lon coordinate values, are listed below: netcdf cmorph_global_daily { dimensions: lat = UNLIMITED ; // (480 currently) lon = 1440 ; time = 7305 ; variables: float lat(lat) ; lat:units = "degrees_north" ; lat:long_name = "Latitude" ; float lon(lon) ; lon:units = "degrees_east" ; lon:long_name = "Longitude" ; float prcp(lat, lon, time)

Python: How to use MFdataset in netCDF4

人盡茶涼 提交于 2019-12-04 21:16:05
I am trying to read multiple NetCDF files and my code returns the error: ValueError: MFNetCDF4 only works with NETCDF3_* and NETCDF4_CLASSIC formatted files, not NETCDF4. I looked up the documentation and MFdataset is not supported by NetCDF4, so I'm confused where to go from here. I think the error is pretty clear, but there are ways to avoid it. 1/ You could convert the NetCDF files from NetCDF4 to the classic format using e.g. nccopy : nccopy -k classic nc4_file.nc ncclassic_file.nc 2/ xarray has a similar method (called open_mfdataset ) which is able to handle NetCDF4 files. A quick test: