繁体   English   中英

使用气候数据运营商 (CDO) 的每日数据得出的每月潮湿天数总和

[英]Monthly sum of wet days from daily data using Climate Data Operators (CDO)

我有具有每日时间分辨率的气候数据,并且想要按月和按年计算有降水(例如,大于 1 毫米/天)的天数。

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

例如cdo eca_pd,1 infile outfile

是否有命令返回每个月和/或每年的雨天?

使用 NCO 的ncap2创建一个二进制标志,然后将其汇总到所需的维度:

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

您可以使用 CDO 的屏蔽 function 完成此任务。

第一步是制作一个等效文件,如果 P> 阈值(在您的情况下为 1 毫米/天),则为 1,否则为 0。 为此,我们使用“大于或等于一个常数”gec function(或 ge="greater than",如果您愿意):

cdo gec,1 input.nc mask.nc 

(假设输入文件中的单位是毫米/天)。

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

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

当然你可以 pipe 如果你想在一行上这样做:例如

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

如果您想计算特定月份的气候学,我们可以更进一步。 如果您有多年数据集,那么您可以使用出色的“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 计算这些统计数据更容易,我很少发现内置的气候函数可以准确地计算出我想要的统计数据)。

您也可以在cf-python中执行此操作,基本上使用与上述 CDO 示例相同的方法,但在 Python 环境中,使用wherecollapse方法:

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())

暂无
暂无

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

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