本文整理汇总了Python中cdo.Cdo.ensmean方法的典型用法代码示例。如果您正苦于以下问题:Python Cdo.ensmean方法的具体用法?Python Cdo.ensmean怎么用?Python Cdo.ensmean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cdo.Cdo
的用法示例。
在下文中一共展示了Cdo.ensmean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main_improved
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import ensmean [as 别名]
def main_improved(in_folder=""):
print("Processing {}".format(in_folder))
out_folder = in_folder + "_clim"
if not os.path.isfile(out_folder):
os.makedirs(out_folder)
cdo_obj = Cdo()
opath = os.path.join(out_folder, "mean_year.nc")
inpaths = os.path.join(in_folder, "*")
cdo_obj.ensmean(input=inpaths, output=opath, options="-f nc")
示例2: main
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import ensmean [as 别名]
def main(in_folder = "/skynet1_rech3/huziy/EXP_0.1deg/DFS4.3_interpolated",
out_folder = "/skynet3_rech1/huziy/NEMO_OFFICIAL/dev_v3_4_STABLE_2012/NEMOGCM/CONFIG/GLK/DFS4.3_clim"):
create_links_to_forcing_files.create_links(expdir=out_folder, forcing_dir=in_folder)
cdo_obj = Cdo()
for vname in varnames:
opath = os.path.join(out_folder, "{0}.nc".format(vname))
inpaths = os.path.join(out_folder, "{0}_y*.nc".format(vname))
cdo_obj.ensmean(input = inpaths, output = opath, options = "-f nc")
print("processed: {0}".format(vname))
示例3: modelUncertaintyWorker
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import ensmean [as 别名]
def modelUncertaintyWorker(resource):
"""retuns the result
:param resource: list of pathes to netCDF files
"""
from cdo import Cdo
cdo = Cdo()
from flyingpigeon.utils import check_timestepps
# check resource for consistency
resource_qc = check_timestepps(resource)
try:
# ensemble mean and magnitude
nc_ensmean = cdo.ensmean(input = resource_qc, output = 'nc_ensmean.nc')
logger.info('ensmean calculations done')
except Exception as e:
logger.error('ensmean calculations failed: %s ' % e )
try:
#nc_delta = nc_ensmean(lastpt) - nc_ensmean(firstpt)
nc_laststep = cdo.seltimestep('-1', input = nc_ensmean, output = 'nc_laststep.nc')
nc_firststep = cdo.seltimestep(1, input = nc_ensmean, output = 'nc_firststep.nc')
nc_delta = cdo.sub(input = [nc_laststep, nc_firststep], output = 'nc_delta.nc')
nc_absdelta = cdo.abs(input = nc_delta, output = 'nc_absdelta.nc')
logger.info('delta calculation done')
except Exception as e:
logger.error('delta calculation failed: %s ' % e )
try:
# ensemble std
nc_ensstd = cdo.ensstd(input = resource_qc, output = 'nc_ensstd.nc')
logger.info('std calculation done')
except Exception as e:
logger.error('std calculation failed: %s ' % e )
try:
# compute mask: if nc_absdelta > nc_enssstd
nc_level = cdo.mulc(1, input = nc_ensstd, output = 'nc_level.nc')
nc_binmask = cdo.gt(input = [nc_absdelta, nc_level], output = 'nc_binmask.nc')
logger.info('calculated mask')
except Exception as e:
logger.error('mask calculation failed: %s ' % e )
#if > const
#cdo.gtc('arg', input=infile, ontput=outfile)
# mean + sigma as a mask
# sigma1 = cdo.fldstd(input = nc_ensmean, output = 'nc_sigma1.nc')
# mask
# mean + 2* sigma as a mask
# merge to on result netCDF
# cdo.merge(input=[file1, file2], output='result.nc')
result = nc_ensmean #ensemble mean
result2 = nc_ensstd #ensemble std
result3 = nc_absdelta #magnitude of model change
result4 = nc_binmask #absdelta > std
return result, result2, result3, result4
示例4: method_A
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import ensmean [as 别名]
#.........这里部分代码省略.........
# set the periodes:
try:
start = int(start)
end = int(end)
if timeslice == None:
timeslice = int((end - start) / 3)
if timeslice == 0:
timeslice = 1
else:
timeslice = int(timeslice)
start1 = start
start2 = start1 + timeslice - 1
end1 = end - timeslice + 1
end2 = end
logger.info('timeslice and periodes set')
except Exception as e:
msg = 'failed to set the periodes'
logger.exception(msg)
raise Exception(msg)
try:
files = []
for i, mf in enumerate(mergefiles):
files.append(cdo.selyear('{0}/{1}'.format(start1,end2), input=[mf.replace(' ','\ ')] , output='file_{0}_.nc'.format(i) )) #python version
logger.info('timeseries selected from defined start to end year')
except Exception as e:
msg = 'seltime and mergetime failed'
logger.exception(msg)
raise Exception(msg)
try:
# ensemble mean
nc_ensmean = cdo.ensmean(input=files , output='nc_ensmean.nc')
logger.info('ensemble mean calculation done')
except Exception as e:
msg = 'ensemble mean failed'
logger.exception(msg)
raise Exception(msg)
try:
# ensemble std
nc_ensstd = cdo.ensstd(input=files , output='nc_ensstd.nc')
logger.info('ensemble std and calculation done')
except Exception as e:
msg = 'ensemble std or failed'
logger.exception(msg)
raise Exception(msg)
# get the get the signal as difference from the beginning (first years) and end period (last years), :
try:
selyearstart = cdo.selyear('%s/%s' % (start1,start2), input = nc_ensmean, output = 'selyearstart.nc' )
selyearend = cdo.selyear('%s/%s' % (end1,end2), input = nc_ensmean, output = 'selyearend.nc' )
meanyearst = cdo.timmean(input = selyearstart, output= 'meanyearst.nc')
meanyearend = cdo.timmean(input = selyearend, output= 'meanyearend.nc')
signal = cdo.sub(input=[meanyearend, meanyearst], output = 'signal.nc')
logger.info('Signal calculation done')
except Exception as e:
msg = 'calculation of signal failed'
logger.exception(msg)
raise Exception(msg)
# get the intermodel standard deviation (mean over whole period)
try:
#std_selyear = cdo.selyear('%s/%s' % (end1,end2), input=nc_ensstd, output='std_selyear.nc')
#std = cdo.timmean(input = std_selyear, output = 'std.nc')