Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ systems availalbe from the atmosphere model.
When using the `RBFInterpolator`, we strongly encourage the use of scipy 1.9+
which provides a speed gain of O(100) times.

v0.0.12 or below only supports numpy v1.
Supports NumPy v1 and v2 (>=1.23,<3). For best performance with RBFInterpolator, use SciPy 1.9+.

## Documentation

Expand Down
43 changes: 17 additions & 26 deletions example/compare_ps_cooling_rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,46 +63,39 @@
# format the data into matplotlib.tricontour readable format
_x.append(BP(logg_i, Mbol) - RP(logg_i, Mbol))
_y.append(G(logg_i, Mbol))
_z1.append(wdlf.cooling_rate_interpolator(logL, m_valid))
_z2.append(wdlf_nps.cooling_rate_interpolator(logL, m_valid))
_z1.append(-wdlf.cooling_rate_interpolator(logL, m_valid))
_z2.append(-wdlf_nps.cooling_rate_interpolator(logL, m_valid))

x = np.concatenate(_x)
y = np.concatenate(_y)
z1 = np.log10(np.concatenate(_z1))
z2 = np.log10(np.concatenate(_z2))

# masking the non-finite values
mask1 = np.isfinite(z1)
mask2 = np.isfinite(z2)
# masking the non-finite values across x, y, and z
mask1 = np.isfinite(x) & np.isfinite(y) & np.isfinite(z1)
mask2 = np.isfinite(x) & np.isfinite(y) & np.isfinite(z2)
mask12 = mask1 & mask2
CMAP = "RdBu_r"
LEVELS = 50

# make the contour lines
ax1.tricontour(
x[mask1], y[mask1], z1[mask1], levels=LEVELS, linewidths=0.5, colors="k"
)
ax2.tricontour(
x[mask2], y[mask2], z1[mask2], levels=LEVELS, linewidths=0.5, colors="k"
)
ax1.tricontour(x[mask1], y[mask1], z1[mask1], levels=LEVELS, linewidths=0.5, colors="k")
ax2.tricontour(x[mask2], y[mask2], z2[mask2], levels=LEVELS, linewidths=0.5, colors="k")
ax3.tricontour(
x[mask1 & mask2],
y[mask1 & mask2],
(z1 / z2)[mask1 & mask2],
x[mask12],
y[mask12],
(z1 / z2)[mask12],
levels=LEVELS,
linewidths=0.5,
colors="k",
)
# make the contour shades
contour1 = ax1.tricontourf(
x[mask1], y[mask1], z1[mask1], levels=LEVELS, cmap=CMAP
)
contour2 = ax2.tricontourf(
x[mask2], y[mask2], z2[mask2], levels=LEVELS, cmap=CMAP
)
contour1 = ax1.tricontourf(x[mask1], y[mask1], z1[mask1], levels=LEVELS, cmap=CMAP)
contour2 = ax2.tricontourf(x[mask2], y[mask2], z2[mask2], levels=LEVELS, cmap=CMAP)
contour3 = ax3.tricontourf(
x[mask1 & mask2],
y[mask1 & mask2],
(z1 / z2)[mask1 & mask2],
x[mask12],
y[mask12],
(z1 / z2)[mask12],
levels=LEVELS,
cmap=CMAP,
)
Expand All @@ -127,6 +120,4 @@

plt.suptitle("log(dL/dt) contour plot")
plt.subplots_adjust(wspace=0.0, left=0.075, right=0.975)
plt.savefig(
os.path.join(HERE, "example_output", "compare_ps_cooling_rates.png")
)
plt.savefig(os.path.join(HERE, "example_output", "compare_ps_cooling_rates.png"))
108 changes: 27 additions & 81 deletions example/converting_from_gaia_to_sdss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
except NameError:
HERE = os.path.dirname(os.path.realpath(__name__))

_hdu = fits.open(os.path.join(HERE, "GaiaEDR3_WD_SDSSspec.FITS"))[1]
_hdu = fits.open(os.path.join(HERE, "GaiaEDR3_WD_SDSSspec.fits"))[1]
data = _hdu.data
size = len(data)

