如何提取给定经度/纬度的 NetCDF 每月总计?
我已经下载了一个NetCDF文件,该文件包含塞拉利昂(Sierra Leone)每月降雨的总和。
我想在一年中提取一组特定坐标的每月总和的时间序列,因此我希望总共有12个值。这是我尝试的。
ds = xr.open_dataset('era_monthly_yr2018.nc')*1000
lon_freetown = -13
lat_freetown = 8
df = ds.sel(latitude=(lat_freetown), longitude=(lon_freetown), method='nearest').to_dataframe()
df = df.drop('longitude',1)
df = df.drop('latitude',1)
df1 = df.reset_index()
print(df)
longitude latitude tp
time
2018-01-01 -13.0 8.0 0.096221
2018-02-01 -13.0 8.0 0.043679
2018-03-01 -13.0 8.0 0.875490
2018-04-01 -13.0 8.0 1.571830
2018-05-01 -13.0 8.0 4.642695
2018-06-01 -13.0 8.0 24.877733
2018-07-01 -13.0 8.0 21.150408
2018-08-01 -13.0 8.0 14.919422
2018-09-01 -13.0 8.0 22.914684
2018-10-01 -13.0 8.0 5.977770
2018-11-01 -13.0 8.0 3.168352
2018-12-01 -13.0 8.0 0.894481
print(df1)
time tp
0 2018-01-01 0.096221
1 2018-02-01 0.043679
2 2018-03-01 0.875490
3 2018-04-01 1.571830
4 2018-05-01 4.642695
5 2018-06-01 24.877733
6 2018-07-01 21.150408
7 2018-08-01 14.919422
8 2018-09-01 22.914684
9 2018-10-01 5.977770
10 2018-11-01 3.168352
11 2018-12-01 0.894481
但是,我得到的结果不是我期望的。降雨远低于预期,这使我认为自己做错了什么。
有没有人以前使用过每月的NETCDF文件并知道我可能出错的地方?另外,我有一个小时格式的相同数据,但无法弄清楚我如何从中获得每月总和
I've downloaded a NetCDF file that contains monthly summed totals of rainfall over Sierra Leone.
I want to extract a time series of these monthly sums for a specific set of coordinates over the year period, so I'm expecting to have 12 values in total. Here's what I've tried.
ds = xr.open_dataset('era_monthly_yr2018.nc')*1000
lon_freetown = -13
lat_freetown = 8
df = ds.sel(latitude=(lat_freetown), longitude=(lon_freetown), method='nearest').to_dataframe()
df = df.drop('longitude',1)
df = df.drop('latitude',1)
df1 = df.reset_index()
print(df)
longitude latitude tp
time
2018-01-01 -13.0 8.0 0.096221
2018-02-01 -13.0 8.0 0.043679
2018-03-01 -13.0 8.0 0.875490
2018-04-01 -13.0 8.0 1.571830
2018-05-01 -13.0 8.0 4.642695
2018-06-01 -13.0 8.0 24.877733
2018-07-01 -13.0 8.0 21.150408
2018-08-01 -13.0 8.0 14.919422
2018-09-01 -13.0 8.0 22.914684
2018-10-01 -13.0 8.0 5.977770
2018-11-01 -13.0 8.0 3.168352
2018-12-01 -13.0 8.0 0.894481
print(df1)
time tp
0 2018-01-01 0.096221
1 2018-02-01 0.043679
2 2018-03-01 0.875490
3 2018-04-01 1.571830
4 2018-05-01 4.642695
5 2018-06-01 24.877733
6 2018-07-01 21.150408
7 2018-08-01 14.919422
8 2018-09-01 22.914684
9 2018-10-01 5.977770
10 2018-11-01 3.168352
11 2018-12-01 0.894481
However, the result I get isn't what I'm expecting. The rainfall is much lower than expected which makes me think I'm doing something wrong.
Has anyone worked with monthly NetCDF files before and know where I could be going wrong? Alternatively, I have the same data in an hourly format, but can't figure out how I'd obtain monthly sums from this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论