Magnetometry
Magnetometry
A class which contains magnetometry data for a single sample along with methods for
parsing, processing, and analyzing the data. Note that "single sample" means that
in situations in which a single material is measured in multiple samples, each
sample should be treated as a separate Magnetometry
object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str | Path
|
The path to the directory containing the .dat files for the sample. |
required |
sample_id |
str
|
The sample ID. If not provided, the name of the directory containing the .dat files will be used. |
'auto'
|
magnetic_data_scaling |
str | list[str]
|
Default |
'auto'
|
true_field_correction |
str | Path
|
The path to a file containing the M vs. H data of a Pd standard sample and to
be used for correcting the field of all |
''
|
parse_raw |
bool
|
Default |
False
|
Attributes:
Name | Type | Description |
---|---|---|
sample_id |
str
|
The sample ID. |
files |
list[DatFile]
|
A list of the |
magnetic_data_scaling |
list[str]
|
A record of the scaling options used to scale the magnetic data. Options are
"mass", "molar", "eicosane", and "diamagnetic_correction". Currently supported
combinations are: |
sample_info |
SampleInfo
|
Information specific to the particular sample used for magnetic measurements.
Note that this is determined by reading the first |
mvsh |
list[MvsH]
|
A list of the |
zfc |
list[ZFC]
|
A list of the |
fc |
list[FC]
|
A list of the |
analyses |
list[Analysis]
|
A list of the analyses performed on the data. |
Notes
Scaling of magnetic data occurs during object initialization, unless
magnetic_data_scaling
is set to ''
. If the user needs to overwrite the
automatically scaled values (say, if the sample information from the .dat file
needs to be altered), the user can do so by overwriting the relevant attributes of
the sample_info
attribute (e.g. mass
, molecular_weight
, etc.), then calling
the scale_dc_data
method.
Source code in magnetopy\magnetometry.py
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 676 677 678 |
|
get_mvsh(temperature)
Get the MvsH
object at the specified temperature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temperature |
float
|
Temperature in Kelvin. |
required |
Returns:
Type | Description |
---|---|
MvsH
|
The |
Raises:
Type | Description |
---|---|
self.ExperimentNotFoundError
|
If no |
Source code in magnetopy\magnetometry.py
get_zfc(field)
Get the ZFC
object at the specified field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field |
float
|
Field in Oe. |
required |
Returns:
Type | Description |
---|---|
ZFC
|
The |
Raises:
Type | Description |
---|---|
self.ExperimentNotFoundError
|
If no |
Source code in magnetopy\magnetometry.py
get_fc(field)
Get the FC
object at the specified field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field |
float
|
Field in Oe. |
required |
Returns:
Type | Description |
---|---|
FC
|
The |
Raises:
Type | Description |
---|---|
self.ExperimentNotFoundError
|
If no |
Source code in magnetopy\magnetometry.py
correct_field(field_correction_file)
A convenience method for correcting the field of all MvsH
objects in the
Magnetometry
object using the same field correction file.
See magnetopy.experiments.mvsh.MvsH.correct_field
for more information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_correction_file |
str | Path
|
The path to the field correction file. |
required |
Source code in magnetopy\magnetometry.py
scale_dc_data()
Scales the magnetic moment of all DcExperiment
objects (i.e., MvsH
,
ZFC
, and FC
objects) in the Magnetometry
object according to the scaling
options specified in magnetic_data_scaling
and the sample information in
sample_info
. This is run during object initialization but is available to
the user in the event that either the defaul scaling options or the sample
information need to be changed for proper data scaling.
See magnetopy.experiments.utils.scale_dc_data
for more information.
Source code in magnetopy\magnetometry.py
add_analysis(analysis)
Add an analysis to the Magnetometry
object.
See magnetopy.magnetometry.Analysis
for more information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
analysis |
Analysis | list[Analysis]
|
An instance of a class (or list of such instances) that implements the
|
required |
Source code in magnetopy\magnetometry.py
plot_mvsh(temperatures=None, normalized=False, segment='', colors='auto', labels='auto', title='', **kwargs)
Plot the M vs. H data in the Magnetometry
object. If temperatures
is
None
, all MvsH
objects will be plotted. Otherwise, only the MvsH
objects
at the specified temperatures will be plotted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temperatures |
float | list[float] | None
|
Default |
None
|
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]
|
The figure and axes objects of the plot. |
Source code in magnetopy\magnetometry.py
plot_zfcfc(fields=None, y_val='moment', normalized=False, colors='auto', labels='auto', title='', **kwargs)
Plot the ZFC/FC data in the Magnetometry
object. If fields
is None
,
all ZFC
and FC
objects will be plotted. Otherwise, only the ZFC
and FC
objects at the specified fields will be plotted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fields |
float | list[float] | None
|
Default |
None
|
normalized |
bool
|
If |
False
|
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]
|
The figure and axes objects of the plot. |
Source code in magnetopy\magnetometry.py
create_report(directory=None, overwrite=False)
Create a JSON report of the Magnetometry
object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory |
str | Path | None
|
Default |
None
|
overwrite |
bool
|
Default |
False
|
Source code in magnetopy\magnetometry.py
as_dict()
Create a dictionary representation of the Magnetometry
object.
Returns:
Type | Description |
---|---|
dict[str, Any]
|
|
Source code in magnetopy\magnetometry.py
as_json(indent=0)
Create a JSON representation of the Magnetometry
object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indent |
int
|
Default 0. The number of spaces to indent the JSON. |
0
|
Returns:
Type | Description |
---|---|
str
|
|
Source code in magnetopy\magnetometry.py
extract_mvsh(eps=0.001, min_samples=10, ndigits=0)
Extracts all M vs. H experiments found within files
. This is run
during object initialization but is available to the user in the event that
the default parsing parameters need to be changed for proper data extraction.
See magnetopy.experiments.mvsh.MvsH.get_all_in_file
for more information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eps |
float
|
|
0.001
|
min_samples |
int
|
|
10
|
ndigits |
int
|
|
0
|
Returns:
Type | Description |
---|---|
list[MvsH]
|
The |
Source code in magnetopy\magnetometry.py
extract_zfc(n_digits=0)
Extracts all ZFC experiments found within files
. This is run
during object initialization but is available to the user in the event that
the default parsing parameters need to be changed for proper data extraction.
See magnetopy.experiments.zfcfc.ZFC.get_all_in_file
for more information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_digits |
int
|
|
0
|
Returns:
Type | Description |
---|---|
list[ZFC]
|
The |
Source code in magnetopy\magnetometry.py
extract_fc(n_digits=0)
Extracts all FC experiments found within files
. This is run
during object initialization but is available to the user in the event that
the default parsing parameters need to be changed for proper data extraction.
See magnetopy.experiments.zfcfc.FC.get_all_in_file
for more information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_digits |
int
|
Default 0 |
0
|
Returns:
Type | Description |
---|---|
list[FC]
|
The |
Source code in magnetopy\magnetometry.py
SampleInfo
dataclass
Information specific to the particular sample used for magnetic measurements.
Attributes:
Name | Type | Description |
---|---|---|
material |
str | None
|
The material used for the sample. Possibly a chemical formula. |
comment |
str | None
|
Any comments about the sample. |
mass |
float | None
|
The mass of the sample in milligrams. |
volume |
float | None
|
The volume of the sample in milliliters or cubic centimeters. |
molecular_weight |
float | None
|
The molecular weight of the sample in grams per mole. |
size |
float | None
|
The size of the sample in millimeters. |
shape |
str | None
|
The shape of the sample. |
holder |
str | None
|
The type of sample holder used. Usually "quartz", "straw", or "brass". |
holder_detail |
str | None
|
Any additional details about the sample holder. |
offset |
float | None
|
The vertical offset of the sample holder in millimeters. |
eicosane_mass |
float | None
|
The mass of the eicosane in milligrams. |
diamagnetic_correction |
float | None
|
The diamagnetic correction in emu/mol. |
Source code in magnetopy\magnetometry.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 |
|
from_dat_file(dat_file, eicosane_field_hack=True)
classmethod
Create a SampleInfo object from a .dat file (either a path to the file or a DatFile object). Sample information is extracted from the header of the .dat file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dat_file |
str | Path | DatFile
|
The .dat file to read the sample information from. |
required |
eicosane_field_hack |
bool
|
For abuse of the Quantum Design sample info fields, where the "volume" and "size" fields are used to store the eicosane mass and diamagnetic correction, respectively. The default is True. |
True
|
Returns:
Type | Description |
---|---|
SampleInfo
|
|
Source code in magnetopy\magnetometry.py
as_dict()
Create a dictionary representation of the SampleInfo object.
Returns:
Type | Description |
---|---|
dict[str, foat | str | None]
|
|