Open tylerbarna opened 4 years ago
Hey Tyler,
Thanks for your detailed post, it's certainly easier to diagnose things the more information we have, so definitely erring on the side of including too much information rather than too little is the way to go!
Going through these one at a time:
Issue 1: Yes, this is something that we've seen before for users using Windows. As far as I know it only happens with Windows machines, I've never heard of this from someone using something unix-based. I don't understand the architecture differences well enough to be able to give you good insight as to how to fix it, and neither of us have windows machines to test out possible fixes, so unfortunately I don't have a good fix for you. I have two unsatisfying options for you. One of those is to run the code inside some sort of a try/except statement so it handles the bad cases gracefully and automatically re-runs, and the other is to do your data creation inside a Google Colab (or equivalent), and then either do your analysis there or save the output .fits files, transfer them to your local machine and then do your analysis with those. But if you (or anyone else reading this) do find a solution we'd happily accept a pull request that sorts it!
Issue 2: That's a weird one! When you copy that link where it's throwing the error into a web browser and try to go there, you get the same issue (where normally it would download the data). And indeed, changing the sector number to 16 and running the same link works absolutely as expected. So this is something with TESSCut, which we use behind the scenes to get the TESS data in the north. Have you had this issue for multiple days? The TESS folks are in the midst of re-processing much of the data, so it's possible that they're just doing sector 17 right now and so that sector is temporarily unavailable. If this has been going on for a few days, the best approach is to contact the folks at MAST, either through email (archive at stsci dot edu) or twitter (MAST_News), let them know you're having an issue with the TESSCut API, and include that specific mast.stsci.edu/tesscut/.... query that is giving the 400 error.
Issue 3: this is another Windows specific issue. When you run the system with tc=False
(which says don't use TESSCut, use our postcard system to get the data, which at present only works for sectors 1-13) eleanor uses a 'pointing model' behind the scenes to determine what pixels in your aperture the star falls on throughout the sector, and for some reason on Windows machines it doesn't automatically figure out the right file structure for where this pointing model is stored. If you print eleanor.Source().pointing
(as star.pointing or whatever you saved your Source() object as + dot pointing) you should get back a big table of pointing information, and I would guess you will get None. In this case, the fix is just adding in one or two more lines of code. In between your calls to Source() and TargetData(), if you set star.pm_dir
to be properly the directory that the postcard information---including the pointing model---was downloaded into, that will fix this. The variable star.postcard
will include the name of the postcard which you will need to parse to get the right location. Adding that fix will get you on your way (and this should only be an issue when you run with tc=False). This one is the same issue as #171 so hopefully the information in that discussion will help as well.
Good luck! There is a lot of scattered light from the Earth in the North and supernovae tend to be relatively quite faint compared to the stars we normally look at, so happy to talk through more artisanal detrending/systematics removal if you run into issues getting good quality light curves for your targets.
Update: your Issue 2 works fine for me today through the browser, so can you please try that one again inside of eleanor and verify that it now works for you as well?
Hi Ben,
I may try to see if I can do anything to fix issue 1 for Windows and will be sure to submit a pull request if I figure anything out. I'm also going to look into running my notebooks on my University's computing cluster to hopefully alleviate those issues. Thank you for the additional information for issue 3, I'll be sure to try manually setting the directory, and I'll be sure to contact you if I have any issues with the detrending once I have everything running closer to expectations. I hope to find the lightcurves for a number of supernovae in the TESS field -- I imagine at least a few of them will require a fair bit of work to improve their quality.
As for issue 2, I've just run the code again, and I've encountered an interesting new error. When running the following code for the first time since I initially submitted my issue
SN2020jdo = SkyCoord('18 15 43.648 +58 12 54.81',unit=(u.hourangle,u.deg))
source = eleanor.Source(coords=SN2020jdo,sector=17)
I receive this error
No eleanor postcard has been made for your target (yet). Using TessCut instead.
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
<ipython-input-26-6729b95ac64b> in <module>
1 SN2020jdo = SkyCoord('18 15 43.648 +58 12 54.81',unit=(u.hourangle,u.deg))
----> 2 source = eleanor.Source(coords=SN2020jdo,sector=17)
C:\ProgramData\Anaconda3\lib\site-packages\eleanor\source.py in __init__(self, tic, gaia, coords, name, fn, sector, fn_dir, tc, local, post_dir, pm_dir, metadata_path)
247
248 if tc == False:
--> 249 self.locate_postcard(local)
250 if tc == True:
251 self.locate_with_tesscut() # sets sector, camera, chip, postcard,
C:\ProgramData\Anaconda3\lib\site-packages\eleanor\source.py in locate_postcard(self, local)
380 else:
381 print("No eleanor postcard has been made for your target (yet). Using TessCut instead.")
--> 382 self.locate_with_tesscut()
383
384 else:
C:\ProgramData\Anaconda3\lib\site-packages\eleanor\source.py in locate_with_tesscut(self)
421
422 if fn_exists is None:
--> 423 manifest = Tesscut.download_cutouts(coords, self.tesscut_size, sector=self.sector, path=download_dir)
424 cutout = fits.open(manifest['Local Path'][0])
425 self.postcard_path = manifest['Local Path'][0]
C:\ProgramData\Anaconda3\lib\site-packages\astroquery\mast\tesscut.py in download_cutouts(self, coordinates, size, sector, path, inflate, objectname)
230 zipfile_path = "{}tesscut_{}.zip".format(path, time.strftime("%Y%m%d%H%M%S"))
231
--> 232 self._download_file(astrocut_url, zipfile_path)
233
234 localpath_table = Table(names=["Local Path"], dtype=[str])
C:\ProgramData\Anaconda3\lib\site-packages\astroquery\query.py in _download_file(self, url, local_filepath, timeout, auth, continuation, cache, method, head_safe, **kwargs)
278 auth=auth, **kwargs)
279
--> 280 response.raise_for_status()
281 if 'content-length' in response.headers:
282 length = int(response.headers['content-length'])
C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py in raise_for_status(self)
939
940 if http_error_msg:
--> 941 raise HTTPError(http_error_msg, response=self)
942
943 def close(self):
HTTPError: 504 Server Error: Gateway Time-out for url: https://mast.stsci.edu/tesscut/api/v0.1/astrocut?ra=273.9318666666667&dec=58.215225000000004&y=31&x=31&units=px§or=17
However, after running it a second time, no error is returned
No eleanor postcard has been made for your target (yet). Using TessCut instead.
Downloading URL https://mast.stsci.edu/tesscut/api/v0.1/astrocut?ra=273.9318666666667&dec=58.215225000000004&y=31&x=31&units=px§or=17 to C:\Users\Tyler\.eleanor/tesscut\tesscut_20200709152731.zip ... [Done]
Inflating...
<eleanor.source.Source at 0x2b955974e08>
Now, when I try to call eleanor.TargetData with the source object, the following error is returned
data = eleanor.TargetData(source, height=15, width=15, bkg_size=31)
No eleanor postcard has been made for your target (yet). Using TessCut instead.
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-28-4a1f17e1ee66> in <module>
1 SN2020jdo = SkyCoord('18 15 43.648 +58 12 54.81',unit=(u.hourangle,u.deg))
2 source = eleanor.Source(coords=SN2020jdo,sector=17)
----> 3 data = eleanor.TargetData(source, height=15, width=15, bkg_size=31)
C:\ProgramData\Anaconda3\lib\site-packages\eleanor\targetdata.py in __init__(self, source, height, width, save_postcard, do_pca, do_psf, bkg_size, crowded_field, cal_cadences, try_load, regressors, language)
175 self.post_obj = Postcard_tesscut(source.cutout)
176
--> 177 self.ffiindex = self.post_obj.ffiindex
178 self.flux_bkg = self.post_obj.bkg
179 self.get_time(source.coords)
C:\ProgramData\Anaconda3\lib\site-packages\eleanor\postcard.py in ffiindex(self)
349 sector = self.header['SECTOR']
350 eleanorpath = os.path.join(os.path.expanduser('~'), '.eleanor')
--> 351 A = np.loadtxt(eleanorpath + '/metadata/s{0:04d}/cadences_s{0:04d}.txt'.format(sector))
352 return A
353
C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows)
966 fname = os_fspath(fname)
967 if _is_string_like(fname):
--> 968 fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
969 fencoding = getattr(fh, 'encoding', 'latin1')
970 fh = iter(fh)
C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\_datasource.py in open(path, mode, destpath, encoding, newline)
267
268 ds = DataSource(destpath)
--> 269 return ds.open(path, mode, encoding=encoding, newline=newline)
270
271
C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\_datasource.py in open(self, path, mode, encoding, newline)
621 encoding=encoding, newline=newline)
622 else:
--> 623 raise IOError("%s not found." % path)
624
625
OSError: C:\Users\Tyler\.eleanor/metadata/s0017/cadences_s0017.txt not found.
I don't think I've come across an error like this before; I imagine this may have something to do with either TESSCut not retrieving all of the necessary data or MAST not having the .txt file on the server. Were you able to retrieve a lightcurve for this target in sector 17?
Ah okay yes I know this one. I keep meaning to fix that error to make it more transparent but haven't found the time.
The 504 error just means it tried to reach MAST and got no response. Possibly they were down for a minute, that happens very intermittently.
The re-run (cadences_s0017.txt not found) error happens when the metadata that eleanor uses for the detrending doesn't get properly downloaded. It created the right directory (~/.eleanor/metadata/s0017) but didn't get all the right files in there. Double check that directory compared to ../s0016, I expect they have a different number of files. If so, delete the entire s0017 directory and re-run, and it will download all the files you need (hopefully!) and then you'll be in business.
Hi Ben, sorry for missing your response, but clearing the directory and rerunning it seemed to fix the issue. I've still been trying to recreate the results from Vallely et al. (2019) (specifically figures 3 and 4), but I'm still having some trouble with replicating the results even after fixing the previous issues. I'm not sure that this is an issue with eleanor, but I was wondering if you would be able to shed any light on the situation. The trouble I'm having lies with the actual lightcurves being generated; to put it briefly, the authors of the paper average the lightcurves of two nearby stars that they subtract from the lightcurve of the supernova ASASSN-18tb. Their results seem to indicate that the averaged star lightcurves are approximately one half the magnitude of the supernova, but I've found that the averaged flux of the two stars to be roughly six times the magnitude of the flux of ASASSN-18tb when I use eleanor.
While I realize I plot flux whereas they plot electron counts, this result is still unexpected (I also made the unfortunate choice to reverse the color scheme for my plot; apologies for that). Because of this, I questioned whether I was identifying the correct targets for the stars and/or the supernova. For the supernova, I've been using its coordinates in eleanor.Source(), but for the two stars, I've been using the Gaia DR2 IDs as listed in the paper. Would this have any effect on source identification or aperture choice? Additionally, I've made most of my plots by using data.to_lightkurve() and I wasn't sure if that function used the raw flux or the corrected flux -- that could also be a potential reason for the issue.
There was one other thing I wanted to ask about in regards to how eleanor handles the postcards and the FFIs. It seems I'm getting an interesting disparity when using vis.plot_gaia_overlay() and vis.pixel_by_pixel() for ASASSN-18tb. if I run the following:
source = eleanor.Source(tic=10000583619, sector=1)
data = eleanor.TargetData(source,height=23,width=23,
do_psf=False,do_pca=False)
vis = eleanor.Visualize(data)
fig_cont = vis.aperture_contour()
fig_gaia = vis.plot_gaia_overlay(tic=10000583619, magnitude_limit=19)
fig_pix = vis.pixel_by_pixel(data_type='raw')
the following plots are returned:
I was wondering if there was a reason why vis.plot_gaia_overlay() and vis.pixel_by_pixel() seem to be flipped upside-down when compared to one another and if this could possibly have anything to do with my issues with finding lightcurves consistent with Vallely et al. (2019). I ask because Figure 4 from that paper seems to match the orientation of vis.plot_gaia_overlay() rather than vis.pixel_by_pixel() (although the color scheme and magnitude limit may differ)
I appreciate any insight you may be able to offer, and thank you again for the help with the earlier issues.
Hi Tyler,
1) The different flux levels could mean a few different things. The most likely case I think is that you're using a different aperture than they are, and there's significantly more light from the star in your aperture than the others, either because you have much more of the PSF, you also have a background star in the same aperture, or some combination of those two. I'd check closely for differences in the apertures before doing anything else.
2) It shouldn't matter what you pass in as a Gaia ID or a TIC or coordinates---the first thing the code does is given what you've provided works out what the other ones should be, and then everything happens identically. As long as the TIC coordinates match up with the Gaia DR2 coordinates, they would be identical afterwards.
3) Lightkurve should take in the corr_flux I believe, although I also believe there's a way to force it to take something different. corr_flux is designed for transit searches so it by design removes long-term trends in the data, so it should be expected to flatten a supernova curve. Better to use the raw_flux. As you note, there's some background in the raw flux. You can get rid of most of it by hand using flux_bkg, or by passing in information from nearby pixels using the regressors
tool in corrected_flux or similarly the lightkurve RegressionCorrector class. I did it by hand and got most of the way there with the following:
star=eleanor.Source(tic=10000583619, sector=1)
data = eleanor.TargetData(star, height=17, width=17, do_pca=True, do_psf=False)
q = data.quality == 0
plt.plot(data.time[q], data.raw_flux[q]+0.20*data.flux_bkg[q], '.')
4) Unfortunately the two tools to give the detector in different orientations! Both know the correct WCS so if you're giving the proper coordinates or Gaia DR2 IDs of the targets you're trying to use as calibrators you should get the right light curve. But if you're trying to identify coordinates by hand-drawing apertures you should be cognizant of how columns and rows are defined on each to make sure you're getting the right pixels.
Hope that helps!
Thank you, this was very helpful! It does seem that the issue may have been with the aperture -- I think one of the problems was that I hadn't set an aperture that was consistent between the objects as they had. Setting them to a consistent circular aperture seemed to help, especially with the two reference stars. The plot you provided is much closer to what I was expecting for the supernova, I'll be sure to try out the regression correction. Again, thank you for the advice; I realize eleanor isn't really intended for this application, so I appreciate the help!
I'm currently investigating the viability of using eleanor to identify Type Ia supernova lightcurves at or around their peak luminosity as part of a senior thesis, and I've recently encountered a few issues that I wanted to seek some clarification on. (Note: The issues I've encountered are generally similar to those mentioned in issue #171 . However, there are a few ways in which the issues I'm running into differ and I've compiled a bit more information about potential causes of these issues)
For context, I'm running the latest development version of eleanor on python 3.7.6 with a jupyter notebook. I'm using a Windows 10 machine (Version 1909) with an Intel 9700K, 32GB of RAM, and an NVME SSD.
Issue 1
I'll start off with the issue I suspect may be more specific to my machine and/or Windows. When I first installed eleanor, I was having trouble with eleanor.Source() encountering an error when first being run for a new target.
When I run
from the quickstart tutorial, I receive the following error:
When using eleanor.Source(), this issue almost always resolved itself upon being run a second time. Through some experimentation I have found that, when using eleanor.multi_sectors() to observe an object present in n sectors, it seems the code will only successfully execute after being run n+1 times. I also found that I am able to replicate the issue by clearing the cached files in the ./eleanor/ folder. From what I can tell, it seems there's an issue with eleanor.Source() where it attempts to read or modify the cached fits file before it's been entirely written to the disk. I've mostly been able to work around this by running the code multiple times, but I figured it was worth mentioning.
Issue 2
This issue is fairly specific, and I'm not entirely sure if it's an issue with eleanor, MAST, or something else. When I run the following code
I receive this error
Of all the targets I've been working with, this is the only one that returns that error, and retrieving this source for other sectors works fine if the files are cached. This also occurs when using eleanor.multi_sectors() to retrieve data from all the sectors the target is present in,
Issue 3
Finally, this is probably the most vexing problem I've encountered. When I first ran the quickstart tutorial, the results were as expected, with the correct lightcurve being generated with the correct aperture. From there, I attempted to replicate the lightcurves in Figure 3 of Vallely et al. (2019). When I use eleanor to find a lightcurve for ASASSN-18tb, I get the following result
While Figure 3 in Vallely et al. is measuring electron counts, the above plot is still not consistent with their results. Investigating this further, I plotted the TPF and aperture.
I found this aperture to be very odd, as I had thought the TPF was centered on the target itself. Additionally, when attempting to find the two reference stars used to subtract the background light from the supernova in Vallely et. al, I found that the two stars had essentially the same flux as the supernova when they should have roughly half the magnitude.
Upon checking their apertures, I found two familiar apertures
I'm unsure why these three objects are behaving this way; the TESS magnitudes found by eleanor are fairly close to the ones reported in the paper, so I believe eleanor is correctly identifying the targets, but otherwise the results don't match up at all despite the authors stating they found their process found the same results as the ones found by eleanor. This issue persists even after restarting the kernel, restarting jupyter, or restarting the system, and clearing the cache also has no effect.
My apologies for the lengthy post, I thought that these issues were connected somewhat and I wanted to provide as much information as possible. Thank you