nikhil-sarin / redback

A Bayesian inference software package for end-to-end fitting and interpretation of electromagnetic transients
GNU General Public License v3.0
47 stars 24 forks source link

open catalogue wrong alias. #196

Closed br155bundi closed 7 months ago

br155bundi commented 8 months ago

When attempting to download data from the open transient catalogues, the alias is not recognised, for example 'at2017gfo'

nikhil-sarin commented 8 months ago

Hi @br155bundi - this is not a redback issue but a OACAPI one. You can see that even the examples in the readme there (https://github.com/astrocatalogs/OACAPI) do not work currently.

br155bundi commented 8 months ago

Hi, thank you for your response. I see, that is unfortunate. I do have the open catalogue data file downloaded. Would you recommend that I follow the steps on page: https://redback.readthedocs.io/en/latest/transients.html#loading-private-simulated-data . Or is there a straight forward way to convert this into a transient object? Thank you again.

nikhil-sarin commented 8 months ago

Hi @br155bundi - yep. Also this example is a good reference https://github.com/nikhil-sarin/redback/blob/master/examples/creating_transient_objects.py

Let me know how you go. I'll keep this issue open for now.

br155bundi commented 8 months ago

Brilliant, thank you so much.

br155bundi commented 8 months ago

Hello, apologies for the continued questions. I have been trying to replicate the method outlined in the link that you sent for a kilonova object. I have magnitude and time data from the Open Transient Catalogue GitHub for GW170817. However, I can't seem to work out how to tell the transient function which magnitudes are related to which bands. What format is it looking for the magnitudes and bands to be in? Again, many thanks for your assistance.

nikhil-sarin commented 8 months ago

Hi - have you had a look at this example?

https://github.com/nikhil-sarin/redback/blob/master/examples/kilonova_example.py

Redback magnitudes are calculated in AB. So if you want to fit in magnitudes you will need to switch data_mode in the transient object to 'magnitude' and the output format in the model_kwargs to 'magnitude' as well.

br155bundi commented 8 months ago

Hi, yes i had looked at that. At the moment I can't get kilonova.plot_data() to run. I think it's an issue with the fact that the csv file I have has a column for magnitudes and another for associated bands and I'm unsure how to parse this information into the arguments in the kilonova object.

nikhil-sarin commented 8 months ago

Bands is a separate argument, so you should be able to set up the object as

df = pd.read.csv(your_file.csv) kilonova = redback.transient.Kilonova(..., magnitude=df['magnitude'].values, bands=df['bands'].values)

This example may also be useful

https://github.com/nikhil-sarin/redback/blob/master/examples/supernova_with_unknown_explosion_date.py

br155bundi commented 8 months ago

Ah brilliant. I've managed to get the kilonova.plot_data() to run. However, when I try to run the fit_model() command I get the error that 'uvw2' not in registry. I suppose this filter is not taken into account. Is there a way of ignoring this or moving past it without using that specific filter? Again, your help with this so far has been much appreciated, thank you.

nikhil-sarin commented 8 months ago

No worries. Uvw2 is implemented. Redback uses sncosmo for filter definitions when doing magnitudes and this requires you to use the same naming scheme as sncosmo. There is a utility function in redback here (https://github.com/nikhil-sarin/redback/blob/master/redback/utils.py) - called sncosmo_bandname_from_band that will convert a list of bands to the labelscheme that sncosmo requires.

You can pass your filter list to that function, and it will return a list that you can load the transient object with, or just evaluate the model on that filter definition and keep your list/labels in the transient object. Note that this function is just a dictionary lookup so it might need some labels to be written in a different format. E.g., uvw2 will be returned as sncosmo requires as uvot::uvw2 but passing in uvot:uvW2 or something will not work.

The list of implemented filters is here https://github.com/nikhil-sarin/redback/blob/master/redback/tables/filters.csv but if there is a filter not implemented in redback/sncosmo you can add it using the example I sent in the previous comment.

If you do want to only fit specific filters, the transient object has a keyword argument called active_bands, which is a list you can pass, and then you will only fit the active bands and not every filter.

nikhil-sarin commented 7 months ago

Hi @br155bundi, I'm going to close this issue unless there's anything else.

br155bundi commented 7 months ago

Hello, apologies, I thought I had responded to your last message. I have joined the slack so if it is not too much trouble I may ask a few questions there in the future. Thank you again for you help here.