---
title: "X-Ray Diffraction JSON-LD"
author: "Weiqi Yue, Pawan K. Tripathi, Roger H. French"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{X-Ray Diffraction JSON-LD}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

## XRD JSON-LD Description

The XRD JSON-LD template is designed based on the patterns collected and the experimental settings. The patterns are captured as images with associated metadata that contain storing information. The experimental settings are typically classified according to beam line characteristics, detector characteristics, and sample attributes, while other metadata are organized into additional categories. A more detailed structure is illustrated in the schema diagram.

## Use R pacakage FAIRmaterials to creating JSON-LD for XRD

```{r, message=FALSE, eval=FALSE}
library(FAIRmaterials)

# Create R data frame for xrd
xrd_data <- data.frame(
  'said' = c('Ce02-lpa', 'CeO2-Atex'),
  'indx"' = c(52, 53),
  'img_stck' = c(12, 15),
  'beamnrgy' = c(69.525, 69.525),
  'wavelngt' = c(0.1783, 0.1783)
)

# This will generate JSON-LD file for the example data in R
output <- fairify_data(xrd_data, domain = 'XRD')
```

## Use Python package fairmaterials to create JSON-LD for XRD

```{r, message=FALSE, eval=FALSE}
from fairmaterials.fairify_data import *
import pandas as pd

# create python data frame for xrd
data = {'said':['Ce02-lpa','Ce02-Atex'],
        'indx':[52,53],
        'img_stck':[12,15],
        'beamnrgy':[69.525, 69.525],
        'wavelngt':[0.1783, 0.1783]
       }


xrd_data = pd.DataFrame(data)

# This will generate JSON-LD file for the example data in Python
fairify_data(xrd_data,'XRD')

```

## XRD schema diagram

```{r, out.width="1600px", echo=FALSE}
knitr::include_graphics("XRD.drawio.png")
```

## Acknowledgment

This material is supported by the Department of Energy (DOE) - National Nuclear Security Administration (NNSA): [DOE-NNSA-B6477887].
