從FITS-Table讀取數據,並獲取包含該表的Struct,其中每個標記表示一列。IDL - 結構陣列到結構陣列
有沒有辦法將數組的結構重新格式化爲結構數組? 這樣,數組中的一個Struct代表一個Row?
通過@mgalloy做了一般性的解決方案(見下文):
function SoA2AoS, table
if (table eq !NULL) then return, !NULL
tnames = tag_names(table)
new_table = create_struct(tnames[0], (table.(0)[0]))
for t = 1L, n_tags(table) - 1L do begin
new_table = create_struct(new_table, tnames[t], (table.(t))[0])
endfor
new_table = replicate(new_table, n_elements(table.(0)))
for t = 0L, n_tags(table) - 1L do begin
new_table.(t) = table.(t)
endfor
return, new_table
end
再次感謝。我目前正試圖找到一種更通用的方法,因此它不依賴於標籤的名稱(如果甚至可能的話)。 – user3199134