docs: def iodp_kly4s_lore(kly4s_file, meas_out='measurements.txt',
             spec_infile='specimens.txt', spec_out='specimens.txt',  instrument='IODP-KLY4S',
             actual_volume="",dir_path='.', input_dir_path=''):
      """
      Converts ascii files generated by SUFAR ver.4.0 and downloaded from the LIMS online
      repository to MagIC (datamodel 3) files
  
      Parameters
      ----------
      kly4s_file : str
          input LORE downloaded csv file, required
      meas_output : str
          measurement output filename, default "measurements.txt"
      spec_infile : str
          specimen infile, default specimens.txt
          [file created by iodp_samples_csv from LORE downloaded sample file]
      spec_outfile : str
          specimen outfile, default "kly4s_specimens.txt"
      instrument : str
          instrument name, default ""
      actual_volume : float
          the nominal volume is assumed to be 8cc or even 10cc, depending on the shipboard
          software used, actual_vol is the  actual specimen volume in cc
      dir_path : str
          output directory, default "."
      input_dir_path : str
          input file directory IF different from dir_path, default ""
  
      Returns
      --------
      type - Tuple : (True or False indicating if conversion was sucessful, file name written)
  
      """
      # initialize defaults
      version_num = pmag.get_version()
      # format variables
      input_dir_path, output_dir_path = pmag.fix_directories(input_dir_path, dir_path)
      # set up required columns
      meas_reqd_columns=['specimen','measurement','experiment','sequence','quality','method_codes',\
                         'instrument_codes','citations',\
                         'treat_temp','treat_ac_field','treat_dc_field',\
                        'treat_dc_field_phi','treat_dc_field_theta','meas_temp',\
                        'dir_dec','dir_inc','magn_moment','magn_volume',\
                         'description','timestamp','software_packages',\
                         'external_database_ids','experiments','treat_step_num']
      spec_reqd_columns=['specimen','sample','result_quality','method_codes','volume',\
                         'specimen_name_alternatives','citations',\
                        'aniso_type','aniso_s_n_measurements',\
                        'azimuth','dip','aniso_s_sigma',\
                        'aniso_s_unit','aniso_tilt_correction',]
      # sort out file paths
      kly4s_file = pmag.resolve_file_name(kly4s_file, input_dir_path)
      spec_out = pmag.resolve_file_name(spec_out, dir_path)
      spec_file=pmag.resolve_file_name(spec_infile, dir_path)
      meas_out = pmag.resolve_file_name(meas_out, dir_path)
      # read in necessary data:
      specs=pd.read_csv(spec_file,sep='\t',header=1) # read in existing specimen table
      if len(specs)==0:
          print ('you must download and process the samples table from LORE prior to using this')
          print ('see convert_2_magic.iodp_samples_csv for help')
          return False
      LORE_specimens=list(specs.specimen.unique())
      in_df=pd.read_csv(kly4s_file)
      if len(in_df)==0:
          print ('you must download a csv file from the LIMS database and place it in your input_dir_path')
          return False
      measurements_df=pd.DataFrame(columns=meas_reqd_columns)
      specimens_df=pd.DataFrame(columns=spec_reqd_columns)
      hole,kly4s_specimens=iodp_sample_names(in_df)
      for spec in list(kly4s_specimens.unique()):
          if spec not in LORE_specimens:
              print (spec, ' not found in specimen table')
  
      # set up defaults
          # specimens table defaults
      specimens_df['specimen']=kly4s_specimens
      specimens_df['sample']=kly4s_specimens
      specimens_df['result_quality']='g'
      specimens_df['citations']='This study'
      specimens_df['aniso_type']='AMS'
      specimens_df['azimuth']=0
      specimens_df['dip']=0
      specimens_df['aniso_s_n_measurements']=192
      specimens_df['aniso_tilt_correction']=0
      specimens_df['aniso_s_unit']='SI'
      specimens_df['aniso_s_sigma']=''
      specimens_df['method_codes']= "LP-X:AE-H:LP-AN-MS"
      specimens_df['experiments']=specimens_df['specimen'].astype('str')+'_'+ "LP-AN-MS"
          # measurements table
      measurements_df['specimen']=kly4s_specimens
      measurements_df['quality']='g'
      measurements_df['citations']='This study'
      measurements_df['meas_temp']=273
      measurements_df['software_packages']=version_num
      measurements_df["treat_temp"] = '%8.3e' % (273)  # room temp in kelvin
      measurements_df["meas_temp"] = '%8.3e' % (273)  # room temp in kelvin
      measurements_df["treat_ac_field"] = '0'
      measurements_df["treat_dc_field"] = '0'
      measurements_df["treat_dc_field_phi"] = '0'
      measurements_df["treat_dc_field_theta"] = '0'
      measurements_df["treat_step_num"] = '1'
      measurements_df["standard"] = 'u'  # assume all data are "good"
      measurements_df['instrument_codes']="IODP-KLY4S" # assume all measurements on shipboard KLY4S
      measurements_df['description']='Bulk sucsecptibility measurement'
      measurements_df['method_codes']='LP-X'
      measurements_df['experiment']=measurements_df['specimen'].astype('str')+'_'+\
                                    measurements_df['method_codes'].astype('str')
      meas_num=range(len(kly4s_specimens))
      measurements_df['sequence']=meas_num
      measurements_df['measurement']=measurements_df['experiment'].astype('str')+'-'+\
                                     measurements_df['sequence'].astype('str')
  # parse the measurement data into  columns
      nominal_volume=in_df['Sample volume (CC)']*1e-6 # convert cc to m^3
      if actual_volume:
          actual_volume=(1e-6*actual_volume)
          factor=nominal_volume/actual_volume
      else:
          actual_volume=nominal_volume
          factor=1
      measurements_df['susc_chi_volume']=in_df['Bulk susceptibility(SI)']*factor
      measurements_df['external_database_ids']='LORE['+in_df['Test No.'].astype('str')+']'
  # parse specimen data into columns
      specimens_df['specimen_name_alternatives']=in_df['Text ID']
      specimens_df['volume']=actual_volume
      s1=in_df['Normalized tensor K11']
      s2=in_df['Normalized tensor K22']
      s3=in_df['Normalized tensor K33']
      s4=in_df['Normalized tensor K12']
      s5=in_df['Normalized tensor K23']
      s6=in_df['Normalized tensor K13']
      if 'Standard deviation(SI)' in in_df.columns:
          specimens_df['aniso_s_sigma']=in_df['Standard deviation(SI)']
      #if (s1+s2+s3)>.35: # AGICO format
      #    s1=s1/3
      #    s2=s2/3
      #    s3=s3/3
      #    s4=s4/3
      #    s5=s5/3
      #    s6=s6/3
      specimens_df['aniso_s'] = s1.astype('str')+':'+ s2.astype('str')+':'+s3.astype('str')+':'+\
                                s4.astype('str')+':'+ s5.astype('str')+':'+ s6.astype('str')
      tau1=in_df['Kmax susceptibility (SI)']/3
      v1_dec=in_df['Kmax dec (deg)']
      v1_inc=in_df['Kmax inc (deg)']
      specimens_df['aniso_v1']=tau1.astype('str')+":"+v1_dec.astype('str')+":"+v1_inc.astype('str')
      tau2=in_df['Kint susceptibility (SI)']/3
      v2_dec=in_df['Kint dec (deg)']
      v2_inc=in_df['Kint inc (deg)']
      specimens_df['aniso_v2']=tau2.astype('str')+":"+v2_dec.astype('str')+":"+v2_inc.astype('str')
      tau3=in_df['Kmin susceptibility (SI)']/3
      v3_dec=in_df['Kmin dec (deg)']
      v3_inc=in_df['Kmin inc (deg)']
      specimens_df['aniso_v3']=tau3.astype('str')+":"+v3_dec.astype('str')+":"+v3_inc.astype('str')
  
  
  # output data files
      measurements_df.fillna("",inplace=True)
      meas_dicts = measurements_df.to_dict('records')
  
      pmag.magic_write(meas_out, meas_dicts, 'measurements')
      specimens_df.fillna("",inplace=True)
      spec_dicts = specimens_df.to_dict('records')
      pmag.magic_write(spec_out, spec_dicts, 'specimens')
  
      return True