{ "cells": [ { "cell_type": "markdown", "id": "2fad641c", "metadata": {}, "source": [ "[](https://colab.research.google.com/github/usnistgov/AFL-agent/blob/main/docs/source/tutorials/autosas_tutorial.ipynb)\n", "\n", "# Basic Fitting with AutoSAS\n", "\n", "This tutorial demonstrates how to use AutoSAS to fit small-angle scattering (SAS) data with different models. We'll explore how to:\n", "- Load and prepare SAS data\n", "- Set up an AutoSAS fit for a single model\n", "- Compare and evaluate the fits" ] }, { "cell_type": "markdown", "id": "ced056ca", "metadata": {}, "source": [ "## Google Colab Setup\n", "\n", "Only uncomment and run the next cell if you are running this notebook in Google Colab or if don't already have the AFL-agent package installed." ] }, { "cell_type": "code", "execution_count": null, "id": "5543936a", "metadata": {}, "outputs": [], "source": [ "# !pip install git+https://github.com/usnistgov/AFL-agent.git" ] }, { "cell_type": "markdown", "id": "607446da", "metadata": {}, "source": [ "## Getting Started\n", "\n", "First, let's import the necessary packages and load our example dataset:" ] }, { "cell_type": "code", "execution_count": 5, "id": "0a3a2890", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "from AFL.double_agent import *\n", "from AFL.double_agent.AutoSAS import AutoSAS\n" ] }, { "cell_type": "markdown", "id": "c7496ebc", "metadata": {}, "source": [ "Next, let's load the example dataset. We'll subselect only part of the dataset to work with" ] }, { "cell_type": "code", "execution_count": 6, "id": "6a0749bd", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset> Size: 17kB\n", "Dimensions: (sample: 10, q: 100)\n", "Coordinates:\n", " * q (q) float64 800B 0.001 0.001072 0.00115 ... 0.8697 0.9326 1.0\n", "Dimensions without coordinates: sample\n", "Data variables:\n", " I (sample, q) float64 8kB 5.465e+03 4.598e+03 3.859e+03 ... 1.08 1.03\n", " dI (sample, q) float64 8kB 545.9 429.3 342.6 ... 0.1025 0.1025 0.1025\n", " model (sample) object 80B 'surface_fractal' ... 'surface_fractal'
<xarray.Dataset> Size: 35kB\n", "Dimensions: (sample: 10, q: 100, models: 1,\n", " surface_fractal_params: 3,\n", " fit_q_surface_fractal: 100)\n", "Coordinates:\n", " * q (q) float64 800B 0.001 0.001072 ... 0.9326 1.0\n", " * models (models) <U15 60B 'surface_fractal'\n", " * surface_fractal_params (surface_fractal_params) <U26 312B 'surface_fr...\n", " * fit_q_surface_fractal (fit_q_surface_fractal) float64 800B 0.001 ......\n", "Dimensions without coordinates: sample\n", "Data variables:\n", " I (sample, q) float64 8kB 5.465e+03 ... 1.03\n", " dI (sample, q) float64 8kB 545.9 429.3 ... 0.1025\n", " model (sample) object 80B 'surface_fractal' ... 'sur...\n", " sas_fit_sample (sample) int64 80B 0 1 2 3 4 5 6 7 8 9\n", " fit_all_chisq (sample, models) float64 80B 1.023 ... 1.083\n", " probabilities (sample, models) float64 80B 1.0 1.0 ... 1.0 1.0\n", " surface_fractal_fit_val (surface_fractal_params, sample) float64 240B ...\n", " surface_fractal_fit_err (surface_fractal_params, sample) float64 240B ...\n", " fit_I_surface_fractal (sample, fit_q_surface_fractal) float64 8kB 5....\n", " residuals_surface_fractal (sample, fit_q_surface_fractal) float64 8kB -0...