Get Specific Months Data and annual mean

spec_moth_dat

get specific months’ data

Parameter:

  • DaArray (xr.DataArray): shape = (time, *number) original Dataarray

  • months (list): get data from specific month

Raises:

  • ValueError: xr.DataArray’ input is required, not the %s

Returns:

  • xr.DataArray: data in specific month

Example

Load Modules

[1]:
import xarray as xr
import sacpy as scp

Load and Get Data

[2]:
sst = scp.load_sst()['sst']
scp.spec_moth_dat(sst,[1,2])
<frozen importlib._bootstrap>:219: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility. Expected 16 from C header, got 96 from PyObject
[2]:
<xarray.DataArray 'sst' (time: 62, lat: 13, lon: 57)>
[45942 values with dtype=float64]
Coordinates:
  * time     (time) datetime64[ns] 1991-01-16T12:00:00 ... 2021-02-16T12:00:00
  * lon      (lon) int64 20 25 30 35 40 45 50 55 ... 270 275 280 285 290 295 300
  * lat      (lat) int64 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30

spec_moth_yrmean

get specific month data and average them in each year

Parameter:

  • DaArray (xr.DataArray): shape = (time, *number) original Dataarray

  • months (list): get data from specific month

Returns:

  • xr.DataArray: data in specific month and average them in each year

Example

[4]:
sst = scp.load_sst()['sst']
scp.spec_moth_yrmean(sst,[12,1,2])
[4]:
<xarray.DataArray 'sst' (time: 30, lat: 13, lon: 57)>
array([[[        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        ...,
        [        nan,         nan,         nan, ...,         nan,
         25.82674297, 25.56359132],
        [        nan,         nan,         nan, ..., 24.08079465,
         23.95300039, 23.89301427],
        [        nan,         nan,         nan, ..., 21.20026779,
         21.11359294, 21.35712878]],

       [[        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
...
        [        nan,         nan,         nan, ...,         nan,
         27.00849136, 26.57378038],
        [        nan,         nan,         nan, ..., 25.40256437,
         25.14014912, 24.91551399],
        [        nan,         nan,         nan, ..., 22.52778212,
         22.33078369, 22.41735236]],

       [[        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        [        nan,         nan,         nan, ...,         nan,
                 nan,         nan],
        ...,
        [        nan,         nan,         nan, ...,         nan,
         26.71056239, 26.41532103],
        [        nan,         nan,         nan, ..., 25.12457975,
         24.86658351, 24.81672478],
        [        nan,         nan,         nan, ..., 22.16162841,
         22.10272376, 22.36174266]]])
Coordinates:
  * time     (time) int64 1991 1992 1993 1994 1995 ... 2016 2017 2018 2019 2020
  * lon      (lon) int64 20 25 30 35 40 45 50 55 ... 270 275 280 285 290 295 300
  * lat      (lat) int64 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30