netcdf

Plot NetCDF variable-grid data file using ggplot2: “Vector is too large” error

点点圈 提交于 2019-12-03 21:53:41
I need to plot some data from this NetCDF file (1.1MB). The file contains a 413x229 grid (94577 points). Every point has a precipitation value which I need to print in the correct LAT-LON. The grid is not necessarily constant, so that we have two additional 413x229 variables (xlat and xlon) containing the lat-lon values for each grid point. Thanks to the hints from these questions... How to plot contours on a map with ggplot2 when data is on an irregular grid? R - Plotting netcdf climate data Plotting netcdf in R with correct grid How to plot latitude/longitude points over netcdf map Plotting

R: Write RasterStack and preserve layer names

不羁岁月 提交于 2019-12-03 08:52:12
问题 I have a raster stack, stk , consisting of three raster images in R. Here is a simple example # set up a raster stack with three layers > library(raster) > r <- raster(nrows=10,ncols=10) > r[] <- rnorm(100) > stk <- stack(r,r,r) # layer names are set by default > names(stk) [1] "layer.1" "layer.2" "layer.3" I assign names to the raster layers: # set layer names to "one", "two" and "three" > names(stk) <- c('one','two','three') > names(stk) [1] "one" "two" "three" When I write the RasterStack

NetCDF to Raster Brick “Unable to find inherited method for function &#039;brick&#039; for &#039;ncdf4&#039;”

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Really simple problem with the raster package, also using ncdf4 to load in an ECMWF Era-Interim Netcdf file. Simply doing this: a <- nc_open("SSTs.nc") B <- brick(a, varname="sst") Returns this: Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘brick’ for signature ‘"ncdf4"’ The file is just SST data over the whole globe, for 1 month (Jan2016). When I convert it into an array (i.e. extract dimensions/variable, and convert time to UTC, shove it into an array) I don't get the same error, but the

Creating a nested dictionary from a flattened dictionary

旧城冷巷雨未停 提交于 2019-12-03 08:06:11
问题 I have a flattened dictionary which I want to make into a nested one, of the form flat = {'X_a_one': 10, 'X_a_two': 20, 'X_b_one': 10, 'X_b_two': 20, 'Y_a_one': 10, 'Y_a_two': 20, 'Y_b_one': 10, 'Y_b_two': 20} I want to convert it to the form nested = {'X': {'a': {'one': 10, 'two': 20}, 'b': {'one': 10, 'two': 20}}, 'Y': {'a': {'one': 10, 'two': 20}, 'b': {'one': 10, 'two': 20}}} The structure of the flat dictionary is such that there should not be any problems with ambiguities. I want it to

How to take a subset from a netCDF file using latitude/longitude boundaries in R

ぃ、小莉子 提交于 2019-12-03 06:14:55
I have a netCDF file that I wish to extract a subset from defined by latitude/longitude boundaries (i.e. a lat/long defined box), using the ‘ncdf’ package in R. A summary of my netCDF file is below. It has two dimensions (latitude and longitude) and 1 variable (10U_GDS4_SFC). It is essentially a lat/long grid containing wind values: [1] "file example.nc has 2 dimensions:" [1] "lat_0 Size: 1280" [1] "lon_1 Size: 2560" [1] "------------------------" [1] "file example.nc has 1 variables:" [1] "float 10U_GDS4_SFC[lon_1,lat_0] Longname:10 metre U wind component Missval:1e+30" The latitude variable

Efficient way to plot data on an irregular grid

风格不统一 提交于 2019-12-03 06:14:43
I work with satellite data organized on an irregular two-dimensional grid whose dimensions are scanline (along track dimension) and ground pixel (across track dimension). Latitude and longitude information for each centre pixel are stored in auxiliary coordinate variables, as well as the four corners coordinate pairs (latitude and longitude coordinates are given on the WGS84 reference ellipsoid). The data is stored in netCDF4 files. What I am trying to do is efficiently plotting these files (and possibly a combination of files—next step!) on a projected map. My approach so far, inspired by

Loop through netcdf files and run calculations - Python or R

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is my first time using netCDF and I'm trying to wrap my head around working with it. I have multiple version 3 netcdf files (NOAA NARR air.2m daily averages for an entire year). Each file spans a year between 1979 - 2012. They are 349 x 277 grids with approximately a 32km resolution. Data was downloaded from here . The dimension is time (hours since 1/1/1800) and my variable of interest is air. I need to calculate accumulated days with a temperature Day 1 = +4 degrees, accumulated days = 0 Day 2 = -1 degrees, accumulated days = 1 Day 3

Loop through netcdf files and run calculations - Python or R

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is my first time using netCDF and I'm trying to wrap my head around working with it. I have multiple version 3 netcdf files (NOAA NARR air.2m daily averages for an entire year). Each file spans a year between 1979 - 2012. They are 349 x 277 grids with approximately a 32km resolution. Data was downloaded from here . The dimension is time (hours since 1/1/1800) and my variable of interest is air. I need to calculate accumulated days with a temperature Day 1 = +4 degrees, accumulated days = 0 Day 2 = -1 degrees, accumulated days = 1 Day 3

Opinions on NetCDF vs HDF5 for storing scientific data?

ぃ、小莉子 提交于 2019-12-03 01:00:39
问题 Anyone out there have enough experience w/ NetCDF and HDF5 to give some pluses / minuses about them as a way of storing scientific data? I've used HDF5 and would like to read/write via Java but the interface is essentially a wrapper around the C libraries, which I have found confusing, so NetCDF seems intriguing but I know almost nothing about it. edit: my application is "only" for datalogging, so that I get a file that has a self-describing format. Important features for me are being able to

Writing R raster stack to NetCDF

匿名 (未验证) 提交于 2019-12-03 00:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 file , but it only seems to have one month