本文整理汇总了Python中cdo.Cdo.ydaymean方法的典型用法代码示例。如果您正苦于以下问题:Python Cdo.ydaymean方法的具体用法?Python Cdo.ydaymean怎么用?Python Cdo.ydaymean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cdo.Cdo
的用法示例。
在下文中一共展示了Cdo.ydaymean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: seacyc
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import ydaymean [as 别名]
def seacyc(archive, simulation, method='base'):
"""
substracts the seasonal cycle
:param archive: netCDF file containing the reference period
:param simulation: netCDF file containg the period to be analysed
:param method: method to generat the seasonal cycle files
base = seasonal cycle generated from reference period
sim = seasonal cycle generated from period to be analysed
own = seasonal cycle generated for both time windows
"""
from shutil import copy
from cdo import Cdo
cdo = Cdo()
# calculate seasonal cycle and add an additional file into the working directory
# base) cdo -s ydaymean ${basedir}base_${varname}_${dtrstr}${region}_${datestring1}_${namestring}.nc seasoncyc_base.nc
# cp seasoncyc_base.nc seasoncyc_sim.nc ;;
# sim) cdo -s ydaymean ${simdir}sim_${varname}_${dtrstr}${region}_${datestring2}_${namestring}.nc seasoncyc_sim.nc
# cp seasoncyc_sim.nc seasoncyc_base.nc ;;
# own) cdo -s ydaymean ${basedir}base_${varname}_${dtrstr}${region}_${datestring1}_${namestring}.nc seasoncyc_base.nc
# cdo -s ydaymean ${simdir}sim_${varname}_${dtrstr}${region}_${datestring2}_${namestring}.nc seasoncyc_sim.nc ;;
if method == 'base':
seasoncyc_base = cdo.ydaymean(input=archive, output='seasoncyc_base.nc' )
seasoncyc_sim = 'seasoncyc_sim.nc'
copy(seasoncyc_base, seasoncyc_sim)
if method == 'sim':
seasoncyc_sim = cdo.ydaymean(input=simulation, output='seasoncyc_sim.nc' )
seasoncyc_base = 'seasoncyc_base.nc'
copy(seasoncyc_sim, seasoncyc_base)
if method == 'own':
seasoncyc_base = cdo.ydaymean(input=archive, output='seasoncyc_base.nc' )
seasoncyc_sim = cdo.ydaymean(input=simulation, output='seasoncyc_sim.nc' )
return seasoncyc_base, seasoncyc_sim
示例2: seacyc
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import ydaymean [as 别名]
def seacyc(archive, simulation, method='base'):
"""
Subtracts the seasonal cycle.
:param archive: netCDF file containing the reference period
:param simulation: netCDF file containing the period to be analysed
:param method: method to generate the seasonal cycle files
base = seasonal cycle generated from reference period
sim = seasonal cycle generated from period to be analysed
own = seasonal cycle generated for both time windows
:return [str,str]: two netCDF filenames for analysis and reference period (located in working directory)
"""
try:
logger.debug('seacyc started with method: %s' % method)
from shutil import copy
from flyingpigeon.ocgis_module import call
from flyingpigeon.utils import get_variable
from cdo import Cdo
cdo = Cdo()
if method == 'base':
seasoncyc_base = cdo.ydaymean(
input=archive, output='seasoncyc_base.nc')
variable = get_variable(archive)
# seasoncyc_base = call(resource=archive,
# variable=variable,
# prefix='seasoncyc_base',
#calc=[{'func': 'mean', 'name': variable}],
# calc_grouping=['day','month'] )
logger.debug('seasoncyc_base calculated : %s' % seasoncyc_base)
cdo.ydaymean(input=archive, output='seasoncyc_base.nc')
seasoncyc_sim = 'seasoncyc_sim.nc'
copy(seasoncyc_base, seasoncyc_sim)
elif method == 'sim':
# seasoncyc_sim = call(resource=archive,
# variable=variable,
# prefix='seasoncyc_sim',
#calc=[{'func': 'mean', 'name': variable}],
# calc_grouping=['day','month'] )
cdo.ydaymean(input=simulation, output='seasoncyc_sim.nc')
seasoncyc_base = 'seasoncyc_base.nc'
copy(seasoncyc_sim, seasoncyc_base)
elif method == 'own':
# seasoncyc_base = call(resource=archive,
# variable=variable,
# prefix='seasoncyc_base',
#calc=[{'func': 'mean', 'name': variable}],
# calc_grouping=['day','month'] )
seasoncyc_base = cdo.ydaymean(
input=archive, output='seasoncyc_base.nc')
# seasoncyc_sim = call(resource=archive,
# variable=variable,
# prefix='seasoncyc_sim',
#calc=[{'func': 'mean', 'name': variable}],
# calc_grouping=['day','month'] )
seasoncyc_sim = cdo.ydaymean(
input=simulation, output='seasoncyc_sim.nc')
else:
raise Exception('normalisation method not found')
except Exception as e:
msg = 'seacyc function failed : %s ' % e
logger.debug(msg)
raise Exception(msg)
return seasoncyc_base, seasoncyc_sim