cape.pykes.jobxml: Interface to Kestrel main XML control file

This module provides the class JobXML, which reads, edits, and writes the main XML file that sets the main inputs for Kestrel jobs.

class cape.pykes.jobxml.JobXML(arg0=None, **kw)

Interface to XML files

Call:
>>> xml = JobXML(fxml)
>>> xml = JobXML(xml1)
>>> xml = JobXML(et)
>>> xml = JobXML(e)
>>> xml = JobXML(txt)
>>> xml = JobXML()
Inputs:
fxml: str

Name of an XML file

et: xml.etree.ElementTree.ElementTree

An XML element tree

e: xml.etree.ElementTree.Element

An XML root element

txt: str

XML text to parse directly

xml1: XMLFile

Another instance (of parent class)

Outputs:
xml: JobXML

Instance of Kestrel job XML file interface

Attributes:
xml.tree: xml.etree.ElementTree.ElementTree

An XML element tree interface to contents

xml.root: xml.etree.ElementTree.Element

The root element of the XML element tree

xml.fname: None | str

Name of file read or default file name to write

Versions:
  • 2021-10-18 @ddalle: v0.0: Started

find_input(name: str, parent: str)

Get XML element of freestream or other section by tag name

Call:
>>> elem = xml.find_input(name)
>>> elem = xml.find_input(name, parent)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

name: str

Name of freestream input attribute to query

parent: {"BodyHierarchy.Freestream"} | str

Option to use non-default path to flow quantities

Outputs:
elem: None | Element

Element matching all criteria

Versions:
  • 2021-10-18 @ddalle: v1.0

  • 2024-04-17 @ddalle: v2.0; Kestrel removed <InputList>

find_kcfd(tag)

Find an XML element from the KCFD settings

Call:
>>> elem = xml.find_kcfd(tag)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

tag: str

Element tag in KCFD parent

Outputs:
elem: None | Element

Element matching all criteria

Versions:
  • 2021-10-18 @ddalle: v1.0

find_section_item(**kw)

Prepare dict item descriptor for set_elem()

Call:
>>> elem = xml.find_section_item(**kw)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

tag: str

Element tag using full path or shortcut

section: {None} | Input | KCFD | str

Name of special section

value: {None} | str

Value to set, if any

attrib: {None} | dict

Requirements to match for elem.attrib

attribs: {None} | list[attrib]

Target attrib for each level of tags

tail: {None} | str

Target elem.tail, ignoring head/tail white space

exacttext: {None} | str

Target elem.text, exact match

exacttail: {None} | str

Target elem.tail, exact match

Outputs:
elem: None | Element

Element matching all criteria

Versions:
  • 2021-10-18 @ddalle: v1.0

get_alpha()

Get angle of attack from InputList section

Call:
>>> alpha = xml.get_alpha()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
alpha: None | float | str

Converted value of XML element text

get_beta()

Get sideslip angle from InputList section

Call:
>>> beta = xml.get_beta()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
beta: None | float | str

Converted value of XML element text

get_freestream(name: str)

Get the Python value of a Freestream condition

Call:
>>> v = xml.get_freestream(name)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

name: str

Name of input attribute to query

Outputs:
v: None | any

(Converted) text of InputList.Input element with attribute name matching

Versions:
  • 2024-04-17 @ddalle: v1.0

get_fvmcfd(tag: str)

Get converted text from the FVMCFD settings

Call:
>>> v = xml.get_fvmcfd(tag)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

tag: str

Element tag in KCFD parent

Outputs:
v: None | any

Converted text from found element

Versions:
  • 2021-10-18 @ddalle: v1.0

  • 2024-04-17 @ddalle: v2.0; Kestrel moved KCFD section

get_job_name() str

Get Kestrel job name from InputList section

Call:
>>> job_name = xml.get_job_name()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
job_name: None | float | str

Converted value of XML element text

get_kcfd(tag: str)

Get converted text from the KCFD settings

Call:
>>> v = xml.get_kcfd(tag)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

tag: str

Element tag in KCFD parent

Outputs:
v: None | any

Converted text from found element

Versions:
  • 2021-10-18 @ddalle: v1.0

  • 2024-04-17 @ddalle: v2.0; Kestrel moved KCFD section

get_kcfd_iters()

Get number of iterations from KCFD section

Call:
>>> iters = xml.get_kcfd_iters()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
iters: None | float | str

Converted value of XML element text

get_kcfd_subiters()

Get number of subiterations from KCFD section

Call:
>>> subiters = xml.get_kcfd_subiters()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
subiters: None | float | str

Converted value of XML element text

get_kcfd_timestep()

Get non-dimensional time step from KCFD section

Call:
>>> timestep = xml.get_kcfd_timestep()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
timestep: None | float | str

Converted value of XML element text

get_mach()

Get Mach number from InputList section

Call:
>>> mach = xml.get_mach()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
mach: None | float | str

Converted value of XML element text

get_pressure()

Get freestream pressure from InputList section

Call:
>>> pressure = xml.get_pressure()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
pressure: None | float | str

Converted value of XML element text

get_relen()

Get Reynolds length from InputList section

Call:
>>> relen = xml.get_relen()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
relen: None | float | str

Converted value of XML element text

get_restart()

Get restart flag from InputList section

Call:
>>> restart = xml.get_restart()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
restart: None | float | str

Converted value of XML element text

get_rey()

Get Reynolds number from InputList section

Call:
>>> rey = xml.get_rey()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
rey: None | float | str

Converted value of XML element text

get_temperature()

Get freestream temperature from InputList section

Call:
>>> temperature = xml.get_temperature()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
temperature: None | float | str

Converted value of XML element text

get_velocity()

