Functions returning ClimAF objects¶
Except for the first three paragraphs, this section is for advanced use. As a first step, you should consider using
the builtin data definitions described at projects
.
You may need to come back to this section for reference
cscalar : returns a scalar value (float) in python (using cMA)¶
fadd : add two CliMAF objects or a CliMAF object and a constant¶

climaf.functions.
fadd
(dat1, dat2)[source]¶ Addition of two CliMAF object, or multiplication of the CliMAF object given as first argument and a constant as second argument (string, float or integer)
Shortcut to ccdo(dat,operator=’addc,’+str(c)) and ccdo2(dat1,dat2,operator=’add’)
>>> ds1= .... #some dataset, with whatever variable >>> ds2= .... #some other, compatible dataset >>> ds1_plus_ds2 = fadd(ds1,ds2) # ds1 + ds2
>>> ds1= .... #some dataset, with whatever variable >>> c = '1' #a constant >>> ds1_plus_c = fadd(ds1,c) # ds1 + c
fsub : subtract two CliMAF objects or a CliMAF object and a constant¶

climaf.functions.
fsub
(dat1, dat2)[source]¶ Substraction of two CliMAF object, or multiplication of the CliMAF object given as first argument and a constant as second argument (string, float or integer)
Shortcut to ccdo(dat,operator=’subc,’+str(c)) and ccdo2(dat1,dat2,operator=’sub’)
>>> ds1= .... #some dataset, with whatever variable >>> ds2= .... #some other, compatible dataset >>> ds1_minus_ds2 = fsub(ds1,ds2) # ds1  ds2
>>> ds1= .... #some dataset, with whatever variable >>> c = '1' #a constant >>> ds1_minus_c = fsub(ds1,c) # ds1  c >>> just to check
fmul : multiply two CliMAF objects or a CliMAF object and a constant¶

climaf.functions.
fmul
(dat1, dat2)[source]¶ Multiplication of two CliMAF objects, or multiplication of the CliMAF object given as first argument and a constant as second argument (string, float or integer)
Shortcut to ccdo(dat1,dat2,operator=’mul’) and ccdo(dat,operator=’mulc,’+c)
>>> ds1= .... #some dataset, with whatever variable >>> ds2= .... #some other, compatible dataset >>> ds1_times_ds2 = fmul(ds1,ds2) # ds1 * ds2
>>> ds1= .... #some dataset, with whatever variable >>> c = '1' #a constant >>> ds1_times_c = fmul(ds1,c) # ds1 * c
fdiv : divide two CliMAF objects or a CliMAF object and a constant¶

climaf.functions.
fdiv
(dat1, dat2)[source]¶ Division of two CliMAF object, or multiplication of the CliMAF object given as first argument and a constant as second argument (string, float or integer)
Shortcut to ccdo(dat1,dat2,operator=’div’) and ccdo(dat,operator=’divc,’+c)
>>> ds1= .... #some dataset, with whatever variable >>> ds2= .... #some other, compatible dataset >>> ds1_by_ds2 = fdiv(ds1,ds2) # ds1 / ds2
>>> ds1= .... #some dataset, with whatever variable >>> c = '1' #a constant >>> ds1_times_c = fdiv(ds1,c) # ds1 * c
apply_scale_offset : Returns a CliMAF object after applying a scale and offset¶

climaf.functions.
apply_scale_offset
(dat, scale, offset)[source]¶ Returns a CliMAF object after applying a scale and offset ! Shortcut to: ccdo(ccdo(dat,operator=’mulc,’+str(float(scale))),operator=’addc,’+str(float(offset)))
Note : this function should be used parcimonioulsy because the model in CliMAF for dealing with scaling and offset is rather :
 to automatically scale and offset the data to S.I. units at
input/reading stage; this si done by declaring scaling for
each relevant variable in a project using function
calias()
; it also allows to set the units  if the S.I. units are not suitable for a plot, to use plot operators arguments ‘scale’ and ‘offset’ to change the values
 to automatically scale and offset the data to S.I. units at
input/reading stage; this si done by declaring scaling for
each relevant variable in a project using function
diff_regrid : Regrids dat1 on dat2 and returns the difference between dat1 and dat2¶
diff_regridn : Regrids dat1 and dat2 on a chosen cdogrid (default is n90) and returns the difference between dat1 and dat2¶

