Documentation page for thr.py

Perform THR computation on IVT data

Author: guangzhi XU (xugzhi1987@gmail.com) Update time: 2020-07-22 09:58:36.

thr.THR(ivtNV, kernel, oroNV=None, high_terrain=600, verbose=True)

Perform THR filtering process on 3d data

Parameters:
  • ivtNV (NCVAR) – 3D or 4D input IVT data, with dimensions (time, lat, lon) or (time, level, lat, lon).
  • kernel (list or tuple) – list/tuple of integers specifying the shape of the kernel/structuring element used in the gray erosion process.
Keyword Arguments:
 
  • oroNV (NCVAR or None) –

    2D array, surface orographic data in meters. This optional surface height info is used to perform a separate reconstruction computation for areas with high elevations, and the results can be used to enhance the continent-penetration ability of landfalling ARs. Sensitivity in landfalling ARs is enhanced, other areas are not affected. Needs to have compatible (lat, lon) shape as <ivt>. If None, omit this process and treat areas with different heights all equally.

    New in v2.0.

  • high_terrain (float) –

    minimum orographic height (in m) to define as high terrain area, within which a separate reconstruction is performed. Only used if <oroNV> is not None.

    New in v2.0.

  • verbose (bool) – print some messages or not.
Returns:

ivtNV (NCVAR) – 3D or 4D array, input <ivt>. ivtrecNV (NCVAR): 3D or 4D array, the reconstruction component from the

THR process.

ivtanoNV (NCVAR): 3D or 4D array, the difference between input <ivt>

and <ivtrecNV>.

thr.getAttrDict(ref_var, component)

Prepare a metadata dict from a reference variable

Parameters:
  • ref_var (ipart.utils.NCVAR) – NCVAR obj from which meta is obtained and modified.
  • component (str) – ‘reconstruction’ or ‘anomaly’. Strings as modifiers to modify attributes in <ref_var>.
Returns:

attdict (dict) – attribute dictionary.

thr.rotatingTHR(filelist, varin, kernel, outputdir, oroNV=None, selector=None, high_terrain=600, verbose=True)

Compute time filtering on data in different files.

Parameters:
  • filelist (list) – list of abs paths to data files. User is responsible to make sure files in list have correct chronological order. Note that time axis in data files should be the 1st axis.
  • varin (str) – variable id in files.
  • kernel (list or tuple) – list/tuple of integers specifying the shape of the kernel/structuring element used in the gray erosion process.
  • selector (utils.funcs.Selector) – selector obj to select subset of data.
  • outputdir (str) – path to folder to save outputs.
Keyword Arguments:
 
  • oroNV (NCVAR) –

    2D array, surface orographic data in meters. This additional surface height info is used to perform a separate reconstruction computation for areas with high elevations, and the results can be used to enhance the continent-penetration ability of landfalling ARs. Sensitivity in landfalling ARs is enhanced, other areas are not affected. Needs to have compatible shape as <ivt>. If None, omit this process and treat areas with different heights all equally.

    New in v2.0.

  • high_terrain (float) –

    minimum orographic height to define as high terrain area, within which a separate reconstruction is performed. Only used if <oroNV> is not None.

    New in v2.0.

  • verbose (bool) – print some messages or not.

Designed to perform temporal filtering on data that are too large to fit into memory, e.g. high-resolution data across multiple decades.

Function will read in 2 files at once, call the filtering function on the concatenated data, and shift 1 step to the next 2 files. If at the begining, pad 0s to the left end. If in the mid, pad filtered data in the mid of the concatenated data in the previous step. If at the end, pad 0s to the right end.

The filtering function <func> is assumed to apply a filtering window with odd length n, and truncates (n-1)/2 points from both ends. If the function doesn’t truncate data, will raise an exception.