text: """
  e3sm_to_cmip cmor handler script
  
  Variable: so4_a1 (Concentration of so4_a1, in kg/kg)
  
  Matt Nicholson
  24 Feb 2020
  """
  from __future__ import absolute_import, division, print_function, unicode_literals
  
  import cmor
  from e3sm_to_cmip.lib import handle_variables
  
  # list of raw variable names needed
  RAW_VARIABLES = [str('so4_a1')]
  VAR_NAME = str('so4_a1')
  VAR_UNITS = str("kg/kg")
  TABLE = str('CMIP6_Amon.json')
  LEVELS = {
      'name': str('lev'),
      'units': str('hPa'),
      'e3sm_axis_name': 'lev'
  }
  
  
  def write_data(varid, data, timeval, timebnds, index, **kwargs):
      """
      so4_a1 = so4_a1
      """
      cmor.write(
          varid,
          data['so4_a1'][index, :],
          time_vals=timeval,
          time_bnds=timebnds)
  # ------------------------------------------------------------------
  
  
  def handle(infiles, tables, user_input_path, **kwargs):
      """
      Parameters
      ----------
          infiles (List): a list of strings of file names for the raw input data
          tables (str): path to CMOR tables
          user_input_path (str): path to user input json file
      Returns
      -------
          var name (str): the name of the processed variable after processing is complete
      """
      return handle_variables(
          metadata_path=user_input_path,
          tables=tables,
          table=TABLE,
          infiles=infiles,
          raw_variables=RAW_VARIABLES,
          write_data=write_data,
          outvar_name=VAR_NAME,
          outvar_units=VAR_UNITS,
          serial=kwargs.get('serial'),
          levels=LEVELS,
          logdir=kwargs.get('logdir'))
  # ------------------------------------------------------------------