CATTOPY-绘图2D Geodata作为2D经度和纬度的函数

发布于 2025-02-08 17:17:58 字数 2347 浏览 2 评论 0 原文

我想从以下NetCDF文件( R90C_20P_MSG_201403250100.NC )绘制2D数组 rfnet rfnet 作为TEH 2D数组的函数>纬度。

下载NetCDF文件: 或这里

我尝试了以下操作:

import xarray as xr
data = xr.open_dataset('R90C_20P_MSG_201403250100.nc', engine='netcdf4')
print(data)

哪个给出:

<xarray.Dataset>
Dimensions:    (image_y: 565, image_x: 1215)
Dimensions without coordinates: image_y, image_x
Data variables: (12/15)
    LONGITUDE  (image_y, image_x) float32 ...
    LATITUDE   (image_y, image_x) float32 ...
    TAUCO      (image_y, image_x) float32 ...
    RFLW       (image_y, image_x) float32 ...
    RFSW       (image_y, image_x) float32 ...
    TAUCI      (image_y, image_x) float32 ...
    ...         ...
    OLRCICO    (image_y, image_x) float32 ...
    RSRCICO    (image_y, image_x) float32 ...
    RFnet      (image_y, image_x) float32 ...
    ATD        (image_y, image_x) float32 ...
    FUEL       (image_y, image_x) float32 ...
    PC         (image_y, image_x) float32 ...

我可以提取Eg:我可以提取Eg:

LONGITUDE=data['LONGITUDE']
LATITUDE=data['LATITUDE']
RFnet=data['RFnet']

并使用一个简单的绘图访问相应的数据

LONGITUDE.data
LATITUDE.data
RFnet.data

是:

import matplotlib.pyplot as plt

fig = plt.figure(figsize=(8, 4))

ax = fig.add_subplot(111)
img=plt.imshow(RFnet.data, cmap='seismic', vmin=-10, vmax=10)
ax.set_aspect('equal')

cbar = fig.colorbar(img, location='bottom', shrink=0.6, pad=0.15, ax=ax)
cbar.set_label('RFnet')

plt.show()

​我可以将 rfnet 绘制为经度 latitude

纬度和经度的函数:

I would like to plot from the following netcdf file (R90C_20P_MSG_201403250100.nc) the 2d array RFnet as function of teh 2d arrays LONGITUDE and LATITUDE.

Download of netcdf file:
https://gigamove.rwth-aachen.de/de/download/fa5c22f8009f2af3f2c59b5d92ceea7f
or here https://drive.google.com/file/d/17s2XtzS6P6rvT_ceJLnH_dN_9A1S8ViR/view?usp=sharing

I tried the following:

import xarray as xr
data = xr.open_dataset('R90C_20P_MSG_201403250100.nc', engine='netcdf4')
print(data)

which give as output:

<xarray.Dataset>
Dimensions:    (image_y: 565, image_x: 1215)
Dimensions without coordinates: image_y, image_x
Data variables: (12/15)
    LONGITUDE  (image_y, image_x) float32 ...
    LATITUDE   (image_y, image_x) float32 ...
    TAUCO      (image_y, image_x) float32 ...
    RFLW       (image_y, image_x) float32 ...
    RFSW       (image_y, image_x) float32 ...
    TAUCI      (image_y, image_x) float32 ...
    ...         ...
    OLRCICO    (image_y, image_x) float32 ...
    RSRCICO    (image_y, image_x) float32 ...
    RFnet      (image_y, image_x) float32 ...
    ATD        (image_y, image_x) float32 ...
    FUEL       (image_y, image_x) float32 ...
    PC         (image_y, image_x) float32 ...

I can extract e.g.:

LONGITUDE=data['LONGITUDE']
LATITUDE=data['LATITUDE']
RFnet=data['RFnet']

and access the corresponding data with

LONGITUDE.data
LATITUDE.data
RFnet.data

A simple plot would be:

import matplotlib.pyplot as plt

fig = plt.figure(figsize=(8, 4))

ax = fig.add_subplot(111)
img=plt.imshow(RFnet.data, cmap='seismic', vmin=-10, vmax=10)
ax.set_aspect('equal')

cbar = fig.colorbar(img, location='bottom', shrink=0.6, pad=0.15, ax=ax)
cbar.set_label('RFnet')

plt.show()

enter image description here

How can I plot RFnet as function of LONGITUDE and LATITUDE?

LATITUDE AND LONGITUDE ARE 2d ARRAYS:

enter image description here
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷弦 2025-02-15 17:17:58
fig = plt.figure(figsize=(12, 12))
pc = ccrs.PlateCarree()
ax = fig.add_subplot(projection=pc, extent=(-55.530094, 55.530094, 33.582264, 66.823235))

ax.set_global()
ax.coastlines(resolution='50m', # alternative: '110m', '50m', '10m' 
              color='grey')
ax.gridlines(draw_labels=True) 

x = LONGITUDE.data
y = LATITUDE.data
c = RFnet.data
norm=mcolors.Normalize(vmin=-10, vmax=10)
cmap = "seismic"

ax.set_extent(extents=(-20, 20, 32, 52)) # x0, x1, y0, y1 in degrees

im = ax.scatter(x, y, c=c, cmap=cmap, norm=norm, s=2)

cbar = fig.colorbar(im, location='bottom', shrink=1, pad=0.05, ax=ax)
cbar.set_label('RFnet')

plt.show()

fig = plt.figure(figsize=(12, 12))
pc = ccrs.PlateCarree()
ax = fig.add_subplot(projection=pc, extent=(-55.530094, 55.530094, 33.582264, 66.823235))

ax.set_global()
ax.coastlines(resolution='50m', # alternative: '110m', '50m', '10m' 
              color='grey')
ax.gridlines(draw_labels=True) 

x = LONGITUDE.data
y = LATITUDE.data
c = RFnet.data
norm=mcolors.Normalize(vmin=-10, vmax=10)
cmap = "seismic"

ax.set_extent(extents=(-20, 20, 32, 52)) # x0, x1, y0, y1 in degrees

im = ax.scatter(x, y, c=c, cmap=cmap, norm=norm, s=2)

cbar = fig.colorbar(im, location='bottom', shrink=1, pad=0.05, ax=ax)
cbar.set_label('RFnet')

plt.show()

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文