scipy.io.

netcdf_variable#

class scipy.io.netcdf_variable(data, typecode, size, shape, dimensions, attributes=None, maskandscale=False)[原始碼]#

netcdf 檔案的資料物件。

netcdf_variable 物件是透過呼叫 netcdf_file.createVariable 方法在 netcdf_file 物件上建構的。netcdf_variable 物件的行為與 numpy 中定義的陣列物件非常相似,只是它們的資料位於檔案中。資料透過索引讀取,並透過指派給索引子集來寫入;整個陣列可以使用索引 [:] 存取,或(對於純量)使用方法 getValueassignValuenetcdf_variable 物件也具有屬性 shape,其含義與陣列相同,但形狀無法修改。還有另一個唯讀屬性 dimensions,其值是維度名稱的元組。

所有其他屬性都對應於 NetCDF 檔案中定義的變數屬性。變數屬性是透過指派給 netcdf_variable 物件的屬性來建立的。

參數:
dataarray_like

保存變數值的資料陣列。通常,這會初始化為空,但具有正確的形狀。

typecodedtype 字元碼

資料陣列的所需資料類型。

sizeint

資料陣列的所需元素大小。

shape整數序列

陣列的形狀。這應與變數維度的長度相符。

dimensions字串序列

變數使用的維度名稱。必須與 shape 給定的維度長度順序相同。

attributesdict,選用

以字串名稱為鍵的屬性值(任何類型)。這些屬性成為 netcdf_variable 物件的屬性。

maskandscalebool,選用

是否根據屬性自動縮放和/或遮罩資料。預設值為 False。

另請參閱

isrec, shape
屬性:
dimensions字串列表

變數物件使用的維度名稱列表。

isrec, shape

屬性

方法

assignValue(value)

將純量值指派給長度為一的 netcdf_variable

getValue()

從長度為一的 netcdf_variable 檢索純量值。

itemsize()

傳回變數的 itemsize。

typecode()

傳回變數的 typecode。

__getitem__