本文整理匯總了Python中MA.transpose方法的典型用法代碼示例。如果您正苦於以下問題:Python MA.transpose方法的具體用法?Python MA.transpose怎麽用?Python MA.transpose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MA
的用法示例。
在下文中一共展示了MA.transpose方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: from_summset
# 需要導入模塊: import MA [as 別名]
# 或者: from MA import transpose [as 別名]
def from_summset(cls, ds, shaped_like=None):
self = cls(ds.name)
st = time.time()
cols = ds.get_columns()
if shaped_like is not None:
for axis in xtab_axes(shaped_like):
try:
col = ds[axis.name]
except KeyError:
pass
else:
self.axes.append(CrossTabAxis.from_col(col, axis.values))
cols.remove(col)
for col in cols:
if col.is_discrete() and not col.name.startswith('_'):
self.axes.append(CrossTabAxis.from_col(col))
if not self.axes:
raise Error('dataset %r must have at least one discrete column' %
(ds.name,))
indices = [axis.indices.filled() for axis in self.axes]
masks = [axis.indices.mask() for axis in self.axes]
map = MA.transpose(MA.array(indices, mask=masks))
shape = self.get_shape()
for col in ds.get_columns():
if col.is_scalar():
self.add_table(col.name,
data=self.from_vector(map, col.data, shape),
label=col.label)
elapsed = time.time() - st
soom.info('%r crosstab generation took %.3f, %.1f rows/s' %
(self.name, elapsed, len(map) / elapsed))
return self
示例2: testTranspose
# 需要導入模塊: import MA [as 別名]
# 或者: from MA import transpose [as 別名]
def testTranspose (self):
"test transpose"
assert not MA.transpose(self.m).iscontiguous()
assert eq(MA.transpose(self.m), [[1,11], [2,12], [3,13]])
assert eq(MA.transpose(MA.transpose(self.m)), self.m)
示例3: NetCDFFile
# 需要導入模塊: import MA [as 別名]
# 或者: from MA import transpose [as 別名]
# Open the netCDF files, get variables.
#
data_dir = Ngl.ncargpath("data")
ice1 = NetCDFFile(data_dir + "/cdf/fice.nc","r")
#
# Create a masked array to accommodate missing values in the fice variable.
#
fice = ice1.variables["fice"] # fice[120,49,100]
ficea = fice[:,:,:]
fill_value = None
if (hasattr(fice,"missing_value")):
fill_value = fice.missing_value
elif (hasattr(fice,"_FillValue")):
fill_value = fice._FillVlaue
fice_masked = MA.transpose(MA.masked_values(ficea,fill_value),(1,2,0))
hlat = ice1.variables["hlat"] # hlat[49]
hlon = ice1.variables["hlon"] # hlon[100]
dimf = fice.shape # Define an array to hold long-term monthly means.
ntime = fice.shape[0]
nhlat = fice.shape[1]
nhlon = fice.shape[2]
nmo = 0
month = nmo+1
icemon = MA.zeros((nhlat,nhlon),MA.Float0)
for i in xrange(fice_masked.shape[0]):