Get freestream flow velocity from InputList section

Call:
>>> velocity = xml.get_velocity()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
velocity: None | float | str

Converted value of XML element text

get_version() str

Get the Kestrel feature set version identifier

Call:
>>> featureset = xml.get_version()
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

Outputs:
featureset: str

Value of JobInputs attribute featureSet

Versions:
  • 2024-04-17 @ddalle: v1.0

gettext_input(name)

Get the ext of an InputList.Input element

Call:
>>> txt = xml.gettext_input(name)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

name: str

Name of input attribute to query

Outputs:
txt: None | str

Text of InputList.Input element with attribute name matching

Versions:
  • 2021-10-18 @ddalle: v1.0

gettext_kcfd(tag)

Get text from the KCFD settings

Call:
>>> v = xml.gettext_kcfd(tag)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

tag: str

Element tag in KCFD parent

Outputs:
txt: None | str

text from found element

Versions:
  • 2021-10-18 @ddalle: v1.0

set_alpha(alpha)

Set angle of attack in InputList section

Call:
>>> xml.set_alpha(alpha)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

alpha: None | float | str

Value to set in XML file

set_beta(beta)

Set sideslip angle in InputList section

Call:
>>> xml.set_beta(beta)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

beta: None | float | str

Value to set in XML file

set_freestream(name: str, v)

Set the text of an InputList.Input element

Call:
>>> xml.set_freestream(name, v)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

name: str

Name of input attribute to query

v: None | any

Python value to save to element as text

Versions:
  • 2021-10-18 @ddalle: v1.0 (set_input()

  • 2024-04-17 @ddalle: v2.0

set_fvmcfd(tag: str, v)

Set the text of a KCFD element

Call:
>>> xml.set_fvmcfd(tag, v)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

tag: str

Element tag in KCFD parent

v: None | any

Python value to save to element as text

Versions:
  • 2024-04-17 @ddalle: v1.0

set_job_name(job_name: str)

Set Kestrel job name in InputList section

Call:
>>> xml.set_job_name(job_name)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

job_name: None | float | str

Value to set in XML file

set_kcfd(tag: str, v)

Set the text of a KCFD element

Call:
>>> xml.set_kcfd(tag, v)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

tag: str

Element tag in KCFD parent

v: None | any

Python value to save to element as text

Versions:
  • 2021-10-18 @ddalle: v1.0

set_kcfd_iters(iters)

Set number of iterations in KCFD section

Call:
>>> xml.set_kcfd_iters(iters)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

iters: None | float | str

Converted value of XML element text

set_kcfd_subiters(subiters)

Set number of subiterations in KCFD section

Call:
>>> xml.set_kcfd_subiters(subiters)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

subiters: None | float | str

Converted value of XML element text

set_kcfd_timestep(timestep)

Set non-dimensional time step in KCFD section

Call:
>>> xml.set_kcfd_timestep(timestep)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

timestep: None | float | str

Converted value of XML element text

set_mach(mach)

Set Mach number in InputList section

Call:
>>> xml.set_mach(mach)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

mach: None | float | str

Value to set in XML file

set_pressure(pressure)

Set freestream pressure in InputList section

Call:
>>> xml.set_pressure(pressure)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

pressure: None | float | str

Value to set in XML file

set_relen(relen)

Set Reynolds length in InputList section

Call:
>>> xml.set_relen(relen)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

relen: None | float | str

Value to set in XML file

set_restart(restart=True)

Set restart flag in InputList section

Call:
>>> xml.set_restart(restart)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

restart: None | float | str

Value to set in XML file

set_rey(rey)

Set Reynolds number in InputList section

Call:
>>> xml.set_rey(rey)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

rey: None | float | str

Value to set in XML file

set_section_item(**kw)

Set value by dictionary of options

Call:
>>> xml.set_section_item(**kw)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

tag: str

Element tag using full path or shortcut

section: {None} | Input | KCFD | str

Name of special section

value: {None} | str

Value to set, if any

attrib: {None} | dict

Requirements to match for elem.attrib

attribs: {None} | list[attrib]

Target attrib for each level of tags

insert: {True} | False

Option to insert new element(s) if not found

indent: {2} | int >= 0

Number of spaces in an indent

tab: {indent * " "} | str

Override indent with a specific string

text: {None} | str

Target elem.text for searching

tail: {None} | str

Target elem.tail for searching

exacttext: {None} | str

Target elem.text, exact match

exacttail: {None} | str

Target elem.tail, exact match

newattrib: {None} | dict

New attributes to set in found element

newtail: {None} | str

Specific final tail text for found dlement

updateattrib: {None} | dict

Attributes to update without resetting elem.attrib

Versions:
  • 2021-10-26 @ddalle: v1.0

set_temperature(temperature)

Set freestream temperature in InputList section

Call:
>>> xml.set_temperature(temperature)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

temperature: None | float | str

Value to set in XML file

set_velocity(velocity)

Set freestream flow velocity in InputList section

Call:
>>> xml.set_velocity(velocity)
Inputs:
xml: JobXML

Instance of Kestrel job XML file interface

velocity: None | float | str

Value to set in XML file

text2val(txt)

Convert XML text to Python value

Call:
>>> v = xml.text2val(txt)
Inputs:
xml: JobXML

XML file interface

txt: str

Text to convert

Outputs:
v: object

Converted value

Versions:
  • 2021-10-18 @ddalle: v1.0

val2text(v)

Convert Python value to XML text

Call:
>>> txt = xml.val2text(v)
Inputs:
xml: JobXML

XML file interface

v: any

Python value to convert

Outputs:
txt: str

Converted text

Versions:
  • 2021-10-18 @ddalle: v1.0