@@ -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
596639class 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 )
0 commit comments