Exemple #1
0
def write_no_daily_prof(run_df, temp, run_group, state):
    '''
    Write the standard non-hourly non-daily profile based temporal profiles
    '''
    cols = ['region_cd','scc','run_group','facid','tract','polynumber','src_id','ann_value']
    run_df = run_df[cols].copy().drop_duplicates()
    # Use main contributing region_cd and SCC for source temporalization
    run_df.sort('ann_value', inplace=True)
    run_df.drop_duplicates('facid', keep='last', inplace=True)
    scalar_cols = [s_col for s_col in temp.aermod.columns if s_col.startswith('Scalar')]
    value_cols = ['qflag',] + scalar_cols
    # Only match by fips/scc or fips; SCC only gets default
    hierarchy = [['region_cd','scc'],['region_cd',]]
    run_df = match_temporal(run_df, temp.aermod, value_cols, hierarchy)
    run_df.drop(['scc','ann_value'], axis=1, inplace=True)
    run_df.drop_duplicates(inplace=True)
    if not run_df[run_df[def_prof.index[0]].isnull()].empty:
        if run_group == 'OILGAS4':
            run_df = fill_default(run_df, def_oil_prof)
        else:
            run_df = fill_default(run_df, def_prof)
    qflag_list = list(run_df['qflag'].drop_duplicates())
    if 'MHRDOW7' in qflag_list:
        scalar_cols = ['Scalar%s' %x for x in xrange(1,2017)]
    elif 'MHRDOW' in qflag_list:
        scalar_cols = ['Scalar%s' %x for x in xrange(1,865)]
    elif 'HROFDY' in qflag_list:
        scalar_cols = ['Scalar%s' %x for x in xrange(1,25)]
    else:
        scalar_cols = ['Scalar%s' %x for x in xrange(1,13)]
    cols = ['run_group','state','region_cd','tract','polynumber','facid','src_id','qflag']
    run_df['state'] = state_dict[state]
    fname = os.path.join(os.environ['WORK_PATH'],'temporal','tract_%s_%s_temporal.csv' %(state,
      run_group))
    run_df.to_csv(fname, index=False, columns=cols+scalar_cols)
Exemple #2
0
def get_no_daily_prof(run_df, temp):
    '''
    Write the standard non-hourly non-daily profile based temporal profiles
    '''
    scalar_cols = [
        s_col for s_col in temp.aermod.columns if s_col.startswith('Scalar')
    ]
    value_cols = [
        'qflag',
    ] + scalar_cols
    # Only match by fips/scc or fips; SCC only gets default
    hierarchy = [['region_cd', 'scc'], [
        'region_cd',
    ]]
    run_df = match_temporal(run_df, temp.aermod, value_cols, hierarchy)
    run_df.drop(['region_cd', 'scc'], axis=1, inplace=True)
    run_df.drop_duplicates(inplace=True)
    if not run_df[run_df[def_prof.index[0]].isnull()].empty:
        run_df = fill_default(run_df, def_prof)
    qflag_list = list(run_df['qflag'].drop_duplicates())
    if 'MHRDOW7' in qflag_list:
        scalar_cols = ['Scalar%s' % x for x in xrange(1, 2017)]
    elif 'MHRDOW' in qflag_list:
        scalar_cols = ['Scalar%s' % x for x in xrange(1, 865)]
    elif 'HROFDY' in qflag_list:
        scalar_cols = ['Scalar%s' % x for x in xrange(1, 25)]
    else:
        scalar_cols = ['Scalar%s' % x for x in xrange(1, 13)]
    return run_df[['run_group', 'met_cell', 'src_id', 'qflag'] +
                  scalar_cols].copy()