#!/usr/bin/env bash

G2() {
    python $GSASII_DIR/GSASIIscriptable.py "$@"
}

homedir=`pwd`
proj_file=${1:-test_cli_create.gpx}
data_file=${2:-aMnO2-air_T_6x10-01004.chi}
refinements_file=${3:-$homedir/9016667.cif}

echo Creating file $proj_file with histogram $data_file

# Create the project file test_cli_create.gpx
# -i = instrument parameters, -d = data file,
# -p = phase, automatically associated with all histograms
G2 create $proj_file \
    -i $homedir/brians_refined_profile.instprm \
    -d $data_file \
    -p $homedir/9016667-with-oxygen.cif

# Check it worked - list phases (-p) and histograms (-g)
echo Listing phases and histograms...
G2 dump -p -d $proj_file

echo Conducting refinements...
G2 refine $proj_file $homedir/alpha-mno2-new.json
echo Done refining

# Export the resulting structure - 0 is for phase #0
# echo Exporting structure
# $G2 export $proj_file 0 test_output.cif
