问题描述
我有一个全球气象数据集,我想访问某个网格(lat,lon)的数据。然而,数据被压缩,即感兴趣的参数不具有尺寸(lat,lon),而是陆地。 land是一个整数的一维数组。
我使用
$ b
<$ c在python中导入了文件$ c> import scipy.io.netcdf as netcdf
path ='/path/.../ncfile .nc'
ncfile = netcdf.netcdf_file(path,'r')
然后我检查了哪些变量,并发现,例如Rainf变量具有尺寸(tstep,land)。我在互联网上对此进行了研究,发现文件landmask_gswp.nc(),它应该包含我需要的信息,即如何从land中提取信息(lat,lon)。
该文件包含变量nav_lat,nav_lon和landmask。根据我的理解,nav_lat和nav_lon与坐标变量x和y有关的是经度和纬度。 landmask是一个二维数组,包含信息ocean = 0或land = 1。
实际上,地面点的数量与我的land一维数组的长度一致。但是,我无法弄清楚如何从中提取(lat,lon)信息。任何帮助将不胜感激。
我希望我让我的问题有点可以理解;我没有编程和/或使用netcdf的经验,所以我希望你能帮忙!提前致谢!
其他人可能会觉得这很有帮助,所以这里是问题的答案。一位朋友为我明白了这一点。
land是扁平数组nav_lat,nav_lon的索引,即land的第一个条目对应纬度:lat.flat [land [0]]和lon.flat [land [0]] 。
I have a global meteorological dataset and I want to access the data for a certain grid (lat,lon). However, the data is compressed, i.e. the parameters of interest do not have the dimensions (lat, lon), but "land". "land" is a 1D array of integers.
I imported the file in python using
import scipy.io.netcdf as netcdf
path = '/path/.../ncfile.nc'
ncfile = netcdf.netcdf_file(path,'r')
Then I checked what variables there were and found that, e.g. the "Rainf" variable has the dimensions (tstep, land). I researched this on the internet and found the file landmask_gswp.nc (http://dods.ipsl.jussieu.fr/gswp/Fixed/landmask_gswp.nc), which is supposed to contain the information I need, that is, how to extract the information (lat, lon) from "land".This file contains the variables nav_lat, nav_lon and landmask. nav_lat and nav_lon relate, to my understanding, the coordinate variables x and y to latitude and longitude. "landmask" is a 2D array and contains the information ocean = 0 or land = 1.Indeed, the number of landpoints agrees with the length of my "land" 1D array. However, I cannot figure out how to extract the (lat, lon) information from it. Any help would be much appreciated.
I hope I made my problem somewhat understandable; I am not experienced with programming and/or using netcdf, so I hope that you can help out! Thanks in advance!
Some others might find this helpful, so here's the answer to the problem. A friend figured it out for me."land" is the index of the flattened array nav_lat, nav_lon, i.e. the first entry of "land" corresponds to the latitude: lat.flat[land[0]] and lon.flat[land[0]].
这篇关于转换netcdf“land” Python中的经纬度变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!