These are chat archives for astropy/astropy

20th
Jul 2017
hogglab
@hogglab
Jul 20 2017 15:56 UTC
I have a question about plotting lightcurves. I have 18 .fits files that all have spectral data - the ones that are important to me are 'TIME' and 'SAP_FLUX', and i need to plot these. i just don't know how i can plot these parameters for all 18 .fits files into one plot.
Daniel Ruschel Dutra
@danielrd6
Jul 20 2017 17:23 UTC
is TIME and SAP_FLUX the names of the MEF extensions?
hogglab
@hogglab
Jul 20 2017 18:29 UTC
?
i compiled all 18 fits files to make one fits file
that has all of the sap_flux's
but i don't know how to bring up all of them when i make a graph
like i only can refer to [1] or any of those individual
see where ti says on line 17 test[1]
that 1 is from any one of the 18 spectra in that compiled fits
but i can't get them all to be called
Daniel Ruschel Dutra
@danielrd6
Jul 20 2017 18:33 UTC
you can just iterate over the list
hogglab
@hogglab
Jul 20 2017 18:33 UTC
you're saying to make a loop?
i've been trying to, i'm new to python
that's from the kplr website
i was tryign to make a loop like this
but dont' know what i woudl input for the things i circled in blue
Daniel Ruschel Dutra
@danielrd6
Jul 20 2017 18:35 UTC
at line line 16 you could say
for i in test:
indent one level in all lines from 17 - 28
and substitute line 17 with
evt_data = Table(i.data)
hogglab
@hogglab
Jul 20 2017 18:38 UTC
that's it?
Daniel Ruschel Dutra
@danielrd6
Jul 20 2017 18:40 UTC
for i in test:
    evt_data = Table(i.data)
    x = evt_data['TIME']
    y = evt_data['SAP_FLUX']

    plt.plot(x, y)
plt.show()
That's the simplest way I can put it.
actually you have to skip the first element of test, since that is the PrimaryHDU and has no data
for i in test[1:]:
hogglab
@hogglab
Jul 20 2017 18:44 UTC
OH WOW
THIS IS IT
THANK YOU SO MUCH
Daniel Ruschel Dutra
@danielrd6
Jul 20 2017 18:44 UTC
You're welcome :)
here it is. it looks weird so i'm going to have to play with it a bit i guess but
yeah that did the trick of somethign i was trying to do for a while
maybe i should try different types of plots
i also have to divide each lightcrve by its median before plotting
Daniel Ruschel Dutra
@danielrd6
Jul 20 2017 18:54 UTC
dividing by the median is easy
x /= np.median(x)
but that would still look weird. If this is to be same target, you should try to stitch the light curves by equalling the last few points of an observation run with the first few of the subsequent run
hogglab
@hogglab
Jul 20 2017 18:57 UTC
that
is x as in you're using it generally or x as in the x axis on my curve
Daniel Ruschel Dutra
@danielrd6
Jul 20 2017 18:59 UTC
x generally, for you it would be y
hogglab
@hogglab
Jul 20 2017 18:59 UTC
i think the curve would look less disjointed if i made the plots wider and the points smaller
hogglab
@hogglab
Jul 20 2017 20:02 UTC
here is the end result
looks nice
Daniel Ruschel Dutra
@danielrd6
Jul 20 2017 20:24 UTC
great!
Joaquin Bogado
@jwackito
Jul 20 2017 23:13 UTC
hey there... I have a question about best way to map a bunch of frames and a time stamps in a astropy NDData, can someone help me?