我有一个netcdf文件,我想只是想象土壤深度图
[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"
Run Code Online (Sandbox Code Playgroud)
似乎我必须将纬度与经度以及地面点连接起来以获得土壤深度的地图.我真的很困惑.任何人都可以帮助我处理这类数据.
我正在尝试使用netcdf库和g ++静态链接一个非常简单的程序。该程序如下所示:
#include "netcdf.h"
int main(void)
{
int ncid, ok;
ok=nc_create("testing.nc", NC_NOCLOBBER, &ncid);
ok=nc_close(ncid);
return(0);
}
Run Code Online (Sandbox Code Playgroud)
如果我像这样编译它,效果很好:
> g++ test.cpp -lnetcdf
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试静态编译它,那么一切都会中断:
> g++ -static test.cpp -lnetcdf
/usr/lib64/libnetcdf.a(nc4file.o): In function `sync_netcdf4_file':
(.text+0x5a): undefined reference to `H5Fflush'
/usr/lib64/libnetcdf.a(nc4file.o): In function `close_netcdf4_file':
(.text+0x11b): undefined reference to `H5Fclose'
/usr/lib64/libnetcdf.a(nc4file.o): In function `get_netcdf_type':
(.text+0x18b): undefined reference to `H5Tget_class'
/usr/lib64/libnetcdf.a(nc4file.o): In function `get_netcdf_type':
(.text+0x1e9): undefined reference to `H5Tis_variable_str'
(...)
Run Code Online (Sandbox Code Playgroud)
许多抱怨,但第一个是针对hdf5。在寻找答案时,我在 unidata上找到了该页面,该页面解释了应该与hdf5和其他库链接的地方。所以我尝试了:
> g++ -static test.cpp -lnetcdf -lhdf5_hl -lhdf5 -lz -lm
/usr/lib64/libnetcdf.a(liboc_la-ocinternal.o): In …Run Code Online (Sandbox Code Playgroud) 我正在尝试在OS X上安装netCDF4 pip install netCDF4,我收到以下错误:
------------------------------------------------------------
/usr/local/bin/pip run on Wed Aug 7 23:02:37 2013
Downloading/unpacking netCDF4
Running setup.py egg_info for package netCDF4
HDF5_DIR environment variable not set, checking some standard locations ..
checking /Users/mc ...
checking /usr/local ...
checking /sw ...
checking /opt ...
checking /opt/local ...
checking /usr ...
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip-build/netCDF4/setup.py", line 114, in <module>
raise ValueError('did not find HDF5 headers')
ValueError: did not find HDF5 headers …Run Code Online (Sandbox Code Playgroud) 我是相对较新的R.我正在尝试从netCDF文件中获取温度数据的不同点(lat,lon)的时间序列.我的示例数据文件在这里,这里是小文件.我已经尝试过netCDF包和我到目前为止使用的代码
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)
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我获取该数据的特定点(lat,lon)的时间序列数据帧(第一列)和另一个数据值.在这种情况下,我正在寻找特定纬度点(并重复多个兴趣点)和给定变量(在这种情况下)的时间序列(1950-01-01至2010-12-31,其中数据为) tasmin).非常感谢您的帮助.谢谢,拜访
我想提取一个相当大的netcdf文件的空间子集.从Loop到netcdf文件并运行计算 - Python或R.
from pylab import *
import netCDF4
f = netCDF4.MFDataset('/usgs/data2/rsignell/models/ncep/narr/air.2m.1989.nc')
# print variables
f.variables.keys()
atemp = f.variables['air'] # TODO: extract spatial subset
Run Code Online (Sandbox Code Playgroud)
如何仅提取对应于状态(例如爱荷华州)的netcdf文件的子集.爱荷华州有以下边界拉特隆:
经度:89°5'W至96°31'W
纬度:40°36'N至43°30'N
如何确定我的系统中安装了哪个版本的netcdf库?有命令行吗?我试图搜索"netcdf",我找到了一堆文件,但我无法确定版本号.是否有命令检查安装的任何版本?
我在ubuntu上
我正在编写一个使用Microsoft Scientific Data-Set读取NetCDF文件的C#程序.
using System;
using System.IO;
using sds = Microsoft.Research.Science.Data;
using Microsoft.Research.Science.Data.Imperative;
namespace NetCDFConsoleApp
{
class Program
{
static void Main(string[] args)
{
// Gets dataset from file.
var dataset = sds.DataSet.Open("E:\\Temp\\test.nc?openMode=readOnly");
// Get the starting DateTime from the meta data.
string dt = (string)dataset.Metadata["START_DATE"];
//load dataset into array
Single[,,] dataValues = dataset.GetData<float[,,]>("ACPR");
//Get DateTime from Metadata fields.
DateTime dt2 = DateTime.ParseExact(dt, "yyyy-MM-dd_HH:mm:ss", null);
// Latitude grid ranges from = 0 to 215; East Cape is ~ 125-144
for …Run Code Online (Sandbox Code Playgroud) 有没有办法使用xarray创建时间维度超过2263年的netCDF文件?
以下是如何创建netCDF玩具数据集http://xarray.pydata.org/en/stable/time-series.html
但是,时间维度有一种pandas日期时间索引,并且不会超出2263,如下所示:https: //github.com/pandas-dev/pandas/issues/13346
以每月的温度数据多年的光栅文件,它具有通过连接访问的名称names(object)按以下格式"Jan.1981",两年与下面的代码工作"Feb.1981"等(例如文件位置 -添加的所有文件太大了
使用以下代码读入并写入NetCDF:
#Load Packages
library(raster)
library(ncdf4)
#Read in temperature files
r1 <- brick('TavgM_1981.grd')
r2 <- brick('TavgM_1982.grd')
#stack them together
TempStack = stack(r1, r2)
#set the coordinate system (as it was missing)
crs(TempStack) <- ('+proj=lcc +lat_1=53.5 +lat_2=53.5 +lat_0=46.834 +lon_0=5 +x_0=1488375 +y_0=-203375 +datum=WGS84 +to_meter=2500 +no_defs +ellps=WGS84 +towgs84=0,0,0')
#reproject to get in lat/lon instead of meters
TempStack<-projectRaster(TempStack, crs=CRS("+init=epsg:4326"))
#Extract monthly data names to assign to netCDf later
names <- names(TempStack)
#write the raster file to NetCDF
writeRaster(TempStack, "Temp.nc", overwrite=TRUE, …Run Code Online (Sandbox Code Playgroud) 我有一个用于海洋温度的NetCDF文件。它具有1个变量(“温度”)和4个维度(时间,经度,纬度和深度)。我只想提取每个时间,经度和纬度的最大深度的温度,以获得底海温度栅格砖。我愿意使用R或在终端中使用Climate Data Operators。
NetCDF文件的属性
nc_open('data.pre1980.nc')
File data.pre1980.nc (NC_FORMAT_CLASSIC):
1 variables (excluding dimension variables):
float temp[lon,lat,depth,time]
standard_name: sea_water_temperature
long_name: TEMPERATURE
units: Celsius_scale
_FillValue: -9.98999971057742e+33
missing_value: -9.98999971057742e+33
pointwidth: 1
4 dimensions:
time Size:324 *** is unlimited ***
standard_name: time
units: months since 1960-01-01
calendar: 360_day
axis: T
lon Size:440
standard_name: longitude
long_name: longitude
units: degree_east
axis: X
lat Size:179
standard_name: latitude
long_name: latitude
units: degree_north
axis: Y
depth Size:40
units: meters
axis: Z
gridtype: 0
4 global attributes:
CDI: Climate Data Interface …Run Code Online (Sandbox Code Playgroud)