Skip to content

Commit 1cc408e

Browse files
committed
Fixes astropy#9205
1 parent 96562b8 commit 1cc408e

2 files changed

Lines changed: 46 additions & 14 deletions

File tree

‎astropy/utils/iers/iers.py‎

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,49 @@ def pm_source(self, i):
592592
"""Set PM source flag for entries in IERS table"""
593593
return np.ones_like(i) * FROM_IERS_B
594594

595+
@classmethod
596+
def _create_a_columns(cls, table):
597+
"""
598+
Return a new table with appropriate combination of IERS_A and B columns.
599+
"""
600+
# UT1_UTC present in IERS B already
601+
table['UT1_UTC_B'] = table['UT1_UTC'].data
602+
table['UT1_UTC_B'].unit = table['UT1_UTC'].unit
603+
table['UT1Flag'] = 'B'
604+
605+
# Repeat for polar motions.
606+
table['PM_X'] = table['PM_x'].data
607+
table['PM_X'].unit = table['PM_x'].unit
608+
table['PM_Y'] = table['PM_y'].data
609+
table['PM_Y'].unit = table['PM_y'].unit
610+
table['PM_X_B'] = table['PM_x'].data
611+
table['PM_X_B'].unit = table['PM_x'].unit
612+
table['PM_Y_B'] = table['PM_y'].data
613+
table['PM_Y_B'].unit = table['PM_y'].unit
614+
table['PolPMFlag'] = 'B'
615+
616+
# IERS A uses marcsec but IERS B uses arcsec for these
617+
# Convert in case someone does a plain .value
618+
table['dX_2000A_B'] = table['dX_2000A'].to(u.marcsec).data
619+
table['dX_2000A_B'].unit = table['dX_2000A'].to(u.marcsec).unit
620+
621+
table['dY_2000A_B'] = table['dY_2000A'].to(u.marcsec).data
622+
table['dY_2000A_B'].unit = table['dY_2000A'].to(u.marcsec).unit
623+
624+
table['NutFlag'] = 'B'
625+
626+
# No predictions in B
627+
# Get the table index for the first row that has predictive values
628+
# PolPMFlag_A IERS (I) or Prediction (P) flag for
629+
# Bull. A polar motion values
630+
# UT1Flag_A IERS (I) or Prediction (P) flag for
631+
# Bull. A UT1-UTC values
632+
#is_predictive = (table['UT1Flag_A'] == 'P') | (table['PolPMFlag_A'] == 'P')
633+
#table.meta['predictive_index'] = np.min(np.flatnonzero(is_predictive))
634+
#table.meta['predictive_mjd'] = table['MJD'][table.meta['predictive_index']]
635+
636+
return table
637+
595638

596639
class IERS_Auto(IERS_A):
597640
"""
@@ -623,7 +666,7 @@ def open(cls):
623666
624667
"""
625668
if not conf.auto_download:
626-
cls.iers_table = IERS.open()
669+
cls.iers_table = IERS_B._create_a_columns(IERS.open())
627670
return cls.iers_table
628671

629672
all_urls = (conf.iers_auto_url, conf.iers_auto_url_mirror)
@@ -655,7 +698,7 @@ def open(cls):
655698
warn(AstropyWarning('failed to download {}, using local IERS-B: {}'
656699
.format(' and '.join(all_urls),
657700
';'.join(err_list)))) # noqa
658-
cls.iers_table = IERS.open()
701+
cls.iers_table = IERS_B._create_a_columns(IERS.open())
659702
return cls.iers_table
660703

661704
cls.iers_table = cls.read(file=filename)

‎astropy/utils/iers/tests/test_iers_b_into_auto.py‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,8 @@ def test_IERS_B_download_agrees_with_IERS_B_local(keyword, atol):
8686

8787
@pytest.mark.parametrize("b_name,a_name", copy_columns)
8888
def test_IERS_B_parameters_loaded_into_IERS_Auto(b_name, a_name):
89-
B = IERS_B.open(IERS_B_FILE)
90-
B[b_name]
9189
A = IERS_Auto.open()
92-
try:
93-
A[a_name]
94-
except KeyError:
95-
if A["MJD"][-1] < 59100 * u.d:
96-
pytest.xfail(
97-
"Bug #9205 IERS B data is available but not merged into "
98-
"IERS_Auto object unless new IERS A data is available."
99-
)
100-
else:
101-
raise
90+
A[a_name]
10291

10392

10493
copy_columns_atol = [

0 commit comments

Comments
 (0)