def convert_to_standard_units(mdf):
    """ Converts the input data to {'pos':'m', 'time':'s', 'fields':'nT', 'grads':'nT/m' """
    mdf_standard = mdf.deepcopy()
    fac = {'p': 1e-12, 'n': 1e-09, 'u': 1e-06, 'm': 0.001, ' ': 1.0, 'k': 
        1000.0, 'M': 1000000.0, 'G': 1000000000.0, 'T': 1000000000000.0}
    upos_prefix = str.rjust(mdf_standard.units.get('pos', 'm'), 2)[0]
    mdf_standard.rescale_pos(fac[upos_prefix])
    mdf_standard.units['pos'] = 'm'
    ufields_prefix = str.rjust(mdf_standard.units.get('fields', 'T'), 2)[0]
    mdf_standard.rescale_fields(1000000000.0 * fac[ufields_prefix])
    mdf_standard.units['fields'] = 'nT'
    ugrads_numerator_prefix = str.rjust(mdf_standard.units.get('grads',
        'nT/m').split('/')[0], 2)[0]
    ugrads_denominator_prefix = str.rjust(mdf_standard.units.get('grads',
        'nT/m').split('/')[1], 2)[0]
    mdf_standard.rescale_grads(1000000000.0 * fac[ugrads_numerator_prefix] *
        fac[ugrads_denominator_prefix] ** -1)
    mdf_standard.units['grads'] = 'nT/m'
    fac_time = {'us': 1e-06, 'ms': 0.001, 's': 1.0, 'min': 60, 'h': 60 * 60,
        'd': 60 * 60 * 24, 'w': 60 * 60 * 24 * 7}
    utime = mdf_standard.units.get('time', 's')
    mdf_standard.rescale_time(fac_time[utime])
    mdf_standard.units['time'] = 's'
    return mdf_standard
