# Path: atmos/utils.py
# def print_if(msg, condition, printfunc=None):
#     """ Print msg if condition is True"""
#     if condition:
#         if printfunc is not None:
#             printfunc(msg)
#         else:
#             print(msg)
# 
# def disptime(fmt=None):
#     now = datetime.now()
# 
#     if fmt == None:
#         fmt = '%02d/%02d/%02d %02d:%02d:%02d'
#     now = (fmt % (now.month, now.day, now.year, now.hour, now.minute,
#            now.second))
#     print(now)
#     return now
# 
# Path: atmos/constants.py



import numpy as np
import pandas as pd
import collections
import scipy.interpolate as interp
import xarray as xray
import time
import atmos.utils as utils
import atmos.xrhelper as xr
from mpl_toolkits import basemap
from xarray import Dataset
from atmos.utils import print_if, disptime
from atmos.constants import const as constants

    if isinstance(data, xray.DataArray):
        i_DataArray = True
        data = data.copy()
        name, _, coords, _ = xr.meta(data)
        attrs = collections.OrderedDict()
        title = 'Vertically integrated by dp/g'
        attrs['title'] = title
        if 'long_name' in data.attrs.keys():
            attrs['long_name'] = data.attrs['long_name']
        if 'units' in data.attrs.keys():
            attrs['units'] = '(' + data.attrs['units'] + ') * kg'
        pname = get_coord(data, 'plev', 'name')
        del(coords[pname])
        if plev is None:
            # -- Make sure pressure levels are in Pa
            plev = get_coord(data, 'plev')
            plev = pres_convert(plev, data[pname].units, 'Pa')
        data[pname].values = plev
    else:
        i_DataArray = False
        # Pack into DataArray to easily extract pressure level subset
        pname = 'plev'
        coords = xr.coords_init(data)
        coords = xr.coords_assign(coords, pdim, pname, plev)
        data = xray.DataArray(data, coords=coords)

    # Extract subset and integrate
    data = subset(data, {pname : (pmin, pmax)})
    vals_int = nantrapz(data.values, data[pname].values, axis=pdim)

# Path: atmos/utils.py
# def print_if(msg, condition, printfunc=None):
#     """ Print msg if condition is True"""
#     if condition:
#         if printfunc is not None:
#             printfunc(msg)
#         else:
#             print(msg)
# 
# def disptime(fmt=None):
#     now = datetime.now()
# 
#     if fmt == None:
#         fmt = '%02d/%02d/%02d %02d:%02d:%02d'
#     now = (fmt % (now.month, now.day, now.year, now.hour, now.minute,
#            now.second))
#     print(now)
#     return now
# 
# Path: atmos/constants.py



# Path: atmos/data.py
import numpy as np
import pandas as pd
import collections
import scipy.interpolate as interp
import xarray as xray
import time
import atmos.utils as utils
import atmos.xrhelper as xr
from mpl_toolkits import basemap
from xarray import Dataset
from atmos.utils import print_if, disptime
from atmos.constants import const as constants


    if isinstance(data, xray.DataArray):
        i_DataArray = True
        data = data.copy()
        name, _, coords, _ = xr.meta(data)
        attrs = collections.OrderedDict()
        title = 'Vertically integrated by dp/g'
        attrs['title'] = title
        if 'long_name' in data.attrs.keys():
            attrs['long_name'] = data.attrs['long_name']
        if 'units' in data.attrs.keys():
            attrs['units'] = '(' + data.attrs['units'] + ') * kg'
        pname = get_coord(data, 'plev', 'name')
        del(coords[pname])
        if plev is None:
            # -- Make sure pressure levels are in Pa
            plev = get_coord(data, 'plev')
            plev = pres_convert(plev, data[pname].units, 'Pa')
        data[pname].values = plev
    else:
        i_DataArray = False
        # Pack into DataArray to easily extract pressure level subset
        pname = 'plev'
        coords = xr.coords_init(data)
        coords = xr.coords_assign(coords, pdim, pname, plev)
        data = xray.DataArray(data, coords=coords)

    # Extract subset and integrate
    data = subset(data, {pname : (pmin, pmax)})
    vals_int = nantrapz(data.values, data[pname].values, axis=pdim)

    vals_int /= constants.g.values