
import os
import smartcarb as sc
import c2sm

def main(date='2015070211', tracer='CO2_BG'):
    path = '/project/d73/output/production_run_02/2015070100_0_72/cosmo_output/'

    rlon,rlat,ps = sc.map.load_cosmo_data(os.path.join(path, 'lffd%s.nc' % date), 'PS')
    rlon,rlat,p = sc.map.load_cosmo_data(os.path.join(path, 'lffd%s.nc' % date), 'P')
    rlon,rlat,T = sc.map.load_cosmo_data(os.path.join(path, 'lffd%s.nc' % date), 'T')
    rlon,rlat,q = sc.map.load_cosmo_data(os.path.join(path, 'lffd%s.nc' % date), 'QV')

    rlon,rlat,h = sc.map.load_cosmo_data(os.path.join(path, 'lffd2015070100c.nc'), 'HHL')
    rlon,rlat,xm = sc.map.load_cosmo_data(os.path.join(path, 'lffd%s.nc' % date), tracer)

    mair = c2sm.conv.calculate_mair(p, ps, h)

    xco2_old = c2sm.conv.calculate_xco2(xm, mair, q=0.0)
    xco2_new = c2sm.conv.calculate_xco2(xm, mair, q=q)

    return rlon, rlat, xco2_old, xco2_new

