def test_carrington_rotation_roundtrip(): t = Time('2010-1-1') crot = sun.carrington_rotation_number(t) t_roundtrip = sun.carrington_rotation_time(crot) dt = t - t_roundtrip # Stated precision in the docstring is 0.11 seconds assert_quantity_allclose(dt.to(u.s), 0 * u.s, atol=0.11 * u.s)
def test_carrington_rotation_starttime(crot, julian_days): # Stated precision in the docstring is 0.11 seconds with warnings.catch_warnings(): # Filter warnings caused by very old dates warnings.filterwarnings("ignore", category=ErfaWarning) assert_quantity_allclose(sun.carrington_rotation_time(crot).tt.jd * u.day, julian_days * u.day, atol=0.11*u.s)
def test_carrington_rotation_starttime(crot, julian_days): # Stated precision in the docstring is 0.11 seconds assert_quantity_allclose(sun.carrington_rotation_time(crot).tt.jd * u.day, julian_days * u.day, atol=0.11 * u.s)
def test_carrington_rotation_str(): # Check that by default a human parseable string is returned t = sun.carrington_rotation_time(2210) assert str(t) == '2018-10-26 20:48:16.137'
def test_carrington_rotation_time_longitude_err(crot, longitude): with pytest.raises(ValueError): sun.carrington_rotation_time(crot * u.one, longitude * u.deg)
def test_carrington_rotation_time_longitude_numpy(crot, longitude, crot_fractional): assert all( sun.carrington_rotation_time(crot * u.one, longitude * u.deg) == sun.carrington_rotation_time(crot_fractional * u.one))
def test_carrington_rotation_time_longitude(crot, longitude, crot_fractional): assert sun.carrington_rotation_time(crot*u.one, longitude*u.deg) == \ sun.carrington_rotation_time(crot_fractional*u.one)
os.chdir(current_dir) # And now plot everything minmax = [-10.,10.] # Full range fig, ax = plt.subplots(constrained_layout=True, figsize=(8,5)) ax.imshow(carr_full_stretched, cmap="gray", vmin=minmax[0], vmax=minmax[1], origin='lower', \ extent=[2092.,2231.,-1,1], aspect='auto') ax.set_xlabel('Carrington rotation') ax.set_ylabel('sin(Latitude)') if plot_sec_axis != 0: from matplotlib.ticker import FuncFormatter ax2 = ax.twiny() formatter_x = FuncFormatter(lambda x, pos: Time(sun.carrington_rotation_time(x), scale='utc', format='isot').value[0:10]) ax2.xaxis.set_major_formatter(formatter_x) ax2.set_xlim(ax.get_xlim()) ax2.set_xlabel('Date') ax2.xaxis.set_tick_params(labelsize=8) ax3 = ax.twinx() formatter_y = FuncFormatter(lambda x, pos: '{:0.2f}'.format((np.arcsin(x)/np.pi)*180.)) ax3.yaxis.set_major_formatter(formatter_y) ax3.set_ylim(ax.get_ylim()) ax3.set_ylabel('Latitude [degrees]') plotfile1 = plotfile1+'_sec_axis' plotfile2 = plotfile2+'_sec_axis' plt.savefig(plotfile1+'.jpg', dpi=200, format='jpg', quality=95)