5. Some useful tips#

Here are some manipulations of recurring Python table data when you want to go further in generating curves from Code_Aster.

Extract from the table from POST_RELEVE_Tla list of post-processing nodes:

When a quantity is post-processed on a group of nodes (with more than one node) for several moments, the nodes appear for each moment, it is therefore necessary to extract the list of these nodes without repetition.

tabpy = tab. EXTR_TABLE ()

Creating the Python Table Object

tno = tabpy. NOEUD .values ()

We extract the values from column NOEUD

lno = list (set ([i.strip () for i in tno]))

Effective method for eliminating

duplicates using set

name.sort ()

Sort in ascending order

Build one or more keywords dynamically:

This can in particular be useful for entering the keyword factor FILTRE of IMPR_TABLE according to the context; in this case a dictionary is built which is then supplied as an argument to the command.

This:

IMPR_TABLE (

UNITE = unit,

TABLE = tab,

FORMAT = “XMGRACE”,

FILTRE = (_F (NOM_PARA =” NOEUD “,

VALE_K = “N4”,),

_F (NOM_PARA =” NOEUD “,

VALE_K = “N4”,),),

NOM_PARA = (“INST”, “VMIS”),

)

is equivalent to this:

mfac = {“FILTRE”: [{“NOM_PARA”: “NOEUD”, “VALE_K”: “N4”},

{“NOM_PARA”: “INTITULE”, “VALE_K”, “”: “example”},],

“NOM_PARA”: [“INST”, “VMIS”],

“UNITE”: unit,

“FORMAT”: “XMGRACE”,}

IMPR_TABLE (

TABLE = tab,

**MFAC

)

The advantage is of course to be able to build the dictionary as you wish.

Note

The factor keywords (here FILTRE) can be constructed using _F (keyword = value), but it is more flexible to see them as a list of dictionaries.