New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADAPT Client #7463
base: main
Are you sure you want to change the base?
ADAPT Client #7463
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think that the client works now, though there may be some code linting that could be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @GillySpace27!
I hope it was ok for me to look over this while it was in draft.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did everything except for the test parts, which I'm not experienced with. Please feel free to give this another once-over.
Hi @GillySpace27, sorry for not getting back to you sooner, I will go over this soon but I have two suggestions:
|
def carrington_time(CR=2193, frames=1): | ||
"""Get the start date for the start of a carrington rotation, | ||
and a duration that will retrieve a given number of frames | ||
|
||
Returns: | ||
_type_: _description_ | ||
""" | ||
date = sunpy.coordinates.sun.carrington_rotation_time(CR) | ||
date_end = date + frames*(3*1.9999999 * u.hour) | ||
|
||
# Format the Search Dates | ||
tstring = r"%Y-%m-%dT%H:%M:%S" | ||
get_date =date.strftime(tstring) | ||
get_date_end=date_end.strftime(tstring) | ||
return get_date, get_date_end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This I think should be moved elsewhere, maybe to sunpy.time?
This also overlaps with https://docs.sunpy.org/en/stable/generated/api/sunpy.coordinates.sun.carrington_rotation_time.html
I need input from the others for the best solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is just a super basic wrapper around that carrington_rotation_time function, I'm glad to put it wherever (I suspect using the strftime is probably not necessary either since it is a Quantity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are people better qualified to answer this than me but...
There are some issues with the implementation here but I think we can look past that to a more general view on what it is trying to do:
So I assume you have this here because you think it will be useful to search via Carrington rotation rather than via a Timerange. As this stands I don't see this adding anything other than what exists on the function you have wrapped.
What I mean is that other than working out how much the end time should differ from the start time to get n results, a user can already convert a 2 CR numbers to times and then insert those into the attrs. Indeed if the user wants n results they can just select the first n rows from the query response before calling Fetch. I also don't think it fits with the other clients where we have a unique helper function in a dataretrieverclient file that has to be called independently before calling a query.
Now what would be cool....
If searching by CR is desired then we could add a CarringtonRotation attr and have the can handle function check for either a.Time or a.CR and then, I don't know exactly where, but either in a pre_search_hook on the generic client or via attrwalker add_converter then we could optionally take either a CR number or a a.Time range to carry out an ADAPT search.
Now what form that new attr should take, I don't know. Your current API is start + number of observations but start+end makes a lot more sense rather than having an attr be composed of 2 different typed values. Is there a particular reason for your choices?
This would be much more teachable via an example than I think preconverrting the CR into times manually.
I wouldn't mind that being a separate follow on PR, as it isn't necessary for the client to operate, but I am not super keen on this function as it stands. I will bow down to those with greater knowledge though (and if so then we need to work on the implementation).
Keen to hear others thoughts.
Co-authored-by: Nabil Freij <nabil.freij@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the additional comments! I did everything except the tests, which I will definitely get around to ASAP. Let me know if you see anything else!
|
||
>>> start_datetime, end_datetime = carrington_time(CR, frames) | ||
>>> longitude_type = '0' | ||
>>> res = Fido.search(attrs.Instrument('adapt'), attrs.Time(start_datetime, end_datetime), ADAPTLngType(LngType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> res = Fido.search(attrs.Instrument('adapt'), attrs.Time(start_datetime, end_datetime), ADAPTLngType(LngType)) | |
>>> res = Fido.search(a.Time(start_datetime, end_datetime), a.Instrument('adapt'), a.adapt.ADAPTLngType(longitude_type)) |
PR Description
Adds functionality to download ADAPT maps using FIDO.
This addresses the following issue: #7152
I believe that the core of this code works but I cant get a dev environment running to test things. I believe I'll have to do more work putting the right parts in the right places for sunpy, but I wanted to get this started by uploading what I have.