예제 #1
0
    def __init__(self, dfile, dialect=None):
        super(SushiBar, self).__init__(dfile=dfile, dialect=dialect)
        data = [i.split('\t') for i in self.simple_import()]
        self.header = ['meas. time', 'x', 'y', 'z', 'M', 'a95', 'sM',
                  'npos', 'par1', 'par2', 'par3', 'par4', 'par5', 'par6']
        header = data.pop(0)
        self.raw_data = {}
        for d in data:
            self.raw_data.setdefault(d[0], [])
            try:
                aux = [convert_time(d[header.index('meas. time')])]
                aux.extend([d[header.index(h)] for h in self.header[1:]])
                aux = [i if i != 'None' else np.nan for i in aux]
                self.raw_data[d[0]].append(aux)
            except ValueError:
                pass

        for sample in self.raw_data:
            self.raw_data[sample] = np.array(self.raw_data[sample]).astype(float)
예제 #2
0
    def __init__(self, dfile, dialect=None):
        tree = ET.parse(dfile)

        specimens = {}

        for specimen in tree.getroot().findall("specimen"):

            # read in specimen properties
            specimens[specimen.attrib["name"]] = {}
            specimens[specimen.attrib["name"]]["coreaz"] = float(specimen.attrib["coreaz"])
            specimens[specimen.attrib["name"]]["coredip"] = float(specimen.attrib["coredip"])
            specimens[specimen.attrib["name"]]["beddip"] = float(specimen.attrib["beddip"])
            specimens[specimen.attrib["name"]]["bedaz"] = float(specimen.attrib["bedaz"])
            specimens[specimen.attrib["name"]]["vol"] = float(specimen.attrib["vol"])
            specimens[specimen.attrib["name"]]["weight"] = float(specimen.attrib["weight"])
            specimens[specimen.attrib["name"]]["stepdata"] = []

            for step in specimen.findall("step"):
                # append all steps from the file
                stepdata = {}

                # get data for one step
                stepdata["step"] = step.attrib["step"]
                stepdata["type"] = step.attrib["type"]
                stepdata["comment"] = step.attrib["comment"]

                # read measurements of this step
                stepdata["measurements"] = []
                for magmoment in step.findall("measurements/magmoment"):
                    measurement_data = {}
                    measurement_data["name"] = magmoment.attrib["type"]
                    measurement_data["values"] = {}
                    measurement_data["values"]["X"] = float(magmoment.attrib["X"])
                    measurement_data["values"]["Y"] = float(magmoment.attrib["Y"])
                    measurement_data["values"]["Z"] = float(magmoment.attrib["Z"])
                    measurement_data["values"]["I"] = float(magmoment.attrib["I"])
                    measurement_data["values"]["D"] = float(magmoment.attrib["D"])
                    measurement_data["values"]["M"] = float(magmoment.attrib["M"])
                    measurement_data["values"]["sM"] = float(magmoment.attrib["sM"])
                    measurement_data["values"]["a95"] = float(magmoment.attrib["a95"])
                    measurement_data["values"]["time"] = convert_time(magmoment.attrib["time"])

                    # in files before version 1.4 attribute no_readings does not exist
                    # use default of three which was always used
                    try:
                        no_readings = int(magmoment.attrib["no_readings"])
                    except KeyError:
                        measurement_data["values"]["no_readings"] = 3
                    else:
                        measurement_data["values"]["no_readings"] = no_readings

                    stepdata["measurements"].append(measurement_data)

                results = step.find("results")

                stepdata["results"] = {}
                stepdata["results"]["X"] = float(results.attrib["X"])
                stepdata["results"]["Y"] = float(results.attrib["Y"])
                stepdata["results"]["Z"] = float(results.attrib["Z"])
                stepdata["results"]["I"] = float(results.attrib["I"])
                stepdata["results"]["D"] = float(results.attrib["D"])
                stepdata["results"]["M"] = float(results.attrib["M"])
                stepdata["results"]["sM"] = float(results.attrib["sM"])
                stepdata["results"]["a95"] = float(results.attrib["a95"])
                stepdata["results"]["time"] = convert_time(results.attrib["time"])

                # if we do not have a holder measurement
                # look for holder data that was substracted from the measurement values
                if specimen.attrib["name"] != "holder":
                    holderresults = step.find("holder")

                    stepdata["holderresults"] = {}
                    stepdata["holderresults"]["X"] = float(holderresults.attrib["X"])
                    stepdata["holderresults"]["Y"] = float(holderresults.attrib["Y"])
                    stepdata["holderresults"]["Z"] = float(holderresults.attrib["Z"])
                    stepdata["holderresults"]["I"] = float(holderresults.attrib["I"])
                    stepdata["holderresults"]["D"] = float(holderresults.attrib["D"])
                    stepdata["holderresults"]["M"] = float(holderresults.attrib["M"])
                    stepdata["holderresults"]["sM"] = float(holderresults.attrib["sM"])
                    stepdata["holderresults"]["a95"] = float(holderresults.attrib["a95"])
                    stepdata["holderresults"]["time"] = holderresults.attrib["time"]

                # add stepdata for current step
                specimens[specimen.attrib["name"]]["stepdata"].append(stepdata)

        self.raw_data = specimens
        self.dfile = dfile
