【发布时间】:2021-05-19 18:04:35
【问题描述】:
我是 netCDF 数据的新手,真的需要一些帮助。我有一个包含 365 次(天)和 14052 个时间序列的文件。数据跨越一个水文年(9 月 13 日至 8 月 14 日)。我正在寻找每个时间序列的年度总数。我附上了我在 python 中的微弱尝试。这给了我所有单元格的总和,但不会根据时间序列将它们分开。
# Imports
import xarray as xr
import numpy as np
# Read a netCDF file into an xarray Dataset object
ds = xr.open_dataset("Desktop/GOA_discharge_2013_2019/goa_dischargex_09012013_08312014.nc")
# Print the contents of the DataSet
print(ds)
# Print the units of the q field
print(ds["q"].units)
# Convert q to a numpy array so that we can take the sum
v = ds["q"].values
# Take the sum of q
sum_13 = np.sum(v)
print("Sum of q_13_14: {}".format(sum_13))
###这是打印出来的
【问题讨论】: