Skip to content

Commit 67d50b4

Browse files
committed
start working on figures
1 parent 8b0cf23 commit 67d50b4

File tree

2 files changed

+134
-144
lines changed

2 files changed

+134
-144
lines changed

py/LSLGA/desiutil.py

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
from matplotlib.patches import Ellipse
2222
from astropy.coordinates import SkyCoord, HeliocentricTrueEcliptic, ICRS, Longitude
2323
import astropy.units as u
24-
from astropy.time import Time
25-
from astropy.utils import iers
26-
from .iers import freeze_iers
27-
2824

2925
def plot_slices(x, y, x_lo, x_hi, y_cut, num_slices=5, min_count=100, axis=None,
3026
set_ylim_from_stats=True, scatter=True):
@@ -1003,114 +999,3 @@ def plot_sky_binned(ra, dec, weights=None, data=None, plot_type='grid',
1003999
return ax
10041000

10051001

1006-
def plot_iers(which='auto', num_points=500, save=None):
1007-
"""Plot IERS data from 2015-2025.
1008-
1009-
Plots the UT1-UTC time offset and polar x,y motions over a 10-year
1010-
period that includes the DESI survey, to demonstrate the time ranges
1011-
when different sources (IERS-A, IERS-B) are used and where values
1012-
are predicted then fixed.
1013-
1014-
This function is primarily intended to document and debug the
1015-
:func:`desiutil.iers.freeze_iers` function.
1016-
1017-
Requires that the matplotlib package is installed.
1018-
1019-
Parameters
1020-
----------
1021-
which : {'auto', 'A', 'B', 'frozen'}
1022-
Select which IERS table source to use. The default 'auto' matches
1023-
the internal astropy default. Use 'A' or 'B' to force the source
1024-
to be either the latest IERS-A table (which will be downloaded),
1025-
or the IERS-B table packaged with the current version of astropy.
1026-
The 'frozen' option calls :func:`~desiutil.iers.freeze_iers`.
1027-
num_points : :class:`int`, optional
1028-
The number of times covering 2015-25 to calculate and plot.
1029-
save : :class:`str`, optional
1030-
Name of file where plot should be saved. Format is inferred from
1031-
the extension.
1032-
1033-
Returns
1034-
-------
1035-
:func:`tuple`
1036-
Tuple (figure, axes) returned by ``plt.subplots()``.
1037-
"""
1038-
#
1039-
# These values are copied from the desisurvey config.yaml file.
1040-
# They may or may not reflect the latest configuration.
1041-
#
1042-
# Survey nominally starts on night of this date. Format is YYYY-MM-DD.
1043-
first_day = date(2019, 12, 1)
1044-
# Survey nominally ends on morning of this date. Format is YYYY-MM-DD.
1045-
last_day = date(2024, 11, 30)
1046-
1047-
# Calculate UTC midnight timestamps covering 2015 - 2025
1048-
start = Time('2015-01-01 00:00')
1049-
stop = Time('2025-01-01 00:00')
1050-
mjd = np.linspace(start.mjd, stop.mjd, num_points)
1051-
times = Time(mjd, format='mjd')
1052-
1053-
t_lo = matplotlib.dates.date2num(start.datetime)
1054-
t_hi = matplotlib.dates.date2num(stop.datetime)
1055-
t = np.linspace(t_lo, t_hi, num_points)
1056-
1057-
t_start = matplotlib.dates.date2num(first_day)
1058-
t_stop = matplotlib.dates.date2num(last_day)
1059-
1060-
# Load the specified IERS table.
1061-
if which == 'auto':
1062-
iers = iers.IERS_Auto.open()
1063-
elif which == 'B':
1064-
iers = iers.IERS_B.open()
1065-
elif which == 'A':
1066-
# This requires network access to download the latest file.
1067-
iers = iers.IERS_A.open(iers.conf.iers_auto_url)
1068-
elif which == 'frozen':
1069-
freeze_iers()
1070-
iers = iers.IERS_Auto.open()
1071-
else:
1072-
raise ValueError('Invalid which option.')
1073-
1074-
# Calculate UT1-UTC using the IERS table.
1075-
dt, dt_status = iers.ut1_utc(times, return_status=True)
1076-
dt = dt.to(u.s).value
1077-
1078-
# Calculate polar x,y motion using the IERS table.
1079-
pmx, pmy, pm_status = iers.pm_xy(times, return_status=True)
1080-
pmx = pmx.to(u.arcsec).value
1081-
pmy = pmy.to(u.arcsec).value
1082-
1083-
assert np.all(dt_status == pm_status)
1084-
codes = np.unique(dt_status)
1085-
1086-
fig, ax = plt.subplots(2, 1, sharex=True, figsize=(8, 6))
1087-
1088-
labels = {-2: 'Fixed', 0: 'IERS-B', 1: 'IERS-A', 2: 'Predict'}
1089-
styles = {-2: 'r:', 0: 'b-', 1: 'go', 2: 'r--'}
1090-
ms = 3
1091-
for code in codes:
1092-
sel = dt_status == code
1093-
ax[0].plot(t[sel], dt[sel], styles[code], ms=ms, label=labels[code])
1094-
ax[1].plot(t[sel], pmx[sel], styles[code], ms=ms, label='Polar x')
1095-
ax[1].plot(t[sel], pmy[sel], styles[code], ms=ms, label='Polar y')
1096-
1097-
ax[0].legend(ncol=4)
1098-
ax[0].set_ylabel('UT1 - UTC [s]')
1099-
ax[1].set_ylabel('Polar x,y motion [arcsec]')
1100-
1101-
for i in range(2):
1102-
# Vertical lines showing the survey start / stop dates.
1103-
ax[i].axvline(t_start, ls='--', c='k')
1104-
ax[i].axvline(t_stop, ls='--', c='k')
1105-
1106-
# Use year labels for the horizontal axis.
1107-
xaxis = ax[1].xaxis
1108-
xaxis.set_major_locator(matplotlib.dates.YearLocator())
1109-
xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y'))
1110-
ax[i].set_xlim(start.datetime, stop.datetime)
1111-
1112-
plt.tight_layout()
1113-
if save:
1114-
plt.savefig(save)
1115-
1116-
return fig, ax

science/paper1/figures.ipynb

Lines changed: 134 additions & 29 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)