File size: 7,103 Bytes
22d9b6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42d624a
4f8211a
22d9b6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
"""this is loading script for milling_LUH_data"""

import h5py
import os

import datasets

_CITATION = """\
@InProceedings{huggingface:dataset,
title = {Multivariate time series data of milling processes with varying tool wear and machine tools},
author={Tobias Stiehl},
year={2023}
}
"""

_DESCRIPTION = """\
"""

_HOMEPAGE = "https://data.mendeley.com/datasets/zpxs87bjt8/3"

_LICENSE = "CC BY 4.0"

class milling_LUH(datasets.GeneratorBasedBuilder):
    """ The presented dataset provides labeled, multivariate time series data of milling processes with varying tool wear and for varying machine tools. The width of the flank wear land VB of peripheral cutting edges is used as a degradation metric. A total of nine end milling cutters were worn from an unused state to end of life (VB ≈ 150 μm) in 3-axis shoulder milling of cast iron 600-3/S. The width of the flank wear land VB was frequently measured with a digital microscope at a magnification of 100x. The tools were of the same model (solid carbide end milling cutter, 4 edges, coated with TiN-TiAlN) but from different batches. Experiments were conducted on three different 5-axis milling centers of a similar size. Workpieces, experimental setups, and process parameters were identical on all of the machine tools. The process forces were recorded with a dynamometer with a sample rate of 25 kHz. The force or torque of the spindle and feed drives, as well as the position control deviation of feed drives, were recorded from the machine tool controls with a sample rate of 500 Hz. The dataset holds a total of 6,418 files labeled with the wear (VB), machine tool (M), tool (T), run (R), and cumulated tool contact time (C). The file “filelist.csv” provides an overview of all the sample files and their corresponding labels. This data could be used to identify signal features that are sensitive to tool wear, to investigate methods for tool wear estimation and tool life prediction, or to examine transfer learning strategies.
"""

    VERSION = datasets.Version("3.0.0")


    def _info(self):
        features = datasets.Features(
            {
                "cumulated_tool_contact_time":datasets.features.Value("float32"), #float64
                "machine":datasets.features.Value("float32"),#float64
                "run":datasets.features.Value("float32"),#float64
                "tool":datasets.features.Value("float32"),#float64
                "wear":datasets.features.Value("float32"),#float64
                "position_control_deviation_axis_x":datasets.Sequence(datasets.Value("float32")), #object
                "position_control_deviation_axis_y":datasets.Sequence(datasets.Value("float32")), #object
                "time_machine":datasets.Sequence(datasets.Value("float32")), #object
                "tool_position_x":datasets.Sequence(datasets.Value("float32")),#object
                "tool_position_y":datasets.Sequence(datasets.Value("float32")), #object
                "tool_position_z":datasets.Sequence(datasets.Value("float32")), # object
                "torque_axis_x":datasets.Sequence(datasets.Value("float32")), #object
                "torque_axis_y":datasets.Sequence(datasets.Value("float32")), #object
                "torque_axis_z":datasets.Sequence(datasets.Value("float32")), #object
                "torque_spindle":datasets.Sequence(datasets.Value("float32")), #object
                "force_sensor_x":datasets.Sequence(datasets.Value("float32")), #object
                "force_sensor_y":datasets.Sequence(datasets.Value("float32")), #object
                "force_sensor_z":datasets.Sequence(datasets.Value("float32")), #object
                "time_sensor":datasets.Sequence(datasets.Value("float32")) #object
            }
        )

        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,  # Here we define them above because they are different between the two configurations
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        files_path = "data"
        # TODO define train, test and validation splits. change only id_start and id_end
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN, 
                gen_kwargs= { "files_path": files_path,
                             "id_start": 0,
                             "id_end":5}
            ),
            datasets.SplitGenerator(
                name=datasets.Split.TEST,
                gen_kwargs = {"files_path": files_path,
                              "id_start":5,
                              "id_end":7}
            ),
            datasets.SplitGenerator(
                name=datasets.Split.VALIDATION,
                gen_kwargs = {"files_path": files_path,
                              "id_start":7,
                              "id_end":9}
            )
        ]

    def _generate_examples(self, files_path, id_start,id_end):
        
        # list of all h5 files in files_path 
        files = [ file for file in os.listdir(files_path) if file.endswith('.h5')]
        for key,file_name in enumerate(files[id_start:id_end]):
            with h5py.File(files_path +"/"+file_name,'r' ) as file:
                labels = file['labels']	
                signals_machine = file['signals_machine']
                signals_sensor = file['signals_sensor']

                labels_keys=list(labels.keys())
                signals_machine_keys=list(signals_machine.keys())
                signals_sensor_keys=list(signals_sensor.keys())

                data={}
                for i in labels_keys:
                    data[i] = float(labels[i][0][0])
                for j in signals_machine_keys:
                    data[j]= signals_machine[j][:].flatten()
                for k in signals_sensor_keys:
                    data[k]= signals_sensor[k][:].flatten()

            yield key, {
                "cumulated_tool_contact_time": data["cumulated_tool_contact_time"],
                "machine": data["machine"],
                "run": data["run"],
                "tool": data["tool"],
                "wear": data["wear"],
                "position_control_deviation_axis_x": data["position_control_deviation_axis_x"],
                "position_control_deviation_axis_y":data["position_control_deviation_axis_y"],
                "time_machine": data["time_machine"],
                "tool_position_x": data["tool_position_x"],
                "tool_position_y": data["tool_position_y"],
                "tool_position_z": data["tool_position_z"],
                "force_axis_x": data["force_axis_x"],
                "force_axis_y": data["force_axis_y"],
                "force_axis_z": data["force_axis_z"],
                "torque_spindle": data["torque_spindle"],
                "force_sensor_x": data["force_sensor_x"],
                "force_sensor_y": data["force_sensor_y"],
                "force_sensor_z": data["force_sensor_z"],
                "time_sensor": data["time_sensor"]
            }