MvsH
MvsH
A single magnetization vs. field (hysteresis) experiment at a single temperature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dat_file |
str, Path, or DatFile
|
The .dat file containing the data for the experiment. |
required |
temperature |
int or float
|
The temperature of the experiment in Kelvin. Requied if the .dat file contains
multiple uncommented experiments at different temperatures. If |
None
|
parse_raw |
bool
|
If |
False
|
**kwargs |
dict
|
Keyword arguments used for algorithmic separation of data at the requested
temperature. See
|
{}
|
Attributes:
Name | Type | Description |
---|---|---|
origin_file |
str
|
The name of the .dat file from which the data was parsed. |
temperature |
float
|
The temperature of the experiment in Kelvin. |
data |
pandas.DataFrame
|
The data from the experiment. Columns are taken directly from the .dat file. |
field_correction_file |
str
|
The name of the .dat file containing the Pd standard sequence used to correct the magnetic field for flux trapping. If no field correction has been applied, this will be an empty string. |
scaling |
list of str
|
The scaling applied to the data. If no scaling has been applied, this will be
an empty list. Possible values are: |
field_range |
tuple of float
|
The minimum and maximum field values in the data. |
Raises:
Type | Description |
---|---|
self.TemperatureNotInDataError
|
If the requested temperature is not in the data or the comments are not formatted correctly and the temperature cannot be automatically detected. |
self.FieldCorrectionError
|
If a field correction is applied but the Pd standard sequence does not have the same number of data points as the MvsH sequence. |
self.SegmentError
|
If the requested segment is not found in the data. |
Source code in magnetopy\experiments\mvsh.py
31 32 33 34 35 36 37 38 39 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 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 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 308 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 349 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 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 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 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
|
simplified_data(segment='')
Returns a simplified version of the data, removing unnecessary columns and renaming the remaining columns to more convenient names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment |
Literal['', 'virgin', 'forward', 'reverse', 'loop']
|
Return the selected segment. By default "", which returns the full data. |
""
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
The simplified data. Contains the columns:
- Where units are not specified, they are determined by the scaling applied to the
data (see |
Source code in magnetopy\experiments\mvsh.py
scale_moment(mass=0, eicosane_mass=0, molecular_weight=0, diamagnetic_correction=0)
Adds the following columns to the DataFrame
in the data
attribute:
"moment"
, "moment_err"
, "chi"
, "chi_err"
, "chi_t"
, and
"chi_t_err"
. A record of what scaling was applied is added to the
scaling
attribute.
See magnetopy.experiments.utils.scale_dc_data
for more information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mass |
float
|
mg of sample, by default 0. |
0
|
eicosane_mass |
float
|
mg of eicosane, by default 0. |
0
|
molecular_weight |
float
|
Molecular weight of the material in g/mol, by default 0. |
0
|
diamagnetic_correction |
float
|
Diamagnetic correction of the material in cm^3/mol, by default 0. |
0
|
Source code in magnetopy\experiments\mvsh.py
correct_field(field_correction_file)
Applies a field correction to the data given data collected on the palladium
standard with the same sequence as the current MvsH
object. Adds a column
called "true_field"
to the DataFrame
in the data
attribute.
See magnetopy.cli.calibration_insall
for information on how to create a
calibration directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_correction_file |
str | Path
|
The name of the .dat file containing the Pd standard sequence, or if a configuration file containing calibration data is present, the name of the sequence in the configuration file. |
required |
Raises:
Type | Description |
---|---|
self.FieldCorrectionError
|
The true field calibration requires that the sequences of both the M vs. H experiment and the calibration experiment be exactly the same. This function only checks that they are the same length, and if they are not, raises this error. |
Notes
As described in the Quantum Design application note[1], the magnetic field reported by the magnetometer is determined by current from the magnet power supply and not by direct measurement. Flux trapping in the magnet can cause the reported field to be different from the actual field. While always present, it is most obvious in hysteresis curves of soft, non-hysteretic materials. In some cases the forward and reverse scans can have negative and postive coercivities, respectively, which is not physically possible.
The true field correction remedies this by using a Pd standard to determine the actual field applied to the sample. Assuming the calibration and sample sequences are the same, it is assumed that the flux trapping is the same for both sequences, and the calculated field from the measurement on the Pd standard is applied to the sample data.
References
[1] Correcting for the Absolute Field Error using the Pd Standard
Source code in magnetopy\experiments\mvsh.py
select_segment(segment)
Returns the requested segment of the data, if it exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment |
Literal['virgin', 'forward', 'reverse', 'loop']
|
The segment of the M vs. H data to return. "loop" refers to the combination of the forward and reverse scans. |
"virgin"
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
The requested segment of the data. |
Raises:
Type | Description |
---|---|
self.SegmentError
|
If the requested segment is not found in the data. |
Source code in magnetopy\experiments\mvsh.py
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 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
|
plot(normalized=False, segment='', color='black', label='auto', title='', **kwargs)
Plots the M vs. H data data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
normalized |
bool
|
If |
False
|
segment |
str
|
If a segment is given, only that segment will be plotted, by default "". |
""
|
color |
str | list[str]
|
The color of the plot, by default "auto". If "auto", the color will be black. |
'black'
|
label |
str | list[str] | None
|
The labels to assign the |
'auto'
|
title |
str
|
The title of the plot, by default "". |
''
|
**kwargs |
Keyword arguments mostly meant to affect the plot style. See
|
{}
|
Returns:
Type | Description |
---|---|
tuple[plt.Figure, plt.Axes]
|
|
Source code in magnetopy\experiments\mvsh.py
plot_raw(segment='forward', scan='up', center='free', colors=('purple', 'orange'), label=True, title='')
Plots the raw voltage data for the requested segment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment |
Literal['virgin', 'forward', 'reverse']
|
The segment of the M vs. H data to plot, by default "forward" |
"virgin"
|
scan |
Literal['up', 'up_raw', 'down', 'down_raw', 'procssed']
|
Which data to plot. |
'up'
|
center |
Literal['free', 'fixed']
|
Only used if |
'free'
|
colors |
tuple[str, str]
|
The (start, end) colors for the color gradient. |
('purple', 'orange')
|
label |
bool
|
Default |
True
|
title |
str
|
The title of the plot. |
''
|
Returns:
Type | Description |
---|---|
tuple[plt.Figure, plt.Axes]
|
|
Source code in magnetopy\experiments\mvsh.py
plot_raw_residual(segment='forward', scan='up', center='free', colors=None, label=True, title='')
Plots the residual of the raw voltage data for the requested segment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment |
Literal['virgin', 'forward', 'reverse']
|
The segment of the M vs. H data to plot, by default "forward" |
"virgin"
|
scan |
Literal['up', 'down']
|
Which data to use in the residual calculation. |
'up'
|
center |
Literal['free', 'fixed']
|
Only used if |
'free'
|
colors |
tuple[str, str]
|
The (start, end) colors for the color gradient. |
None
|
label |
bool
|
Default |
True
|
title |
str
|
The title of the plot. |
''
|
Returns:
Type | Description |
---|---|
tuple[plt.Figure, plt.Axes]
|
|
Source code in magnetopy\experiments\mvsh.py
as_dict()
Returns a dictionary representation of the MvsH
object.
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Keys are: |
Source code in magnetopy\experiments\mvsh.py
get_all_in_file(dat_file, eps=0.001, min_samples=10, ndigits=0, parse_raw=False)
classmethod
Given a .dat file that contains one or more M vs. H experiments, returns a
list of MvsH
objects, one for each experiment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dat_file |
str | Path | DatFile
|
The .dat file containing the data for the experiment. |
required |
eps |
float
|
See |
0.001
|
min_samples |
int
|
See |
10
|
ndigits |
int
|
See |
0
|
parse_raw |
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
list[MvsH]
|
A list of |
Source code in magnetopy\experiments\mvsh.py
TrueFieldCorrection
Bases: MvsH
A special MvsH
class for handling the palladium standard calibration data
used to correct the magnetic field for flux trapping. Unlikely to be used directly
by the user, and instead will be called from the correct_field
method of the
MvsH
class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequence |
str | Path
|
This could be a path to a .dat file containing the Pd standard sequence, or if a configuration file containing calibration data is present, the name of the sequence in the configuration file. |
required |
See Also
magnetopy.cli.calibration_install
Notes
As described in the Quantum Design application note[1], the magnetic field reported by the magnetometer is determined by current from the magnet power supply and not by direct measurement. Flux trapping in the magnet can cause the reported field to be different from the actual field. While always present, it is most obvious in hysteresis curves of soft, non-hysteretic materials. In some cases the forward and reverse scans can have negative and postive coercivities, respectively, which is not physically possible.
The true field correction remedies this by using a Pd standard to determine the actual field applied to the sample. Provided the calibration and sample sequences are the same, it is assumed that the flux trapping is the same for both sequences, and the calculated field from the measurement on the Pd standard is applied to the sample data.
References
[1] Correcting for the Absolute Field Error using the Pd Standard
Source code in magnetopy\experiments\mvsh.py
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 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 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 |
|
plot_mvsh(mvsh, normalized=False, segment='', colors='auto', labels='auto', title='', **kwargs)
Plots either a single M vs. H experiment or several on the same axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mvsh |
MvsH | list[MvsH]
|
The data to plot given as a single or list of |
required |
normalized |
bool
|
If |
False
|
segment |
Literal['', 'virgin', 'forward', 'reverse', 'loop']
|
If a segment is given, only that segment will be plotted, by default "". |
""
|
colors |
str | list[str]
|
A list of colors corresponding to the |
'auto'
|
labels |
str | list[str] | None
|
The labels to assign the |
'auto'
|
title |
str
|
The title of the plot, by default "". |
''
|
**kwargs |
Keyword arguments mostly meant to affect the plot style. See
|
{}
|
Returns:
Type | Description |
---|---|
tuple[plt.Figure, plt.Axes]
|
|
Source code in magnetopy\experiments\mvsh.py
plot_single_mvsh(mvsh, normalized=False, segment='', color='black', label='auto', title='', **kwargs)
Plots a single M vs. H experiment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mvsh |
MvsH
|
The data to plot given as a single |
required |
normalized |
bool
|
If |
False
|
segment |
str
|
If a segment is given, only that segment will be plotted, by default "". |
""
|
color |
str | list[str]
|
The color of the plot, by default "auto". If "auto", the color will be black. |
'black'
|
label |
str | list[str] | None
|
The labels to assign the |
'auto'
|
title |
str
|
The title of the plot, by default "". |
''
|
**kwargs |
Keyword arguments mostly meant to affect the plot style. See
|
{}
|
Returns:
Type | Description |
---|---|
tuple[plt.Figure, plt.Axes]
|
|
Source code in magnetopy\experiments\mvsh.py
plot_multiple_mvsh(mvsh, normalized=False, segment='', colors='auto', labels=None, title='', **kwargs)
Plots several M vs. H experiment on the same axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mvsh |
MvsH | list[MvsH]
|
The data to plot given as a list of |
required |
normalized |
bool
|
If |
False
|
segment |
str
|
If a segment is given, only that segment will be plotted, by default "". |
""
|
colors |
str | list[str]
|
A list of colors corresponding to the |
'auto'
|
labels |
str | list[str] | None
|
The labels to assign the |
None
|
title |
str
|
The title of the plot, by default "". |
''
|
**kwargs |
Keyword arguments mostly meant to affect the plot style. See
|
{}
|
Returns:
Type | Description |
---|---|
tuple[plt.Figure, plt.Axes]
|
|
Source code in magnetopy\experiments\mvsh.py
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 |
|