code: def mark_dmag_rec(s, ind, data):
      
      datablock = []
      for rec in data:
          if rec['er_specimen_name'] == s:
              meths = rec['magic_method_codes'].split(':')
              if 'LT-NO' in meths or 'LT-AF-Z' in meths or 'LT-T-Z' in meths:
                  datablock.append(rec)
      dmagrec = datablock[ind]
      for k in range(len(data)):
          meths = data[k]['magic_method_codes'].split(':')
          if 'LT-NO' in meths or 'LT-AF-Z' in meths or 'LT-T-Z' in meths:
              if data[k]['er_specimen_name'] == s:
                  if data[k]['treatment_temp'] == dmagrec['treatment_temp'] and data[k]['treatment_ac_field'] == dmagrec['treatment_ac_field']:
                      if data[k]['measurement_dec'] == dmagrec['measurement_dec'] and data[k]['measurement_inc'] == dmagrec['measurement_inc'] and data[k]['measurement_magn_moment'] == dmagrec['measurement_magn_moment']:
                          if data[k]['measurement_flag'] == 'g':
                              flag = 'b'
                          else:
                              flag = 'g'
                          data[k]['measurement_flag'] = flag
                          break
      return data
docs: Edits demagnetization data to mark "bad" points with measurement_flag