Expand Down Expand Up @@ -51,38 +51,20 @@
r_itp_teff = atm.interp_am(dependent="r_sdss", independent=["G3", "Teff"])

# Getting the interpolation function depending on G3_BP and Teff
u_itp_bp_teff = atm.interp_am(
dependent="u_sdss", independent=["G3_BP", "Teff"]
)
g_itp_bp_teff = atm.interp_am(
dependent="g_sdss", independent=["G3_BP", "Teff"]
)
r_itp_bp_teff = atm.interp_am(
dependent="r_sdss", independent=["G3_BP", "Teff"]
)
u_itp_bp_teff = atm.interp_am(dependent="u_sdss", independent=["G3_BP", "Teff"])
g_itp_bp_teff = atm.interp_am(dependent="g_sdss", independent=["G3_BP", "Teff"])
r_itp_bp_teff = atm.interp_am(dependent="r_sdss", independent=["G3_BP", "Teff"])

# Getting the interpolation function depending on G3_RP and Teff
u_itp_rp_teff = atm.interp_am(
dependent="u_sdss", independent=["G3_RP", "Teff"]
)
g_itp_rp_teff = atm.interp_am(
dependent="g_sdss", independent=["G3_RP", "Teff"]
)
r_itp_rp_teff = atm.interp_am(
dependent="r_sdss", independent=["G3_RP", "Teff"]
)
u_itp_rp_teff = atm.interp_am(dependent="u_sdss", independent=["G3_RP", "Teff"])
g_itp_rp_teff = atm.interp_am(dependent="g_sdss", independent=["G3_RP", "Teff"])
r_itp_rp_teff = atm.interp_am(dependent="r_sdss", independent=["G3_RP", "Teff"])


# Getting the interpolation function depending on G3_RP and Teff
u_itp_logg_teff = atm.interp_am(
dependent="u_sdss", independent=["logg", "Teff"]
)
g_itp_logg_teff = atm.interp_am(
dependent="g_sdss", independent=["logg", "Teff"]
)
r_itp_logg_teff = atm.interp_am(
dependent="r_sdss", independent=["logg", "Teff"]
)
u_itp_logg_teff = atm.interp_am(dependent="u_sdss", independent=["logg", "Teff"])
g_itp_logg_teff = atm.interp_am(dependent="g_sdss", independent=["logg", "Teff"])
r_itp_logg_teff = atm.interp_am(dependent="r_sdss", independent=["logg", "Teff"])


# converting into SDSS photometry
Expand Down Expand Up @@ -117,9 +99,7 @@
# Plot the (u-g) vs (g-r) colour-colour diagram
# Top row is based on interpolation of (logg, Gaia filter)
# Bottom row is based on interpolation of (Teff, Gaia filter)
fig, ((ax1, ax2, ax3), (ax4, ax5, ax6)) = plt.subplots(
2, 3, sharex=True, figsize=(15, 15)
)
fig, ((ax1, ax2, ax3), (ax4, ax5, ax6)) = plt.subplots(2, 3, sharex=True, figsize=(15, 15))
ax1.scatter(u_sdss - g_sdss, g_sdss - r_sdss, s=1, c=loggH)
ax2.scatter(u_sdss_bp - g_sdss_bp, g_sdss_bp - r_sdss_bp, s=1, c=loggH)
ax3.scatter(u_sdss_rp - g_sdss_rp, g_sdss_rp - r_sdss_rp, s=1, c=loggH)
Expand Down Expand Up @@ -176,12 +156,8 @@
ax3.set_title(r"$\{G3_{\mathrm{RP}}, \log(g)\} \rightarrow \{u, g, r\}$")

