Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop a way so that a calculated T_verwey in the MPMS_verwey_fit notebook can be added to the MagIC contribution #11

Open
Swanson-Hysell opened this issue Feb 12, 2024 · 9 comments
Assignees

Comments

@Swanson-Hysell
Copy link
Member

It makes sense to have the calculations made in the MPMS_verwey_fit be appended to the MagIC contribution and for an updated contribution to then be made. The notebook can be extended to accomplish this task. Implementing an approach in this regard will be important for calculations in other notebooks such as Curie temperatures and hysteresis parameters.

@Swanson-Hysell Swanson-Hysell self-assigned this Feb 12, 2024
@josh-feinberg
Copy link
Collaborator

I like the idea of appending calculated values to a MagIC contribution. We do much the same thing in the IRM database.

@Swanson-Hysell
Copy link
Member Author

One thing that would be nice to do in addition to putting in the value would be to also append a comment that explains how the value was determined (and could include the temperature bounds + polynomial order).

@josh-feinberg
Copy link
Collaborator

It would be ideal if that could be done in an automated way, rather than requesting the user to add this information.

@Swanson-Hysell
Copy link
Member Author

Indeed. We should be able to do that within the notebook. I am thinking that we can make a "dictionary" data object that provides this info. It is going to be more straightforward to do this for a user that is using the function within a code cell than the ipywidget UI. So I can look to build that out first. After that, we can see how it could be integrated into someone who is using the widget approach (or decide to walk the user through the code cell approach without implementing in the widgets).

@Swanson-Hysell
Copy link
Member Author

Swanson-Hysell commented Feb 17, 2024

A note in terms of working on this is that there are tools available within the contribution_builder.py that makes a Contribution class:
https://github.com/PmagPy/PmagPy/blob/master/pmagpy/contribution_builder.py
this class is a collection of is a collection of MagicDataFrames.

These notebooks introduce associated functionality (which I need to familiarize myself with):

https://github.com/PmagPy/PmagPy/blob/master/data_files/notebooks/Intro%20to%20MagIC%20Contributions.ipynb

https://github.com/PmagPy/PmagPy/blob/master/data_files/notebooks/Intro%20to%20MagicDataFrames.ipynb

We can work with this class instead of importing individual files using Pandas which should give a framework for updating newly calculated values.

So the code:

file = dir_path + '/measurements.txt'
measurements = pd.read_csv(file, sep='\t', skiprows=1)

can be replaced with:

contribution = cb.Contribution(dir_path)
measurements = contribution.tables['measurements'].df

@Swanson-Hysell
Copy link
Member Author

Made a bunch of progress on this issue with ccb77ad
We now record the parameters and Verwey temperature estimates and then update the specimens table within the notebook. Need to do the next step of writing this out to the specimens.txt table and recompiling the MagIC contribution. Makes sense to sort out issue #14 in conjunction with doing so.

@Swanson-Hysell
Copy link
Member Author

As discussed in #14, need to write out to the specific row associated with the experiment for which the Verwey fit was made (i.e. ZFC vs FC).

@Swanson-Hysell
Copy link
Member Author

We are going to take the approach of simply appending a new row to the specimens table with the newly calculated values.

@Swanson-Hysell
Copy link
Member Author

Swanson-Hysell commented Mar 27, 2024

Making good progress here. The contribution.tables['specimens'].add_row() functionality enables rows to be appended to the Contribution object which is probably the right approach.

for n in range(0,len(verwey_estimates_and_params)):

    entry = verwey_estimates_and_params[n]
    
    entry['description'] = 'calculated using MPMS_verwey_fit.ipynb with parameters'
    
    # Specify the keys to append to the description and then remove
    keys_to_include = [
        't_range_background_min',
        't_range_background_max',
        'excluded_t_min',
        'excluded_t_max',
        'poly_deg',
    ]

    # Update the description by appending selected key-value pairs
    for key in keys_to_include:
        entry['description'] += f', {key}: {entry[key]}'

    # Remove the keys that were added to the description
    for key in keys_to_include:
        del entry[key]
     
    df = contribution.tables['specimens'].df
    sample = df.loc[df['specimen'] == entry['specimen'], 'sample'].iloc[0]
    weight = df.loc[df['specimen'] == entry['specimen'], 'weight'].iloc[0]
    entry['sample'] = sample
    entry['weight'] = weight
    
    contribution.tables['specimens'].add_row(entry['specimen'],verwey_estimates_and_params[n])

Now that the contribution object is being written to, I think it likely makes sense to put the code within a function and to then also take the next step of generating an updated MagIC file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants