I am trying to plot a light curve at a certain interval and set my kernel to read the file starting at a certain header. When I print my x and y values, they match up to the interval I set, but once I plot, it plots the WHOLE dataset as if I never restricted it with a skip_header at all, which is confusing because this is from an older routine I’ve done, and I’ve never had this problem before with any other datasets I’ve used.
This dataset in particular is very large (over 45000 lines), and I’m trying to look at the last 11000 lines or so for a specific period of time, so while I can’t put in all of the data, I can try and put in as many datapoints as possible from where I had wanted to start and some from the end so that there is something to work with. The first column is the time of observation (in MJD), the second column is the flux of the object and the third column is the error of the second column. I had set the skip_header in order to look at an interval of intensely monitored data (hence why there’s a lot of time stamps that are almost identical) from 56955 – 59110:
56955.249057806606 2.225637 2.066504
56955.24917573113 2.906579 0.5933052
56955.24929365566 3.430041 0.6559768
56955.24941158019 1.996177 0.5362438
56955.24952950472 3.055742 0.6702293
56955.24964742924 2.807112 0.6557623
56955.24976535377 2.723114 0.5942342
56955.2498832783 2.579723 0.5768454
56955.25000120283 1.994163 0.5260279
56955.25011912736 2.826056 0.6116026
57151.561321957546 3.461871 0.645721
57151.561439882076 2.933483 0.6083286
57151.561557806606 3.051795 0.619824
57151.56167573113 3.264719 0.6062458
57151.56179365566 4.166972 0.6850498
57151.56191158019 2.823483 0.5983652
57151.56202950472 5.528487 0.814224
57151.56214742924 2.896889 0.5942114
57151.56226535377 4.507289 0.7126694
57151.5623832783 2.866986 0.6138276
57151.56250120283 2.785882 0.5837799
57151.56261912736 3.268119 0.6068772
57151.562737051885 3.121862 0.6151329
57151.562854976415 3.651836 0.6816578
57151.562972900945 3.233772 0.62522
57151.56309082547 3.153281 0.5959166
57151.56320875 2.79295 0.6177107
57151.56332667453 2.815265 0.5630551
57151.56344459906 2.751948 0.6028816
57151.56356252359 3.306673 0.6211404
57151.56368044811 2.220478 0.5261355
57151.56379837264 3.480417 0.6537772
57184.08844459906 3.274329 0.6092318
57184.08856252358 3.057429 0.5896085
57184.08868044811 3.142311 0.5835152
57184.08879837264 3.057604 0.5896422
57184.08891629717 2.623944 0.5483238
57184.089034221695 2.600297 0.5307854
57184.089152146225 3.575541 0.622425
57184.089270070755 2.742214 0.6287372
57184.089387995286 3.081095 0.6054505
57184.08950591981 1.672518 0.462543
57184.08962384434 3.490993 0.6281997
57184.08974176887 2.417206 0.6000872
57184.0898596934 2.322826 0.5333252
57184.08997761793 3.05768 0.5896569
57184.09009554245 2.925466 0.5630085
57184.09021346698 2.803018 0.6075559
57184.09033139151 2.600508 0.5308284
57184.090449316034 2.525404 0.6097533
57184.090567240564 4.44222 0.6937625
57184.090685165094 1.804648 0.4946223
57184.090803089624 2.70888 0.5417781
57184.090921014154 2.106017 0.5108127
57184.09103893868 2.43104 0.5441894
57184.09115686321 3.057709 0.5896624
57184.09127478774 2.167223 0.4846072
57184.09139271226 2.21443 0.5221925
57184.09151063679 4.307299 0.6897239
57184.09162856132 2.430778 0.5182454
57184.09174648585 3.274226 0.6092125
57184.09186441038 2.817077 0.5524765
57184.0919823349 2.732421 0.5589527
57184.09210025943 3.05757 0.5896355
57184.09221818396 2.430948 0.5441689
57184.09233610849 5.309473 0.7585018
57184.092454033016 1.173819 0.5352785
57184.092571957546 2.756094 0.575641
57184.092689882076 2.539575 0.5549115
57184.092807806606 4.249719 0.6905623
…
58966.50577935141 1.754738 0.5373108
58966.5069585967 2.186991 0.5471897
58966.50813784198 1.130976 0.4545428
58966.509317087264 1.651608 0.5551976
58966.51049633254 1.894271 0.5566368
58966.51167557783 2.40661 0.5842662
58971.8819585967 0.6648926 0.3151302
58971.88313784198 1.057266 0.256631
58971.884317087264 1.293281 0.2893841
58971.88549633254 1.056862 0.2645827
58971.88667557783 1.264739 0.2830219
58971.887854823115 1.350237 0.2949098
58971.889034068394 0.9227211 0.2712489
58971.89021331368 0.6526145 0.2191811
58971.89139255896 0.9170059 0.2370399
58971.892571804245 1.618029 0.3175093
58971.89375104953 1.439235 0.3002796
58971.89493029481 0.8620246 0.2895116
58980.55412840802 3.079561 1.034459
58980.5553076533 1.657865 0.5307714
58980.55648689858 2.245098 0.5801354
58980.55766614387 1.904343 0.5831209
58980.558845389154 2.063941 0.5334636
58980.56002463443 2.942607 0.6278495
58980.56120387972 1.073781 0.4315559
58980.562383125 1.800799 0.5762376
58980.563562370284 1.042554 0.4526092
58980.56474161557 1.131361 0.4547821
58980.56592086085 1.348874 0.5069342
58980.567100106135 1.454402 0.5465938
58980.56827935141 2.005936 0.5900149
58980.5694585967 2.31635 0.5623149
58980.57063784198 1.016554 0.7287736
58987.07417557783 0.9628347 0.2946667
58987.075354823115 1.047415 0.2187034
58987.076534068394 0.9119756 0.2041557
58987.07771331368 2.5208 0.8471503
58987.07889255896 1.110273 0.797823
58987.080071804245 1.28724 1.938599
58987.34304350236 1.051434 0.2716978
58987.34422274764 0.9936518 0.2343108
58987.34540199293 0.663515 0.2125841
58987.346581238206 1.487886 0.2866216
58987.34776048349 1.316436 0.2808193
58987.34893972877 1.81836 0.3971744
58987.35011897406 1.254957 0.2619059
58987.35129821934 1.972095 0.6993931
58987.35365670991 1.715693 1.032851
58987.354835955186 2.115329 0.7106273
58987.35601520047 1.017249 0.3114874
58987.35719444575 3.283559 1.424081
58987.35837369104 2.695172 1.278698
58987.35955293632 1.945537 1.171511
59005.950354823115 2.457725 1.163689
59005.951534068394 3.043288 1.143221
59005.95271331368 2.366545 1.026372
59005.95389255896 1.926578 0.9129619
59005.955071804245 2.354125 1.019919
59005.95625104953 2.080575 0.9851156
59005.95743029481 2.521668 1.012959
59005.958609540095 4.456445 1.42578
59005.959788785374 5.528537 1.38302
59005.96096803066 5.901176 1.431893
59005.962147275946 4.452185 1.308231
59005.963326521225 2.271442 0.984378
59005.96450576651 2.593893 0.975126
59005.96568501179 3.112013 1.04498
59005.966864257076 5.040055 1.302375
59005.96804350236 3.548844 1.256438
59006.01639255896 0.1889598 0.0758722
59006.017571804245 0.9539176 0.3377603
59006.01875104953 1.089439 0.4376564
59006.01993029481 1.804744 0.5523254
59006.021109540095 1.722343 0.5792394
59006.022288785374 1.61273 0.541734
59006.02346803066 1.729053 0.5530951
59006.024647275946 2.21328 0.5534554
59006.025826521225 2.235688 0.559241
59006.02700576651 1.940165 0.5700822
59006.02818501179 3.576312 0.715561
59006.029364257076 2.040711 0.5273219
59006.03054350236 1.532922 0.5436429
59006.03172274764 3.197589 0.6529181
59006.03290199293 2.638396 0.6057053
59006.034081238206 2.946389 0.6433144
59006.03526048349 1.908081 0.5840286
59006.083609540095 4.845532 1.627224
59006.084788785374 2.652127 0.6630784
59006.08596803066 1.676968 0.5940136
59006.087147275946 1.806198 0.5780618
59006.088326521225 2.051368 0.628334
59006.08950576651 3.026706 0.6950729
59006.09068501179 1.666243 0.55966
59006.091864257076 1.835313 0.5873797
59006.09304350236 2.168168 0.6643145
59006.09422274764 3.275818 0.7520134
59006.09540199293 2.879874 0.6791745
59006.096581238206 1.117225 0.4843119
59006.09776048349 1.80344 0.6062369
59006.09893972877 5.281922 0.964704
59006.10011897406 1.165037 0.5051103
59006.10129821934 3.953659 0.8433538
59006.10247746462 2.705614 0.7952228
59006.149647275946 3.686483 1.597388
59006.150826521225 2.188352 0.5652736
59006.15200576651 3.377672 0.7048876
59006.15318501179 3.6791 0.7359723
59006.154364257076 2.291994 0.5735082
59006.15554350236 2.601798 0.6510282
59006.15672274764 2.110224 0.5453274
59006.15790199293 3.52231 0.7198028
59006.159081238206 2.170314 0.5606626
59006.16026048349 3.474165 0.7247801
59006.16143972877 3.062065 0.6851414
59006.16261897406 3.136759 0.6691918
59006.16379821934 1.60031 0.5380025
59006.16497746462 2.681267 0.6708045
59006.16615670991 3.37432 0.7041485
59006.167335955186 1.162702 0.4673519
59006.16851520047 1.013747 0.4397691
59006.16969444575 2.966131 1.285436
59006.21804350236 2.024002 1.067142
59006.21922274764 4.568729 1.534547
59006.22040199293 3.165954 1.272088
59006.221581238206 4.237229 1.423462
59006.22276048349 3.005121 1.30295
59006.22393972877 2.382994 1.1304
59006.22511897406 4.457604 1.496137
59006.22629821934 2.668072 1.072038
59006.22747746462 3.044263 1.223039
59006.22865670991 3.355417 1.260333
59006.229835955186 2.591919 1.041112
59006.23101520047 3.592251 1.350341
59006.23219444575 2.005093 1.057362
59006.23337369104 1.934918 1.019356
59006.23455293632 2.846426 1.143272
59006.2357321816 1.159595 0.8324305
59006.23691142689 2.924155 2.098018
59006.28526048349 3.57719 1.201509
59006.28643972877 3.926041 0.7293754
59006.28761897406 2.339945 0.5679554
59006.28879821934 2.507434 0.591222
59006.28997746462 2.732702 0.6114095
59006.29115670991 2.448398 0.5778043
59006.292335955186 3.609849 0.6950849
59006.29351520047 2.486035 0.6034146
59006.29469444575 3.091182 0.644885
59006.29587369104 2.261428 0.5656795
59006.29705293632 1.977666 0.5813087
59006.2982321816 2.803351 0.6271753
59006.29941142689 2.294421 0.5568204
59006.30059067217 2.223968 0.5396812
59006.30176991745 2.714541 0.6071876
59006.30294916274 2.268873 0.5507894
59006.30412840802 2.309407 1.093666
59006.63667557783 2.470434 0.9284391
59006.637854823115 2.327981 0.5822504
59006.639034068394 2.327025 0.6840961
59006.64021331368 2.751391 0.6317564
59006.64139255896 2.131856 0.5509151
59006.642571804245 3.120302 0.6813228
59006.64375104953 2.941339 0.6752878
59006.64493029481 2.230671 0.5580754
59006.646109540095 3.084072 0.7718636
59006.82299633254 0.5579632 0.8380607
59006.82417557783 2.001342 0.4087262
59006.825354823115 2.240355 0.4237761
59006.826534068394 1.695472 0.3702841
59006.82771331368 1.409272 0.3422467
59006.82889255896 3.151832 0.5114559
59006.830071804245 1.729261 0.3776329
59006.83125104953 3.119518 0.9548466
59006.89375104953 2.530131 0.7745616
59006.89493029481 4.21794 0.7578832
59006.896109540095 4.320116 0.7892219
59006.897288785374 4.127552 0.7802157
59006.89846803066 2.374419 0.5601022
59006.899647275946 4.752351 0.8538708
59006.900826521225 3.416019 0.7125719
59006.90200576651 2.133289 0.5516762
59006.96096803066 10.34151 7.416362
59006.962147275946 3.583725 3.332487
59006.963326521225 16.79554 8.84984
59006.96450576651 10.42674 7.477483
59006.96568501179 11.52099 8.262221
59006.966864257076 5.543301 5.154687
59006.96804350236 9.320571 8.653817
59006.96922274764 19.83254 18.45142
59006.971581238206 7.538471 7.006477
59009.31474161557 3.464492 2.085111
59009.31592086085 1.868892 0.9855589
59009.317100106135 2.730272 1.097784
59009.31827935141 2.471687 1.072739
59009.3194585967 1.36249 0.820633
59009.32063784198 2.322338 1.100688
59009.321817087264 2.446578 1.060277
59009.32299633254 3.823443 1.437247
59009.32417557783 2.539448 1.101312
59009.325354823115 3.413683 1.282931
59009.326534068394 4.353062 1.393052
59009.32771331368 5.131232 3.681547
59101.50342086085 2.856692 0.6935412
59101.504600106135 2.71897 0.6600548
59101.50577935141 3.140092 0.6858205
59101.5069585967 2.793892 0.6417556
59101.50813784198 2.48059 0.6205522
59101.509317087264 3.294646 0.7194869
59101.51049633254 3.17599 0.6934885
59101.51167557783 2.491026 0.6233154
59101.512854823115 4.353469 0.8230349
59101.514034068394 1.845499 1.71612
59103.72393972877 2.230527 0.5123628
59103.72511897406 2.556621 0.4388096
59103.72629821934 2.226284 0.4068094
59103.72747746462 2.04568 0.3939903
59103.72865670991 2.001833 0.3854967
59103.729835955186 2.609824 0.441313
59103.73101520047 2.533585 0.4412917
59103.73219444575 2.271652 0.4150048
59103.73337369104 0.8394531 0.5060697
59104.792335955186 3.112703 0.5051742
59104.79351520047 2.446651 0.4398435
59104.79469444575 2.236333 0.4307367
59104.79587369104 2.715993 0.4730386
59104.79705293632 2.681876 0.4674111
59104.7982321816 2.856258 0.476382
59104.79941142689 2.899498 0.4902721
59104.80059067217 2.464417 0.4502209
59104.80176991745 2.338096 0.4420473
59104.80294916274 2.527087 0.4616175
59104.80412840802 2.834575 0.4863211
59104.8053076533 2.739051 0.4771781
59104.80648689858 1.767242 0.5658772
59106.59540199293 2.56547 0.4765565
59106.596581238206 1.898414 0.3878809
59106.59776048349 3.102969 0.4908226
59106.59893972877 2.767867 0.4615829
59106.60011897406 1.946241 0.3896038
59106.60129821934 2.517643 0.4452874
59106.60247746462 2.047855 0.4098381
59110.767571804245 14.23822 8.571443
59110.76875104953 34.5416 32.15226
59110.771109540095 10.49669 5.52988
59110.772288785374 38.72036 23.30975
59110.77346803066 16.28188 7.707895
59110.77700576651 6.871766 4.93134
from astropy.io import fits, ascii
import numpy as np
from astropy.table import Table
import pandas as pd
import scipy as sp
from astropy.time import Time
from astropy.timeseries import LombScargle
from astropy.timeseries import TimeSeries
from celerite import GP
import matplotlib.pyplot as plt
# test run with new files
data = np.genfromtxt('3C273_XRT_mjd.txt', skip_header = 34985)
x = data[:,0]
print(x)
y = data[:,1]
dy = data[:,2]
num = len(x)
print('Number of data points:', num)
print('Start MJD:', x[0])
print('End MJD:', x[num - 1])
# plotting initial light curve for 3c 273
plt.subplots(1,1, figsize=(12,8))
plt.scatter(x, y)
plt.xlabel('Time (MJD)')
plt.ylabel('Flux')
plt.title('3C 273 XRT initial LC')
plt.show()
I had created a new file converting the times originally found from seconds to MJD, thinking maybe the file wasn’t organized in chronological order, but this did nothing to solve the problem. I’ve tried different header starts, and it still shows the exact same starter plot. I have also restarted the kernel and re-ran the script, and it still plotted the same plot as if there was no header indicated. It should be showing a plot from an interval of 56000 – 59000, and instead it is showing the entire plot from 51910 to 59000.
user25022035 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.