ax4.set_title(r"$\{G3, T_{\mathrm{eff}}\} \rightarrow \{u, g, r\}$")
ax5.set_title(
r"$\{G3_{\mathrm{BP}}, T_{\mathrm{eff}}\} \rightarrow \{u, g, r\}$"
)
ax6.set_title(
r"$\{G3_{\mathrm{RP}}, T_{\mathrm{eff}}\} \rightarrow \{u, g, r\}$"
)
ax5.set_title(r"$\{G3_{\mathrm{BP}}, T_{\mathrm{eff}}\} \rightarrow \{u, g, r\}$")
ax6.set_title(r"$\{G3_{\mathrm{RP}}, T_{\mathrm{eff}}\} \rightarrow \{u, g, r\}$")

ax1.grid()
ax2.grid()
Expand All @@ -190,21 +166,15 @@
ax5.grid()
ax6.grid()

plt.subplots_adjust(
top=0.95, bottom=0.075, left=0.08, right=0.975, wspace=0.0, hspace=0.1
)
plt.subplots_adjust(top=0.95, bottom=0.075, left=0.08, right=0.975, wspace=0.0, hspace=0.1)

plt.savefig(
os.path.join(HERE, "example_output", "gaia_to_sdss_cc_diagram.png")
)
plt.savefig(os.path.join(HERE, "example_output", "gaia_to_sdss_cc_diagram.png"))

# Plot the residual of the catalogue value to converted values
# Top row is the residual in u from the interpolation of G_BP, G & G_RP
# Middle row is the residual in g from the interpolation of G_BP, G & G_RP
# Bottom row is the residual in r from the interpolation of G_BP, G & G_RP
fig, ((ax1, ax2, ax3), (ax4, ax5, ax6), (ax7, ax8, ax9)) = plt.subplots(
3, 3, sharex=True, figsize=(15, 15)
)
fig, ((ax1, ax2, ax3), (ax4, ax5, ax6), (ax7, ax8, ax9)) = plt.subplots(3, 3, sharex=True, figsize=(15, 15))

ax1.scatter(TeffH, data["umag"] - u_sdss_bp_teff, s=1)
ax2.scatter(TeffH, data["umag"] - u_sdss_teff, s=1)
Expand All @@ -218,29 +188,17 @@
ax8.scatter(TeffH, data["rmag"] - r_sdss_teff, s=1)
ax9.scatter(TeffH, data["rmag"] - r_sdss_rp_teff, s=1)

ax1.set_title(
r"$u_{\mathrm{catalogue}} - u(T_{\mathrm{eff}}, G_{\mathrm{BP}})$"
)
ax1.set_title(r"$u_{\mathrm{catalogue}} - u(T_{\mathrm{eff}}, G_{\mathrm{BP}})$")
ax2.set_title(r"$u_{\mathrm{catalogue}} - u(T_{\mathrm{eff}}, G)$")
ax3.set_title(
r"$u_{\mathrm{catalogue}} - u(T_{\mathrm{eff}}, G_{\mathrm{RP}})$"
)
ax3.set_title(r"$u_{\mathrm{catalogue}} - u(T_{\mathrm{eff}}, G_{\mathrm{RP}})$")

ax4.set_title(
r"$g_{\mathrm{catalogue}} - g(T_{\mathrm{eff}}, G_{\mathrm{BP}})$"
)
ax4.set_title(r"$g_{\mathrm{catalogue}} - g(T_{\mathrm{eff}}, G_{\mathrm{BP}})$")
ax5.set_title(r"$g_{\mathrm{catalogue}} - g(T_{\mathrm{eff}}, G)$")
ax6.set_title(
r"$g_{\mathrm{catalogue}} - g(T_{\mathrm{eff}}, G_{\mathrm{RP}})$"
)
ax6.set_title(r"$g_{\mathrm{catalogue}} - g(T_{\mathrm{eff}}, G_{\mathrm{RP}})$")

ax7.set_title(
r"$r_{\mathrm{catalogue}} - r(T_{\mathrm{eff}}, G_{\mathrm{BP}})$"
)
ax7.set_title(r"$r_{\mathrm{catalogue}} - r(T_{\mathrm{eff}}, G_{\mathrm{BP}})$")
ax8.set_title(r"$r_{\mathrm{catalogue}} - r(T_{\mathrm{eff}}, G)$")
ax9.set_title(
r"$r_{\mathrm{catalogue}} - r(T_{\mathrm{eff}}, G_{\mathrm{RP}})$"
)
ax9.set_title(r"$r_{\mathrm{catalogue}} - r(T_{\mathrm{eff}}, G_{\mathrm{RP}})$")

