Spaces:
Running
Running
Upload 12 files
Browse files- Maps_B_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_HI_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_Mcdm_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_MgFe_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_Mgas_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_Mtot_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_P_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_Vcdm_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_Vgas_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_Z_IllustrisTNG_CV_z=0.00.npy +3 -0
- Maps_ne_IllustrisTNG_CV_z=0.00.npy +3 -0
- app.py +112 -0
Maps_B_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e742dfa728f5d7a496dcec44265506e164a5dce46891c63d169277eab65d354f
|
3 |
+
size 106168448
|
Maps_HI_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c3491050d73e09bce100f216b87a3aaf49e38f77ae6d20d3bda6d06e7df460a5
|
3 |
+
size 106168448
|
Maps_Mcdm_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ab0c7db6adb906aa76504f8e4e4c07c4b8b571497014a49dc345b36b2cd3b629
|
3 |
+
size 106168448
|
Maps_MgFe_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:92022c6c4e4bb1000d04cad8d6ededeba8c301f37c8694a8d4d375570d2216ca
|
3 |
+
size 106168448
|
Maps_Mgas_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cfcbef6180b7e61ceb3c7cf8f81c7d4fc5ab0e3803c08f7f19c439dc66900e04
|
3 |
+
size 106168448
|
Maps_Mtot_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:52b8c5460406b19850a5c9d88824c3f8cf9caa917eee43ec196e594277123b23
|
3 |
+
size 106168448
|
Maps_P_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e316824d16c317797b448276769c8ee4bbf9686ee4cf238c501f44c63fac3c4a
|
3 |
+
size 106168448
|
Maps_Vcdm_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e1ba0229f06582e2c48d4db330cf2c3fe166a28cbf6575c9dba19fa0ba9c09d4
|
3 |
+
size 106168448
|
Maps_Vgas_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dd6bffa05ac7bbea2d255003bfda0380e0c0822e315b7e02f3654d1c113379fe
|
3 |
+
size 106168448
|
Maps_Z_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5ca7252229cbc2772056a9c47ac8262124bdfbcdb22d3cd9ba953d8132c5f3e5
|
3 |
+
size 106168448
|
Maps_ne_IllustrisTNG_CV_z=0.00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6e804bf2e9ae7fbbd974047f3751bbf2d28f261cd5ee7634eeef486b3f75ae5e
|
3 |
+
size 106168448
|
app.py
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import sys,os
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
# image parameters
|
6 |
+
height = 300
|
7 |
+
width = 300
|
8 |
+
|
9 |
+
# this function reads and normalizes the images
|
10 |
+
def load_normalize_images(f_images):
|
11 |
+
|
12 |
+
# load the images
|
13 |
+
images = np.load(f_images)
|
14 |
+
|
15 |
+
# normalize the values
|
16 |
+
images = np.log10(images)
|
17 |
+
minimum, maximum = np.min(images), np.max(images)
|
18 |
+
images = (images-minimum)/(maximum-minimum)
|
19 |
+
|
20 |
+
return images
|
21 |
+
|
22 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_T_IllustrisTNG_CV_z=0.00.npy'
|
23 |
+
images1 = load_normalize_images(f_images)
|
24 |
+
|
25 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_B_IllustrisTNG_CV_z=0.00.npy'
|
26 |
+
images2 = load_normalize_images(f_images)
|
27 |
+
|
28 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_Mgas_IllustrisTNG_CV_z=0.00.npy'
|
29 |
+
images3 = load_normalize_images(f_images)
|
30 |
+
|
31 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_MgFe_IllustrisTNG_CV_z=0.00.npy'
|
32 |
+
images4 = load_normalize_images(f_images)
|
33 |
+
|
34 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_Vcdm_IllustrisTNG_CV_z=0.00.npy'
|
35 |
+
images5 = load_normalize_images(f_images)
|
36 |
+
|
37 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_Z_IllustrisTNG_CV_z=0.00.npy'
|
38 |
+
images6 = load_normalize_images(f_images)
|
39 |
+
|
40 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_HI_IllustrisTNG_CV_z=0.00.npy'
|
41 |
+
images7 = load_normalize_images(f_images)
|
42 |
+
|
43 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_Mcdm_IllustrisTNG_CV_z=0.00.npy'
|
44 |
+
images8 = load_normalize_images(f_images)
|
45 |
+
|
46 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_ne_IllustrisTNG_CV_z=0.00.npy'
|
47 |
+
images9 = load_normalize_images(f_images)
|
48 |
+
|
49 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_P_IllustrisTNG_CV_z=0.00.npy'
|
50 |
+
images10 = load_normalize_images(f_images)
|
51 |
+
|
52 |
+
f_images = '/mnt/ceph/users/camels/PUBLIC_RELEASE/CMD/2D_maps/data/IllustrisTNG/Maps_Vgas_IllustrisTNG_CV_z=0.00.npy'
|
53 |
+
images11 = load_normalize_images(f_images)
|
54 |
+
|
55 |
+
|
56 |
+
images = np.vstack([images1, images2, images3, images4, images5, images6,
|
57 |
+
images7, images8, images9, images10, images11])
|
58 |
+
|
59 |
+
|
60 |
+
# function that applies when the submit button is clicked
|
61 |
+
def guess_field(field, correct, wrong, state):
|
62 |
+
|
63 |
+
labels = {0:'Temperature', 1:'Magnetic fields', 2:'Gas mass',
|
64 |
+
3:'Mg/Fe', 4:'Dark matter velocity', 5:'Metallicity',
|
65 |
+
6:'Neutral hydrogen', 7:'Dark matter mass', 8:'Electron density',
|
66 |
+
9:'Gas pressure', 10:'Gas velocity'}
|
67 |
+
|
68 |
+
block = state//num_images_field
|
69 |
+
if field==labels[block]:
|
70 |
+
text = "Correct! This is from a %s map"%labels[block]
|
71 |
+
correct += 1
|
72 |
+
else:
|
73 |
+
text = "Wrong! This is from a %s map"%labels[block]
|
74 |
+
wrong += 1
|
75 |
+
return text, correct, wrong, gr.Button(interactive=False)
|
76 |
+
|
77 |
+
# function that applies when the next image button is clicked
|
78 |
+
def reset():
|
79 |
+
index = np.random.choice(np.arange(num_images), size=1)[0]
|
80 |
+
return gr.Image(value=images[index],type="numpy"), None, None, gr.Button(interactive=True), index
|
81 |
+
#return gr.Image(value=images[index],label="Image id: %d"%index,type="numpy"), None, None, gr.Button(interactive=True), index
|
82 |
+
|
83 |
+
num_images = images.shape[0]
|
84 |
+
num_images_field = images1.shape[0]
|
85 |
+
|
86 |
+
index = np.random.choice(np.arange(num_images), size=1)[0]
|
87 |
+
image = images[index]
|
88 |
+
correct, wrong = 0, 0
|
89 |
+
|
90 |
+
with gr.Blocks() as demo:
|
91 |
+
|
92 |
+
state = gr.State(value=index)
|
93 |
+
|
94 |
+
with gr.Row():
|
95 |
+
with gr.Column():
|
96 |
+
image = gr.Image(value=image, #label="Image id: %d"%index,
|
97 |
+
type="numpy", height=height, width=width)
|
98 |
+
results = gr.Textbox(label="Results", interactive=False)
|
99 |
+
with gr.Column():
|
100 |
+
options = gr.Radio(choices=["Temperature", "Magnetic fields", "Gas mass", "Mg/Fe", "Dark matter velocity", "Metallicity", "Neutral hydrogen", "Dark matter mass", "Electron density", "Gas pressure", "Gas velocity"],
|
101 |
+
label="Which field shows the image?")
|
102 |
+
submit_button = gr.Button("Submit")
|
103 |
+
next_image = gr.Button("Next image")
|
104 |
+
with gr.Row():
|
105 |
+
correct = gr.Number(label="Correct", value=correct, interactive=False)
|
106 |
+
wrong = gr.Number(label="Wrong", value=wrong, interactive=False)
|
107 |
+
|
108 |
+
submit_button.click(guess_field, inputs=[options, correct, wrong, state],
|
109 |
+
outputs=[results, correct, wrong, submit_button])
|
110 |
+
next_image.click(reset, inputs=[], outputs=[image, results, options, submit_button, state])
|
111 |
+
|
112 |
+
demo.launch()
|