使用气候数据操作员(CDO)从每日数据中得出的月湿日数总和。

问题描述 投票:0回答:1

我有日时空分辨率的气候数据,想知道按月和按年统计的降水天数(例如,大于1mmday)。

我已经尝试过 eca_pd,1eca_rr1但这些命令返回所有年份的湿日总数。

例如: cdo eca_pd,1 infile outfile

是否有一个命令可以返回每个月或每年的湿日数?

terminal netcdf netcdf4 nco cdo-climate
1个回答
2
投票

你可以用CDO的遮挡功能来完成这个任务。

第一步是做一个等效文件,如果P>阈值(在你的例子中是1mmday)为1,否则为0。 为此,我们使用 "大于或等于一个常数 "的gec函数(或者ge="大于",如果你喜欢的话)。

cdo gec,1 input.nc mask.nc 

(假设你的输入文件中的单位是mmday).

然后,你可以简单地将这个掩码与你想要的统计期间(月、年等)相加。

cdo monsum mask.nc nwetdays_mon.nc 
cdo yearsum mask.nc nwetdays_year.nc

当然,如果你喜欢在一条线上做这件事,你也可以管这个:如

cdo monsum -gec,1 input.nc nwetdays_mon.nc 

如果你想计算出某个月的气候学,我们还可以更进一步。 如果你有一个多年的数据集,那么你可以使用奇妙的 "ymonstat "命令。 例如,一旦你计算出了上面的月度湿润天数系列,你就可以用 "ymonstat "命令计算出每个月的平均数。

cdo ymonmean nwetdays_mon.nc nwetdays_mon_clim.nc

然后,你可以从这个月度气候学的系列差值中,得到每个月的湿润日数在系列中的异常值

cdo ymonsub nwetdays_mon.nc nwetdays_mon_clim.nc nwetdays_mon_anom.nc

希望对大家有所帮助!

(ps:我通常总觉得这样直接用CDO计算这类统计数字比较容易,我很少发现内置的气候函数能计算出 恰恰 我想要的统计数据)。)


4
投票

与NCO的 ncap2,创建一个二进制标志,然后在所需的维度上累计。

ncap2 -s 'rainy=(precip > 1);rainy_days=rainy.total($time)' in.nc out.nc

2
投票

你也可以在 cf-python,基本上使用与上述CDO示例相同的方法,但在Python环境中,使用和。哪儿崩塌 方法;

import cf

# Read the dataset
f = cf.read('filename.nc')[0]

# Mask out dry days (assuming that your data
#                    units are 'mm day-1' or 'kg m-2 day-1', etc.)
wet = f.where(cf.le(1), cf.masked)

# If the data are in units of 'metres/day', say, then you could do:
#   wet = f.where(cf.le(0.001), cf.masked)
# or
#   wet = f.where(cf.le(1, 'mm day-1'), cf.masked)
# etc.

# Count the wet day occurrences by month
count_monthly = wet.collapse('T: sample_size', group=cf.M())

# Count the wet day occurrences by year
count_yearly = wet.collapse('T: sample_size', group=cf.Y())

# Get the data as numpy arrays
print(count_monthly.array)
print(count_yearly.array)


# Count the wet day totals by month
wet_day_sum_monthly = wet.collapse('T: sum', group=cf.M())

# Count the wet day totals by year
wet_day_sum_yearly = wet.collapse('T: sum', group=cf.Y())
© www.soinside.com 2019 - 2024. All rights reserved.