如何从NETCDF文件中创建横截面海洋档案?

发布于 2025-02-12 20:14:06 字数 837 浏览 0 评论 0原文

我想沿着海岸线的横断面创建一个3D(长,深度,氧)的横截面。例如,类似于使用Metpy软件包,但是我似乎无法使XY数据工作,并且我正在使用海洋数据而不是大气数据。

我已经尝试了以下(理论上使用Metpy软件包,我需要使用Metpy软件包):

df="F:/L3_prog_ControlRun201808_ocean_avg.nc" #my dataset
ds=xr.open_dataset(df,engine='netcdf4') 
ds['lon_rho']=ds['lon_rho']-360 #to make the longitude in degrees East

data = ds['oxygen'].metpy.assign_crs({
    "grid_mapping_name": "mercator",
    "latitude_of_projection_origin":43,
    "longitude_of_central_meridian":-66,
    "standard_parallel":0,
    "false_easting":360
}).metpy.assign_y_x()
#this does not create x,y coordinates for some reason

#If the above had worked, I would like to create a cross-section on the transect between:
start=(43.5, -65)
end=(44.5,-63.8)

#using:
cross = cross_section(data, start, end).set_coords(('lat_rho', 'lon_rho'))
print(cross)

I would like to create a cross-section of 3D (long, depth, oxygen) along a transect that follows a coastline. E.g. similar to using the MetPy package, however I cannot seem to get the x-y data to work, and I am working with ocean data rather than atmospheric data.

I have tried the following (using the MetPy package as it theoretically does what I need):

df="F:/L3_prog_ControlRun201808_ocean_avg.nc" #my dataset
ds=xr.open_dataset(df,engine='netcdf4') 
ds['lon_rho']=ds['lon_rho']-360 #to make the longitude in degrees East

data = ds['oxygen'].metpy.assign_crs({
    "grid_mapping_name": "mercator",
    "latitude_of_projection_origin":43,
    "longitude_of_central_meridian":-66,
    "standard_parallel":0,
    "false_easting":360
}).metpy.assign_y_x()
#this does not create x,y coordinates for some reason

#If the above had worked, I would like to create a cross-section on the transect between:
start=(43.5, -65)
end=(44.5,-63.8)

#using:
cross = cross_section(data, start, end).set_coords(('lat_rho', 'lon_rho'))
print(cross)

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文