예제 #3
0
    def __init__(self, dfile, dialect=None):
        tree = ET.parse(dfile)

        specimens = {}

        for specimen in tree.getroot().findall("specimen"):

            # read in specimen properties
            specimens[specimen.attrib['name']] = {}
            specimens[specimen.attrib['name']]['coreaz'] = float(
                specimen.attrib['coreaz'])
            specimens[specimen.attrib['name']]['coredip'] = float(
                specimen.attrib['coredip'])
            specimens[specimen.attrib['name']]['beddip'] = float(
                specimen.attrib['beddip'])
            specimens[specimen.attrib['name']]['bedaz'] = float(
                specimen.attrib['bedaz'])
            specimens[specimen.attrib['name']]['vol'] = float(
                specimen.attrib['vol'])
            specimens[specimen.attrib['name']]['weight'] = float(
                specimen.attrib['weight'])
            specimens[specimen.attrib['name']]['stepdata'] = []

            for step in specimen.findall("step"):
                # append all steps from the file
                stepdata = {}

                # get data for one step
                stepdata['step'] = step.attrib['step']
                stepdata['type'] = step.attrib['type']
                stepdata['comment'] = step.attrib['comment']

                # read measurements of this step
                stepdata['measurements'] = []
                for magmoment in step.findall("measurements/magmoment"):
                    measurement_data = {}
                    measurement_data['name'] = magmoment.attrib['type']
                    measurement_data['values'] = {}
                    measurement_data['values']['X'] = float(
                        magmoment.attrib['X'])
                    measurement_data['values']['Y'] = float(
                        magmoment.attrib['Y'])
                    measurement_data['values']['Z'] = float(
                        magmoment.attrib['Z'])
                    measurement_data['values']['I'] = float(
                        magmoment.attrib['I'])
                    measurement_data['values']['D'] = float(
                        magmoment.attrib['D'])
                    measurement_data['values']['M'] = float(
                        magmoment.attrib['M'])
                    measurement_data['values']['sM'] = float(
                        magmoment.attrib['sM'])
                    measurement_data['values']['a95'] = float(
                        magmoment.attrib['a95'])
                    measurement_data['values']['time'] = convert_time(
                        magmoment.attrib['time'])

                    # in files before version 1.4 attribute no_readings does not exist
                    # use default of three which was always used
                    try:
                        no_readings = int(magmoment.attrib['no_readings'])
                    except KeyError:
                        measurement_data['values']['no_readings'] = 3
                    else:
                        measurement_data['values']['no_readings'] = no_readings

                    stepdata['measurements'].append(measurement_data)

                results = step.find('results')

                stepdata['results'] = {}
                stepdata['results']['X'] = float(results.attrib['X'])
                stepdata['results']['Y'] = float(results.attrib['Y'])
                stepdata['results']['Z'] = float(results.attrib['Z'])
                stepdata['results']['I'] = float(results.attrib['I'])
                stepdata['results']['D'] = float(results.attrib['D'])
                stepdata['results']['M'] = float(results.attrib['M'])
                stepdata['results']['sM'] = float(results.attrib['sM'])
                stepdata['results']['a95'] = float(results.attrib['a95'])
                stepdata['results']['time'] = convert_time(
                    results.attrib['time'])

                # if we do not have a holder measurement
                # look for holder data that was substracted from the measurement values
                if specimen.attrib['name'] != 'holder':
                    holderresults = step.find('holder')

                    stepdata['holderresults'] = {}
                    stepdata['holderresults']['X'] = float(
                        holderresults.attrib['X'])
                    stepdata['holderresults']['Y'] = float(
                        holderresults.attrib['Y'])
                    stepdata['holderresults']['Z'] = float(
                        holderresults.attrib['Z'])
                    stepdata['holderresults']['I'] = float(
                        holderresults.attrib['I'])
                    stepdata['holderresults']['D'] = float(
                        holderresults.attrib['D'])
                    stepdata['holderresults']['M'] = float(
                        holderresults.attrib['M'])
                    stepdata['holderresults']['sM'] = float(
                        holderresults.attrib['sM'])
                    stepdata['holderresults']['a95'] = float(
                        holderresults.attrib['a95'])
                    stepdata['holderresults']['time'] = holderresults.attrib[
                        'time']

                # add stepdata for current step
                specimens[specimen.attrib['name']]['stepdata'].append(stepdata)

        self.raw_data = specimens
        self.dfile = dfile