ax2.set_yticklabels([""])
ax3.set_yticklabels([""])
Expand Down Expand Up @@ -280,19 +238,13 @@

ax1.set_xscale("log")

plt.subplots_adjust(
top=0.95, bottom=0.07, left=0.08, right=0.975, wspace=0.0, hspace=0.15
)
plt.subplots_adjust(top=0.95, bottom=0.07, left=0.08, right=0.975, wspace=0.0, hspace=0.15)

plt.savefig(
os.path.join(HERE, "example_output", "gaia_to_sdss_ugr_residual.png")
)
plt.savefig(os.path.join(HERE, "example_output", "gaia_to_sdss_ugr_residual.png"))


# Plot the residual of the catalogue value to derived values from (logg, Teff)
fig, (ax1, ax2, ax3) = plt.subplots(
1, 3, sharex=True, sharey=True, figsize=(15, 10)
)
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, sharex=True, sharey=True, figsize=(15, 10))

ax1.scatter(TeffH, data["umag"] - u_model, s=1)
ax2.scatter(TeffH, data["gmag"] - g_model, s=1)
Expand All @@ -317,12 +269,6 @@

ax1.set_xscale("log")

plt.subplots_adjust(
top=0.95, bottom=0.075, left=0.075, right=0.975, wspace=0.0, hspace=0.15
)
plt.subplots_adjust(top=0.95, bottom=0.075, left=0.075, right=0.975, wspace=0.0, hspace=0.15)

