# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernel_info:
#     name: python3
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pprint as pp

# ## Client Setup

from magic_data_server.client_api import MagicClientAPI
client=MagicClientAPI(port=5001)



# ## Accessing products

p_ids=client.get_paper_ids()


print(p_ids)

catalog=client.get_catalog(paper_id='19e')


pp.pprint(catalog)

targets_dict=client.get_targets(paper_id='19e')
pp.pprint(targets_dict)

files_dict=client.search_by_name('TXS0210+515',paper_id='19e')
pp.pprint(files_dict)

sed_table=client.get_table_data(file_name='magic_19e_sed_fig3_mwl_target01.ecsv',paper_id='19e')

sed_table

sed_table['nufnu'].to('GeV/(cm2 s)')

sed_table_no_fit=client.get_table_data(file_name='magic_19e_sed_fig3_mwl_target01.ecsv',paper_id='19e')

from magic_data_server.plot_tools import DataPlot

# +
# %matplotlib notebook

sed_plot=DataPlot()
sed_plot.add_sed(sed_table)
sed_plot.ax.set_ylim(5E-14,1E-9)
sed_plot.ax.grid()
# -

client.search_by_name('1ES0229+200',paper_id='19e')

lc_table=client.get_table_data(file_name='magic_19e_lc1_fig2_target11.ecsv',paper_id='19e')

lc_table

lc_table['nufnu'].to('GeV/(cm2 s)')

# +
# %matplotlib notebook

lc_plot=DataPlot()
lc_plot.add_lc(lc_table)
lc_plot.ax.grid()

# -

# ## Error communication 

# The cells below show how error communication works.

# +
#missing file error communication

lc_table=client.get_table_data(file_name='magic_19e_lc1_fig2_targetX.ecsv',paper_id='19e')

# +
#worngly formatted file error communication

lc_table=client.get_table_data(file_name='magic_19e_lc1_fig2_target010.ecsv',paper_id='19e')
# -



StarcoderdataJupyterScriptsDedupFiltered