Skip to content

GCM post process tool for climate research using parallel computing

Notifications You must be signed in to change notification settings

Yefee/gcmaverager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About GCMAverager

GCMAverger is a lightweight post process package designed for large amount general circulation model(GCM) outputs using parallel computing. It was originally designed to post process a long run from the community earth system model (CESM), who genreated hundreds of TBs data. NCAR has developed two fancy tools: pyAverager and pyReshaper, which do the samething as GAMAverager, however, they are pooly maintained and not easy to use.

GCMAverager is a xarray-based project, therefore python 2.7, 3.4, 3.5, and 3.6 are supported. Right now, GCMAverager primarily can

  • extract variables from time slice history files into time series files;
  • compute annual (decadal) and seasonal mean for model outputs from time slice or time series files.

Installation

via github

git clone https://github.com/Yefee/gcmaverager.git
cd gcmaverager
python setup.py install

via pip

pip install gcmaverager

Get started

GCMAverager supports several kinds of average method:

  • ANN (annual mean)
  • MAM (March-April-May, annual mean)
  • JJA (June-July-August, annual mean)
  • SON (September-October-November, annual mean)
  • DJF (December-January-February, annual mean)
  • decadal-ANN (decadal annual mean)
  • decadal-MAM (March-April-May, decadal annual mean)
  • decadal-SON (June-July-August, decadal annual mean)
  • decadal-JJA (September-October-November, decadal annual mean)
  • decadal-DJF (December-January-February, decadal annual mean)
  • TS (extract time series file from original GCM outputs)

Extract time series file from time slice files

This feature only suppports Py 3.x.

    import gcmaverager as ga
    import xarray as xr

    rootDir = '/Volumes/Chengfei_Data_Center/iTrace/test/'
    tarDir = '/Volumes/Chengfei_Data_Center/iTrace/output/'
    prefix = 'test'
    suffix = '0001-0999'
    method = ['TS']

    # get file list and create an xarray object
    fl = ga.getFilelist(rootDir)
    ds = xr.open_mfdataset(fl, decode_times=False, atuoclose=True)

    # derive time dependent variables
    varList = ds.variables.keys()
    varList = [v for v in varList if "time" in ds[
        v].dims and len(ds[v].dims) > 2]

    # feed it to GAMAverager
    fl = [ds[var] for var in varList]
    ga.averager(fl, tarDir, prefix, suffix,  method)

The outputs are in tarDir, which has pattern prefix+variable+suffix+'.nc'(e.g. test.TEMP.0001-0999.nc)

Compute average from time slice files

This feature only suppports Py 3.x.


    import gcmaverager as ga
    import xarray as xr

    rootDir = '/Volumes/Chengfei_Data_Center/iTrace/test/'
    tarDir = '/Volumes/Chengfei_Data_Center/iTrace/output/'
    prefix = 'test'
    suffix = '0001-0999'
    method = ['ANN', 'decadal-ANN']

    # get file list and create an xarray object
    fl = ga.getFilelist(rootDir)
    ds = xr.open_mfdataset(fl, decode_times=False, atuoclose=True)

    # derive time dependent variables
    varList = ds.variables.keys()
    varList = [v for v in varList if "time" in ds[
        v].dims and len(ds[v].dims) > 2]

    # feed it to GAMAverager
    fl = [ds[var] for var in varList]
    ga.averager(fl, tarDir, prefix, suffix,  method)

The outputs are in tarDir, which has pattern prefix+variable+suffix+'ANN.nc'(e.g. test.TEMP.0001-0999.ANN.nc)

Compute average from time series files


    import gcmaverager as ga

    rootDir = '/Volumes/Chengfei_Data_Center/iTrace/test/'
    tarDir = '/Volumes/Chengfei_Data_Center/iTrace/output/'
    prefix = 'test'
    suffix = '0001-0999'
    method = ['ANN', 'decadal-ANN']

    # get file list and create an xarray object
    fl = ga.getFilelist(rootDir)

    # feed it to GAMAverager
    ga.averager(fl, tarDir, prefix, suffix,  method)

About

GCM post process tool for climate research using parallel computing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages