Closed cosimoNigro closed 5 years ago
Hi,
the astropy table has to be loaded using the Data
Class, and then passed to ObsData:
from jetset.data_loader import ObsData
from astropy.table import Table
from jetset.test_data_helper import test_SEDs
from jetset.data_loader import Data
data_table=Data(data_table=test_SEDs[1])
sed_data=ObsData(data_table=data_table)
You can find all the examples here: https://jetset.readthedocs.io/en/latest/user_guide/load_data/Jet_example_load_data.html
Regarding the table generated in the snippet, you need to give at least the 'data_scale' and the 'restframe' values. You can do this in three different ways
1) adding the metadata to the table text
table_string = """# %ECSV 0.9
# ---
# datatype:
# - {name: x, unit: Hz, datatype: float64}
# - {name: y, unit: erg / (cm2 s), datatype: float64}
# - {name: dy, unit: erg / (cm2 s), datatype: float64}
# meta: !!omap
# - {z: 0.0336 }
# - {restframe: obs}
# - {data_scale: lin-lin}
# schema: astropy-2.0
x y dy
6.204e-05 6.555e-13 1.74e-13
0.000153032 1.4282e-12 4.255e-13
0.00039292 2.052e-12 1.14e-13
0.000355696 2.7004e-12 7.31e-13
0.000947144 4.0304e-12 9.389e-13
0.570768 1.00878e-11 3.7122e-12
0.756888 7.7958e-12 4.392e-12"""
t = Table.read(table_string, format='ascii')
data_table=Data(data_table=t)
sed_data=ObsData(data_table=data_table)
2) adding it to the metadata of the Data object
data_table=Data(data_table=t)
data_table.metadata['data_scale']='lin-lin'
data_table.metadata['restframe']='obs'
sed_data=ObsData(data_table=data_table)
3) passing 'data_scale' and the 'restframe' to the constructor of ObsData
data_table=Data(data_table=t)
sed_data=ObsData(data_table=Data(data_table=t),data_scale='lin-lin',restframe='obs')
Probably all these information are not written clearly in the docs, I will try to improve the docs, or probably to make the data loader smoother. Thanks a lot for the feedback
Thanks for the clarification @andreatramacere. I am sorry, it was my fault, I was looking at the wrong docs http://isdc.unige.ch/~tramacer/jetset_doc/build/user_guide/model_fit/fit_example.html Closing it!
no fault, the feedback is always useful! Can you tell me where was referenced the wrong doc? I have to update the link in case Thanks!
I cannot load a dataset into the
ObsData
object, not even the default datasets injetset.test_data_helper
. Here a snippetgives me the error
looking into the code https://github.com/andreatramacere/jetset/blob/master/jetset/data_loader.py#L223
ObsData
has adata_table
argument in the__init__
than then is checked wheter it is aTable
instance https://github.com/andreatramacere/jetset/blob/master/jetset/data_loader.py#L262But even generating a dummy astropy table
I cannot load it in
ObsData
Any idea on how to solve it and why not even default dataset work?