Matlab-based FBG data processing and mapping method
Through the FBG data processing method based on Matlab, the problems of complex operations and human errors in the existing technology are solved, efficient FBG data processing and graphical analysis are achieved, and the data processing efficiency is significantly improved.
Patent Information
- Application Number
- CN202411443569.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-10-16
AI Technical Summary
The prior art is complex when processing fiber Bragg grating (FBG) sensor data, and is prone to artificial operation errors, and the data processing efficiency is low.
The FBG data processing and drawing method based on Matlab is used to collect txt files through FBG equipment, filter the effective information and convert it into a csv file, calculate the wavelength difference, perform temperature compensation conversion, convert it into strain data, and draw the strain curve.
It achieves fast and efficient FBG data processing and graphical analysis, simplifies the operation process, avoids human operation errors, and significantly improves data processing efficiency.
Smart Images

Figure CN119337610A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of FBG data processing, and in particular relates to a FBG data processing and drawing method based on Matlab. Background Art
[0002] At present, when processing the data obtained by the fiber Bragg grating (FBG) sensor and performing graphical analysis, the existing technology often uses Excel to process the large amount of spectral data generated by FBG monitoring. However, the traditional Excel tool is complicated to operate, and many processing steps need to be performed manually. The process is relatively cumbersome, resulting in low data processing efficiency, and a large number of files need to be processed manually. For example, when calculating the wavelength difference, the traditional Excel processing method needs to select the corresponding data for a single file, make a difference, and perform a formula conversion, which consumes a lot of manpower and is prone to human operation errors. At the same time, during the drawing setting process, the user needs to click one by one to select the data range, set the calculation formula and adjust the chart options. The operation is complicated. These repetitive tasks consume a lot of human resources and are prone to errors.
[0003] Matlab, as a high-performance numerical calculation and data analysis software, has powerful functions in data processing and graphics drawing, which makes it an ideal tool for processing FBG data. However, how to use Matlab to process FBG data is an urgent problem to be solved. Summary of the invention
[0004] The purpose of the present invention is to provide a FBG data processing and drawing method based on Matlab, which solves the problem that the operation is complicated and human operation errors are prone to occur when Excel is used to process FBG data in the prior art.
[0005] The technical solution adopted by the present invention is a FBG data processing and mapping method based on Matlab, comprising the following steps: Step 1: Collect the txt file containing wavelength data through the FBG device, filter the valid information through Matlab, and convert the txt file into a csv file; Step 2: Use Matlab to traverse all csv files in step 1, and make a difference between the wavelength data of all monitoring points and the wavelength data of the initial monitoring position to obtain the wavelength difference data; Step 3, perform temperature compensation conversion through Matlab and calculate the real wavelength difference data; Step 4: Convert the real wavelength difference data obtained in step 3 into strain data through Matlab and save it in the corresponding location folder; Step 5: Read the strain curve of the strain data obtained in step 4 through Matlab, and save the processed strain curve to another specified folder.
[0006] The present invention is also characterized in that: The specific process of step 1 is as follows: Step 1.1, define the source folder path: folder_path, and the new folder path: new_folder_path, and check again whether the new folder exists. If not, create a new folder; Step 1.2, use the dir function in Matlab to get the file list of all txt files in the source folder, traverse the file list of all txt files, filter the valid data and convert it into csv file.
[0007] The specific steps of step 1.2 are as follows: Step 1.2.1, traverse all txt files in the source folder; Step 1.2.2, get the file name of each txt file; Step 1.2.3, construct the complete file path of the txt file; Step 1.2.4, use the fopen function in Matlab to open the txt file and read the content; Step 1.2.5, use the textscan function in Matlab to split the text content of the txt file by line; Step 1.2.6, close the txt file; Step 1.2.7, delete useless data corresponding to device ID and date; Step 1.2.8, construct a new file name and path; Step 1.2.9, use the fopen function in Matlab to open the new file in step 1.2.8 in write mode; Step 1.2.10, use the fprintf function in Matlab to write the data processed in step 1.2.7 into a new file to generate a csv file; Step 1.2.11. Close the csv file.
[0008] The specific steps of step 2 are as follows: Step 2.1, read all the csv file contents in step 1, and customize the data in the csv file so that the data size in each csv file is consistent; Step 2.2, traverse all csv files intercepted in step 1, calculate the difference between the wavelength data in each csv file and the wavelength data of the initial monitoring position, and retain the time-related data in the first and second columns of each csv file, wherein the wavelength data of the initial monitoring position is specifically the data collected at the point where the first grating is located during the monitoring process; Step 2.3, except for the first and second columns of the csv file in step 2.2, number the remaining columns of data in ascending order, the number of numbers is equal to the number of grating layouts, and then generate a new csv file as a wavelength difference file and store it in the specified new folder.
[0009] The specific steps of step 3 are as follows: Step 3.1, traverse the new folder in step 2; Step 3.2: Read each wavelength difference file.
[0010] Step 3.3, subtract the remaining columns of data in the wavelength difference file except the first and second columns of data related to time from the independently set temperature compensation column data, wherein the independently set temperature compensation column data is acquired by independent grating monitoring points.
[0011] Step 3.4: Rename the wavelength difference file in step 3.3 as the true wavelength difference file. Step 3.5. Generate a new csv file based on the true wavelength difference file in step 3.4 and store it in the specified new folder.
[0012] Step 3.6: Delete the folder where the wavelength difference file in step 2 is located.
[0013] The specific steps of step 4 are as follows: Step 4.1. Use the uigetdir function in Matlab to pop up a dialog box, select the new folder in step 3.4, and generate another new folder for storing the newly generated files; Step 4.2: Use the dir function in Matlab to list and traverse all csv files containing true wavelength differences, and convert the true wavelength difference data into strain data.
[0014] The specific steps of step 4.2 are as follows: Step 4.2.1, use the fullfile function in Matlab to construct the file path of the complete csv file containing the true wavelength difference; Step 4.2.2, use the readtable function in Matlab to read the csv file containing the true wavelength difference and convert it into a table format; Step 4.2.3, except for the first and second columns of the csv file related to time in step 4.2.2, multiply the remaining columns of data by K; In step 4.2.3, K represents the relative wavelength drift strain sensitivity coefficient of the fiber Bragg grating, and the specific calculation formula is as follows:
[0015] in, and represents the elastic coefficient of the material, v represents the Poisson's ratio, is the effective refractive index, is the Bragg center wavelength difference, is the Lame constant, is the longitudinal tensile strain of the optical fiber.
[0016] Step 4.2.4: After processing in step 4.2.3, the data in the csv file is converted from real wavelength difference data to strain data. Use the fileparts function in Matlab to decompose the file path of the real wavelength difference csv file in step 4.2.3, obtain the file name, and modify the file name to the strain data csv file through the strrep function; Step 4.2.5, use the fullfile function in Matlab to construct a new csv file path, including the new file name and extension; Step 4.2.6. Use the writetable function in Matlab to write the processed table data into a new csv file.
[0017] The specific process of step 5 is as follows: Step 5.1. Use the uigetdir function in Matlab to pop up a dialog box, select the folder containing strain data in step 4 as the data source, and create another new folder to store the line chart; Step 5.2: Use the dir function in Matlab to list all csv files in the data source, and traverse each csv file to obtain strain data and draw a line graph.
[0018] In step 5.2, traverse each csv file and obtain the strain data to draw a line graph. The specific operations are as follows: Step 5.2.1. Create a new graphics window and use the fullfile function in Matlab to construct the complete csv file path.
[0019] Step 5.2.2: Use the readtable function in Matlab to read the csv file to obtain strain data.
[0020] Step 5.2.3, obtain time data, where each line represents 0.001 seconds; Step 5.2.4, draw a line chart for each column of data; Step 5.2.5, set the graph properties, including the horizontal axis label, vertical axis label, title and legend; Step 5.2.6. Save the graphic as a PNG file and rename the file according to user needs; Step 5.2.7. Close the graphics window and after all files have been processed, a message will be displayed indicating that all line graphs have been saved.
[0021] The beneficial effects of the present invention are: The present invention is based on the FBG data processing and drawing method of Matlab. The method adopts the mode of traversing folders to read all data, and the effective information screening range can be manually set. The txt format data collected by FBG is converted into csv format data which is convenient for processing. The operation is simple, and the pre-processing flow of data screening and file format conversion can be realized quickly and efficiently. At the same time, the method can calculate the wavelength difference in batches and convert the data into strain values. The whole process is realized based on Matlab, and the operation is simple, a large amount of human resources is saved, and no human operation error is involved. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flow chart of the FBG data processing and drawing method based on Matlab of the present invention; Figure 2 It is a diagram of the FBG sensor arrangement and pipeline test system with a total length of 15.14m in Comparative Example 1 of the present invention; Figure 3 This is a summary diagram of the FBG data file collected in 1 minute in Comparative Example 1 of the present invention; Figure 4 This is a diagram showing the size of a single FBG file in Comparative Example 1 of the present invention; Figure 5 This is a summary diagram of the total time consumption of the processing flow in Example 1 of the present invention; Figure 6 is a line graph showing changes in the data in the CSV file containing strain data over time in Example 1 of the present invention; Figure 7 is a line graph showing changes in the third and fourth columns of the CSV file containing strain data over time in Example 1 of the present invention; Figure 8 is a line graph showing changes in the third to fifth columns of the CSV file containing strain data over time in Example 1 of the present invention; Fig. 9This is a diagram of the FBG sensor arrangement and pipeline test system with a total length of 130 m in Comparative Example 2 of the present invention; Fig.10 This is a summary diagram of the FBG data file collected in 5 minutes in Comparative Example 2 of the present invention; Fig.11 This is a diagram showing the size of a single FBG file in Comparative Example 2 of the present invention; Fig.12 This is a summary diagram of the total time consumption of the processing flow in Example 2 of the present invention; Fig.13 This is a line graph showing the change of the data in the third to eighth columns of the CSV file containing strain data in Example 2 of the present invention over time. DETAILED DESCRIPTION
[0023] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0024] The present invention is based on Matlab FBG data processing and mapping method, comprising the following steps: Step 1: Collect the txt file containing wavelength data through the FBG device, filter the valid information through Matlab, and convert the txt file into a csv file; The specific process of step 1 is as follows: Step 1.1, define the source folder path: folder_path, and the new folder path: new_folder_path, and check again whether the new folder exists. If not, create a new folder; Step 1.2, use the dir function in Matlab to get the file list of all txt files in the source folder, traverse the file list of all txt files, filter the valid data and convert them into csv files; The specific steps of step 1.2 are as follows: Step 1.2.1, traverse all txt files in the source folder; Step 1.2.2, get the file name of each txt file; Step 1.2.3, construct the complete file path of the txt file; Step 1.2.4, use the fopen function in Matlab to open the txt file and read the text content; Step 1.2.5, use the textscan function in Matlab to split the text content of the txt file by line; Step 1.2.6, close the txt file; Step 1.2.7, delete useless data corresponding to device ID and date; since the data collected by FBG are in the same format, the device ID information and date information contained therein are usually considered useless information and do not participate in the data processing process. Therefore, the device ID information and date information in the data are removed and saved; Step 1.2.8, construct a new file name and path; Step 1.2.9, use the fopen function in Matlab to open the new file in step 1.2.8 in write mode; Step 1.2.10, use the fprintf function in Matlab to write the data processed in step 1.2.7 into a new file to generate a csv file; Step 1.2.11. Close the csv file.
[0025] Step 2: Use Matlab to traverse all csv files in step 1, and make a difference between the wavelength data of all monitoring points and the initial monitoring position data to obtain the wavelength difference data; The specific steps of step 2 are as follows: Step 2.1, read all the csv file contents in step 1, and customize the data in the csv file so that the data size in each csv file is consistent; Step 2.2, traverse all csv files intercepted by step 1, and calculate the difference between the wavelength data in each csv file and the wavelength data of the initial monitoring position, and retain the time-related data in the first and second columns of each csv file, wherein the initial monitoring position wavelength data is specifically the data collected at the point where the first grating is located during the monitoring process; Step 2.3: Except for the first and second columns of the csv file in step 2.2, number the remaining columns of data in ascending order, and the number of numbers is equal to the number of grating layouts. Then generate a new csv file as a wavelength difference file and store it in the specified new folder.
[0026] Step 3, perform temperature compensation conversion through Matlab and calculate the real wavelength difference data; The specific steps of step 3 are as follows: Step 3.1, traverse the new folder in step 2.4; Step 3.2: Read each wavelength difference file.
[0027] Step 3.3, except for the first and second columns of data related to time in the wavelength difference file, the remaining columns of data are subtracted from the independently set temperature compensation column data, which is collected by independent grating monitoring points. Specifically, since the FBG sensor is sensitive to temperature, changes in ambient temperature will directly affect the accuracy of strain measurement. Therefore, it is necessary to set up an independent grating monitoring point as a temperature compensation data collection point. Through effective temperature compensation, the accuracy and stability of data measurement can be ensured, and data misreading caused by temperature fluctuations can be avoided, thereby providing more reliable and accurate data support.
[0028] Step 3.4: Rename the wavelength difference file in step 3.3 as the true wavelength difference file. Step 3.5. Generate a new csv file based on the true wavelength difference file in step 3.4 and store it in the specified new folder.
[0029] Step 3.6: Delete the folder where the wavelength difference file in step 2 is located.
[0030] Step 4: Use Matlab to convert the real wavelength difference data obtained in step 3 into strain data and save it in the corresponding location folder. Converting the wavelength difference data after temperature compensation into strain data can further enhance the descriptiveness of the data and meet actual needs more intuitively.
[0031] Step 4.1. Use the uigetdir function in Matlab to pop up a dialog box, select the new folder in step 3.4, and generate another new folder for storing the newly generated files; Step 4.2: Use the dir function in Matlab to list and traverse all csv files containing true wavelength differences, and convert the true wavelength difference data into strain data.
[0032] The specific steps of step 4.2 are as follows: Step 4.2.1, use the fullfile function in Matlab to construct the file path of the complete csv file containing the true wavelength difference; Step 4.2.2, use the readtable function in Matlab to read the csv file containing the true wavelength difference and convert it into a table format; Step 4.2.3, except for the first and second columns of the csv file related to time in step 4.2.2, multiply the remaining columns of data by K; In step 4.2.3, K represents the relative wavelength drift strain sensitivity coefficient of the fiber Bragg grating, and the specific calculation formula is as follows:
[0033] in, and represents the elastic coefficient of the material, v represents the Poisson's ratio, is the effective refractive index, is the Bragg center wavelength difference, is the Lame constant, is the longitudinal tensile strain of the optical fiber.
[0034] Step 4.2.4: After processing in step 4.2.3, the data in the csv file is converted from real wavelength difference data to strain data. Use the fileparts function in Matlab to decompose the file path of the real wavelength difference csv file in step 4.2.3, obtain the file name, and modify the file name to the strain data csv file through the strrep function; Step 4.2.5, use the fullfile function in Matlab to construct a new csv file path, including the new file name and extension; Step 4.2.6. Use the writetable function in Matlab to write the processed table data into a new csv file.
[0035] Step 5: Select the saved strain data and draw the strain curve graph corresponding to each channel.
[0036] Step 5.1. Use the uigetdir function in Matlab to pop up a dialog box, select the folder containing strain data in step 4 as the data source, and create another new folder to store the line chart; Step 5.2: Use the dir function in Matlab to list all csv files in the data source, and traverse each csv file to obtain strain data and draw a line graph.
[0037] As described in step 5.2, traverse each csv file to obtain strain data and draw a line graph. The specific operations are as follows: Step 5.2.1. Create a new graphics window and use the fullfile function in Matlab to construct the complete csv file path.
[0038] Step 5.2.2: Use the readtable function in Matlab to read the csv file to obtain strain data.
[0039] Step 5.2.3, obtain time data, where each line represents 0.001 seconds; Step 5.2.4, draw a line chart for each column of data; Step 5.2.5, set the graph properties, including the horizontal axis label, vertical axis label, title and legend; Step 5.2.6. Save the graphic as a PNG file and rename the file according to user needs; Step 5.2.7. Close the graphics window and after all files have been processed, a message will be displayed indicating that all line graphs have been saved.
[0040] The FBG data processing and drawing method based on Matlab of the present invention adopts the mode of traversing folders to read all data, can manually set the effective information screening range, converts the txt format data collected by FBG into csv format data which is convenient to process, is simple to operate, can quickly and efficiently realize the data screening and file format preprocessing flow; at the same time, can batch calculate the wavelength difference and convert the data into strain value, the whole process is all realized based on Matlab, is simple to operate, saves a lot of human resources, and does not contain human operation errors, at the same time, the processing flow based on Matlab can realize the drawing function, select different data areas for visual drawing or save files.
[0041] The present invention is based on the FBG data processing and mapping method of Matlab, and the specific embodiments are as follows: Comparative Example 1 A simulation test of grouting pipe blockage was carried out, and FBG sensors were used for monitoring. The total length of the test system was 15.14m, and a total of 6 FBG sensors were deployed. Figure 2 As shown in the figure, the grouting pump provides power for the entire grouting pipeline blockage simulation system. The mixing barrels 1 and 2 mix the mud evenly to ensure that the mud can be normally transported in the pipeline. The outlet of the grouting pump is connected to the pipeline inlet A of the metal pipeline through a high-pressure hose (DN32). The pipeline outlet B of the metal pipeline is connected to the inlet of the mixing barrel 2 through a high-pressure hose (DN32). The mixing barrel 2 to the mixing barrel 1, as well as the grouting pumps are all connected through a high-pressure hose (DN32). The metal pipeline is fixed by a number of clamps. A main valve, flow meter and pressure gauge are provided at the outlet of the grouting pump. The slurry flows from the outlet of the grouting pump along the high-pressure hose into the metal pipe, into the mixing barrel 2 and the mixing barrel 1. Finally, only the inlet of the grouting pump flows into the grouting pump. Several FBG sensors are provided on the metal pipeline between the pipeline inlet A and the pipeline outlet B, and valves are provided at the blockage points set on the metal pipeline. The details are as follows: The valve at the blockage point was closed for different times to simulate different degrees of blockage, and data was collected through FBG. The valve at the blockage point was closed for 2, 4, 6, 8, 10, and 12 times to simulate working conditions at different degrees of blockage. The monitoring time was set to 1 minute, and the data collected by FBG was summarized: The summary diagram of the FBG data file collected in 1 minute is as follows: Figure 3As shown, when the data collection time is 1 minute and the test pipeline length is 15.14 meters, the file size collected for a single valve with a single blockage degree is about 300KB, and the data volume is about 2920 lines.
[0042] At the same time, the size of a single FBG file is shown in the figure, Figure 4 As shown in the figure, the experiment is based on the working condition that the pipeline length is 15.14m and the data collection time is 1min. Although the method of manually processing data using Excel tools is feasible, there is a risk of errors caused by human operation.
[0043] Example 1 On the basis of the above comparative example 1, the FBG data processing and drawing method based on Matlab of the present invention is used for data post-processing, and the process includes: batch reading of txt files collected by FBG, screening of valid data and conversion into csv files, calculation of wavelength difference, temperature compensation conversion, strain conversion and batch drawing. Since the size of each file is not consistent, normalization processing is required, that is, custom interception of data in csv files so that the data size in each csv file is consistent. Here, 1500 lines are taken as valid data as an example, and a total of 5 steps of processing flow are performed on the above 7 files with a total size of about 2MB, and the program response time is output.
[0044] The total time consumption of the processing flow is summarized in the figure, such as Figure 5 As shown in the figure, for a 15.14m long pipeline, 7 files with a collection time of 1min are collected, and 1500 lines are taken as valid data. From batch reading, filtering valid data and converting them into csv files, to wavelength difference calculation, temperature compensation conversion, strain conversion and batch drawing, the entire process is completed, and the total time is about: 1.24s+51.39s+16.33s+6.67s=75.63s This method does not have manual operation errors, is simple to operate, and shows extremely high processing efficiency. Finally, the strain curve diagram drawn is as follows: Figure 6-8 As shown, Figure 6 The third column of the CSV file containing strain data is a line graph showing the change of data over time. Figure 7 This is a line graph showing the change of the third and fourth columns of the CSV file containing strain data over time. Figure 8 It is a line graph of the change of the third to fifth columns of the CSV file containing strain data over time, which realizes batch drawing.
[0045] Comparative Example 2 Since the amount of data in comparative example 1 is small, in order to verify the versatility of this method, a larger-scale grouting pipeline blockage simulation test is further carried out, the total length of the test system is increased to 130m, and the number of FBG sensors is increased to 32. The schematic diagram of the FBG sensor layout and the pipeline test system diagram are as follows: Fig. 9 As shown in the figure, the grouting pump provides power for the entire grouting pipeline blockage simulation system. The mixing barrel 1 and the mixing barrel 2 mix the mud evenly to ensure that the mud can be normally transported in the high-pressure hose. The outlet of the grouting pump is connected to the pipe inlet A of the metal pipe through the high-pressure hose. The pipe outlet B of the metal pipe is connected to the inlet of the mixing barrel 2 through the high-pressure hose. The mixing barrel 2 is connected to the mixing barrel 1, and the grouting pumps are connected through the high-pressure hose. The metal pipe is fixed by a number of clamps. A valve 1, an electromagnetic flowmeter and a pressure gauge are provided at the outlet of the grouting pump. A valve 9 is provided at the inlet of the mixing barrel 2. The slurry flows from the outlet of the grouting pump along the high-pressure hose into the metal pipe, into the mixing barrel 2 and the mixing barrel 1. Finally, only the inlet of the grouting pump flows into the grouting pump. There are 7 valves on the metal pipe between the pipe inlet A and the pipe outlet B, including: angle clamp valve knife gate valve A and angle clamp valve knife gate valve B. The metal pipe also includes an electromagnetic flowmeter, a pressure gauge and a number of FBG sensors. The details are as follows: The valve is still closed for different times to simulate different degrees of blockage, and data is collected through FBG. The valve 2 at the blockage point is closed for 1 to 10 times to simulate the working conditions under different degrees of blockage, and the monitoring time is extended to 5 minutes. The data collected by FBG are summarized as follows: The summary diagram of the FBG data file collected in 5 minutes is as follows: Fig.10 As shown in the figure, when the data collection time is 5 minutes and the test pipeline length is 130 meters, the file size collected for a single valve and a single blockage degree has reached about 270MB, and the data volume has reached 680,000 lines. Because a single file occupies too much system memory, the system often crashes during file operations, greatly reducing the efficiency of manual processing.
[0046] At the same time, the size of a single FBG file is shown in the figure, Fig.11 As shown in the figure, the experiment is based on the condition that the pipeline length is 130m and the data collection time is 5min. When the test system is applied to the engineering field test, it will face the pipeline length of several kilometers and longer monitoring time. Therefore, it is basically not feasible to use Excel tools to manually process the data.
[0047] Example 2 On the basis of the above comparative example 2, the FBG data processing and drawing method based on Matlab of the present invention is still used to perform the entire process of data post-processing, which includes: batch reading of txt files collected by FBG, screening of valid data and conversion to csv files, calculation of wavelength difference, temperature compensation conversion, strain conversion and batch drawing. Since the size of each file is not consistent, normalization processing is required. Here, taking 200,000 rows as valid data as an example, the above 10 files with a total size of about 2.7G are processed in a total of 5 steps, and the program response time is output.
[0048] The total time consumption of the processing flow is summarized in the figure, such as Fig.12 As shown in the figure, for a pipeline of 89.71m in length, 10 files with a collection time of 5min are collected. Taking 200,000 lines as valid data as an example, the entire process is completed from batch reading, screening valid data and converting them into csv files, to wavelength difference calculation, temperature compensation conversion, strain conversion and batch drawing. The total processing time is about: 343.22s+129.02s+44.96s+19.32s=536.52s For extremely large amounts of data, this method can still demonstrate extremely high processing efficiency through a simple processing flow, and ultimately draw a strain curve, such as Fig.13 As shown in the figure, the line graph of the change of the data in columns 3-8 of the csv file containing strain data over time, where each column of data is the data collected by a FBG. Through Matlab software, the txt files collected by FBG are read in batches, the valid data is retained and converted into csv files, and then the wavelength difference is calculated, the temperature compensation factor is eliminated, and finally the wavelength difference is converted into strain data and batch plotted, which effectively solves the problems of complex operation, low data processing efficiency and human operation errors when using Excel tools.
Claims
1. FBG data processing and plotting method based on Matlab, characterized in that: The following steps are involved: Step 1: Collect the txt file containing wavelength data through the FBG device, filter the valid information through Matlab, and convert the txt file into a csv file; Step 2: Use Matlab to traverse all csv files in step 1, and make a difference between the wavelength data of all monitoring points and the initial monitoring position data to obtain the wavelength difference data; Step 3, perform temperature compensation conversion through Matlab and calculate the real wavelength difference data; Step 4: Convert the real wavelength difference data obtained in step 3 into strain data through Matlab and save it in the corresponding location folder; Step 5: Read the strain curve of the strain data obtained in step 4 through Matlab, and save the processed strain curve to another specified folder.
2. The FBG data processing and mapping method based on Matlab according to claim 1, characterized in that: The specific process of step 1 is as follows: Step 1.1, define the source folder path: folder_path, and the new folder path: new_folder_path, and check again whether the new folder exists. If not, create a new folder; Step 1.2, use the dir function in Matlab to get the file list of all txt files in the source folder, traverse the file list of all txt files, filter the valid data and convert it into csv file.
3. The FBG data processing and mapping method based on Matlab according to claim 2, characterized in that: The specific steps of step 1.2 are as follows: Step 1.2.1, traverse all txt files in the source folder; Step 1.2.2, get the file name of each txt file; Step 1.2.3, construct the complete file path of the txt file; Step 1.2.4, use the fopen function in Matlab to open the txt file and read the content; Step 1.2.5, use the textscan function in Matlab to split the text content of the txt file by line; Step 1.2.6, close the txt file; Step 1.2.7, delete useless data corresponding to device ID and date; Step 1.2.8, construct a new file name and path; Step 1.2.9, use the fopen function in Matlab to open the new file in step 1.2.8 in write mode; Step 1.2.10, use the fprintf function in Matlab to write the data processed in step 1.2.7 into a new file to generate a csv file; Step 1.2.
11. Close the csv file.
4. The FBG data processing and mapping method based on Matlab according to claim 1, characterized in that: The specific steps of step 2 are as follows: Step 2.1, read all the csv file contents in step 1, and customize the data in the csv file so that the data size in each csv file is consistent; Step 2.2, traverse all csv files intercepted by step 1, and calculate the difference between the wavelength data in each csv file and the wavelength data of the initial monitoring position, and retain the time-related data in the first and second columns of each csv file, wherein the initial monitoring position wavelength data is specifically the data collected at the point where the first grating is located during the monitoring process; Step 2.3: Except for the first and second columns of the csv file in step 2.2, number the remaining columns of data in ascending order, and the number of numbers is equal to the number of grating layouts. Then generate a new csv file as a wavelength difference file and store it in the specified new folder.
5. The FBG data processing and mapping method based on Matlab according to claim 1, characterized in that: The specific steps of step 3 are as follows: Step 3.1, traverse the new folder in step 2; Step 3.2, read each wavelength difference file; Step 3.3, except for the first and second columns of data related to time in the wavelength difference file, the remaining columns of data are subtracted from the independently set temperature compensation column data, and the independently set temperature compensation column data is acquired by independent grating monitoring point positions; Step 3.4, rename the wavelength difference file in step 3.3 as the real wavelength difference file; Step 3.5, generate a new csv file based on the real wavelength difference file in step 3.4, and store it in the specified new folder; Step 3.6: Delete the folder where the wavelength difference file in step 2 is located.
6. The FBG data processing and mapping method based on Matlab according to claim 1, characterized in that: The specific steps of step 4 are as follows: Step 4.
1. Use the uigetdir function in Matlab to pop up a dialog box, select the new folder in step 3.4, and generate another new folder for storing the newly generated files; Step 4.2: Use the dir function in Matlab to list and traverse all csv files containing true wavelength differences, and convert the true wavelength difference data into strain data.
7. The FBG data processing and plotting method based on Matlab according to claim 6, characterized in that: The specific steps of step 4.2 are as follows: Step 4.2.1, use the fullfile function in Matlab to construct the file path of the complete csv file containing the true wavelength difference; Step 4.2.2, use the readtable function in Matlab to read the csv file containing the true wavelength difference and convert it into a table format; Step 4.2.3, except for the first and second columns of the csv file related to time in step 4.2.2, multiply the remaining columns of data by K; Step 4.2.4: After processing in step 4.2.3, the data in the csv file is converted from real wavelength difference data to strain data. Use the fileparts function in Matlab to decompose the file path of the real wavelength difference csv file in step 4.2.3, obtain the file name, and modify the file name to the strain data csv file through the strrep function; Step 4.2.5, use the fullfile function in Matlab to construct a new csv file path, including the new file name and extension; Step 4.2.
6. Use the writetable function in Matlab to write the processed table data into a new csv file.
8. The FBG data processing and mapping method based on Matlab according to claim 7, characterized in that: The K mentioned in step 4.2.3 represents the relative wavelength drift strain sensitivity coefficient of the fiber Bragg grating, and the specific calculation formula is as follows: in, and represents the elastic coefficient of the material, v represents the Poisson's ratio, is the effective refractive index, is the Bragg center wavelength difference, is the Lame constant, is the longitudinal tensile strain of the optical fiber.
9. The FBG data processing and mapping method based on Matlab according to claim 1, characterized in that: The specific process of step 5 is as follows: Step 5.
1. Use the uigetdir function in Matlab to pop up a dialog box, select the folder containing strain data in step 4 as the data source, and create another new folder to store the line chart; Step 5.2: Use the dir function in Matlab to list all csv files in the data source, and traverse each csv file to obtain strain data and draw a line graph.
10. The FBG data processing and plotting method based on Matlab according to claim 9, characterized in that: As described in step 5.2, traverse each csv file, obtain the strain data and draw a line graph. The specific operations are as follows: Step 5.2.
1. Create a new graphics window and use the fullfile function in Matlab to construct the complete csv file path. Step 5.2.2, use the readtable function in Matlab to read the csv file to obtain strain data; Step 5.2.3, obtain time data, where each line represents 0.001 seconds; Step 5.2.4, draw a line chart for each column of data; Step 5.2.5, set the graph properties, including the horizontal axis label, vertical axis label, title and legend; Step 5.2.
6. Save the graphic as a PNG file and rename the file according to user needs; Step 5.2.
7. Close the graphics window and after all files have been processed, a message will be displayed indicating that all line graphs have been saved.
Citation Information
Patent Citations
Python-based ReaxFF force field calculation result data processing method
CN110767267A
Monitoring and analysis method based on three-phase imbalance of AC motor of diesel locomotive
CN114089187A
Method for identifying blockage state of long-distance pumping pipeline based on fiber bragg grating sensing
CN117705353A
Device, method and program for outputting csv files
JP2011248617A
Information processing device for saving extended image file into which image information file and table files are integrated
US20240329901A1