plt.savefig(
os.path.join(
HERE, "example_output", "gaia_to_sdss_ugr_residual_logg_teff.png"
)
)
plt.savefig(os.path.join(HERE, "example_output", "gaia_to_sdss_ugr_residual_logg_teff.png"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
0.000000000000000000e+00,0.000000000000000000e+00
2.000000000000000111e-01,0.000000000000000000e+00
4.000000000000000222e-01,0.000000000000000000e+00
6.000000000000000888e-01,0.000000000000000000e+00
8.000000000000000444e-01,0.000000000000000000e+00
1.000000000000000000e+00,0.000000000000000000e+00
1.200000000000000178e+00,0.000000000000000000e+00
1.400000000000000133e+00,0.000000000000000000e+00
1.600000000000000089e+00,0.000000000000000000e+00
1.800000000000000044e+00,0.000000000000000000e+00
2.000000000000000000e+00,0.000000000000000000e+00
2.200000000000000178e+00,0.000000000000000000e+00
2.400000000000000355e+00,0.000000000000000000e+00
2.600000000000000089e+00,0.000000000000000000e+00
2.800000000000000266e+00,0.000000000000000000e+00
3.000000000000000000e+00,0.000000000000000000e+00
3.200000000000000178e+00,0.000000000000000000e+00
3.400000000000000355e+00,0.000000000000000000e+00
3.600000000000000089e+00,0.000000000000000000e+00
3.800000000000000266e+00,0.000000000000000000e+00
4.000000000000000000e+00,0.000000000000000000e+00
4.200000000000000178e+00,0.000000000000000000e+00
4.400000000000000355e+00,0.000000000000000000e+00
4.600000000000000533e+00,0.000000000000000000e+00
4.800000000000000711e+00,0.000000000000000000e+00
5.000000000000000000e+00,0.000000000000000000e+00
5.200000000000000178e+00,0.000000000000000000e+00
5.400000000000000355e+00,0.000000000000000000e+00
5.600000000000000533e+00,0.000000000000000000e+00
5.800000000000000711e+00,0.000000000000000000e+00
6.000000000000000000e+00,0.000000000000000000e+00
6.200000000000000178e+00,0.000000000000000000e+00
6.400000000000000355e+00,0.000000000000000000e+00
6.600000000000000533e+00,0.000000000000000000e+00
6.800000000000000711e+00,0.000000000000000000e+00
7.000000000000000000e+00,0.000000000000000000e+00
7.200000000000000178e+00,0.000000000000000000e+00
7.400000000000000355e+00,0.000000000000000000e+00
7.600000000000000533e+00,1.452820744402814308e-06
7.800000000000000711e+00,2.316401968045364023e-06
8.000000000000000000e+00,4.135666435844960641e-06
8.200000000000001066e+00,6.905484926428360603e-06
8.400000000000000355e+00,1.000068454866825995e-05
8.599999999999999645e+00,1.303352329966973936e-05
8.800000000000000711e+00,1.663433994580483004e-05
9.000000000000000000e+00,2.206976628343802424e-05
9.200000000000001066e+00,2.914431392067501526e-05
9.400000000000000355e+00,3.954686603182952569e-05
9.600000000000001421e+00,5.244474501181333061e-05
9.800000000000000711e+00,7.369889760635863721e-05
1.000000000000000000e+01,1.080241815544411531e-04
1.020000000000000107e+01,1.673924405349510062e-04
1.040000000000000036e+01,2.873564700597401600e-04
1.060000000000000142e+01,4.740243368115756731e-04
1.080000000000000071e+01,6.838370596631814782e-04
1.100000000000000000e+01,9.098380694761996944e-04
1.120000000000000107e+01,1.213832697259131484e-03
1.140000000000000036e+01,1.519083949405588716e-03
1.160000000000000142e+01,1.797866060089233029e-03
1.180000000000000071e+01,2.250988097814828059e-03
1.200000000000000000e+01,2.652895257043666900e-03
1.220000000000000107e+01,3.039233904119627381e-03
1.240000000000000036e+01,3.480085172361011264e-03
1.260000000000000142e+01,4.004752365723417140e-03
1.280000000000000071e+01,4.625256028327274019e-03
1.300000000000000000e+01,5.386890044921867522e-03
1.320000000000000107e+01,6.290566853776904249e-03
1.340000000000000036e+01,7.337085971229602953e-03
1.360000000000000142e+01,8.576579851142763014e-03
1.380000000000000071e+01,1.002235907082497587e-02
1.400000000000000000e+01,1.192278794231089838e-02
1.420000000000000107e+01,1.603394668086973590e-02
1.440000000000000036e+01,3.003934154516918476e-02
1.460000000000000142e+01,8.565381817191905500e-02
1.480000000000000071e+01,1.135851514071995610e-01
1.500000000000000000e+01,1.290846947907298425e-01
1.520000000000000107e+01,3.120940126210522414e-01
1.540000000000000036e+01,1.694224597129313226e-01
1.560000000000000142e+01,2.978388550508933794e-02
1.580000000000000071e+01,1.337537801314938463e-02
1.600000000000000000e+01,7.076544044009562204e-03
1.619999999999999929e+01,4.253819898124666481e-03
1.640000000000000213e+01,2.635737152719528405e-03
1.660000000000000142e+01,1.805960391430549549e-03
1.680000000000000071e+01,1.559642561720750399e-03
1.700000000000000000e+01,1.107672468584792146e-03
1.719999999999999929e+01,8.251744084013920479e-04
1.740000000000000213e+01,7.771957590116150083e-04
1.760000000000000142e+01,8.209199137250370714e-04
1.780000000000000071e+01,7.166084372125504321e-04
1.800000000000000000e+01,5.381768996588575217e-04
1.819999999999999929e+01,3.808848031817914826e-04
1.840000000000000213e+01,2.969268122693000892e-04
1.860000000000000142e+01,2.351749349003155515e-04
1.880000000000000071e+01,1.944312461364976403e-04
1.900000000000000000e+01,1.688236901970693307e-04
1.920000000000000284e+01,1.479996166048389418e-04
1.940000000000000213e+01,1.297881761888876285e-04
1.960000000000000142e+01,1.223245100380137933e-04
1.980000000000000071e+01,1.113864926004944327e-04
Loading
Loading