docs: def get_data(self):
          """
          reads data from current WD measurement.txt or magic_measurements.txt
          depending on data model and sorts it into main measurements data
          structures given bellow:
          Data - {specimen: {
                  zijdblock:[[treatment temp-str,dec-float, inc-float,
                          mag_moment-float, ZI-float, meas_flag-str ('b','g'),
                          method_codes-str]],
                  zijdblock_geo:[[treatment temp-str,dec-float, inc-float,
                          mag_moment-float, ZI-float, meas_flag-str ('b','g'),
                          method_codes-str]],
                  zijdblock_tilt:[[treatment temp-str,dec-float, inc-float,
                          mag_moment-float, ZI-float, meas_flag-str ('b','g'),
                          method_codes-str]],
                  zijdblock_lab_treatments: [str],
                  zijdblock_steps: [str],
                  measurement_flag: [str ('b','g')],
                  mag_meas_data_index: [int],
                  csds: [float],
                  pars: {},
                  zdata: array.shape = 2x2 (float),
                  zdata_geo: array.shape = 2x2 (float),
                  zdata_tilt: array.shape = 2x2 (float),
                  vector_diffs: [float],
                  vds: float }}
          Data_hierarchy - {specimen: {
                              study: {}
                              locations: {}
                              sites: {}
                              samples: {}
                              specimens: {}
                              sample_of_specimen: {}
                              site_of_specimen: {}
                              site_of_sample: {}
                              location_of_site: {}
                              location_of_specimen: {}
                              study_of_specimen: {}
                              expedition_name_of_specimen: {} }}
          """
          # ------------------------------------------------
          # Read magic measurement file and sort to blocks
          # ------------------------------------------------
  
          # All meas data information is stored in Data[secimen]={}
          Data = {}
          Data_hierarchy = {}
          Data_hierarchy['study'] = {}
          Data_hierarchy['locations'] = {}
          Data_hierarchy['sites'] = {}
          Data_hierarchy['samples'] = {}
          Data_hierarchy['specimens'] = {}
          Data_hierarchy['sample_of_specimen'] = {}
          Data_hierarchy['site_of_specimen'] = {}
          Data_hierarchy['site_of_sample'] = {}
          Data_hierarchy['location_of_site'] = {}
          Data_hierarchy['location_of_specimen'] = {}
          Data_hierarchy['study_of_specimen'] = {}
          Data_hierarchy['expedition_name_of_specimen'] = {}
  
          if self.data_model == 3:
  
              if 'measurements' not in self.con.tables:
                  self.user_warning(
                      "Measurement data file is empty and the GUI cannot start, aborting")
                  return Data, Data_hierarchy
  
              if self.con.tables['measurements'].df.empty:
                  self.user_warning(
                      "Measurement data file is empty and the GUI cannot start, aborting")
                  return Data, Data_hierarchy
  
              # extract specimen data from measurements table
              if not len(self.spec_data):
                  specs = self.con.tables['measurements'].df['specimen'].unique()
                  df = pd.DataFrame(index=specs, columns=['specimen'])
                  df.index.name = 'specimen_name'
                  df['specimen'] = specs
                  self.con.tables['specimens'].df = df
                  self.spec_data = df
  
              if not len(self.spec_data):
                  self.user_warning(
                      "Measurement data file does not seem to have specimen data and the GUI cannot start, aborting")
                  return Data, Data_hierarchy
  
  
              if 'sample' not in self.spec_data.columns or 'sample' not in self.samp_data.columns:
                  if 'specimen' not in self.spec_data.columns:
                      self.spec_data['specimen'] = self.con.tables['measurements'].df['specimen']
                      self.spec_data.set_index('specimen', inplace=True)
                      self.spec_data['specimen'] = self.spec_data.index
  
                  ui_dialog = demag_dialogs.user_input(
                      self, ["# of characters to remove"], heading="Sample data could not be found attempting to generate sample names by removing characters from specimen names")
                  self.show_dlg(ui_dialog)
                  ui_data = ui_dialog.get_values()
                  try:
                      samp_ncr = int(ui_data[1]["# of characters to remove"])
                  except ValueError:
                      self.user_warning(
                          "Invalid input, specimen names will be used for sample names instead")
                      samp_ncr = 0
                  self.spec_data['sample'] = [x[:-samp_ncr]
                                              for x in self.spec_data['specimen']]
  
                  self.samp_data['sample'] = self.spec_data['sample']
                  self.samp_data.set_index('sample', inplace=True)
                  self.samp_data['sample'] = self.samp_data.index
  
              if 'site' not in self.samp_data.columns or 'site' not in self.site_data.columns:
                  ui_dialog = demag_dialogs.user_input(
                      self, ["# of characters to remove", "site delimiter"], heading="No Site Data found attempting to create site names from specimen names")
                  self.show_dlg(ui_dialog)
                  ui_data = ui_dialog.get_values()
                  try:
                      site_ncr = int(ui_data[1]["# of characters to remove"])
                      self.samp_data['site'] = [x[:-site_ncr]
                                                for x in self.spec_data['specimen']]
                  except ValueError:
                      try:
                          sd = ui_data[1]["site delimiter"]
                          self.samp_data['site'] = [
                              x.split(sd)[0] for x in self.spec_data['specimen']]
                      except ValueError:
                          self.samp_data['site'] = [
                              x for x in self.spec_data['specimen']]
  
                  self.site_data['site'] = self.samp_data['site']
                  self.site_data.drop_duplicates(inplace=True)
                  self.site_data.set_index('site', inplace=True)
                  self.site_data['site'] = self.site_data.index
  
              if 'location' not in self.site_data.columns or 'location' not in self.loc_data.columns:
                  ui_dialog = demag_dialogs.user_input(
                      self, ["location name for all sites"], heading="No Location found")
                  self.show_dlg(ui_dialog)
                  ui_data = ui_dialog.get_values()
                  self.site_data['location'] = ui_data[1]["location name for all sites"]
  
                  self.loc_data['location'] = self.site_data['location']
                  self.loc_data.drop_duplicates(inplace=True)
                  self.loc_data.set_index('location', inplace=True)
                  self.loc_data['location'] = self.loc_data.index
  
              # add data to other dataframes
              self.con.propagate_location_to_measurements()
              self.con.propagate_location_to_specimens()
  
              # get measurement data from contribution object
              meas_container = self.con.tables['measurements']
              meas_data3_0 = meas_container.df
  
              meas_data3_0.replace({'specimen': {nan: 'unknown'}, 'sample': {nan: 'unknown'}, 'site': {
                                   nan: 'unknown'}, 'location': {nan: 'unknown'}}, inplace=True)
              meas_data3_0['specimen'] = meas_data3_0['specimen'].apply(str)
              meas_data3_0['sample'] = meas_data3_0['sample'].apply(str)
              meas_data3_0['site'] = meas_data3_0['site'].apply(str)
              meas_data3_0['location'] = meas_data3_0['location'].apply(str)
  
              # do some filtering
  #            if 'location' in meas_data3_0.columns:
  #                if any(meas_data3_0['location'].isnull()):
  #                    print("-W- Some measurements are missing location data, and will not be used")
  #                meas_data3_0 = meas_data3_0[meas_data3_0['location'].notnull()]
  # meas_data3_0.replace({'location':float('nan')},'unknown',inplace=True)
  #            if 'site' in meas_data3_0.columns:
  #                if any(meas_data3_0['site'].isnull()):
  #                    print("-W- Some measurements are missing site data, and will not be used")
  #                meas_data3_0 = meas_data3_0[meas_data3_0['site'].notnull()]
  # meas_data3_0.replace({'site':float('nan')},'unknown',inplace=True)
  #            if 'sample' in meas_data3_0.columns:
  #                if any(meas_data3_0['sample'].isnull()):
  #                    print("-W- Some measurements are missing sample data, and will not be used")
  #                meas_data3_0 = meas_data3_0[meas_data3_0['sample'].notnull()]
  # meas_data3_0.replace({'sample':float('nan')},'unknown',inplace=True)
  #            if 'specimen' in meas_data3_0.columns:
  #                missing = meas_data3_0[meas_data3_0['specimen'].isnull()]
  #                if len(missing):
  #                    print("-W- {} measurements are missing specimen data, and will not be used".format(missing))
  #                meas_data3_0 = meas_data3_0[meas_data3_0['specimen'].notnull()]
  # meas_data3_0.replace({'specimen':float('nan')},'unknown',inplace=True)
  
  #            col_names = ['specimen', 'sample', 'site', 'location']
  #            for col_name in col_names:
  #                if col_name in meas_data3_0.columns:
  #                    pruned = meas_data3_0[meas_data3_0[col_name].apply(cb.not_null)]
  #                    num_missing = len(meas_data3_0) - len(pruned)
  #                    if num_missing:
  #                        msg = "{} measurements cannot be associated with a {} and will be excluded\nTry using Pmag GUI (step 3) to make sure you have provided the full chain from specimen to location.".format(num_missing, col_name)
  #                        pw.simple_warning(msg)
  #                        print("-W- {} measurements are missing {} data and will be excluded".format(num_missing, col_name))
  #                        meas_data3_0 = pruned
              Mkeys = ['magn_moment', 'magn_volume', 'magn_mass']
  # fish out all the relavent data
              meas_data3_0 = meas_data3_0[meas_data3_0['method_codes'].str.contains(
                  'LT-NO|LT-AF-Z|LT-T-Z|LT-M-Z|LT-LT-Z') == True]
              if not len(meas_data3_0):
                  self.user_warning("Your measurements table contains none of the required method codes to run Demag GUI: [LT-NO, LT-AF-Z, LT-T-Z, LT-M-Z, LT-LT-Z]")
                  return {}, {}
  # now convert back to 2.5  changing only those keys that are necessary for thellier_gui
              meas_con_dict = map_magic.get_thellier_gui_meas_mapping(
                  meas_data3_0, output=2)
              intensity_col = cb.get_intensity_col(meas_data3_0)
              if not intensity_col:
                  self.user_warning("Your measurements table must have one of the following columns to run Demag GUI: 'magn_moment', 'magn_volume', 'magn_mass',or 'magn_uncal'")
                  return {}, {}
  
              print('-I- Using {} for intensity'.format(intensity_col))
              self.intensity_col = meas_con_dict[intensity_col]
              meas_data2_5 = meas_data3_0.rename(columns=meas_con_dict)
              # make a list of dictionaries to maintain backward compatibility
              mag_meas_data = meas_data2_5.to_dict("records")
  
          else:  # data model 2.5
              try:
                  print(("-I- Read magic file %s" % self.magic_file))
              except ValueError:
                  self.magic_measurement = self.choose_meas_file()
                  print(("-I- Read magic file %s" % self.magic_file))
              mag_meas_data, file_type = pmag.magic_read(self.magic_file)
              if file_type != "magic_measurements":
                  self.user_warning("You have selected data model 2.5, but your measurements file is either not in 2.5, or is not a measurements file.\n{} has file type: {}".format(self.magic_file, file_type))
                  return {}, {}
  
  
          self.mag_meas_data = self.merge_pmag_recs(mag_meas_data)
  
          # get list of unique specimen names with measurement data
          CurrRec = []
          sids = pmag.get_specs(self.mag_meas_data)  # specimen ID's
          for s in sids:
              if s not in list(Data.keys()):
                  Data[s] = {}
                  Data[s]['zijdblock'] = []
                  Data[s]['zijdblock_geo'] = []
                  Data[s]['zijdblock_tilt'] = []
                  Data[s]['zijdblock_lab_treatments'] = []
                  Data[s]['pars'] = {}
                  Data[s]['csds'] = []
                  Data[s]['zijdblock_steps'] = []
                  Data[s]['measurement_flag'] = []  # a list of points 'g' or 'b'
                  # index in original magic_measurements.txt
                  Data[s]['mag_meas_data_index'] = []
                  Data[s]['measurement_names'] = []
  
          prev_s = None
          cnt = -1
          # list of excluded lab protocols. copied from pmag.find_dmag_rec(s,data)
          self.excluded_methods = ["LP-AN-ARM", "LP-AN-TRM", "LP-ARM-AFD",
                                   "LP-ARM2-AFD", "LP-TRM-AFD", "LP-TRM", "LP-TRM-TD", "LP-X", "LP-PI-ARM"]
          self.included_methods = [
              "LT-NO", "LT-AF-Z", "LT-T-Z", "LT-M-Z", "LT-LT-Z"]
  #        self.mag_meas_data.sort(key=meas_key)
          # asiigned default values for NRM
          if len(self.mag_meas_data) > 0 and self.intensity_col in list(self.mag_meas_data[0].keys()):
              NRM = float(self.mag_meas_data[0][self.intensity_col])
          for rec in self.mag_meas_data:
              # if "measurement_number" in rec.keys() and str(rec['measurement_number']) == '1' and "magic_method_codes" in rec.keys() and "LT-NO" not in rec["magic_method_codes"].split(':'):
              #    NRM = 1 #not really sure how to handle this case but assume that data is already normalized
              cnt += 1  # index counter
              s = rec["er_specimen_name"]
              if "er_sample_name" in list(rec.keys()):
                  sample = rec["er_sample_name"]
              else:
                  sample = ''
              if "er_site_name" in list(rec.keys()):
                  site = rec["er_site_name"]
              else:
                  site = ''
              if "er_location_name" in list(rec.keys()):
                  location = rec["er_location_name"]
              else:
                  location = ''
              expedition_name = ""
              if "er_expedition_name" in list(rec.keys()):
                  expedition_name = rec["er_expedition_name"]
  
              methods = rec["magic_method_codes"].replace(
                  " ", "").strip("\n").split(":")
              LP_methods = []
              LT_methods = []
  
              for k in ['zdata', 'zdata_geo', 'zdata_tilt', 'vector_diffs']:
                  if k not in Data[s]:
                      Data[s][k] = []
  
              for i in range(len(methods)):
                  methods[i] = methods[i].strip()
              if 'measurement_flag' not in list(rec.keys()):
                  rec['measurement_flag'] = 'g'
              SKIP = True
              lab_treatment = ""
              for meth in methods:
                  if 'DIR' in meth:
                      SKIP = False
                  if meth in self.included_methods:
                      lab_treatment = meth
                      SKIP = False
                  if "LP" in meth:
                      LP_methods.append(meth)
              for meth in self.excluded_methods:
                  if meth in methods:
                      SKIP = True
                      break
              if SKIP:
                  continue
              tr, LPcode, measurement_step_unit = "", "", ""
              if "LT-NO" in methods:
                  tr = 0
                  if prev_s != s and self.intensity_col in rec:
                      try:
                          NRM = float(rec[self.intensity_col])
                      except ValueError:
                          NRM = 1
                  for method in methods:
                      if "AF" in method:
                          LPcode = "LP-DIR-AF"
                          measurement_step_unit = "mT"
                      if "TRM" in method:
                          LPcode = "LP-DIR-T"
                          measurement_step_unit = "C"
              elif "LT-AF-Z" in methods:
                  try:
                      tr = float(rec["treatment_ac_field"])*1e3  # (mT)
                  except ValueError:
                      print(("Could not convert ac field for measurement, was given %s, skipping" %
                             rec["treatment_ac_field"]))
                      continue
                  measurement_step_unit = "mT"  # in magic its T in GUI its mT
                  LPcode = "LP-DIR-AF"
              elif "LT-T-Z" in methods or "LT-LT-Z" in methods:
                  try:
                      tr = float(rec["treatment_temp"])-273.  # celsius
                  except ValueError:
                      print(
                          ("Could not convert temperature for measurement, was given %s, skipping" % rec["treatment_temp"]))
                      continue
                  measurement_step_unit = "C"  # in magic its K in GUI its C
                  LPcode = "LP-DIR-T"
              elif "LT-M-Z" in methods:
                  # temporary for microwave
                  tr = float(rec["measurement_number"])
              else:
                  # attempt to determine from treatment data
                  if all(im not in methods for im in self.included_methods):
                      if 'treatment_temp' in list(rec.keys()) and not str(rec['treatment_temp']).isalpha() and rec['treatment_temp'] != '' and float(rec['treatment_temp']) > 0:
                          tr = float(rec["treatment_temp"])-273.  # celsius
                          measurement_step_unit = "C"  # in magic its K in GUI its C
                          LPcode = "LP-DIR-T"
                      elif 'treatment_ac_field' in list(rec.keys()) and not str(rec['treatment_ac_field']).isalpha() and rec['treatment_ac_field'] != '' and float(rec['treatment_ac_field']) > 0:
                          tr = float(rec["treatment_ac_field"])*1e3  # (mT)
                          measurement_step_unit = "mT"  # in magic its T in GUI its mT
                          LPcode = "LP-DIR-AF"
                      else:
                          tr = 0
                          if prev_s != s and self.intensity_col in rec:
                              try:
                                  NRM = float(rec[self.intensity_col])
                              except ValueError:
                                  NRM = 1
                          for method in methods:
                              if "AF" in method:
                                  LPcode = "LP-DIR-AF"
                                  measurement_step_unit = "mT"
                              if "TRM" in method:
                                  LPcode = "LP-DIR-T"
                                  measurement_step_unit = "C"
                  else:
                      tr = float(rec["measurement_number"])
              if prev_s != s and len(Data[s]['zijdblock']) > 0:
                  NRM = Data[s]['zijdblock'][0][3]
  
              ZI = 0
              if tr != "":
                  Data[s]['mag_meas_data_index'].append(
                      cnt)  # magic_measurement file intex
                  if not int(self.data_model) == 2:
                      try:
                          Data[s]['measurement_names'].append(rec['measurement'])
                      except KeyError:
                          Data[s]['measurement_names'].append(rec['measurement_number'])
                  Data[s]['zijdblock_lab_treatments'].append(lab_treatment)
                  if measurement_step_unit != "":
                      if 'measurement_step_unit' in list(Data[s].keys()):
                          if measurement_step_unit not in Data[s]['measurement_step_unit'].split(":"):
                              Data[s]['measurement_step_unit'] = Data[s]['measurement_step_unit'] + \
                                  ":"+measurement_step_unit
                      else:
                          Data[s]['measurement_step_unit'] = measurement_step_unit
                  dec, inc, inten = "", "", ""
                  if "measurement_dec" in list(rec.keys()) and cb.not_null(rec["measurement_dec"], False):
                      dec = float(rec["measurement_dec"])
                  else:
                      continue
                  if "measurement_inc" in list(rec.keys()) and cb.not_null(rec["measurement_inc"], False):
                      inc = float(rec["measurement_inc"])
                  else:
                      continue
                  if self.intensity_col in list(rec.keys()) and cb.not_null(rec[self.intensity_col], False):
                      intensity = float(rec[self.intensity_col])
                  else:
                      intensity = 1.  # just assume a normal vector
                  if 'magic_instrument_codes' not in list(rec.keys()):
                      rec['magic_instrument_codes'] = ''
                  if 'measurement_csd' in list(rec.keys()):
                      csd = str(rec['measurement_csd'])
                  else:
                      csd = ''
                  Data[s]['zijdblock'].append(
                      [tr, dec, inc, intensity, ZI, rec['measurement_flag'], rec['magic_instrument_codes']])
                  Data[s]['csds'].append(csd)
                  DIR = [dec, inc, intensity/NRM]
                  cart = pmag.dir2cart(DIR)
                  Data[s]['zdata'].append(array([cart[0], cart[1], cart[2]]))
  
                  if 'magic_experiment_name' in list(Data[s].keys()) and Data[s]['magic_experiment_name'] != rec["magic_experiment_name"]:
                      print(("-E- ERROR: specimen %s has more than one demagnetization experiment name. You need to merge them to one experiment-name?" % (s)))
                  if float(tr) == 0 or float(tr) == 273:
                      Data[s]['zijdblock_steps'].append("0")
                  elif measurement_step_unit == "C":
                      Data[s]['zijdblock_steps'].append(
                          "%.0f%s" % (tr, measurement_step_unit))
                  else:
                      Data[s]['zijdblock_steps'].append(
                          "%.1f%s" % (tr, measurement_step_unit))
                  # --------------
                  if 'magic_experiment_name' in list(rec.keys()):
                      Data[s]['magic_experiment_name'] = rec["magic_experiment_name"]
                  if "magic_instrument_codes" in list(rec.keys()):
                      Data[s]['magic_instrument_codes'] = rec['magic_instrument_codes']
                  Data[s]["magic_method_codes"] = LPcode
  
                  # --------------
                  # ""good" or "bad" data
                  # --------------
  
                  flag = 'g'
                  if 'measurement_flag' in list(rec.keys()):
                      if str(rec["measurement_flag"]) == 'b':
                          flag = 'b'
                  Data[s]['measurement_flag'].append(flag)
  
                  # gegraphic coordinates
                  try:
                      sample_azimuth = float(
                          self.Data_info["er_samples"][sample]['sample_azimuth'])
                      sample_dip = float(
                          self.Data_info["er_samples"][sample]['sample_dip'])
                      d_geo, i_geo = pmag.dogeo(
                          dec, inc, sample_azimuth, sample_dip)
                      # if d_geo or i_geo is null, we can't do geographic coordinates
                      # otherwise, go ahead
                      if not any([np.isnan(val) for val in [d_geo, i_geo]]):
                          Data[s]['zijdblock_geo'].append(
                              [tr, d_geo, i_geo, intensity, ZI, rec['measurement_flag'], rec['magic_instrument_codes']])
                          DIR = [d_geo, i_geo, intensity/NRM]
                          cart = pmag.dir2cart(DIR)
                          Data[s]['zdata_geo'].append([cart[0], cart[1], cart[2]])
                  except (IOError, KeyError, ValueError, TypeError) as e:
                      pass
                  #                    if prev_s != s:
                  #                        print( "-W- can't find sample_azimuth,sample_dip for sample %s"%sample)
  
                  # tilt-corrected coordinates
                  try:
                      sample_bed_dip_direction = float(
                          self.Data_info["er_samples"][sample]['sample_bed_dip_direction'])
                      sample_bed_dip = float(
                          self.Data_info["er_samples"][sample]['sample_bed_dip'])
                      d_tilt, i_tilt = pmag.dotilt(
                          d_geo, i_geo, sample_bed_dip_direction, sample_bed_dip)
                      Data[s]['zijdblock_tilt'].append(
                          [tr, d_tilt, i_tilt, intensity, ZI, rec['measurement_flag'], rec['magic_instrument_codes']])
                      DIR = [d_tilt, i_tilt, intensity/NRM]
                      cart = pmag.dir2cart(DIR)
                      Data[s]['zdata_tilt'].append([cart[0], cart[1], cart[2]])
                  except (IOError, KeyError, TypeError, ValueError, UnboundLocalError) as e:
                      pass
                  #                    if prev_s != s:
                  #                        printd("-W- can't find tilt-corrected data for sample %s"%sample)
  
                  if len(Data[s]['zdata']) > 1:
                      Data[s]['vector_diffs'].append(
                          sqrt(sum((array(Data[s]['zdata'][-2])-array(Data[s]['zdata'][-1]))**2)))
  
              # ---------------------
              # hierarchy is determined from magic_measurements.txt
              # ---------------------
  
              if sample not in list(Data_hierarchy['samples'].keys()):
                  Data_hierarchy['samples'][sample] = {}
                  Data_hierarchy['samples'][sample]['specimens'] = []
  
              if site not in list(Data_hierarchy['sites'].keys()):
                  Data_hierarchy['sites'][site] = {}
                  Data_hierarchy['sites'][site]['samples'] = []
                  Data_hierarchy['sites'][site]['specimens'] = []
  
              if location not in list(Data_hierarchy['locations'].keys()):
                  Data_hierarchy['locations'][location] = {}
                  Data_hierarchy['locations'][location]['sites'] = []
                  Data_hierarchy['locations'][location]['samples'] = []
                  Data_hierarchy['locations'][location]['specimens'] = []
  
              if 'this study' not in list(Data_hierarchy['study'].keys()):
                  Data_hierarchy['study']['this study'] = {}
                  Data_hierarchy['study']['this study']['sites'] = []
                  Data_hierarchy['study']['this study']['samples'] = []
                  Data_hierarchy['study']['this study']['specimens'] = []
  
              if s not in Data_hierarchy['samples'][sample]['specimens']:
                  Data_hierarchy['samples'][sample]['specimens'].append(s)
  
              if s not in Data_hierarchy['sites'][site]['specimens']:
                  Data_hierarchy['sites'][site]['specimens'].append(s)
  
              if s not in Data_hierarchy['locations'][location]['specimens']:
                  Data_hierarchy['locations'][location]['specimens'].append(s)
  
              if s not in Data_hierarchy['study']['this study']['specimens']:
                  Data_hierarchy['study']['this study']['specimens'].append(s)
  
              if sample not in Data_hierarchy['sites'][site]['samples']:
                  Data_hierarchy['sites'][site]['samples'].append(sample)
  
              if sample not in Data_hierarchy['locations'][location]['samples']:
                  Data_hierarchy['locations'][location]['samples'].append(sample)
  
              if sample not in Data_hierarchy['study']['this study']['samples']:
                  Data_hierarchy['study']['this study']['samples'].append(sample)
  
              if site not in Data_hierarchy['locations'][location]['sites']:
                  Data_hierarchy['locations'][location]['sites'].append(site)
  
              if site not in Data_hierarchy['study']['this study']['sites']:
                  Data_hierarchy['study']['this study']['sites'].append(site)
  
              # Data_hierarchy['specimens'][s]=sample
              Data_hierarchy['sample_of_specimen'][s] = sample
              Data_hierarchy['site_of_specimen'][s] = site
              Data_hierarchy['site_of_sample'][sample] = site
              Data_hierarchy['location_of_site'][site] = location
              Data_hierarchy['location_of_specimen'][s] = location
              if expedition_name != "":
                  Data_hierarchy['expedition_name_of_specimen'][s] = expedition_name
              prev_s = s
  
          print("-I- done sorting meas data")
          self.specimens = list(Data.keys())
  
          for s in self.specimens:
              if len(Data[s]['zdata']) > 0:
                  Data[s]['vector_diffs'].append(
                      sqrt(sum(array(Data[s]['zdata'][-1])**2)))  # last vector of the vds
              vds = sum(Data[s]['vector_diffs'])  # vds calculation
              Data[s]['vector_diffs'] = array(Data[s]['vector_diffs'])
              Data[s]['vds'] = vds
              Data[s]['zdata'] = array(Data[s]['zdata'])
              Data[s]['zdata_geo'] = array(Data[s]['zdata_geo'])
              Data[s]['zdata_tilt'] = array(Data[s]['zdata_tilt'])
          return(Data, Data_hierarchy)