Skip to content
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

UVFITS rdate question #1433

Open
telegraphic opened this issue May 2, 2024 · 4 comments
Open

UVFITS rdate question #1433

telegraphic opened this issue May 2, 2024 · 4 comments

Comments

@telegraphic
Copy link
Contributor

Hi all, wondering whether this UVFITS code:

        if (self.rdate is None) or (self.rdate == ""):
            rdate_obj = Time(np.floor(self.time_array[0]), format="jd", scale="utc")

Should account for the 0.5 Julian Date fraction offset due to UT1? E.g.

        if (self.rdate is None) or (self.rdate == ""):
            rdate_obj = Time(np.floor(self.time_array[0]) + 0.5, format="jd", scale="utc")
@kartographer
Copy link
Contributor

Hey @telegraphic! The astropy Time object handles (or at least, should handle) the JD "noon offset" under the hood when converting to Gregorian dates. But I did do a quick check to make sure that was the case:

In [1]: from astropy.time import Time

In [2]: Time(2456789.0, format='jd',scale='utc').strftime("%Y-%m-%d")
Out[2]: '2014-05-11'

In [3]: Time(2456789.49, format='jd',scale='utc').strftime("%Y-%m-%d")
Out[3]: '2014-05-11'

In [4]: Time(2456789.5, format='jd',scale='utc').strftime("%Y-%m-%d")
Out[4]: '2014-05-12'

In [5]: Time(2456789.51, format='jd',scale='utc').strftime("%Y-%m-%d")
Out[5]: '2014-05-12'

Looks like it behaves as expected to me! 😄

@telegraphic
Copy link
Contributor Author

@kartographer agreed, but notice there's an errant np.floor in the code:

In [4]: Time(np.floor(2456789.5), format='jd',scale='utc').strftime("%Y-%m-%d")
Out[4]: '2014-05-11'

In [4]: Time(2456789.5, format='jd',scale='utc').strftime("%Y-%m-%d")
Out[4]: '2014-05-12'

In [5]: Time(np.floor(2456789.51), format='jd',scale='utc').strftime("%Y-%m-%d")
Out[5]: '2014-05-11'

In [5]: Time(2456789.51, format='jd',scale='utc').strftime("%Y-%m-%d")
Out[5]: '2014-05-12'

So I think my suggestion is: remove np.floor?

I have now also noticed that DATE-OBS in the AIPS 117 memo is YYYY-MM-DD, and pyuvdata is currently writing the full ISOT:

        hdu.header["DATE-OBS"] = Time(self.time_array[0], scale="utc", format="jd").isot

which I think should be changed to:

        hdu.header["DATE-OBS"] = Time(self.time_array[0], scale="utc", format="jd").strftime("%Y-%m-%d")

I can confirm that MIRIAD is confused when importing UVFITS files, as it uses both DATE-OBS and RDATE

@kartographer
Copy link
Contributor

Ahh, I totally missed the call to np.floor -- yes, that's definitely a bug that should be fixed.

telegraphic pushed a commit to ska-sci-ops/pyuvdata that referenced this issue May 3, 2024
@telegraphic telegraphic mentioned this issue May 3, 2024
11 tasks
@telegraphic
Copy link
Contributor Author

Thanks @kartographer , I wasn't sure if there was a motivation for it, as it seemed rather deliberate! I've issued a PR from my branch. The PR #1436 did introduce a unit test failure with DUT1 now slightly different in one test -- not sure if the new value or golden value is off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants