User Reference for SIMPLE
The simple
namespace contains everything necessary for normal usage of the package.
simple
simple.asarray
asarray(values, dtype=None, saving=False)
Convert data
to a numpy array.
If data
is a string or a sequence of strings and saving=False
, either a single string or a tuple
of string will be returned. If saving
is True
the values will be converted to an array with a byte dtype.
This ensures values are compatible with the hdf5 library.
Arrays with a bytes
dtype will automatically be converted to the str
dtype. If saving
is False
then
this values will be converted to either a string or a tuple of strings (see above).
Parameters:
-
values
–An values like object.
-
dtype
–The data type of the returned values.
-
saving
–Should be
True
is the data is to be saved in a hdf5 file.
Source code in simple/utils.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
|
simple.aselement
aselement(string, without_suffix=False, allow_invalid=False)
Returns a Element
representing an element symbol.
The returned element format is the capitalised element
symbol followed by the suffix, if present. E.g. Pd-104*
where
*
is the suffix.
The case of the element symbol is not considered.
Parameters:
-
string
(str
) –A string containing an element symbol.
-
without_suffix
–If
True
the suffix part of the string is ignored. -
allow_invalid
–If
False
, andstring
cannot be parsed into an element string, an exception is raised. IfTrue
thenstring.strip()
is returned instead.
Examples:
>>> ele = simple.asisotope("pd"); ele
"Pd"
Source code in simple/utils.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 |
|
simple.aselements
aselements(strings, without_suffix=False, allow_invalid=False)
Returns a tuple of Element
strings where each string represents an element symbol.
Parameters:
-
strings
–Can either be a string with element symbol seperated by a
,
or a sequence of strings. -
without_suffix
–If
True
the suffix part of each isotope string is ignored. -
allow_invalid
–If
False
, and a string cannot be parsed into an isotope string, an exception is raised. IfTrue
thenstring.strip()
is returned instead.
Examples:
>>> simple.asisotopes('ru, pd, cd')
('Ru', 'Pd', 'Cd')
>>> simple.asisotopes(['ru', 'pd', 'cd'])
('Ru', 'Pd', 'Cd')
Source code in simple/utils.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
|
simple.asisolist
asisolist(isolist, without_suffix=False, allow_invalid=False)
Return a dictionary consisting of an isotope key mapped to a tuple of isotopes that should make up the key isotope.
If isolist
is list or tuple of keys then each key will be mapped only to itself.
Parameters:
-
isolist
–Either a dictionary mapping a single isotope to a list of isotopes or a sequence of isotopes that will be mapped to themselfs.
-
without_suffix
–If
True
the suffix part of each isotope string is ignored. -
allow_invalid
–If
True
invalid isotopes string are allowed. IfFalse
they will instead raise an exception.
Source code in simple/utils.py
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
|
simple.asisotope
asisotope(string, without_suffix=False, allow_invalid=False)
Returns a Isotope
representing an isotope.
The returned isotope format is the capitalised element
symbol followed by a dash followed by the mass number followed by the suffix, if present. E.g. Pd-104*
where
*
is the suffix.
The order of the element symbol and mass number in string
is not important, but they must proceed the suffix.
The element symbol and mass number may be seperated by -
. The case of the element symbol is not
considered.
Parameters:
-
string
(str
) –A string element symbol and a mass number.
-
without_suffix
–If
True
the suffix part of the isotope string is ignored. -
allow_invalid
–If
False
, andstring
cannot be parsed into an isotope string, an exception is raised. IfTrue
thenstring.strip()
is returned instead.
Examples:
>>> iso = simple.asisotope("104pd"); iso # pd104, 104-Pd etc are also valid
"Pd-104"
>>> iso.symbol, iso.mass
"Pd", "104"
Source code in simple/utils.py
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
|
simple.asisotopes
asisotopes(strings, without_suffix=False, allow_invalid=False)
Returns a tuple of Isotope
strings where each string represents an isotope.
Parameters:
-
strings
–Can either be a string with isotopes seperated by a
,
or a sequence of strings. -
without_suffix
–If
True
the suffix part of each isotope string is ignored. -
allow_invalid
–If
False
, and a string cannot be parsed into an isotope string, an exception is raised. IfTrue
thenstring.strip()
is returned instead.
Examples:
>>> simple.asisotopes('104pd, pd105, 106-Pd')
('Pd-104', 'Pd-105, 106-Pd')
>>> simple.asisotopes(['104pd', 'pd105', '106-Pd'])
('Pd-104', 'Pd-105, 106-Pd')
Source code in simple/utils.py
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 |
|
simple.askeyarray
askeyarray(values, keys, dtype=None)
Returns a numpy array where the columns can be accessed by the column key.
Parameters:
-
values
–An array consisting of 2 dimensions where first dimension is the row and the second
-
keys
–The keys for each column in
values
. Must be the same length as the second dimension ofvalues
. -
dtype
–The values type of the returned array. All columns will have the same dtype.
Notes
If values
has less then 2 dimensions then it is assumed to represent a single row of values.
It is not possible to save this type of array in hdf5 files if they have more than a few hundred columns.
Examples:
>>> a = simple.askeyarray([[1,2,3],[4,5,6]], ['Pd-104','Pd-105','Pd-106']); a
array([(1, 2, 3), (4, 5, 6)],
dtype=[('Pd-104', '<i8'), ('Pd-105', '<i8'), ('Pd-106', '<i8')])
>>> a['Pd-104']
array([1, 4])
Source code in simple/utils.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
simple.asratio
asratio(string, without_suffix=False, allow_invalid=False)
Returns a Ratio
string representing the ratio of two isotopes.
The format of the returned string is the numerator followed by
a /
followed by the normiso. The numerator and normiso string be parsed by asisotope
together with
the given without_suffix
and allow_invalid
arguments passed to this function.
Parameters:
-
string
(str
) –A string contaning two strings seperated by a single
/
. -
without_suffix
(bool
, default:False
) –If
True
the suffix part of the numerator and normiso string is ignored. -
allow_invalid
(bool
, default:False
) –Whether the numerator and normiso has to be a valid isotope string.
If the returned string is an isotope string it will have the following attributes and methods.
Attributes:
-
numer
(str
) –The numerator string
-
denom
(str
) –The normiso string
Functions:
-
latex
–Returns a latex formatted version of the isotope.
-
without_suffix
–Returns a ratio string omitting the numerator and normiso suffix.
Source code in simple/utils.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
|
simple.asratios
asratios(strings, without_suffix=False, allow_invalid=False)
Returns a tuple of Ratio
strings where each string represents the ratio of two isotopes.
Parameters:
-
strings
–Can either be a string with isotope ratios seperated by a
,
or a sequence of strings. -
without_suffix
–If
True
the suffix part of each isotope string is ignored. -
allow_invalid
–If
False
, and a string cannot be parsed into an isotope string, an exception is raised. IfTrue
thenstring.strip()
is returned instead.
Source code in simple/utils.py
765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
|
simple.create_legend
create_legend(ax, outside=False, outside_margin=0.01, **kwargs)
Add a legend to a plot.
Parameters:
-
ax
–The working axes. Accepted values are any matplotlib Axes object or plt instance.
-
outside
(bool
, default:False
) –If
True
the legend will be drawn just outside the upper left corner of the plot. This will overwrite anyloc
andbbox_to_anchor
arguments inkwargs
. -
outside_margin
–Margin between the plot and the legend. Relative to the width of the plot.
-
**kwargs
–Any valid argument for matplotlibs
legend
function.
Source code in simple/plotting.py
1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 |
|
simple.create_rose_plot
create_rose_plot(ax=None, *, vmin=None, vmax=None, log=False, cmap='turbo', colorbar_show=True, colorbar_label=None, colorbar_fontsize=None, xscale=1, yscale=1, segment=None, rres=None, **fig_kw)
Create a plot with a rose projection.
The rose ax is a subclass of matplotlibs polar ax.
Parameters:
-
ax
–If no preexisting ax is given then a new figure with a single rose ax is created. If an existing
-
vmin
(float
, default:None
) –The lower limit of the colour map. If no value is given the minimum value is
0
(or1E-10
if -
vmax
(float
, default:None
) –The upper limit of the colour map. If no value is given then
vmax
is set to1
and all bin default_weight are divided by the heaviest bin weight in each histogram. -
log
(bool
, default:False
) –Whether the color map scale is logarithmic or not.
-
cmap
–The prefixes of the colormap to use. See, [matplotlib documentation][https://matplotlib.org/stable/users/explain/colors/colormaps.html] for a list of available colormaps.
-
colorbar_show
–Whether to add a colorbar to the right of the ax.
-
colorbar_label
–The label given to the colorbar.
-
colorbar_fontsize
–The fontsize of the colorbar label.
-
xscale
–The scale of the x axis.
-
yscale
–The scale of the y axis.
-
segment
–Which segment of the rose diagram to show. Options are
N
,E
,S
,W
,None
. IfNone
the entire circle is shown. -
rres
–The resolution of lines drawn along the radius
r
. The number of points in a line is calculated as -
**fig_kw
–Additional figure keyword arguments passed to the
pyplot.figure
call. Only used whenax
is not given.
Returns:
-
RoseAxes
–The new rose ax.
Source code in simple/plotting.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
simple.get_data
get_data(models, axis_names, *, where=None, latex_labels=True, key=None, default_attrname=None, unit=None, default_value=np.nan, key_in_label=None, numer_in_label=None, denom_in_label=None, model_in_label=None, unit_in_label=None, attrname_in_label=None, axis_name_in_label=None, label=True, prefix_label=None, suffix_label=None, mask=None, mask_na=True, _kwargs=None, **kwargs)
Get one or more datasets from a group of models together with suitable labels.
Each data point is a dictionary that contains a value for each of the axis given in axis_names plus a label describing the data point. The value for each axis is determined by the key argument. This argument has two possible components; the name of the attribute and the index, or key, to be applied this, or the default_attrname, attribute.
The name of the attribute must start with a .
followed by the path to the attribute relative to the Model
object using successive .
for nested attributes, e.g. .intnorm.eRi
.
The index, or key, part of the key can either be an integer, a slice or a sequence of keys seperated by ,
.
The keys will be parsed into either Isotope, Ratio, or
Element strings. If a key is given it is assumed that the attribute contains an isotope
key array. Therefore, Element strings will be replaced with all the isotopes of that element
present in the attribute (Across all models) and Ratio strings will return the numerator value divided by the
denominator value.
If the attribute name is given in key then the index, or key, part must be enclosed in square brackets, e.g.
.intnorm.eRi[105Pd]
. If the default_attrname should be used then key should only contain the index, or key.
By the default the label for each data point only contains the information is not shared with all other data points. Information that is shared between all data points is instead included in the axis labels.
Parameters:
-
models
–A collection of models to plot. A subselection of these models can be made using the where argument.
-
axis_names
– -
where
(str
, default:None
) –If given will be used to create a subselection of models. Any kwargs prefixed with
where_
will be supplied as keyword arguments. SeeModelCollection.where
for more details. -
latex_labels
(bool
, default:True
) –Whether to use the latex formatting in the labels, when available.
-
key
((str, int, slice)
, default:None
) –This can either be a valid index to the default_attrname array or the path, with or without a valid index, of a different attribute. Accepts either single universal value or a list of values, one for each axis (See below for details).
-
default_attrname
–The name of the default attribute to use if xkey and ykey are indexes. By default, the default key array is used. Accepts either single universal value or a list of values, one for each axis (See below for details).
-
unit
–The desired unit for the xkey and ykey. Different units for xkey and ykey can be specified by supplying a
(<xkey_unit>, <ykey_unit>)
sequence. Accepts either single universal value or a list of values, one for each axis (See below for details). -
default_value
–The value given to invalid indexes of arrays. Must have a shape compatible with the size of the indexed array. Accepts either single universal value or a list of values, one for each axis (See below for details).
-
key_in_label
(bool
, default:None
) –Whether to include the key index in the label. Accepts either single universal value or a list of values, one for each axis (See below for details).
-
numer_in_label
(bool
, default:None
) –Whether to include the numerator of a key index in the label. Accepts either single universal value or a list of values, one for each axis (See below for details).
-
denom_in_label
(bool
, default:None
) –Whether to include the denominator of a key index in the label. Accepts either single universal value or a list of values, one for each axis (See below for details).
-
model_in_label
(bool
, default:None
) –Whether to include the model name in the label. Accepts either single universal value or a list of values, one for each axis (See below for details).
-
unit_in_label
(bool
, default:None
) –Whether to include the unit in the label. Accepts either single universal value or a list of values, one for each axis (See below for details).
-
attrname_in_label
(bool
, default:None
) –Whether to include the attribute name in the label. By default the name is only included if it is different from the default_attrname. Accepts a single universal value or a list of values, one for each axis (See below for details).
-
axis_name_in_label
(bool
, default:None
) –Whether to include the axis name in the label. Accepts either single universal value or a value for each axis (See below for details).
-
label
((str, bool, None)
, default:True
) –The label for individual datapoints. Accepts either a single universal value or a list of values, one per data point (See below for details).
-
prefix_label
–Text to be added to the beginning of each data point label. Accepts either a single universal value or a list of values, one per data point (See below for details).
-
suffix_label
–Text to be added at the end of each data point label. Accepts either a single universal value or a list of values, one per data point (See below for details).
-
mask
((str, int, slice)
, default:None
) –Can be used to apply a mask to the data which is plotted. See the
get_mask
function of the Model object. Accepts either a single universal value or a list of values, one per model (See below for details). -
mask_na
(bool
, default:True
) –If
True
masked values will be replaced bynp.nan
values. Only works if all arrays in a dataset have a float based datatype. Accepts either a single universal value or a list of values, one per model (See below for details). -
**kwargs
–
One per axis arguments
These arguments allow you to set a different value for each axis in axis_names. This can be either a single value used for all the axis or a sequence of values, one per axis.
It is also possible to define the value for a specific axis by including a keyword argument consiting
of the axis name followed directly by the argument name. The value specified this way will take presidence over
the value given by the argument itself. For example xkey=102Pd
will set the key argument for
the x axis to 102Pd
.
One per data point arguments
These arguments allow you to set a different value for each data point. The number of data points is equal to the number of models multiplied by the number of datasets generated. This can be either a single value used for all the axis or a sequence of values, one per data point.
One per model arguments
These arguments allow you to set a different value for each model in models. This can be either a single value used for all the axis or a sequence of values, one per model.
Returns:
-
–
Tuple[dict, dict]: Two dictionaries containing:
-
A dictionary with the data points for each model, mapped to the model name
-
A dictionary containing labels for each axis, mapped to the axis name.
-
Examples:
Here is an example of how the return data can be used.
model_datapoints, axis_labels = simple.get_data(models, 'x, y', xkey=..., ykey=...)
# Set the axis labels
plt.set_xlabel(axis_labels['x'])
plt.set_ylabel(axis_labels['y'])
# Iterate though the data and plot it
for model_name, datapoints in model_datapoints.items():
for dp in datapoints:
plt.plot(dp['x'], dp['y'], label=dp['label'])
Source code in simple/plotting.py
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 |
|
simple.get_isotopes_of_element
get_isotopes_of_element(isotopes, element, isotopes_without_suffix=False)
Returns a tuple of all isotopes in a sequence that contain the given element symbol.
Note The strings in isotopes
will be passed through asisotopes before
the evaluation and therefore do not have to be correcly formatted. Invalid isotope string are allowed
but will be ignored by the evaluation.
Parameters:
-
isotopes
–An iterable of strings representing isotopes.
-
element
(str
) –The element symbol.
-
suffix
(str
) –If given the isotopes must also have this suffix.
-
isotopes_without_suffix
(bool
, default:False
) –If
True
suffixes will be removed from the isotopes inisotopes
before the evaluation takes place.
Examples:
>>> simple.utils.get_isotopes_of_element(["Ru-101", "Pd-102", "Rh-103", "Pd-104"], "Pd")
>>> ("Pd-102", "Pd-104")
Source code in simple/utils.py
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
|
simple.load_collection
load_collection(filename, dbfilename=None, *, default_isolist=None, convert_unit=True, overwrite=False, where=None, **where_kwargs)
Loads a selection of models from a file.
If that file does not exist it will create the file from the specified models file. Only when doing this
is the default_isolist
applied. If filename
already exits the assumption is it has the correct isolist.
*Notes
The entire file will be read into memory. This might be an issue if reading very large files. The hdf5 are compressed so will be significantly larger when stored in memory.
When reading the database file to create a subselection of the data using default_isolist
, the subselection is
made when each model is loaded which reduces the amount of memory used.
Parameters:
-
filename
(str
) –Name of the file to load or create.
-
dbfilename
(str
, default:None
) –Name of the raw models file
-
default_isolist
–Isolist applied to loaded models from
dbfilename
. -
convert_units
(bool
) –If
True
and data is stored in a mass unit all values will be divided by the mass number of the isotope before summing values together. The final value is then multiplied by the mass number of the output isotope. -
overwrite
(bool
, default:False
) –If
True
a new file will be created even iffilename
already exists. -
where
(str
, default:None
) –Used to select which models to load.
-
**where_kwargs
–Keyword arguments used in combination with
where
.
Returns:
-
–
A ModelCollection object containing all the loaded models.
Source code in simple/models.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
simple.load_defaults
load_defaults(filename)
Loads default arguments for functions from a YAML formatted file.
To use a set of default values, unpack the arguments in the function call (See example).
You can still arguments and keyword arguments as normal as long as they are not included in the default dictionary.
Returns:
-
–
A named dictionary containing mapping the prefixes given in the yaml file to another dictionary mapping the arguments
-
–
to the specified values.
Examples:
The file default.yaml
is expected to look like this:
somefunction:
arg: value
listarg:
- first thing in list
- second thing in list
anotherfunction:
arg: value
It can be used like this
>>> defaults = simple.load_defaults('defaults.yaml')
>>> somefunction(**defaults['somefunction']) # Unpack arguments into function call
Source code in simple/utils.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
|
simple.mcontour
mcontour(models, xkey, ykey, r=None, weights=1, *, default_attrname=None, unit=None, weights_default_attrname=None, weights_unit=None, weights_default_value=0, mask=None, ax=None, where=None, where_kwargs={}, legend=None, update_ax=True, update_fig=True, **kwargs)
Contour plot on a rose diagram.
Source code in simple/plotting.py
2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 |
|
simple.mcontour_ccsne
mcontour_ccsne(models, xkey, ykey, r=None, weights=1, **kwargs)
Contour plot on a rose diagram for CCNSe models.
Source code in simple/ccsne.py
760 761 762 763 764 765 766 767 768 769 770 771 772 |
|
simple.mhist
mhist(models, xkey, ykey, r=None, weights=1, *, default_attrname=None, unit=None, weights_default_attrname=None, weights_unit=None, weights_default_value=0, mask=None, ax=None, where=None, where_kwargs={}, legend=None, update_ax=True, update_fig=True, **kwargs)
Histogram plot on a rose diagram.
Source code in simple/plotting.py
2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 |
|
simple.mhist_ccsne
mhist_ccsne(models, xkey, ykey, r=None, weights=1, **kwargs)
Histogram plot on a rose diagram for CCNSe models.
Source code in simple/ccsne.py
746 747 748 749 750 751 752 753 754 755 756 757 758 |
|
simple.new_collection
new_collection()
Return an empty ModelCollection object.
Source code in simple/models.py
91 92 93 94 95 |
|
simple.plot
plot(models, xkey, ykey, *, default_attrname=None, unit=None, where=None, mask=None, mask_na=True, ax=None, legend=None, update_ax=True, update_fig=True, **kwargs)
Plot xkey against ykey for each model in `models.
It is possible to plot multiple datasets if xkey and/or ykey is a list of multiple keys for a isotope key
array. If only one of the arguments is a list then the second argument will be reused for each dataset. If a key
is not present in an array then a default value is used. See get_data
for more details.
The data to be plotted is retrieved using the get_data
function. All arguments available
for that function not included in the argument list here can be given as one of the kwargs to this function.
The data will be plotted using matplotlib's plot
function. Additional arguments to this function can be
passed as one of the kwargs to this function. Some plot
arguments have enhanced behaviour detailed in a
section below.
Parameters:
-
models
–A collection of models to plot. A subselection of these models can be made using the where argument.
-
xkey,
(ykey (str, int, slice
) –This can either be a valid index to the default_attrname array or the path, with or without a valid index, of a different attribute. See
get_data
for more details. -
default_attrname
(str
, default:None
) –The name of the default attribute to use if xkey and ykey are indexes.
-
unit
(str
, default:None
) –The desired unit for the xkey and ykey. Different units for xkey and ykey can be specified by supplying a
(<xkey_unit>, <ykey_unit>)
sequence. -
where
(str
, default:None
) –If given will be used to create a subselection of models. Any kwargs prefixed with
where_
will be supplied as keyword arguments. SeeModelCollection.where
for more details. -
mask
((str, int, slice)
, default:None
) –Can be used to apply a mask to the data which is plotted. See the
get_mask
function of the Model object. -
mask_na
(bool
, default:True
) –If
True
masked values will be replaced bynp.nan
values. Only works if both xkey and ykey have a float based datatype. -
ax
–The axes where the data is plotted. Accepted values are any matplotlib Axes object or plt instance. Defaults to
plt.gca()
. -
legend
(bool
, default:None
) –Whether to create a legend. By default, a legend will be created if one or more datapoints have a valid label.
-
update_ax,
(update_fig (bool
) –Whether to update the axes and figure objects using kwargs that have the prefix
ax_
andfig_
. Seesimple.plotting.update_axes
for more details. -
**kwargs
–Valid keyword arguments are those using one of the prefixes define by other arguments, any argument for the
simple.get_data
function, or any valid keyword argument for matplotlib'splot
function.
Data and axis labels
Labels for each axis and individual datapoints will be automatically generated. By default, the axis labels
will contain the information common to all datasets while the label for the individual datapoints will contain
only the unique information. You can override the axis labels by passing ax_xlabel
and ax_ylabel
as
one of the kwargs. You can also override the datapoint labels by passing a list of labels, one each
for each datapoint in the legend. See get_data
for more details on customising the
labels.
Iterable plot arguments
The following arguments for matplotlibs plot
function have enhanced behaviour that allows them to be
iterated through when plotting different models and/or datasets.
-
linestyle
Can be a list of linestyles that will be iterated through. IfTrue
simple's predefined list of linestyles is used. IfFalse
no lines will be shown. -
color
Can be a list of colors that will be iterated through. IfTrue
simple's predefined list of colors is used. IfFalse
the colour defaults to black. -
marker
Can be a list of markers that will be iterated through. IfTrue
simple's predefined list of markers is used. IfFalse
no markers will be shown.
There are two ways these values can be iterated through. Either all the datapoints of a given model gets the same value or each set of datapoints across the different models gets the same value. By default, if there are multiple models then all the datasets for each model will have the same color. If there is only one model then the color will be different for the different datasets. If there are multiple datasets then each dataset across the different models will have the same linestyle and marker. If there is only one dataset then linestyle and marker will be different for each model.
This behaviour can be changed by passing fixed_model_linestyle
, fixed_model_color
and fixed_model_marker
keyword arguments set to either True
or False
If True
each model will
have the same value. If False
each dataset across the different models will have the same value.
Default kwargs and shortcuts
The default values for arguments can be updated by changing the plot.default_kwargs
dictionary. Any
argument not defined in the function description will be included in kwargs. Default values given in the
function definition will be used only if a default value does not exist in plot.default_kwargs
.
Additionally, one or more shortcuts with additional/different default values are attached to this function.
The following shortcuts exist for this function:
-
plot.intnorm
Default values to plot internally normalised data. This sets default_attrname tointnorm
and thedefault_unit
toNone
. -
plot.stdnorm
Default values to plot the basic ratio normalised data. This sets default_attrname tostdnorm
and thedefault_unit
toNone
.
Returns:
-
–
The axes where the data was plotted.
Source code in simple/plotting.py
1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 |
|
simple.plot_ccsne
plot_ccsne(models, ykey, *, semilog=False, onion=None, **kwargs)
Plot for CCSNe models. Plots the mass coordinates on the x-axis.
Source code in simple/ccsne.py
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
|
simple.plotm
plotm(models, xkey, ykey, xycoord=(0, 0), *, arrow=True, arrow_position=0.9, default_attrname=None, unit=None, where=None, mask=None, mask_na=True, ax=None, legend=None, update_ax=True, update_fig=True, **kwargs)
Plot the slope of ykey / xkey for each model in `models.
It is possible to plot multiple datasets if xkey and/or ykey is a list of multiple keys for a isotope key
array. If only one of the arguments is a list then the second argument will be reused for each dataset. If a key
is not present in an array then a default value is used. See get_data
for more details.
The data to be plotted is retrieved using the get_data
function. All arguments available
for that function not included in the argument list here can be given as one of the kwargs to this function.
The data will be plotted using matplotlib's axline
function. Additional arguments to this function can be
passed as one of the kwargs to this function. Some arguments have enhanced behaviour detailed in a
section below.
Parameters:
-
models
–A collection of models to plot. A subselection of these models can be made using the where argument.
-
xkey,
(ykey (str, int, slice
) –This can either be a valid index to the default_attrname array or the path, with or without a valid index, of a different attribute. See
get_data
for more details. -
default_attrname
(str
, default:None
) –The name of the default attribute to use if xkey and ykey are indexes.
-
unit
(str
, default:None
) –The desired unit for the xkey and ykey. Different units for xkey and ykey can be specified by supplying a
(<xkey_unit>, <ykey_unit>)
sequence. -
where
(str
, default:None
) –If given will be used to create a subselection of models. Any kwargs prefixed with
where_
will be supplied as keyword arguments. SeeModelCollection.where
for more details. -
mask
((str, int, slice)
, default:None
) –Can be used to apply a mask to the data which is plotted. See the
get_mask
function of the Model object. -
mask_na
(bool
, default:True
) –If
True
masked values will be replaced bynp.nan
values. Only works if both xkey and ykey have a float based datatype. -
ax
–The axes where the data is plotted. Accepted values are any matplotlib Axes object or plt instance. Defaults to
plt.gca()
. -
legend
(bool
, default:None
) –Whether to create a legend. By default, a legend will be created if one or more datapoints have a valid label.
-
update_ax,
(update_fig (bool
) –Whether to update the axes and figure objects using kwargs that have the prefix
ax_
andfig_
. Seesimple.plotting.update_axes
for more details. -
**kwargs
–Valid keyword arguments are those using one of the prefixes define by other arguments, any argument for the
simple.get_data
function, or any valid keyword argument for matplotlib'splot
function.
Data and axis labels
Labels for each axis and individual datapoints will be automatically generated. By default, the axis labels
will contain the information common to all datasets while the label for the individual datapoints will contain
only the unique information. You can override the axis labels by passing ax_xlabel
and ax_ylabel
as
one of the kwargs. You can also override the datapoint labels by passing a list of labels, one each
for each datapoint in the legend. See get_data
for more details on customising the
labels.
Iterable plot arguments
The following arguments for matplotlibs plot
function have enhanced behaviour that allows them to be
iterated through when plotting different models and/or datasets.
-
linestyle
Can be a list of linestyles that will be iterated through. IfTrue
simple's predefined list of linestyles is used. IfFalse
no lines will be shown. -
color
Can be a list of colors that will be iterated through. IfTrue
simple's predefined list of colors is used. IfFalse
the colour defaults to black.
There are two ways these values can be iterated through. Either all the datapoints of a given model gets the same value or each set of datapoints across the different models gets the same value. By default, if there are multiple models then all the datasets for each model will have the same color. If there is only one model then the color will be different for the different datasets. If there are multiple datasets then each dataset across the different models will have the same linestyle and marker. If there is only one dataset then linestyle and marker will be different for each model.
This behaviour can be changed by passing fixed_model_linestyle
, fixed_model_color
and fixed_model_marker
keyword arguments set to either True
or False
If True
each model will
have the same value. If False
each dataset across the different models will have the same value.
Default kwargs and shortcuts
The default values for arguments can be updated by changing the plot.default_kwargs
dictionary. Any
argument not defined in the function description will be included in kwargs. Default values given in the
function definition will be used only if a default value does not exist in plot.default_kwargs
.
Additionally, one or more shortcuts with additional/different default values are attached to this function.
The following shortcuts exist for this function:
-
plotm.intnorm
Default values to plot internally normalised data. This sets default_attrname tointnorm
and thedefault_unit
toNone
. -
plotm.stdnorm
Default values to plot the basic ratio normalised data. This sets default_attrname tostdnorm
and thedefault_unit
toNone
.
Returns:
-
–
The axes where the data was plotted.
Source code in simple/plotting.py
1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 |
|
simple.set_logging_level
set_logging_level(level)
Set the level of messages to be displayed.
Options are: DEBUG, INFO, WARNING, ERROR.
Source code in simple/utils.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
simple.update_axes
update_axes(ax, kwargs, *, delay=None, update_ax=True, update_fig=True, delay_all=False)
Updates the axes and figure objects.
Keywords beginning with ax_<name>
, xax_<name>
, yax_<name>
and fig_<name>
will be stripped
from kwargs. These will then be used to call the set_<name>
or <name>
method of the axes, axis or
figure object.
If the value mapped to the above arguments is:
- A boolean it is used to determine whether to call the method. The boolean itself will not be passed to
the method. To pass a boolean to a method place it in a tuple, e.g. (True, )
.
- A tuple then the contents of the tuple is unpacked as arguments for the method call.
- A dictionary then the contents of the dictionary is unpacked as keyword arguments for the method call.
- Any other value will be passed as the first argument to the method call.
Additional keyword arguments can be passed to methods by mapping e.g. <ax|xax|yax|fig>_kw_<name>_<keyword>
kwargs to the value. These additional keyword arguments are only used if the
<ax|xax|yax|fig>_<name>
kwargs exists. Note however that they are always stripped from kwargs
.
It is possible to delay calling certain method by adding <ax|xax|yax|fig>_<name>
to *delay
. Keywords
associated with these method will then be included in the returned dictionary. This dictionary can be passed back
to the function at a later time. To delay all calls but remove the relevant kwargs from kwargs use
delay_all=True
.
Returns dict: A dictionary containing the delayed method calls.
Source code in simple/plotting.py
1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 |
|