# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: widgets
#     language: python
#     name: widgets
# ---

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import plotly.express as px

d = np.load("./embedding_3D_dens.npz", allow_pickle=True)
embedding = d["embedding"]
morpho=d["morpho"]
z_phot_test=d["z_phot_test"]
z_spec_test=d["z_spec_test"]
cat_test = d["cat_test"]
mse = np.load("./embedding_2d.npz", allow_pickle=True)["mse"]

morpho_name = np.array(["elliptical"]*len(morpho))
morpho_name[morpho]="spiral"
df = pd.DataFrame({'UMAP-1':embedding[:,0], 'UMAP-2':embedding[:,1], 'UMAP-3':embedding[:,2], "Morphology":morpho_name, "Photo-z":z_phot_test, "Spec-z":z_spec_test, "MSE-recon":mse})


fig = px.scatter_3d(df, x='UMAP-1', y='UMAP-2', z='UMAP-3', color= "Morphology")
fig.update_traces(selector=dict(name="elliptical"), marker=dict(size=1.5,color=('#EF553B')))
fig.update_traces(selector=dict(name="spiral"), marker=dict(size=1.5,color=('#636efa')))
# fig.show()
fig.write_html("UMAP_3D_morpho_dens.html")

fig = px.scatter_3d(df, x='UMAP-1', y='UMAP-2', z='UMAP-3', color= "Photo-z")
fig.update_traces(marker=dict(size=1.5,))
# fig.show()
fig.write_html("UMAP_3D_photo_z.html")

fig = px.scatter_3d(df, x='UMAP-1', y='UMAP-2', z='UMAP-3', color= "Spec-z")
fig.update_traces(marker=dict(size=1.5,))
# fig.show()
fig.write_html("UMAP_3D_spec_z_dens.html")

fig = px.scatter_3d(df, x='UMAP-1', y='UMAP-2', z='UMAP-3', color= np.log10( df["MSE-recon"]), range_color=[-6, -3])
fig.update_traces(marker=dict(size=1.5,))
# fig.show()
fig.write_html("UMAP_3D_mse.html")



StarcoderdataJupyterScriptsDedupFiltered