Time Scale Average

Time Scale Average#

Before proceeding with all the steps, first import some necessary libraries and packages

import easyclimate as ecl
import xarray as xr

Example data are sea ice concentration (SIC) data for the Barents-Kara Sea (30°-90°E, 65°-85°N).

sic_data_Barents_Sea = ecl.tutorial.open_tutorial_dataset("mini_HadISST_ice").sic
sic_data_Barents_Sea
<xarray.DataArray 'sic' (time: 508, lat: 20, lon: 60)> Size: 2MB
[609600 values with dtype=float32]
Coordinates:
  * time     (time) datetime64[ns] 4kB 1981-01-31 1981-02-28 ... 2023-04-30
  * lat      (lat) float32 80B 65.5 66.5 67.5 68.5 69.5 ... 81.5 82.5 83.5 84.5
  * lon      (lon) float32 240B 30.5 31.5 32.5 33.5 34.5 ... 86.5 87.5 88.5 89.5
Attributes:
    standard_name:  sea_ice_area_fraction
    long_name:      Monthly 1 degree resolution sea ice concentration
    units:          1
    cell_methods:   time: lat: lon: median


Mean States#

Solving for the overall climatological mean state was solved using easyclimate.calc_all_climatological_mean.

ecl.calc_all_climatological_mean(sic_data_Barents_Sea, dim="time")
<xarray.DataArray 'sic' (lat: 20, lon: 60)> Size: 5kB
array([[       nan,        nan,        nan, ...,        nan,        nan,
               nan],
       [       nan,        nan,        nan, ...,        nan,        nan,
               nan],
       [       nan,        nan,        nan, ...,        nan,        nan,
               nan],
       ...,
       [0.877244  , 0.8792713 , 0.87023586, ..., 0.9318309 , 0.9357874 ,
        0.93395644],
       [0.93192923, 0.9332087 , 0.93057084, ..., 0.95885825, 0.9580121 ,
        0.95854366],
       [0.94389784, 0.94403535, 0.9427558 , ..., 0.9602362 , 0.9616337 ,
        0.9612792 ]], dtype=float32)
Coordinates:
  * lat      (lat) float32 80B 65.5 66.5 67.5 68.5 69.5 ... 81.5 82.5 83.5 84.5
  * lon      (lon) float32 240B 30.5 31.5 32.5 33.5 34.5 ... 86.5 87.5 88.5 89.5
Attributes:
    standard_name:  sea_ice_area_fraction
    long_name:      Monthly 1 degree resolution sea ice concentration
    units:          1
    cell_methods:   time: lat: lon: median


If the climate state is for each season, the results are solved using easyclimate.calc_seasonal_climatological_mean.

