docs: def k15(k15file, dir_path='.', input_dir_path='',
          meas_file='measurements.txt', aniso_outfile='specimens.txt',
          samp_file="samples.txt", result_file ="rmag_anisotropy.txt",
          specnum=0, sample_naming_con='1', location="unknown",
          data_model_num=3):
      """
      converts .k15 format data to MagIC  format.
      assumes Jelinek Kappabridge measurement scheme.
  
      Parameters
      ----------
      k15file : str
          input file name
      dir_path : str
          output file directory, default "."
      input_dir_path : str
          input file directory IF different from dir_path, default ""
      meas_file : str
          output measurement file name, default "measurements.txt"
      aniso_outfile : str
          output specimen file name, default "specimens.txt"
      samp_file: str
          output sample file name, default "samples.txt"
      aniso_results_file : str
          output result file name, default "rmag_results.txt", data model 2 only
      specnum : int
          number of characters to designate a specimen, default 0
      samp_con : str
          sample/site naming convention, default '1', see info below
      location : str
          location name, default "unknown"
      data_model_num : int
          MagIC data model [2, 3], default 3
  
      Returns
      --------
      type - Tuple : (True or False indicating if conversion was sucessful, samp_file name written)
  
  
      Info
      --------
        Infile format:
            name [az,pl,strike,dip], followed by
            3 rows of 5 measurements for each specimen
  
         Sample naming convention:
              [1] XXXXY: where XXXX is an arbitrary length site designation and Y
                  is the single character sample designation.  e.g., TG001a is the
                  first sample from site TG001.    [default]
              [2] XXXX-YY: YY sample from site XXXX (XXX, YY of arbitary length)
              [3] XXXX.YY: YY sample from site XXXX (XXX, YY of arbitary length)
              [4-Z] XXXXYYY:  YYY is sample designation with Z characters from site XXX
              [5] site name same as sample
              [6] site name entered in site_name column in the orient.txt format input file  -- NOT CURRENTLY SUPPORTED
              [7-Z] [XXXX]YYY:  XXXX is site designation with Z characters with sample name XXXXYYYY
              NB: all others you will have to customize your self
                   or e-mail ltauxe@ucsd.edu for help.
  
      """
      #
      # initialize some variables
      #
      input_dir_path, output_dir_path = pmag.fix_directories(input_dir_path, dir_path)
      version_num = pmag.get_version()
      syn = 0
      itilt, igeo, linecnt, key = 0, 0, 0, ""
      first_save = 1
      k15 = []
      citation = 'This study'
  
      data_model_num = int(float(data_model_num))
  
      # set column names for MagIC 3
      spec_name_col = 'specimen'  #
      samp_name_col = 'sample'   #
      site_name_col = 'site'   #
      loc_name_col = 'location' #
      citation_col = 'citations'
      method_col = 'method_codes'
      site_description_col = 'description'
      expedition_col = 'expedition_name'
      instrument_col = 'instrument_codes'
      experiment_col = 'experiments'
      analyst_col = 'analysts'
      quality_col = 'quality'
      aniso_quality_col = 'result_quality'
      meas_standard_col = 'standard'
      meas_description_col = 'description'
      aniso_type_col = 'aniso_type'
      aniso_unit_col = 'aniso_s_unit'
      aniso_n_col = 'aniso_s_n_measurements'
      azimuth_col = 'azimuth'
      spec_volume_col = 'volume'
      samp_dip_col = 'dip'
      bed_dip_col = 'bed_dip'
      bed_dip_direction_col = 'bed_dip_direction'
      chi_vol_col = 'susc_chi_volume'
      aniso_sigma_col = 'aniso_s_sigma'
      aniso_unit_col = 'aniso_s_unit'
      aniso_tilt_corr_col = 'aniso_tilt_correction'
      meas_table_name = 'measurements'
      spec_table_name = 'specimens'
      samp_table_name = 'samples'
      site_table_name = 'sites'
      meas_name_col = 'measurement'
      meas_time_col = 'timestamp'
      meas_ac_col = 'meas_field_ac'
      meas_temp_col = "meas_temp"
      #
      software_col = 'software_packages'
      description_col = 'description' # sites.description
      treat_temp_col = 'treat_temp'
      meas_orient_phi_col = "meas_orient_phi"
      meas_orient_theta_col = "meas_orient_theta"
      aniso_mean_col = 'aniso_s_mean'
      result_description_col = "description"
  
      # set defaults correctly for MagIC 2
      if data_model_num == 2:
          if meas_file == 'measurements.txt':
              meas_file = 'magic_measurements.txt'
          if samp_file == 'samples.txt':
              samp_file = 'er_samples.txt'
          if aniso_outfile == 'specimens.txt':
              aniso_outfile = 'rmag_anisotropy.txt'
  
      # set column names for MagIC 2
      if data_model_num == 2:
          spec_name_col = 'er_specimen_name'
          samp_name_col = 'er_sample_name'
          site_name_col = 'er_site_name'
          loc_name_col = 'er_location_name'
          citation_col = 'er_citation_names'
          method_col = 'magic_method_codes'
          site_description_col = 'site_description'
          expedition_col = 'er_expedition_name'
          instrument_col = 'magic_instrument_codes'
          experiment_col = 'magic_experiment_names'
          analyst_col = 'er_analyst_mail_names'
          quality_col = 'measurement_flag'
          aniso_quality_col = 'anisotropy_flag'
          meas_standard_col = 'measurement_standard'
          meas_description_col = 'measurement_description'
          aniso_type_col = 'anisotropy_type'
          aniso_unit_col = 'anisotropy_unit'
          aniso_n_col = 'anisotropy_n'
          azimuth_col = 'sample_azimuth'
          spec_volume_col = 'specimen_volume'
          samp_dip_col = 'sample_dip'
          bed_dip_col = 'sample_bed_dip'
          bed_dip_direction_col = 'sample_bed_dip_direction'
          chi_vol_col = 'measurement_chi_volume'
          aniso_sigma_col = 'anisotropy_sigma'
          aniso_unit_col = 'anisotropy_unit'
          aniso_tilt_corr_col = 'anisotropy_tilt_correction'
          meas_table_name = 'magic_measurements'
          spec_table_name = 'er_specimens'
          samp_table_name = 'er_samples'
          site_table_name = 'er_sites'
          meas_name_col = 'measurement_number'
          meas_time_col = 'measurement_date'
          meas_ac_col = 'measurement_lab_field_ac'
          meas_temp_col = "measurement_temp"
          #
          software_col = 'magic_software_packages'
          description_col = 'rmag_result_name'
          treat_temp_col = 'treatment_temp'
          meas_temp_col = "measurement_temp"
          meas_orient_phi_col = "measurement_orient_phi"
          meas_orient_theta_col = "measurement_orient_theta"
          aniso_mean_col = 'anisotropy_mean'
          result_description_col = "result_description"
  
  
  # pick off stuff from command line
      Z = ""
      if "4" in sample_naming_con:
          if "-" not in sample_naming_con:
              print("option [4] must be in form 4-Z where Z is an integer")
              return False, "option [4] must be in form 4-Z where Z is an integer"
          else:
              Z = sample_naming_con.split("-")[1]
              sample_naming_con = "4"
      if sample_naming_con == '6':
          Samps, filetype = pmag.magic_read(
              os.path.join(input_dir_path, samp_table_name + ".txt"))
      samp_file = pmag.resolve_file_name(samp_file, output_dir_path)
      meas_file = pmag.resolve_file_name(meas_file, output_dir_path)
      aniso_outfile = pmag.resolve_file_name(aniso_outfile, output_dir_path)
      result_file = pmag.resolve_file_name(result_file, output_dir_path)
      k15file = pmag.resolve_file_name(k15file, input_dir_path)
      if not os.path.exists(k15file):
          print(k15file)
          return False, "You must provide a valid k15 format file"
      try:
          SampRecs, filetype = pmag.magic_read(
              samp_file)  # append new records to existing
          samplist = []
          for samp in SampRecs:
              if samp[samp_name_col] not in samplist:
                  samplist.append(samp[samp_name_col])
      except IOError:
          SampRecs = []
      # measurement directions for Jelinek 1977 protocol:
      Decs = [315, 225, 180, 135, 45, 90, 270, 270, 270, 90, 180, 180, 0, 0, 0]
      Incs = [0, 0, 0, 0, 0, -45, -45, 0, 45, 45, 45, -45, -90, -45, 45]
      # some defaults to read in  .k15 file format
      # list of measurements and default number of characters for specimen ID
  # some magic default definitions
      #
      # read in data
      with open(k15file, 'r') as finput:
          lines = finput.readlines()
      MeasRecs, SpecRecs, AnisRecs, ResRecs = [], [], [], []
      # read in data
      MeasRec, SpecRec, SampRec, SiteRec, AnisRec, ResRec = {}, {}, {}, {}, {}, {}
      for line in lines:
          linecnt += 1
          rec = line.split()
          if linecnt == 1:
              MeasRec[method_col] = ""
              SpecRec[method_col] = ""
              SampRec[method_col] = ""
              AnisRec[method_col] = ""
              SiteRec[method_col] = ""
              ResRec[method_col] = ""
              MeasRec[software_col] = version_num
              SpecRec[software_col] = version_num
              SampRec[software_col] = version_num
              AnisRec[software_col] = version_num
              SiteRec[software_col] = version_num
              ResRec[software_col] = version_num
              MeasRec[method_col] = "LP-X"
              MeasRec[quality_col] = "g"
              MeasRec[meas_standard_col] = "u"
              MeasRec[citation_col] = "This study"
              SpecRec[citation_col] = "This study"
              SampRec[citation_col] = "This study"
              AnisRec[citation_col] = "This study"
              ResRec[citation_col] = "This study"
              MeasRec[spec_name_col] = rec[0]
              MeasRec[experiment_col] = rec[0] + ":LP-AN-MS"
              AnisRec[experiment_col] = rec[0] + ":AMS"
              ResRec[experiment_col] = rec[0] + ":AMS"
              SpecRec[spec_name_col] = rec[0]
              AnisRec[spec_name_col] = rec[0]
              SampRec[spec_name_col] = rec[0]
              if data_model_num == 2:
                  ResRec[description_col] = rec[0]
              if data_model_num == 3:
                  ResRec[spec_name_col] = rec[0]
              specnum = int(specnum)
              if specnum != 0:
                  MeasRec[samp_name_col] = rec[0][:-specnum]
              if specnum == 0:
                  MeasRec[samp_name_col] = rec[0]
              SampRec[samp_name_col] = MeasRec[samp_name_col]
              SpecRec[samp_name_col] = MeasRec[samp_name_col]
              AnisRec[samp_name_col] = MeasRec[samp_name_col]
              if data_model_num == 3:
                  ResRec[samp_name_col] = MeasRec[samp_name_col]
              else:
                  ResRec[samp_name_col + "s"] = MeasRec[samp_name_col]
              if sample_naming_con == "6":
                  for samp in Samps:
                      if samp[samp_name_col] == AnisRec[samp_name_col]:
                          sitename = samp[site_name_col]
                          location = samp[loc_name_col]
              elif sample_naming_con != "":
                  sitename = pmag.parse_site(
                      AnisRec[samp_name_col], sample_naming_con, Z)
              MeasRec[site_name_col] = sitename
              MeasRec[loc_name_col] = location
              SampRec[site_name_col] = MeasRec[site_name_col]
              SpecRec[site_name_col] = MeasRec[site_name_col]
              AnisRec[site_name_col] = MeasRec[site_name_col]
              ResRec[loc_name_col] = location
              ResRec[site_name_col] = MeasRec[site_name_col]
              if data_model_num == 2:
                  ResRec[site_name_col + "s"] = MeasRec[site_name_col]
              SampRec[loc_name_col] = MeasRec[loc_name_col]
              SpecRec[loc_name_col] = MeasRec[loc_name_col]
              AnisRec[loc_name_col] = MeasRec[loc_name_col]
              if data_model_num == 2 :
                  ResRec[loc_name_col + "s"] = MeasRec[loc_name_col]
              if len(rec) >= 3:
                  SampRec[azimuth_col], SampRec[samp_dip_col] = rec[1], rec[2]
                  az, pl, igeo = float(rec[1]), float(rec[2]), 1
              if len(rec) == 5:
                  SampRec[bed_dip_direction_col], SampRec[bed_dip_col] = '%7.1f' % (
                      90. + float(rec[3])), (rec[4])
                  bed_az, bed_dip, itilt, igeo = 90. + \
                      float(rec[3]), float(rec[4]), 1, 1
          else:
              for i in range(5):
                  # assume measurements in micro SI
                  k15.append(1e-6 * float(rec[i]))
              if linecnt == 4:
                  sbar, sigma, bulk = pmag.dok15_s(k15)
                  hpars = pmag.dohext(9, sigma, sbar)
                  MeasRec[treat_temp_col] = '%8.3e' % (
                      273)  # room temp in kelvin
                  MeasRec[meas_temp_col] = '%8.3e' % (
                      273)  # room temp in kelvin
                  for i in range(15):
                      NewMeas = copy.deepcopy(MeasRec)
                      NewMeas[meas_orient_phi_col] = '%7.1f' % (Decs[i])
                      NewMeas[meas_orient_theta_col] = '%7.1f' % (Incs[i])
                      NewMeas[chi_vol_col] = '%12.10f' % (k15[i])
                      NewMeas[meas_name_col] = '%i' % (i + 1)
                      if data_model_num == 2:
                          NewMeas["magic_experiment_name"] = rec[0] + ":LP-AN-MS"
                      else:
                          NewMeas["experiment"] = rec[0] + ":LP-AN-MS"
                      MeasRecs.append(NewMeas)
                  if SampRec[samp_name_col] not in samplist:
                      SampRecs.append(SampRec)
                      samplist.append(SampRec[samp_name_col])
                  SpecRecs.append(SpecRec)
                  AnisRec[aniso_type_col] = "AMS"
                  ResRec[aniso_type_col] = "AMS"
                  s1_val = '{:12.10f}'.format(sbar[0])
                  s2_val = '{:12.10f}'.format(sbar[1])
                  s3_val = '{:12.10f}'.format(sbar[2])
                  s4_val = '{:12.10f}'.format(sbar[3])
                  s5_val = '{:12.10f}'.format(sbar[4])
                  s6_val = '{:12.10f}'.format(sbar[5])
                  # MAgIC 2
                  if data_model_num == 2:
                      AnisRec["anisotropy_s1"] = s1_val
                      AnisRec["anisotropy_s2"] = s2_val
                      AnisRec["anisotropy_s3"] = s3_val
                      AnisRec["anisotropy_s4"] = s4_val
                      AnisRec["anisotropy_s5"] = s5_val
                      AnisRec["anisotropy_s6"] = s6_val
                  # MagIC 3
                  else:
                      vals = [s1_val, s2_val, s3_val, s4_val, s5_val, s6_val]
                      AnisRec['aniso_s'] = ":".join([str(v).strip() for v in vals])
                  AnisRec[aniso_mean_col] = '%12.10f' % (bulk)
                  AnisRec[aniso_sigma_col] = '%12.10f' % (sigma)
                  AnisRec[aniso_mean_col] = '{:12.10f}'.format(bulk)
                  AnisRec[aniso_sigma_col] = '{:12.10f}'.format(sigma)
                  AnisRec[aniso_unit_col] = 'SI'
                  AnisRec[aniso_n_col] = '15'
                  AnisRec[aniso_tilt_corr_col] = '-1'
                  AnisRec[method_col] = 'LP-X:AE-H:LP-AN-MS'
                  AnisRecs.append(AnisRec)
                  ResRec[method_col] = 'LP-X:AE-H:LP-AN-MS'
                  ResRec[aniso_tilt_corr_col] = '-1'
  
                  if data_model_num == 3:
                      aniso_v1 = ':'.join([str(i) for i in (hpars['t1'], hpars['v1_dec'], hpars['v1_inc'],  hpars['v2_dec'], hpars['v2_inc'], hpars['e12'], hpars['v3_dec'], hpars['v3_inc'], hpars['e13'])])
                      aniso_v2 = ':'.join([str(i) for i in (hpars['t2'], hpars['v2_dec'], hpars['v2_inc'], hpars['v1_dec'], hpars['v1_inc'], hpars['e12'], hpars['v3_dec'], hpars['v3_inc'], hpars['e23'])])
                      aniso_v3 = ':'.join([str(i) for i in (hpars['t3'], hpars['v3_dec'], hpars['v3_inc'], hpars['v1_dec'], hpars['v1_inc'], hpars['e13'], hpars['v2_dec'], hpars['v2_inc'], hpars['e23'])])
                      ResRec['aniso_v1'] = aniso_v1
                      ResRec['aniso_v2'] = aniso_v2
                      ResRec['aniso_v3'] = aniso_v3
                  else: # data model 2
                      ResRec["anisotropy_t1"] = '%12.10f' % (hpars['t1'])
                      ResRec["anisotropy_t2"] = '%12.10f' % (hpars['t2'])
                      ResRec["anisotropy_t3"] = '%12.10f' % (hpars['t3'])
                      ResRec["anisotropy_fest"] = '%12.10f' % (hpars['F'])
                      ResRec["anisotropy_ftest12"] = '%12.10f' % (hpars['F12'])
                      ResRec["anisotropy_ftest23"] = '%12.10f' % (hpars['F23'])
                      ResRec["anisotropy_v1_dec"] = '%7.1f' % (hpars['v1_dec'])
                      ResRec["anisotropy_v2_dec"] = '%7.1f' % (hpars['v2_dec'])
                      ResRec["anisotropy_v3_dec"] = '%7.1f' % (hpars['v3_dec'])
                      ResRec["anisotropy_v1_inc"] = '%7.1f' % (hpars['v1_inc'])
                      ResRec["anisotropy_v2_inc"] = '%7.1f' % (hpars['v2_inc'])
                      ResRec["anisotropy_v3_inc"] = '%7.1f' % (hpars['v3_inc'])
                      ResRec['anisotropy_v1_eta_dec'] = ResRec['anisotropy_v2_dec']
                      ResRec['anisotropy_v1_eta_inc'] = ResRec['anisotropy_v2_inc']
                      ResRec['anisotropy_v1_zeta_dec'] = ResRec['anisotropy_v3_dec']
                      ResRec['anisotropy_v1_zeta_inc'] = ResRec['anisotropy_v3_inc']
                      ResRec['anisotropy_v2_eta_dec'] = ResRec['anisotropy_v1_dec']
                      ResRec['anisotropy_v2_eta_inc'] = ResRec['anisotropy_v1_inc']
                      ResRec['anisotropy_v2_zeta_dec'] = ResRec['anisotropy_v3_dec']
                      ResRec['anisotropy_v2_zeta_inc'] = ResRec['anisotropy_v3_inc']
                      ResRec['anisotropy_v3_eta_dec'] = ResRec['anisotropy_v1_dec']
                      ResRec['anisotropy_v3_eta_inc'] = ResRec['anisotropy_v1_inc']
                      ResRec['anisotropy_v3_zeta_dec'] = ResRec['anisotropy_v2_dec']
                      ResRec['anisotropy_v3_zeta_inc'] = ResRec['anisotropy_v2_inc']
                      ResRec["anisotropy_v1_eta_semi_angle"] = '%7.1f' % (
                          hpars['e12'])
                      ResRec["anisotropy_v1_zeta_semi_angle"] = '%7.1f' % (
                          hpars['e13'])
                      ResRec["anisotropy_v2_eta_semi_angle"] = '%7.1f' % (
                          hpars['e12'])
                      ResRec["anisotropy_v2_zeta_semi_angle"] = '%7.1f' % (
                          hpars['e23'])
                      ResRec["anisotropy_v3_eta_semi_angle"] = '%7.1f' % (
                          hpars['e13'])
                      ResRec["anisotropy_v3_zeta_semi_angle"] = '%7.1f' % (
                          hpars['e23'])
                  ResRec[result_description_col] = 'Critical F: ' + hpars["F_crit"] + ';Critical F12/F13: ' + hpars["F12_crit"]
                  #
                  ResRecs.append(ResRec)
                  if igeo == 1:
                      sbarg = pmag.dosgeo(sbar, az, pl)
                      hparsg = pmag.dohext(9, sigma, sbarg)
                      AnisRecG = copy.copy(AnisRec)
                      ResRecG = copy.copy(ResRec)
                      if data_model_num == 3:
                          AnisRecG["aniso_s"] = ":".join('{:12.10f}'.format(i) for i in sbarg)
                      if data_model_num == 2:
                          AnisRecG["anisotropy_s1"] = '%12.10f' % (sbarg[0])
                          AnisRecG["anisotropy_s2"] = '%12.10f' % (sbarg[1])
                          AnisRecG["anisotropy_s3"] = '%12.10f' % (sbarg[2])
                          AnisRecG["anisotropy_s4"] = '%12.10f' % (sbarg[3])
                          AnisRecG["anisotropy_s5"] = '%12.10f' % (sbarg[4])
                          AnisRecG["anisotropy_s6"] = '%12.10f' % (sbarg[5])
  
                      AnisRecG[aniso_tilt_corr_col] = '0'
                      ResRecG[aniso_tilt_corr_col] = '0'
  
                      if data_model_num == 3:
                          aniso_v1 = ':'.join([str(i) for i in (hparsg['t1'], hparsg['v1_dec'], hparsg['v1_inc'],  hparsg['v2_dec'], hparsg['v2_inc'], hparsg['e12'], hparsg['v3_dec'], hparsg['v3_inc'], hparsg['e13'])])
                          aniso_v2 = ':'.join([str(i) for i in (hparsg['t2'], hparsg['v2_dec'], hparsg['v2_inc'], hparsg['v1_dec'], hparsg['v1_inc'], hparsg['e12'], hparsg['v3_dec'], hparsg['v3_inc'], hparsg['e23'])])
                          aniso_v3 = ':'.join([str(i) for i in (hparsg['t3'], hparsg['v3_dec'], hparsg['v3_inc'], hparsg['v1_dec'], hparsg['v1_inc'], hparsg['e13'], hparsg['v2_dec'], hparsg['v2_inc'], hparsg['e23'])])
                          ResRecG['aniso_v1'] = aniso_v1
                          ResRecG['aniso_v2'] = aniso_v2
                          ResRecG['aniso_v3'] = aniso_v3
                      #
                      if data_model_num == 2:
                          ResRecG["anisotropy_v1_dec"] = '%7.1f' % (hparsg['v1_dec'])
                          ResRecG["anisotropy_v2_dec"] = '%7.1f' % (hparsg['v2_dec'])
                          ResRecG["anisotropy_v3_dec"] = '%7.1f' % (hparsg['v3_dec'])
                          ResRecG["anisotropy_v1_inc"] = '%7.1f' % (hparsg['v1_inc'])
                          ResRecG["anisotropy_v2_inc"] = '%7.1f' % (hparsg['v2_inc'])
                          ResRecG["anisotropy_v3_inc"] = '%7.1f' % (hparsg['v3_inc'])
                          ResRecG['anisotropy_v1_eta_dec'] = ResRecG['anisotropy_v2_dec']
                          ResRecG['anisotropy_v1_eta_inc'] = ResRecG['anisotropy_v2_inc']
                          ResRecG['anisotropy_v1_zeta_dec'] = ResRecG['anisotropy_v3_dec']
                          ResRecG['anisotropy_v1_zeta_inc'] = ResRecG['anisotropy_v3_inc']
                          ResRecG['anisotropy_v2_eta_dec'] = ResRecG['anisotropy_v1_dec']
                          ResRecG['anisotropy_v2_eta_inc'] = ResRecG['anisotropy_v1_inc']
                          ResRecG['anisotropy_v2_zeta_dec'] = ResRecG['anisotropy_v3_dec']
                          ResRecG['anisotropy_v2_zeta_inc'] = ResRecG['anisotropy_v3_inc']
                          ResRecG['anisotropy_v3_eta_dec'] = ResRecG['anisotropy_v1_dec']
                          ResRecG['anisotropy_v3_eta_inc'] = ResRecG['anisotropy_v1_inc']
                          ResRecG['anisotropy_v3_zeta_dec'] = ResRecG['anisotropy_v2_dec']
                          ResRecG['anisotropy_v3_zeta_inc'] = ResRecG['anisotropy_v2_inc']
                      #
                      ResRecG[result_description_col] = 'Critical F: ' + \
                          hpars["F_crit"] + ';Critical F12/F13: ' + \
                          hpars["F12_crit"]
                      ResRecs.append(ResRecG)
                      AnisRecs.append(AnisRecG)
                  if itilt == 1:
                      sbart = pmag.dostilt(sbarg, bed_az, bed_dip)
                      hparst = pmag.dohext(9, sigma, sbart)
                      AnisRecT = copy.copy(AnisRec)
                      ResRecT = copy.copy(ResRec)
                      if data_model_num == 3:
                          aniso_v1 = ':'.join([str(i) for i in (hparst['t1'], hparst['v1_dec'], hparst['v1_inc'],  hparst['v2_dec'], hparst['v2_inc'], hparst['e12'], hparst['v3_dec'], hparst['v3_inc'], hparst['e13'])])
                          aniso_v2 = ':'.join([str(i) for i in (hparst['t2'], hparst['v2_dec'], hparst['v2_inc'], hparst['v1_dec'], hparst['v1_inc'], hparst['e12'], hparst['v3_dec'], hparst['v3_inc'], hparst['e23'])])
                          aniso_v3 = ':'.join([str(i) for i in (hparst['t3'], hparst['v3_dec'], hparst['v3_inc'], hparst['v1_dec'], hparst['v1_inc'], hparst['e13'], hparst['v2_dec'], hparst['v2_inc'], hparst['e23'])])
                          ResRecT['aniso_v1'] = aniso_v1
                          ResRecT['aniso_v2'] = aniso_v2
                          ResRecT['aniso_v3'] = aniso_v3
                      #
                      if data_model_num == 2:
                          AnisRecT["anisotropy_s1"] = '%12.10f' % (sbart[0])
                          AnisRecT["anisotropy_s2"] = '%12.10f' % (sbart[1])
                          AnisRecT["anisotropy_s3"] = '%12.10f' % (sbart[2])
                          AnisRecT["anisotropy_s4"] = '%12.10f' % (sbart[3])
                          AnisRecT["anisotropy_s5"] = '%12.10f' % (sbart[4])
                          AnisRecT["anisotropy_s6"] = '%12.10f' % (sbart[5])
                          AnisRecT["anisotropy_tilt_correction"] = '100'
                          ResRecT["anisotropy_v1_dec"] = '%7.1f' % (hparst['v1_dec'])
                          ResRecT["anisotropy_v2_dec"] = '%7.1f' % (hparst['v2_dec'])
                          ResRecT["anisotropy_v3_dec"] = '%7.1f' % (hparst['v3_dec'])
                          ResRecT["anisotropy_v1_inc"] = '%7.1f' % (hparst['v1_inc'])
                          ResRecT["anisotropy_v2_inc"] = '%7.1f' % (hparst['v2_inc'])
                          ResRecT["anisotropy_v3_inc"] = '%7.1f' % (hparst['v3_inc'])
                          ResRecT['anisotropy_v1_eta_dec'] = ResRecT['anisotropy_v2_dec']
                          ResRecT['anisotropy_v1_eta_inc'] = ResRecT['anisotropy_v2_inc']
                          ResRecT['anisotropy_v1_zeta_dec'] = ResRecT['anisotropy_v3_dec']
                          ResRecT['anisotropy_v1_zeta_inc'] = ResRecT['anisotropy_v3_inc']
                          ResRecT['anisotropy_v2_eta_dec'] = ResRecT['anisotropy_v1_dec']
                          ResRecT['anisotropy_v2_eta_inc'] = ResRecT['anisotropy_v1_inc']
                          ResRecT['anisotropy_v2_zeta_dec'] = ResRecT['anisotropy_v3_dec']
                          ResRecT['anisotropy_v2_zeta_inc'] = ResRecT['anisotropy_v3_inc']
                          ResRecT['anisotropy_v3_eta_dec'] = ResRecT['anisotropy_v1_dec']
                          ResRecT['anisotropy_v3_eta_inc'] = ResRecT['anisotropy_v1_inc']
                          ResRecT['anisotropy_v3_zeta_dec'] = ResRecT['anisotropy_v2_dec']
                          ResRecT['anisotropy_v3_zeta_inc'] = ResRecT['anisotropy_v2_inc']
                      #
                      ResRecT[aniso_tilt_corr_col] = '100'
                      ResRecT[result_description_col] = 'Critical F: ' + \
                          hparst["F_crit"] + ';Critical F12/F13: ' + \
                          hparst["F12_crit"]
                      ResRecs.append(ResRecT)
                      AnisRecs.append(AnisRecT)
                  k15, linecnt = [], 0
                  MeasRec, SpecRec, SampRec, SiteRec, AnisRec = {}, {}, {}, {}, {}
  
      # samples
      pmag.magic_write(samp_file, SampRecs, samp_table_name)
      # specimens / rmag_anisotropy / rmag_results
      if data_model_num == 3:
          AnisRecs.extend(ResRecs)
          SpecRecs = AnisRecs.copy()
          SpecRecs, keys = pmag.fillkeys(SpecRecs)
          pmag.magic_write(aniso_outfile, SpecRecs, 'specimens')
          flist = [meas_file, aniso_outfile, samp_file]
      else:
          pmag.magic_write(aniso_outfile, AnisRecs, 'rmag_anisotropy')  # add to specimens?
          pmag.magic_write(result_file, ResRecs, 'rmag_results') # added to specimens (NOT sites)
          flist = [meas_file, samp_file, aniso_outfile, result_file]
      # measurements
      pmag.magic_write(meas_file, MeasRecs, meas_table_name)
  
      print("Data saved to: " + ", ".join(flist))
      return True, meas_file