Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -51,8 +51,12 @@ nasa_soho_mp4=[
|
|
51 |
{"name":"SDO/HMI Magnetogram", "source":"https://soho.nascom.nasa.gov/data/LATEST/current_hmi_mag-512.mp4"},
|
52 |
]
|
53 |
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
56 |
html = """
|
57 |
<div>
|
58 |
PAGE_LINK
|
@@ -247,10 +251,8 @@ def make_nasa_soho_image_trigger():
|
|
247 |
|
248 |
def nasa_sdo_images(obj,size,date1,date2):
|
249 |
html_in=f"<style>{css}</style><div class='img_box_soho'>"
|
250 |
-
|
251 |
-
|
252 |
-
else:
|
253 |
-
size1=size
|
254 |
if int(date2[6:8])-int(date1[6:8]) >0:
|
255 |
return ("<div style='font-size:xxx-large'>Reduce Timespan to 24 hours</div>")
|
256 |
|
@@ -261,8 +263,14 @@ def nasa_sdo_images(obj,size,date1,date2):
|
|
261 |
sdo_source_format = f"https://sdo.gsfc.nasa.gov/assets/img/browse/{in_year}/{in_month}/{in_day}/"
|
262 |
get_url=sdo_source_format
|
263 |
print(get_url)
|
264 |
-
feed1 = requests.get(get_url)
|
265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
link_box=[]
|
267 |
# Parse the HTML content using BeautifulSoup
|
268 |
soup = bs4.BeautifulSoup(feed1.content, 'html.parser')
|
@@ -271,18 +279,16 @@ def nasa_sdo_images(obj,size,date1,date2):
|
|
271 |
for element in anchor_elements:
|
272 |
href=element.get('href')
|
273 |
if href.endswith('.jpg'):
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
#link_box.append(link_json)
|
285 |
-
html_in+=f'<div class="img_class_sdo"><a href="{sdo_source_format}{href}" target="_blank">{href}</a><br><img src={sdo_source_format}{href}></div>'
|
286 |
html_in+="</div>"
|
287 |
return html_in
|
288 |
def run():
|
@@ -352,12 +358,8 @@ with gr.Blocks() as app:
|
|
352 |
minute2=gr.Number(label="Minute",minimum=0,maximum=59,precision=0,value=int(timestamp[1]),min_width=10)
|
353 |
|
354 |
with gr.Row():
|
355 |
-
sdo_drop1=gr.Dropdown(label="Instrument", choices=["All","
|
356 |
-
|
357 |
-
"0304","0335","1600","1700","4500",
|
358 |
-
"211193171","211193171n","211193171rg",
|
359 |
-
"094335193","304211171"], value="All")
|
360 |
-
sdo_drop2=gr.Dropdown(label="Size", choices=[256,512,1024,2048,4096,"All"],value=512)
|
361 |
|
362 |
sdo_btn=gr.Button("Load")
|
363 |
sdo_html=gr.HTML()
|
|
|
51 |
{"name":"SDO/HMI Magnetogram", "source":"https://soho.nascom.nasa.gov/data/LATEST/current_hmi_mag-512.mp4"},
|
52 |
]
|
53 |
|
54 |
+
sdo_obj = ["HMIB","HMIBC","HMIIC","HMIIF","HMID","HMII","HMI171",
|
55 |
+
"0094","0131","0171","0193","0211",
|
56 |
+
"0304","0335","1600","1700","4500",
|
57 |
+
"211193171","211193171n","211193171rg",
|
58 |
+
"094335193","304211171"]
|
59 |
+
sdo_size= [256,512,1024,2048,4096]
|
60 |
html = """
|
61 |
<div>
|
62 |
PAGE_LINK
|
|
|
251 |
|
252 |
def nasa_sdo_images(obj,size,date1,date2):
|
253 |
html_in=f"<style>{css}</style><div class='img_box_soho'>"
|
254 |
+
|
255 |
+
|
|
|
|
|
256 |
if int(date2[6:8])-int(date1[6:8]) >0:
|
257 |
return ("<div style='font-size:xxx-large'>Reduce Timespan to 24 hours</div>")
|
258 |
|
|
|
263 |
sdo_source_format = f"https://sdo.gsfc.nasa.gov/assets/img/browse/{in_year}/{in_month}/{in_day}/"
|
264 |
get_url=sdo_source_format
|
265 |
print(get_url)
|
266 |
+
feed1 = requests.get(get_url)
|
267 |
|
268 |
+
|
269 |
+
if "All" in size:
|
270 |
+
size = sdo_size
|
271 |
+
if "All" in obj:
|
272 |
+
obj = sdo_obj
|
273 |
+
|
274 |
link_box=[]
|
275 |
# Parse the HTML content using BeautifulSoup
|
276 |
soup = bs4.BeautifulSoup(feed1.content, 'html.parser')
|
|
|
279 |
for element in anchor_elements:
|
280 |
href=element.get('href')
|
281 |
if href.endswith('.jpg'):
|
282 |
+
for o in obj:
|
283 |
+
for s in size:
|
284 |
+
ls=href.split("_")
|
285 |
+
print(ls[1][0:4])
|
286 |
+
print(date1[8:13])
|
287 |
+
if ls[1][0:4]>=date1[8:13]:
|
288 |
+
src_obj=ls[3].split('.jpg')[0]
|
289 |
+
if src_obj == o:
|
290 |
+
if int(ls[2]) == int(size):
|
291 |
+
html_in+=f'<div class="img_class_sdo"><a href="{sdo_source_format}{href}" target="_blank">{href}</a><br><img src={sdo_source_format}{href}></div>'
|
|
|
|
|
292 |
html_in+="</div>"
|
293 |
return html_in
|
294 |
def run():
|
|
|
358 |
minute2=gr.Number(label="Minute",minimum=0,maximum=59,precision=0,value=int(timestamp[1]),min_width=10)
|
359 |
|
360 |
with gr.Row():
|
361 |
+
sdo_drop1=gr.Dropdown(label="Instrument", multiselect=True, choices=["All"]+sdo_obj, value="0094")
|
362 |
+
sdo_drop2=gr.Dropdown(label="Size", multiselect=True, choices=["All"]+sdo_size,value=512)
|
|
|
|
|
|
|
|
|
363 |
|
364 |
sdo_btn=gr.Button("Load")
|
365 |
sdo_html=gr.HTML()
|