ecl.calc_seasonal_climatological_mean(sic_data_Barents_Sea, dim="time")
<xarray.DataArray 'sic' (season: 4, lat: 20, lon: 60)> Size: 19kB
array([[[       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        ...,
        [0.92078125, 0.9253906 , 0.9153125 , ..., 0.989375  ,
         0.9890625 , 0.98664063],
        [0.9571094 , 0.95734376, 0.958125  , ..., 0.9867188 ,
         0.98578125, 0.9857031 ],
        [0.960625  , 0.9615625 , 0.96070313, ..., 0.98398435,
         0.98515624, 0.9838281 ]],

       [[       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
...
        [0.95984375, 0.9634375 , 0.9628125 , ..., 0.99210936,
         0.99109375, 0.988125  ],
        [0.96867186, 0.9694531 , 0.97015625, ..., 0.9910156 ,
         0.9909375 , 0.9903906 ],
        [0.9719531 , 0.971875  , 0.9717187 , ..., 0.9882031 ,
         0.9895312 , 0.98828125]],

       [[       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        ...,
        [0.7614286 , 0.7625397 , 0.7449206 , ..., 0.8363492 ,
         0.844127  , 0.8452381 ],
        [0.88079363, 0.8851587 , 0.87738097, ..., 0.91642857,
         0.91515875, 0.91642857],
        [0.9123016 , 0.9113492 , 0.9086508 , ..., 0.92579365,
         0.9272222 , 0.9281746 ]]], dtype=float32)
Coordinates:
  * lat      (lat) float32 80B 65.5 66.5 67.5 68.5 69.5 ... 81.5 82.5 83.5 84.5
  * lon      (lon) float32 240B 30.5 31.5 32.5 33.5 34.5 ... 86.5 87.5 88.5 89.5
  * season   (season) object 32B 'DJF' 'JJA' 'MAM' 'SON'
Attributes:
    standard_name:  sea_ice_area_fraction
    long_name:      Monthly 1 degree resolution sea ice concentration
    units:          1
    cell_methods:   time: lat: lon: median


However, if the climate state is for each month, the results are solved using easyclimate.calc_seasonal_cycle_mean.

ecl.calc_seasonal_cycle_mean(sic_data_Barents_Sea, dim="time")
<xarray.DataArray 'sic' (month: 12, lat: 20, lon: 60)> Size: 58kB
array([[[       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        ...,
        [0.9181395 , 0.9183721 , 0.9062791 , ..., 0.9906977 ,
         0.9902325 , 0.9872093 ],
        [0.96255815, 0.9618605 , 0.9623256 , ..., 0.9883721 ,
         0.9872093 , 0.987907  ],
        [0.9632558 , 0.96465117, 0.96279067, ..., 0.9851163 ,
         0.98697674, 0.9860465 ]],

       [[       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
...
        [0.8907143 , 0.8957143 , 0.882619  , ..., 0.96428573,
         0.9659524 , 0.9628571 ],
        [0.93523806, 0.9342857 , 0.93714285, ..., 0.97309524,
         0.9714286 , 0.97166663],
        [0.9411905 , 0.9407143 , 0.9388095 , ..., 0.96690476,
         0.9671428 , 0.96619046]],

       [[       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        [       nan,        nan,        nan, ...,        nan,
                nan,        nan],
        ...,
        [0.91714287, 0.9292857 , 0.9211905 , ..., 0.9842857 ,
         0.9847619 , 0.98190475],
        [0.9438095 , 0.9445238 , 0.9454762 , ..., 0.9809524 ,
         0.98      , 0.9792857 ],
        [0.95095235, 0.9511905 , 0.9519048 , ..., 0.97761905,
         0.9802381 , 0.97761905]]], dtype=float32)
Coordinates:
  * lat      (lat) float32 80B 65.5 66.5 67.5 68.5 69.5 ... 81.5 82.5 83.5 84.5
  * lon      (lon) float32 240B 30.5 31.5 32.5 33.5 34.5 ... 86.5 87.5 88.5 89.5
  * month    (month) int64 96B 1 2 3 4 5 6 7 8 9 10 11 12
Attributes:
    standard_name:  sea_ice_area_fraction
    long_name:      Monthly 1 degree resolution sea ice concentration
    units:          1
    cell_methods:   time: lat: lon: median


Remove Seasonal Cycle#

easyclimate.remove_seasonal_cycle_mean helps us to remove seasonal cycles (annual cycles) from the data in order to obtain monthly average anomalies.

<xarray.DataArray 'sic' (time: 508, lat: 20, lon: 60)> Size: 2MB
array([[[        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        ...,
        [ 0.03186047,  0.05162793,  0.05372089, ..., -0.01069766,
         -0.01023251, -0.01720929],
        [-0.01255816, -0.01186049, -0.01232558, ..., -0.00837207,
         -0.0072093 , -0.01790696],
        [-0.02325583, -0.01465118, -0.01279068, ..., -0.01511627,
         -0.00697672, -0.01604646]],

       [[        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
...
        [ 0.04511625,  0.04116273,  0.03116274, ...,  0.00813955,
          0.00860465,  0.0004651 ],
        [ 0.02302319,  0.02255809,  0.02069765, ...,  0.00999999,
         -0.00023258,  0.00976747],
        [ 0.01930231,  0.0197674 ,  0.01906973, ...,  0.00116277,
          0.0095349 ,  0.00093019]],

       [[        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        ...,
        [ 0.02116275,  0.01837206,  0.01883715, ...,  0.00744188,
          0.00790697,  0.01069766],
        [ 0.02069765,  0.01953483,  0.01837206, ..., -0.00116283,
         -0.00093025, -0.00093025],
        [ 0.01906973,  0.01906973,  0.0197674 , ...,  0.00255811,
          0.00139529,  0.00255811]]], dtype=float32)
Coordinates:
  * time     (time) datetime64[ns] 4kB 1981-01-31 1981-02-28 ... 2023-04-30
  * lat      (lat) float32 80B 65.5 66.5 67.5 68.5 69.5 ... 81.5 82.5 83.5 84.5
  * lon      (lon) float32 240B 30.5 31.5 32.5 33.5 34.5 ... 86.5 87.5 88.5 89.5
    month    (time) int64 4kB 1 2 3 4 5 6 7 8 9 10 11 ... 7 8 9 10 11 12 1 2 3 4
Attributes:
    standard_name:  sea_ice_area_fraction
    long_name:      Monthly 1 degree resolution sea ice concentration
    units:          1
    cell_methods:   time: lat: lon: median


We can visualize the results by plotting.

sic_data_Barents_Sea_remove_seasonal_cycle.mean(dim=("lat", "lon")).sel(
    time=slice("2010-01-01", "2015-12-31")
).plot(
    figsize=(10, 3),
    marker=".",
)
plot time scale average
[<matplotlib.lines.Line2D object at 0x7f80527130d0>]

Total running time of the script: (0 minutes 0.897 seconds)