benmontet / f3

Full Frame Fotometry from the Kepler Full Frame Images
MIT License
20 stars 6 forks source link

demo fails to load kepler json information #5

Open awmann opened 2 years ago

awmann commented 2 years ago

This is from running target.make_postcard() following the demo. I only updated the path, but it never got far enough for the path to matter.

JSONDecodeError                           Traceback (most recent call last)
~/anaconda3/lib/python3.8/site-packages/kplr/api.py in mast_request(self, category, adapter, sort, mission, **params)
    197         try:
--> 198             result = json.loads(txt)
    199         except ValueError:

~/anaconda3/lib/python3.8/json/__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    356             parse_constant is None and object_pairs_hook is None and not kw):
--> 357         return _default_decoder.decode(s)
    358     if cls is None:

~/anaconda3/lib/python3.8/json/decoder.py in decode(self, s, _w)
    336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338         end = _w(s, end).end()

~/anaconda3/lib/python3.8/json/decoder.py in raw_decode(self, s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

APIError                                  Traceback (most recent call last)
<ipython-input-4-92c152c5ca9d> in <module>
----> 1 target.make_postcard()

~/f3/f3/photometry.py in make_postcard(self, npix, shape, buffer_size)
     61         source = self.kic
     62         client = kplr.API()
---> 63         targ = client.target(source)
     64 
     65         channel = [targ.params['Channel_0'], targ.params['Channel_1'], 

~/anaconda3/lib/python3.8/site-packages/kplr/api.py in target(self, kepid, **params)
    334 
    335         """
--> 336         stars = self.targets(kic_kepler_id=kepid, max_records=1, **params)
    337         if not len(stars):
    338             raise ValueError("No KIC target found with id: '{0}'"

~/anaconda3/lib/python3.8/site-packages/kplr/api.py in targets(self, **params)
    351         params["max_records"] = params.pop("max_records", 100)
    352         params["select"] = params.get("select", "*")
--> 353         stars = self.mast_request("kepler_fov", adapter=mast.target_adapter,
    354                                   **params)
    355         return [Target(self, s) for s in stars]

~/anaconda3/lib/python3.8/site-packages/kplr/api.py in mast_request(self, category, adapter, sort, mission, **params)
    199         except ValueError:
    200             full_url = handler.geturl() + "?" + urllib.parse.urlencode(params)
--> 201             raise APIError(code, full_url,
    202                            "No JSON object could be decoded.\n" + txt)
    203 

APIError: The API returned code 200 for URL: 'https://archive.stsci.edu/kepler/kepler_fov/search.php?kic_kepler_id=8462852&max_records=1&select=%2A&action=Search&outputformat=JSON&coordformat=dec&verb=3' with message:
No JSON object could be decoded.

It then prints out all the option value=XXX stuff.

I went to the provided URL, and it does look like a JSON object. So I tried fiddling with my kplr API version and my JSON reader (this is built-in, so no success there). This is Python3.8, but I get the same output with Python3.7 and across computers.

My only guess is that Kepler has changed something minor in the format of their object on that URL. But that's just a guess.

benmontet commented 2 years ago

Oh dear! I think your guess is very likely the correct one, as I can reproduce this over here.

I'm teaching this term so my latency for looking at any code might be higher than you'd like it to be. Are you looking at stars that were also observed in 30-minute cadence? If so we have a catalog of FFI light curves all of those premade and I'm happy to share the data we have for any targets you'd like. If you are looking after fainter targets we don't have those but I'll try to at least sort out a hacky workaround over the next few days!

awmann commented 2 years ago

Long-term it would be nice to recover stars that are lacking Kepler LCs, but that's not at all urgent. This is exploratory. So the premade curves would be more than sufficient for now. At a minimum, we can see how well this will work on a typical target.