Skip to content

Commit bb02bb5

Browse files
committed
Fixes astropy#9205
1 parent 1f5b12f commit bb02bb5

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
@@ -598,6 +598,49 @@ def pm_source(self, i):
598598
"""Set PM source flag for entries in IERS table"""
599599
return np.ones_like(i) * FROM_IERS_B
600600

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

602645
class IERS_Auto(IERS_A):
603646
"""
@@ -629,7 +672,7 @@ def open(cls):
629672
630673
"""
631674
if not conf.auto_download:
632-
cls.iers_table = IERS_B.open()
675+
cls.iers_table = IERS_B._create_a_columns(IERS.open())
633676
return cls.iers_table
634677

635678
all_urls = (conf.iers_auto_url, conf.iers_auto_url_mirror)
@@ -661,7 +704,7 @@ def open(cls):
661704
warn(AstropyWarning('failed to download {}, using local IERS-B: {}'
662705
.format(' and '.join(all_urls),
663706
';'.join(err_list)))) # noqa
664-
cls.iers_table = IERS_B.open()
707+
cls.iers_table = IERS_B._create_a_columns(IERS.open())
665708
return cls.iers_table
666709

667710
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)