當前位置: 首頁>>代碼示例>>Python>>正文


Python Cdo.ydaymean方法代碼示例

本文整理匯總了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
開發者ID:mcalvcas,項目名稱:flyingpigeon,代碼行數:36,代碼來源:analogs.py

示例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
開發者ID:KatiRG,項目名稱:flyingpigeon,代碼行數:71,代碼來源:analogs.py


注:本文中的cdo.Cdo.ydaymean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。