本文整理匯總了Python中openmdao.util.filewrap.FileParser.transfer_array方法的典型用法代碼示例。如果您正苦於以下問題:Python FileParser.transfer_array方法的具體用法?Python FileParser.transfer_array怎麽用?Python FileParser.transfer_array使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類openmdao.util.filewrap.FileParser
的用法示例。
在下文中一共展示了FileParser.transfer_array方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_output_parse_array
# 需要導入模塊: from openmdao.util.filewrap import FileParser [as 別名]
# 或者: from openmdao.util.filewrap.FileParser import transfer_array [as 別名]
def test_output_parse_array(self):
data = "Anchor\n" + \
"10 20 30 40 50 60 70 80\n" + \
"11 21 31 41 51 61 71 81\n" + \
"Key a b c d e\n"
outfile = open(self.filename, 'w')
outfile.write(data)
outfile.close()
gen = FileParser()
gen.set_file(self.filename)
gen.set_delimiters(' ')
gen.mark_anchor('Anchor')
val = gen.transfer_array(1, 1, 1, 8)
self.assertEqual(val[0], 10)
self.assertEqual(val[7], 80)
val = gen.transfer_array(1, 5, 2, 6)
self.assertEqual(val[0], 50)
self.assertEqual(val[9], 61)
gen.mark_anchor('Key')
val = gen.transfer_array(0, 2, 0, 6)
self.assertEqual(val[4], 'e')
val = gen.transfer_array(0, 2, fieldend=6)
self.assertEqual(val[4], 'e')
# Now, let's try column delimiters
gen.reset_anchor()
gen.mark_anchor('Anchor')
gen.set_delimiters('columns')
val = gen.transfer_array(1, 7, 1, 15)
self.assertEqual(val[0], 30)
self.assertEqual(val[2], 50)
val = gen.transfer_array(1, 10, 2, 18)
self.assertEqual(val[0], 40)
self.assertEqual(val[5], 61)
val = gen.transfer_array(3, 5, 3, 10)
self.assertEqual(val[0], 'a b c')
try:
gen.transfer_array(1, 7, 1)
except ValueError, err:
msg = "fieldend is missing, currently required"
self.assertEqual(str(err), msg)
示例2: parse_output
# 需要導入模塊: from openmdao.util.filewrap import FileParser [as 別名]
# 或者: from openmdao.util.filewrap.FileParser import transfer_array [as 別名]
def parse_output(self):
"""Parses the HSRNOISE output file and extracts data."""
outfile = FileParser()
outfile.set_file('test.output')
outfile.mark_anchor("JN8C4 JET NOISE MODULE")
outfile.mark_anchor("TOTAL")
self.thetas = outfile.transfer_array(4,2,4,18)
self.Freq = outfile.transfer_2Darray(7,1,30,1)
self.SPL = outfile.transfer_2Darray(7,2,30,18)
outfile.mark_anchor("DBA")
self.OASPL = outfile.transfer_array(-1, 2, -1, 18)
self.OASPL30 = outfile.transfer_var(-1, 4)
self.OASPL60 = outfile.transfer_var(-1, 7)
self.OASPL90 = outfile.transfer_var(-1, 10)
self.OASPL120 = outfile.transfer_var(-1, 13)
self.OASPL150 = outfile.transfer_var(-1, 16)
outfile.mark_anchor("EPNL SUMMARY")
self.TotalEPNL = outfile.transfer_var(9, 2)
self.TotalMaxPNLT = outfile.transfer_var(9, 5)
self.JetEPNL = outfile.transfer_var(8, 2)
示例3: load_model
# 需要導入模塊: from openmdao.util.filewrap import FileParser [as 別名]
# 或者: from openmdao.util.filewrap.FileParser import transfer_array [as 別名]
def load_model(self, control_input='control.in',
flocond_input='flocond.in',
expnd_input='expnd.in',
zrdmix_input='zrdmix.in',
hwall_input='hwall.in'):
'''Reads in an existing set of input files and populates the model.'''
ignore = ['ist', 'ifab']
ct = Namelist(self)
ct.set_filename(control_input)
ct.parse_file()
ct.load_model(ignore=ignore)
ignore = ['p01d', 'p02d', 't01d', 't02d', 'rm1', 'rm2', 'gam', 'pinf',
'a1d', 'a2d', 'a3d']
fc = Namelist(self)
fc.set_filename(flocond_input)
fc.parse_file()
fc.load_model(ignore=ignore)
self.flow_in.pri.Pt = fc.find_card('floc', 'p01d')
self.flow_in.sec.Pt = fc.find_card('floc', 'p02d')
self.flow_in.pri.Tt = fc.find_card('floc', 't01d')
self.flow_in.sec.Tt = fc.find_card('floc', 't02d')
self.flow_in.pri.Mach = fc.find_card('floc', 'rm1')
self.flow_in.sec.Mach = fc.find_card('floc', 'rm2')
self.flow_in.gamma = fc.find_card('floc', 'gam')
self.flow_in.Pstatic = fc.find_card('floc', 'pinf')
a1d = fc.find_card('floc', 'a1d')
a2d = fc.find_card('floc', 'a2d')
a3d = fc.find_card('floc', 'a3d')
ep = Namelist(self)
ep.set_filename(expnd_input)
ep.parse_file()
ep.load_model()
ignore = ['RLD', 'H0LM', 'H0HY', 'ALP1', 'ALP2', 'BWID']
zr = Namelist(self)
zr.set_filename(zrdmix_input)
zr.parse_file()
zr.load_model(ignore=ignore)
self.geo_in.length = zr.find_card('zrd', 'RLD')
self.geo_in.LhWave = zr.find_card('zrd', 'H0LM')
self.geo_in.LhMh = zr.find_card('zrd', 'H0HY')
self.geo_in.ChuteAngles = zr.find_card('zrd', 'ALP1')
#self.geo_in.ChuteAngles = zr.find_card('zrd', 'ALP2')
BWID = zr.find_card('zrd', 'BWID')
parser = FileParser()
parser.set_file(hwall_input)
parser.set_delimiters(", ")
nrow = parser.transfer_var(0, 1)
geom = zeros((nrow, 2), 'd')
for index in range(nrow):
geom[index, :] = parser.transfer_array(1+index, 1, 1+index, 2)
self.geom = geom
# Reverse area calculations for AsAp, AeAt and AR
# Note that DREA only uses half the area as it assumes a plane of symmetry
self.geo_in.Apri = 2.0*a1d
self.geo_in.AsAp = 2.0*a2d/self.geo_in.Apri
self.geo_in.Asec = self.geo_in.AsAp*self.geo_in.Apri
self.geo_in.AeAt = 2.0*a3d/(self.geo_in.Apri+self.geo_in.Asec)
self.geo_in.AR = BWID*BWID/(self.geo_in.Apri+self.geo_in.Asec)
#self.geo_in.length = self.geom[-1, 0]
self.geo_in.width = 0.5*(self.geo_in.Apri + self.geo_in.Asec)/self.geom[0,1]
self.geo_in.Aexit = 2.0*self.geom[-1,1]*self.geo_in.width