简体   繁体   English

如何在 nc 文件的 xarray 中重塑经度数据

[英]How do I reshape longitude data in an xarray of nc files

The current format of the longitude data is in the form (0,360) as shown in the picture.经度数据的当前格式为(0,360)形式,如图所示。 I want to get it to be (-180,180) where (-180,0) is equal to (180,360).我想让它成为(-180,180),其中(-180,0)等于(180,360)。

代码图像

Assuming you have a column of longitude data (it's hard to tell from your sample), something like this should work:假设您有一列经度数据(很难从您的样本中看出),这样的事情应该可以工作:

pick = pd['longitude']>180
pd.loc[pick,'longitude'] = pd.loc[pick,'longitude'] - 360

The first line chooses the rows where longitude needs adjusting.第一行选择需要调整经度的行。 The second line does the math for only those rows.第二行仅对这些行进行数学运算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM