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
Add possibility to convert time during ascii and csv conversion #76
Conversation
2226a03
to
493a6f9
Compare
Codecov Report
@@ Coverage Diff @@
## master #76 +/- ##
==========================================
+ Coverage 18.84% 19.22% +0.37%
==========================================
Files 53 53
Lines 9466 9510 +44
==========================================
+ Hits 1784 1828 +44
Misses 7682 7682
Continue to review full report at Codecov.
|
Thanks @PierreZ!! 👍 We are going to want to make it more clear in the docstring that these times are for "Solar System Barycenter" (cf. archive manual page 17). This is important because it is common to assume that e.g. an ISO timestamp is Earth-centered, but Kepler gives the time a photon would arrive in the Solar System Barycenter to take Earth's ever-changing position in the Solar System out of the equation. I also wonder if we can add a specific unit-test to verify the conversion, e.g. we could check whether header keywords TSTART and DATE-OBS are equal if converted using the method used here. (I'm being nitpicky because it's so easy to get time systems wrong.) |
You're right to be nitpicky! I'll update the branch with a better docstring and another unit-test, is that ok for you? |
@PierreZ I can't imagine anything that would make me happier =) |
(Also: add yourself to |
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 great to me! Thanks again @PierreZ
pyke/kepconvert.py
Outdated
|
||
* byear_str | ||
|
||
* jyear_str |
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 guess you can remove the blank lines between items.
|
||
for conversion in SUPPORTED_CONVERSION: | ||
|
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.
no need for this blank line here as well
start.format = conversion | ||
|
||
assert start.value == dateobs.value |
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.
nice test :) 👍
Unfortunately, I just left for vacation without my computer 😛 I will remove the blank lines on my return 👍 |
@PierreZ Nah, no worries =) if there is no major concern by @barentsen we can merge this and clean up later :) |
As you wish 👍 |
pyke/kepconvert.py
Outdated
@@ -368,6 +425,9 @@ def kepconvert_main(): | |||
parser.add_argument('infile', help='Name of input file', type=str) | |||
parser.add_argument('conversion', help='Type of data conversion', type=str, | |||
choices=['fits2asc', 'fits2csv', 'asc2fits'], default='fits2asc') | |||
parser.add_argument('timeformat', dest='timeformat', default='', | |||
help="Export time into any subformat handled by astropy.Time", | |||
type=str) |
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.
We're going to want to make this an optional argument (i.e. change timeformat
into --timeformat
).
pyke/kepconvert.py
Outdated
@@ -368,6 +409,9 @@ def kepconvert_main(): | |||
parser.add_argument('infile', help='Name of input file', type=str) | |||
parser.add_argument('conversion', help='Type of data conversion', type=str, | |||
choices=['fits2asc', 'fits2csv', 'asc2fits'], default='fits2asc') | |||
parser.add_argument('--timeformat', dest='timeformat', default='', | |||
help="Export time into any subformat handled by astropy.Time", |
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 suggest adding a few examples to the help string, i.e.: ...any subformat handled by astropy.time (e.g. mjd, iso, decimalyear)
. It should also say default="jd"
.
pyke/kepconvert.py
Outdated
@@ -121,12 +144,30 @@ def kepconvert(infile, conversion, columns, outfile=None, baddata=True, | |||
for colname in tqdm(colnames): | |||
try: | |||
if colname.lower() == 'time': | |||
work.append(table.field(colname) + bjdref) | |||
if len(timeformat) > 0: |
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.
For clarity, let's have timeformat="jd"
as the default in the function definition, and then we can have if timeformat != "jd"
here.
Back from vacation! Thanks @barentsen for the advice, just pushed a commit to apply your changes! |
I guess this should be good to go? :) @barentsen |
Thanks 👍 |
Thank you, @PierreZ =) |
With this fix, column 'TIME' can be converted into any astropy.Time supported subformat such as: