LM-SAL / aiapy

Python library for AIA data analysis
https://aiapy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

Added a function to obtain the SDO location at a given time - [merged] #183

Closed nabobalis closed 10 months ago

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 07:56

_Merges sdocoord -> master

Added a function to obtain the SDO location at a given time, via a DRMS query.

To do:

nabobalis commented 4 years ago

In GitLab by @markcheung on Apr 14, 2020, 09:50

Thanks @ayshih. Useful function indeed. So since it's WIP, you don't want it to be approved yet?

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 10:53

@markcheung I've marked it as WIP because I think the user experience is currently a bit poor. A significant fraction of possible input times have no directly matching DRMS record, so this function errors out far too often (assuming that the user doesn't somehow already know what times are valid).

I think searching for a range of records around the input time and then interpolating is probably the way to go, but I haven't tried to implement that yet.

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 13:38

added 1 commit

Compare with previous version

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 13:39

Okay, I've now added interpolation. Tests are still missing.

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 14, 2020, 14:43

It's worth noting that we do interpolation of times from DRMS queries in a few other places as well:

where I'm using the word "interpolation" very loosely. These are all slightly different cases, but I wonder if we could settle on a single way to do this rather than implementing it three different ways.

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 14, 2020, 14:44

Commented on aiapy/util/util.py line 14

I'm not a huge fan of this name. Maybe sdo_position or get_sdo_position or get_sdo_coordinate?

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 14, 2020, 14:47

Commented on aiapy/util/util.py line 35

Can we use sunpy.net.jsoc.JSOCClient here instead of drms directly? This is how the DRMS is queried elsewhere in the package.

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 19:18

Commented on aiapy/util/util.py line 14

How about sdo_location() instead?

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 19:25

Commented on aiapy/util/util.py line 35

I just tried rewriting this using sunpy.net.jsoc.JSOCClient, and it works fine when it works. However, the error is not sensible when it can't find a matching record, which makes error-catching awkward:

>>> import astropy.units as u
>>> from sunpy.net import jsoc
>>> from sunpy.net import attrs as a
>>> client = jsoc.JSOCClient()  
>>> keys = client.search_metadata(a.Time(Time('2011-06-07T00:00:00'), Time('2011-06-07T00:00:00')),
...                               a.jsoc.Series('aia.lev1'),
...                               a.jsoc.Keys('T_START, HAEX_OBS, HAEY_OBS, HAEZ_OBS'))
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-9-7889d99dd9f1> in <module>
      5 keys = client.search_metadata(a.Time(Time('2011-06-07T00:00:00'), Time('2011-06-07T00:00:00')),
      6                      a.jsoc.Series('aia.lev1'),
----> 7                      a.jsoc.Keys('T_START, HAEX_OBS, HAEY_OBS, HAEZ_OBS'))  

c:\users\ayshih\onedrive\code\sunpy\sunpy\net\jsoc\jsoc.py in search_metadata(self, *query, **kwargs)
    407             iargs.update({'meta': True})
    408             blocks.append(iargs)
--> 409             res = res.append(self._lookup_records(iargs))
    410 
    411         return res

c:\users\ayshih\onedrive\code\sunpy\sunpy\net\jsoc\jsoc.py in _lookup_records(self, iargs)
    860             key = keywords
    861 
--> 862         r = c.query(ds, key=key, rec_index=isMeta)
    863 
    864         # If the method was called from search_metadata(), return a Pandas Dataframe,

~\anaconda3\lib\site-packages\drms\client.py in query(self, ds, key, seg, link, convert_numeric, skip_conversion, pkeys, rec_index, n)
   1117 
   1118         if rec_index:
-> 1119             index = [it['name'] for it in lres['recinfo']]
   1120             for r in res:
   1121                 r.index = index

KeyError: 'recinfo'

I'd recommend sticking with direct use of drms.

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 19:31

Commented on aiapy/util/util.py line 14

changed this line in version 3 of the diff

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 19:31

added 1 commit

Compare with previous version

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 19:32

Commented on aiapy/util/util.py line 14

I've changed the name to sdo_location() for now.

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 19:33

added 1 commit

Compare with previous version

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 19:34

unmarked as a Work In Progress

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 19:41

added 1 commit

Compare with previous version

nabobalis commented 4 years ago

In GitLab by @ayshih on Apr 14, 2020, 19:43

added 1 commit

Compare with previous version

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 17, 2020, 11:43

Commented on aiapy/util/util.py line 35

Ah that's annoying :disappointed:. drms seems like the logical choice here then.

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 17, 2020, 11:43

Commented on aiapy/util/util.py line 14

Works for me!

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 17, 2020, 11:44

resolved all threads

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 17, 2020, 11:44

marked the checklist item Settle on the name of the function (currently sdo_location()) as completed

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 17, 2020, 11:44

marked the checklist item Resolve whether to switch to using sunpy.net.jsoc.JSOCClient instead of drms as completed

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 17, 2020, 11:45

wow a changelog too. you've raised the stakes now!

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 17, 2020, 11:45

approved this merge request

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 21, 2020, 07:25

mentioned in commit 10918562c3fd3d59f6d45448b4a8df407ad81920

nabobalis commented 4 years ago

In GitLab by @wtbarnes on Apr 21, 2020, 07:25

merged