climaf.functions.
diff_regridn
(data1, data2, cdogrid=u'n90', option=u'remapbil')[source]¶ Regrids dat1 and dat2 on a chosen cdogrid (default is n90) and returns the difference between dat1 and dat2 The user can specify the cdo regridding method with the argument option (as in regridn(); default is option=’remapbil’).
 # some dataset, with whatever variable
>>> dat1= ....
 # some dataset, with the same variable as dat1
>>> dat2= ....
 # > uses cdogrid=’n90’ and option=’remapbil’
>>> diff_dat1_dat2 = diff_regridn(dat1,dat2)
 # > Returns the difference on 2 deg grid
>>> diff_dat1_dat2 = diff_regridn(dat1,dat2,cdogrid='r180x90')
 # > Returns the difference on 2 deg grid regridded with the remapdis CDO method
>>> diff_dat1_dat2 = diff_regridn(dat1,dat2,cdogrid='r180x90', option='remapdis')
annual_cycle : Computes the annual cycle as the 12 climatological months of dat¶
clim_average : Computes climatological averages on the annual cycle of a dataset¶

climaf.functions.
clim_average
(dat, season)[source]¶ Computes climatological averages on the annual cycle of a dataset, on the months specified with ‘season’, either:
 the annual mean climatology (season => ‘ann’,’annual’,’climato’,’clim’,’climatology’,’annual_average’,’anm’)
 seasonal climatologies (e.g. season = ‘DJF’ or ‘djf’ to compute the seasonal climatology over DecemberJanuaryFebruary; available seasons: DJF, MAM, JJA, SON, JFM, JAS, JJAS
 individual monthly climatologies (e.g. season = ‘january’, ‘jan’, ‘1’ or 1 to get the climatological January)
 annual maximum or minimum (typically makes sense with the mixed layer depth)
Note that you can use upper case or lower case characters to specify the months or seasons.
clim_average computes the annual cycle for you.
>>> dat= .... # some dataset, with whatever variable >>> climds_JFM = clim_average(dat,'JFM') # The climatology of dat over JanuaryFebruaryMarch >>> climds_ANM = clim_average(dat,'annual_mean') # The annual mean climatology >>> climds_September = clim_average(dat,'September') # The annual mean climatology of September >>> climds_September = clim_average(dat,9) # Same as previous example, with a float
lonlatvert_interpolation : Interpolates a lon/lat/pres field (two possible ways)¶

climaf.functions.
lonlatvert_interpolation
(dat1, dat2=None, vertical_levels=None, cdo_horizontal_grid=u'r1x90', horizontal_regridding=True)[source]¶ Interpolates a lon/lat/pres field dat1 via two possible ways:  either by providing a target lon/lat/pres field dat2 => dat1 is regridded both horizontally and vertically on dat2  or by providing a list of vertical levels => dat1 is regridded horizontally on the cdo_horizontal_grid (default=’r1x90’), and vertically on the list of vertical levels The user can provide the vertical levels (in Pa) like this: vertical_levels=[100000,85000,50000,20000,…] # or vertical_levels=’100000,85000,50000,20000’ Before the computations, the function checks the unit of the vertical axis; it is converted to Pa if necessary directly in the netcdf file(s) corresponding to dat1(2).
>>> dat = ds(project='CMIP5',model='IPSLCM5ALR',variable='ua',period='19801985', experiment='historical',table='Amon') >>> ref = ds(project='ref_pcmdi',variable='ua',product='ERAINT')
>>> zonmean_dat = zonmean(time_average(dat)) >>> zonmean_ref = zonmean(time_average(ref))
>>> dat_interpolated_on_ref = lonlatvert_interpolation(zonmean_dat,zonmean_ref) >>> dat_interpolated_on_list_of_levels = lonlatvert_interpolation(zonmean_dat, ... vertical_levels='100000,85000,50000,20000,' ... '10000,5000,2000,1000')
zonmean : Return the zonal mean field of dat¶
diff_zonmean : Returns the zonal mean bias of dat1 against dat2 (based on lonlatpres_interpolation)¶

climaf.functions.
diff_zonmean
(dat1, dat2)[source]¶ Returns the zonal mean bias of dat1 against dat2
The function first computes the zonal means of dat1 and dat2. Then, it interpolates the zonal mean field of dat1 on the zonal mean field of dat2 with the function lonlatvert_interpolation. It finally returns the bias field.
>>> ds1= .... # some dataset, with whatever variable >>> ds2= .... # some dataset, with the same variable as ds1 >>> diff_zonmean_ds1_ds2 = diff_zonmean(ds1,ds2) # Zonal mean difference between ds1 and ds2