netcdf

How to extract variable names from a netCDF file in R?

為{幸葍}努か 提交于 2019-12-01 03:28:34
I am writing a function in R to extract some air quality modelling data from netCDF files. I have the Package "ncdf" installed. In order to allow other users or myself to choose what variables to extract from a netCDF file, I would like to extract the names of all variables in the file, so that I can present in a simple list rather than just print.ncdf() the file to give too much information. Is there any way of doing it? I tried unlist() to the var field of the ncdf object but it seemed that it returned the contents as well... I googled and searched stack* overflow * but didn't seem to find

How to extract variable names from a netCDF file in R?

[亡魂溺海] 提交于 2019-11-30 23:18:58
问题 I am writing a function in R to extract some air quality modelling data from netCDF files. I have the Package "ncdf" installed. In order to allow other users or myself to choose what variables to extract from a netCDF file, I would like to extract the names of all variables in the file, so that I can present in a simple list rather than just print.ncdf() the file to give too much information. Is there any way of doing it? I tried unlist() to the var field of the ncdf object but it seemed that

Extract time series of a point ( lon, lat) from netCDF in R

对着背影说爱祢 提交于 2019-11-30 22:29:50
I am relatively new on R. I am trying to get time series of different points ( lat, lon) of temperature data from a netCDF file. My sample data file is here and here is the small file . I have tried netCDF package and the code i have used so far library(ncdf) obsdata = open.ncdf("obs.nc") print.ncdf(obsdata) obsdatadates = obsdata$dim$time$vals obsdatadates = as.Date(obsdatadates,origin = '1950-01-01') obsdatadates obsoutput = get.var.ncdf(obsdata, varid = 'tasmin', start = c(1,1,1), count = c(1,1,22280)) dim(obsoutput) datafinal=merge(obsdatadates,obsoutput) Can anyone help me to get a

Extract time series of a point ( lon, lat) from netCDF in R

社会主义新天地 提交于 2019-11-30 17:01:35
问题 I am relatively new on R. I am trying to get time series of different points ( lat, lon) of temperature data from a netCDF file. My sample data file is here and here is the small file . I have tried netCDF package and the code i have used so far library(ncdf) obsdata = open.ncdf("obs.nc") print.ncdf(obsdata) obsdatadates = obsdata$dim$time$vals obsdatadates = as.Date(obsdatadates,origin = '1950-01-01') obsdatadates obsoutput = get.var.ncdf(obsdata, varid = 'tasmin', start = c(1,1,1), count =

plot gebco data in python basemap

我的未来我决定 提交于 2019-11-30 16:40:20
I have downloaded some gebco bathymetry data as a netCDF file. I would like to plot it with python-basemap. I have tried, import netCDF4 from mpl_toolkits.basemap import Basemap # Load data dataset = netCDF4.Dataset('/home/david/Desktop/GEBCO/gebco_08_-30_45_5_65.nc') # Extract variables x = dataset.variables['x_range'] y = dataset.variables['y_range'] spacing = dataset.variables['spacing'] # Data limits nx = (x[-1]-x[0])/spacing[0] # num pts in x-dir ny = (y[-1]-y[0])/spacing[1] # num pts in y-dir # Reshape data zz = dataset.variables['z'] Z = zz[:].reshape(ny, nx) # setup basemap. m =

Compiling Fortran netCDF programs on Ubuntu

我的未来我决定 提交于 2019-11-30 14:56:02
Ok, newb question here. I'm trying to compile simple_xy_wr.f90 -- a netCDF example program -- using gfortran on Ubuntu, and I must be doing something pretty silly; I don't have much experince compiling Fortran. First, I've got the libnetcdf-dev package installed, which includes files like /usr/lib/libnetcdf.a /usr/lib/libnetcdff.a /usr/include/netcdf.mod So, I've tried to compile the code with (various command like) f95 -o xy -I/usr/include/ -L/usr/lib/ -lnetcdff -lnetcdf simple_xy_wr.f90 and I get the following output /tmp/ccE6g7sr.o: In function `check.1847': simple_xy_wr.f90:(.text+0x72):

Merge netCDF files in R

℡╲_俬逩灬. 提交于 2019-11-30 10:21:06
I have 2 netCDF files (each .nc file has 4 variables: Susceptible, Infected, Recovered and Inhabitable. The dimension of each variable is 64 x 88). I would like to merge these 2 files into a single netCDF file such that the merged file will stack separately Susceptible from the 2 files, Infected from the 2 files, Recovered from the 2 files and Inhabitable from the 2 files. Here are the 2 files( first and second ) Could anyone help me with this please? Thanks in advance, Ashok The ncdf4 package will do what you want to do. Have a look at the code below, example for one variable only. #install

Faster reading of time series from netCDF?

為{幸葍}努か 提交于 2019-11-30 05:17:12
I have some large netCDF files that contain 6 hourly data for the earth at 0.5 degree resolution. There are 360 latitude points, 720 longitude points, and 1420 time points per year. I have both yearly files (12 GB ea) and one file with 110 years of data (1.3 TB) stored as netCDF-4 (here is an example of the 1901 data, 1901.nc , its use policy , and the original, public files that I started with ). From what I understood, it should be faster to read from one netCDF file rather than looping over the set of files separated by year and variable originally provided . I want to extract a time series

How to visualize a map from a netcdf file?

给你一囗甜甜゛ 提交于 2019-11-29 21:13:59
问题 I have a netcdf file that I would like to just visualize the soil depth map [1] "file C:\\Users\\SoilDepth-gswp.nc has 3 dimensions:" [1] "x Size: 360" [1] "y Size: 150" [1] "land Size: 15238" [1] "------------------------" [1] "file C:\\SoilDepth-gswp.nc has 3 variables:" [1] "float nav_lon[x,y] Longname:Longitude Missval:1e+30" [1] "float nav_lat[x,y] Longname:Latitude Missval:1e+30" [1] "float SoilDepth[land] Longname:Soil depth Missval:1.00000002004088e+20" It seems that I have to connect

How to properly plot projected gridded data in ggplot2?

余生长醉 提交于 2019-11-29 21:02:13
I've been using using ggplot2 to plot climatic gridded data for years. These are usually projected NetCDF files. Cells are square in model coordinates, but depending on which projection the model uses, might not be so in the real world. My usual approach is to remap the data first on a suitable regular grid, and then plot. This introduces a small modification to the data, usually this is acceptable. However, I've decided this is not good enough anymore: I want to plot the projected data directly, without remapping, as other programs (e.g. ncl ) can, if I am not mistaken, do, without touching