out_with_suffix
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
out_with_suffix [2014/05/07 13:22] – created martin_fisch | out_with_suffix [2022/11/03 15:08] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Out_with_suffix ====== | ||
+ | Description: | ||
+ | Comment: | ||
+ | In complex input files with many diffraction patterns (e.g. parametric ones), a different output is needed for e.g. each temperature.\\ Assuming there is consistent naming of parameters of interest, this can be done easier by using a macro for the output, in which the suffixes of the parameter names can be easily changed. | ||
+ | |||
+ | Contributed by: Martin Fisch | ||
+ | |||
+ | <code topas> | ||
+ | xdd Scan_100.raw ' measured at 100 °C | ||
+ | str | ||
+ | phase_name " | ||
+ | a lp_a_Phase_X_100 5 | ||
+ | b lp_b_Phase_X_100 5 | ||
+ | c lp_c_Phase_X_100 5 | ||
+ | scale scale_PhaseX_100 0.00001 | ||
+ | ..... | ||
+ | out Output.txt append | ||
+ | Out(Get(xdd_path_name, | ||
+ | Out( lp_a_Phase_X_100 , " | ||
+ | Out( lp_b_Phase_X_100 , " | ||
+ | Out( lp_c_Phase_X_100 , " | ||
+ | ..... | ||
+ | |||
+ | xdd Scan_200.raw ' measured at 200 °C | ||
+ | str | ||
+ | phase_name " | ||
+ | a lp_a_Phase_X_200 6 | ||
+ | b lp_b_Phase_X_200 6 | ||
+ | c lp_c_Phase_X_200 6 | ||
+ | scale scale_PhaseX_200 0.00001 | ||
+ | ..... | ||
+ | out Output.txt append | ||
+ | Out(Get(xdd_path_name, | ||
+ | Out( lp_a_Phase_X_200 , " | ||
+ | Out( lp_b_Phase_X_200 , " | ||
+ | Out( lp_c_Phase_X_200 , " | ||
+ | ..... | ||
+ | |||
+ | xdd ..... | ||
+ | </ | ||
+ | |||
+ | Is a lot easier by using a macro: | ||
+ | |||
+ | <code topas> | ||
+ | xdd Scan_100.raw ' measured at 100 °C | ||
+ | str | ||
+ | phase_name " | ||
+ | a lp_a_Phase_X_100 5 | ||
+ | b lp_b_Phase_X_100 5 | ||
+ | c lp_c_Phase_X_100 5 | ||
+ | scale scale_PhaseX_100 0.00001 | ||
+ | ..... | ||
+ | Out_with_suffix(100) | ||
+ | |||
+ | xdd Scan_200.raw ' measured at 200 °C | ||
+ | str | ||
+ | phase_name " | ||
+ | a lp_a_Phase_X_200 6 | ||
+ | b lp_b_Phase_X_200 6 | ||
+ | c lp_c_Phase_X_200 6 | ||
+ | scale scale_PhaseX_200 0.00001 | ||
+ | ..... | ||
+ | Out_with_suffix(200) | ||
+ | |||
+ | xdd ..... | ||
+ | </ | ||
+ | |||
+ | <code topas> | ||
+ | macro Out_with_suffix(suffix) | ||
+ | { | ||
+ | out Output.txt append | ||
+ | Out(Get(xdd_path_name, | ||
+ | Out( lp_a_Phase_X_## | ||
+ | Out( lp_b_Phase_X_## | ||
+ | Out( lp_c_Phase_X_## | ||
+ | '..... add more ..... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | In case phases appear/ | ||
+ | |||
+ | <code topas> | ||
+ | macro Out_with_suffix(suffix) | ||
+ | { | ||
+ | out Output.txt append | ||
+ | Out(Get(xdd_path_name, | ||
+ | if And( (Prm_There(scale_PhaseX_## | ||
+ | { | ||
+ | | ||
+ | Out( lp_b_Phase_X_## | ||
+ | Out( lp_c_Phase_X_## | ||
+ | '..... | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | Out_String(" | ||
+ | } | ||
+ | if And( (Prm_There(scale_PhaseY_## | ||
+ | { | ||
+ | | ||
+ | Out( lp_b_Phase_Y_## | ||
+ | Out( lp_c_Phase_Y_## | ||
+ | '..... | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | Out_String(" | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | will only write the values to a file if the phase is actually there (or more precisely, if its scale factor is there and > 0). \\ | ||
+ | If the phase is not there, the empty values will be replaced by tabs in order to allow easy editing of Output.txt in e.g. Excel. | ||
+ | |||
+ | |||
+ |