【问题标题】:cross section plot using python Iris module使用 python Iris 模块的横截面图
【发布时间】:2017-05-18 18:29:30
【问题描述】:

我想使用为海洋学和气象学开发的 python Iris 模块沿经度绘制横截面,我正在使用他们的示例: http://scitools.org.uk/iris/docs/v1.4/examples/graphics/cross_section.html 我试图将他们的代码更改为我的示例,但我的代码输出为空。

数据:http://data.nodc.noaa.gov/thredds/fileServer/woa/WOA09/NetCDFdata/temperature_annual_1deg.nc

import iris
import iris.plot as iplt
import iris.quickplot as qplt

# Enable a future option, to ensure that the netcdf load works the same way
# as in future Iris versions.
iris.FUTURE.netcdf_promote = True

# Load some test data.
fname = 'temperature_annual_1deg.nc'

theta = iris.load_cube(fname, 'sea_water_temperature')
# Extract a single depth vs longitude cross-section. N.B. This could
# easily be changed to extract a specific slice, or even to loop over *all*
# cross section slices.
cross_section = next(theta.slices(['longitude',
                                   'depth']))

qplt.contourf(cross_section, coords=['longitude', 'depth'],
              cmap='RdBu_r')
iplt.show()

【问题讨论】:

标签: python contour netcdf netcdf4


【解决方案1】:

您需要了解的是,您当前的cross_section 被定义为theta.slices 迭代器的第一个成员,这意味着它从坐标的一端开始(在当前情况下为空)。所以你需要迭代到迭代器的下一个成员,直到你得到一些数据。如果将这些行添加到代码中,也许有助于理解发生了什么:

import numpy as np
cs = theta.slices(['longitude', 'depth'])
for i in cs:
    print(np.nanmax(i))

应该打印如下内容:

--
--
--
-0.8788
-0.9052

【讨论】:

    猜你喜欢
    • 2016-09-27
    • 1970-01-01
    • 2018-08-03
    • 2014-08-01
    • 1970-01-01
    • 2013-09-26
    • 2016-04-26
    • 2019-06-28
    • 2020-02-08
    相关资源
    最近更新 更多