-
Notifications
You must be signed in to change notification settings - Fork 1
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
Horizons #9
Conversation
modified: src/forcedphot/horizons_interface.py
deleted: src/forcedphot/data/targets.csv modified: src/forcedphot/local_dataclasses.py modified: tests/forcedphot/conftest.py
modified: src/forcedphot/horizons_interface.py modified: tests/forcedphot/test_horizons_interface.py
src/forcedphot/data/
modified: src/forcedphot/horizons_interface.py modified: src/forcedphot/local_dataclasses.py modified: tests/forcedphot/conftest.py deleted: tests/forcedphot/test_example_module.py modified: tests/forcedphot/test_horizons_interface.py
Now, it is ready. I think. |
modified: local_dataclasses.py
@mkelley @akoumjian you're on deck to review this with assist from @jrob93 |
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.
Hey, I've had a look through the PR and played around with the code on my local machine. I think this looks good overall, I just have a few comments for consideration:
query_single_range
- should it also accept Horizons kwargs (e.g.
id_type
,closest apparition
etc) as a dict or similar? For example, the user could passparams_dict
toquery_single_range
and then
params_dict = {"id_type":"smallbody"}
obj = Horizons(
id=query.target,
location=self.observer_location,
epochs={"start": query.start.iso, "stop": query.end.iso, "step": query.step},
**params_dict
)
query_ephemeris_from_csv
- this fails if the "data" directory is not in cwd to save the ecsv files. Should this dir be created automatically or be able to be set by the user?
- the function saves results to ecsv, would it be a good idea to make it more consistent with
query_single_range
by returning aQueryResult
object (or list ofQueryResult
s)? I can see the value of saving results to ecsv for very big queries but maybe make saving to file optional? This may end up taking up a user's storage if the saved results are not cleared out. - At some point perhaps there should be a function to create a
QueryResult
object from an ecsv file.
Hope this is 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.
Looks good. Does this have a specific ticket in Issues that is it addressing?
I would recommend a couple changes first.
- Since this is all part of the Ephemeris Service (more like a module or client), I would put this inside a subpackage
forcedphot.ephemeris
to keep it contained there. - I think if this tool is definitely going to support multiple ephemeris clients, now is the time to write the generic
EphemerisClient
interface, which in turn calls the horizons interface. That should either live insrc/forcedphot/ephemeris/__init__.py
or insrc/forcedphot/ephemeris/client.py
, or something similar. - See my notes on what level we serialize the data to ECSV. In general, I would only pass files around and references to file paths as a last resort when data is getting too big for memory or we need to send a lot of data over an API request and it's easier to reference a URL to a file. Not sure how @talister feels about that.
src/forcedphot/horizons_interface.py
Outdated
output_filename = f"{query.target}_{query.start.iso}_{query.end.iso}.ecsv".replace( | ||
":", "-" | ||
).replace(" ", "_") | ||
|
||
# Save the data to a CSV file | ||
# relevant_data.to_csv("./data/" + output_filename, index=False) | ||
|
||
# Save the data to an ECSV file | ||
result_table = Table.from_pandas(relevant_data) | ||
result_table.write("./data/" + output_filename, format="ascii.ecsv", overwrite=True) |
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 know the requirements are the outputs are provided in ECSV. I think it will be easier and make more sense to hold off on writing a file until we need to communicate directly to the client (e.g. over an https request).
I would suggest horizons client, the skybot client, etc. return the EphemerisData object. Then either A) EphemerisService high-level client produces a file or what I like more is B) the Object Detection Controller formatting outputs to return via the API.
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 changed the file structure. The horizons interface has been added to the ephemeris subpackage.
I will add the EphemerisClient at a later time, after at least the Horizons PR has been implemented.
I added a switch to prevent saving ephemeris data to an ecsv file. Currently, both methods (single target, multiple target) return the QueryResult dataclass that contains the ephemeris data.
…eryResult dataclass now. modified: src/forcedphot/horizons_interface.py
src/forcedphot/ephemeris/ tests/forcedphot/ephemeris/
new file: src/forcedphot/ephemeris/horizons_interface.py new file: src/forcedphot/ephemeris/local_dataclasses.py new file: tests/forcedphot/ephemeris/test_horizons_interface.py
modified: src/forcedphot/ephemeris/__init__.py
modified: src/forcedphot/ephemeris/__init__.py
I added the dataclasses to the local_dataclasses.py file to make it easier to call for other interfaces. I included the default_observer_location option, but if the user wants to, he can change it. I uploaded unit tests for the horizons interface.