|
16 | 16 | 'along with this program. If not, see <https://www.gnu.org/licenses/>. |
17 | 17 | ' |
18 | 18 | Imports System.Windows.Forms |
19 | | -Imports System.Text.RegularExpressions |
20 | 19 |
|
21 | 20 | ''' <summary> |
22 | 21 | ''' Custom import dialog for HDF5 files with two-panel selection: |
@@ -59,24 +58,20 @@ Friend Class ImportHDF5Dialog |
59 | 58 |
|
60 | 59 | 'Process each series to extract element names and variable names |
61 | 60 | For Each sInfo As TimeSeriesInfo In Me.tsFile.TimeSeriesInfos |
62 | | - 'Series name format: "DatasetName_ColumnName" (e.g., "T_Dru0161_Q_zu") |
63 | | - 'Parse to get: dataset name and column name |
64 | | - Dim lastUnderscore As Integer = sInfo.Name.LastIndexOf("_"c) |
65 | | - If lastUnderscore <= 0 Then Continue For |
66 | | - |
67 | | - Dim datasetName As String = sInfo.Name.Substring(0, lastUnderscore) |
68 | | - Dim columnName As String = sInfo.Name.Substring(lastUnderscore + 1) |
69 | | - |
70 | | - 'Extract base element name from dataset name |
71 | | - Dim baseElement As String = ExtractBaseElementName(datasetName) |
72 | | - Dim measurementType As String = ExtractMeasurementType(datasetName, baseElement) |
73 | | - |
74 | | - 'Build variable name: measurementType_columnName (e.g., "Q_zu") or just columnName if no measurement type |
75 | | - Dim variableName As String |
76 | | - If measurementType.Length > 0 Then |
77 | | - variableName = $"{measurementType}_{columnName}" |
78 | | - Else |
79 | | - variableName = columnName |
| 61 | + 'Use the dataset/column maps from GINA_HDF5 |
| 62 | + Dim datasetName As String = Me.tsFile.SeriesDatasetMap(sInfo.Index) |
| 63 | + Dim columnName As String = Me.tsFile.SeriesColumnMap(sInfo.Index) |
| 64 | + |
| 65 | + 'Use dataset name as element name |
| 66 | + Dim baseElement As String = datasetName |
| 67 | + |
| 68 | + 'Use column name as variable name |
| 69 | + Dim variableName As String = columnName |
| 70 | + |
| 71 | + '1D datasets have no column name |
| 72 | + If variableName = "" Then |
| 73 | + variableName = datasetName |
| 74 | + baseElement = datasetName |
80 | 75 | End If |
81 | 76 |
|
82 | 77 | 'Add to element series map |
@@ -122,44 +117,6 @@ Friend Class ImportHDF5Dialog |
122 | 117 | End Sub |
123 | 118 |
|
124 | 119 |
|
125 | | - ''' <summary> |
126 | | - ''' Extracts the base element name from a dataset name |
127 | | - ''' Pattern: Element names like T_Dru0161, T_Sch0821, T_Wfg0014 end with digits |
128 | | - ''' Dataset names may have additional suffixes like _Q, _Pges, _AFS |
129 | | - ''' </summary> |
130 | | - Private Function ExtractBaseElementName(datasetName As String) As String |
131 | | - 'Pattern: Match element names that end with digits (e.g., T_Dru0161) |
132 | | - 'The base element is everything up to and including the numeric suffix |
133 | | - Dim match As Match = Regex.Match(datasetName, "^(.+?\d+)") |
134 | | - If match.Success Then |
135 | | - Return match.Groups(1).Value |
136 | | - Else |
137 | | - 'If no pattern match, use the full name up to the last underscore |
138 | | - Dim lastUnderscore As Integer = datasetName.LastIndexOf("_"c) |
139 | | - If lastUnderscore > 0 Then |
140 | | - Return datasetName.Substring(0, lastUnderscore) |
141 | | - Else |
142 | | - Return datasetName |
143 | | - End If |
144 | | - End If |
145 | | - End Function |
146 | | - |
147 | | - ''' <summary> |
148 | | - ''' Extracts the measurement type from a dataset name (e.g., "Q" from "T_Dru0161_Q") |
149 | | - ''' </summary> |
150 | | - Private Function ExtractMeasurementType(datasetName As String, baseElementName As String) As String |
151 | | - If datasetName.Length > baseElementName.Length AndAlso datasetName.StartsWith(baseElementName) Then |
152 | | - Dim suffix As String = datasetName.Substring(baseElementName.Length) |
153 | | - If suffix.StartsWith("_") Then |
154 | | - Return suffix.Substring(1) |
155 | | - Else |
156 | | - Return suffix |
157 | | - End If |
158 | | - Else |
159 | | - Return "" |
160 | | - End If |
161 | | - End Function |
162 | | - |
163 | 120 | Private Sub Button_SelectAllElements_Click(sender As Object, e As EventArgs) Handles Button_SelectAllElements.Click |
164 | 121 | For i As Integer = 0 To ListBox_Elements.Items.Count - 1 |
165 | 122 | ListBox_Elements.SetSelected(i, True) |
@@ -217,21 +174,17 @@ Friend Class ImportHDF5Dialog |
217 | 174 |
|
218 | 175 | 'Select series that match both selected elements AND selected variables |
219 | 176 | For Each sInfo As TimeSeriesInfo In Me.tsFile.TimeSeriesInfos |
220 | | - 'Parse series name |
221 | | - Dim lastUnderscore As Integer = sInfo.Name.LastIndexOf("_"c) |
222 | | - If lastUnderscore <= 0 Then Continue For |
223 | | - |
224 | | - Dim datasetName As String = sInfo.Name.Substring(0, lastUnderscore) |
225 | | - Dim columnName As String = sInfo.Name.Substring(lastUnderscore + 1) |
| 177 | + 'Use the dataset/column maps from GINA_HDF5 |
| 178 | + Dim datasetName As String = Me.tsFile.SeriesDatasetMap(sInfo.Index) |
| 179 | + Dim columnName As String = Me.tsFile.SeriesColumnMap(sInfo.Index) |
226 | 180 |
|
227 | | - Dim baseElement As String = ExtractBaseElementName(datasetName) |
228 | | - Dim measurementType As String = ExtractMeasurementType(datasetName, baseElement) |
| 181 | + Dim baseElement As String = datasetName |
| 182 | + Dim variableName As String = columnName |
229 | 183 |
|
230 | | - Dim variableName As String |
231 | | - If measurementType.Length > 0 Then |
232 | | - variableName = $"{measurementType}_{columnName}" |
233 | | - Else |
234 | | - variableName = columnName |
| 184 | + '1D datasets have no column name |
| 185 | + If variableName = "" Then |
| 186 | + variableName = datasetName |
| 187 | + baseElement = datasetName |
235 | 188 | End If |
236 | 189 |
|
237 | 190 | 'Check if this series should be selected |
|
0 commit comments