from cellpy.utils import easyplot

"""
Explanation: Easyplot user guide
Easyplot is a submodule found in the utils of cellpy. It takes a list of filenames and plots these corresponding to the users input configuration. Please follow the example below to learn how to use it.
1: Import cellpy and easyplot
End of explanation
"""


files = [
    # "./data/raw/20160805_test001_45_cc_01.res",
    # "./data/raw/20160805_test001_45_cc_01_copy.res",
    # "./data/20210430_seam10_01_01_cc_01_Channel_48_Wb_1.xlsx.csv",
    # "./data/20210430_seam10_01_02_cc_01_Channel_49_Wb_1.xlsx.csv",
    # "20210630_seam13_03_02_cc_01",
    # "20210630_seam13_03_03_cc_01",
    "20210630_seam13_04_01_cc_01",
    "20210630_seam13_04_02_cc_01",
    # "20210630_seam13_04_03_cc_01",
]

"""
Explanation: 2: Specify a list of datafiles
You can insert different filetypes as long as they are supported by the automatic detection of cellpy. Currently, if you want to use data from an SQL database, you can only plot other data from the same database. In addition you must specify the server credentials. See step below.
If the file you want is in an arbin SQL database, insert the testname.
End of explanation
"""


easyplot.help()

ezplt = easyplot.EasyPlot(
    files,
    None,
    cyclelife_plot=True,
    cyclelife_percentage=False,
    cyclelife_coulombic_efficiency=True,
    cyclelife_coulombic_efficiency_ylabel="Coulombic efficiency [%]",
    cyclelife_xlabel="Cycles",
    cyclelife_ylabel=r"Capacity $\left[\frac{mAh}{g}\right]$",
    cyclelife_ylabel_percent="Capacity retention [%]",
    cyclelife_legend_outside=True,  # if True, the legend is placed outside the plot
    galvanostatic_plot=True,
    galvanostatic_potlim=(0, 1),  # min and max limit on potential-axis
    galvanostatic_caplim=None,
    galvanostatic_xlabel=r"Capacity $\left[\frac{mAh}{g}\right]$",
    galvanostatic_ylabel="Cell potential [V]",
    dqdv_plot=True,
    dqdv_potlim=None,  # min and max limit on potential-axis
    dqdv_dqlim=None,
    dqdv_xlabel="Cell potential [V]",
    dqdv_ylabel=r"dQ/dV $\left[\frac{mAh}{gV}\right]$",
    specific_cycles=None,  # []
    exclude_cycles=[1, 2],
    all_in_one=False,
    # only_dischg = True,
    only_chg=False,
    outpath="./ezplots/deleteme/",
    figsize=(6, 4),  # 6 inches wide, 4 inches tall
    figres=100,  # Dots per inch
    figtitle=None,  # None = original filepath
)

"""
Explanation: 3: Spawn easyplot object with desired settings
All possible settings can be printed by running 
easyplot.help()
End of explanation
"""


ezplt.set_arbin_sql_credentials("localhost", "sa", "Amund1234", "SQL Server")

"""
Explanation: 3a: SQL settings
If you want to use the Arbin SQL database reader, you must insert the necessary details. This is done by the easyplot function set_arbin_sql_credentials
\
easyplot.set_arbin_sql_credentials(&lt;IP Address&gt;, &lt;Username&gt;, &lt;Password&gt;, &lt;SQL driver type&gt;)
End of explanation
"""


ezplt.plot()

"""
Explanation: 4: Run easyplot!
End of explanation
"""


