Omnibus commited on
Commit
979fb77
·
verified ·
1 Parent(s): 9b5aa1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -2
app.py CHANGED
@@ -5,12 +5,13 @@ import os
5
  from PIL import Image
6
  import moviepy.video.io.ImageSequenceClip as ic
7
  from pathlib import Path
8
-
9
 
10
  import urllib.request
11
  import uuid
12
  main_directory = "https://services.swpc.noaa.gov/"
13
-
 
14
  sdo_aia_latest=[
15
  {"name":"Fe18 94A", "source":"https://umbra.nascom.nasa.gov/images/latest_aia_94.gif"},
16
  {"name":"Fe20 131A", "source":"https://umbra.nascom.nasa.gov/images/latest_aia_131.gif"},
@@ -234,6 +235,27 @@ def make_nasa_soho_image_trigger():
234
  #html_in+= make_nasa_soho_videos()
235
  html_in+="</div>"
236
  return html_in
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  def run():
238
  out=make_tree()
239
  im_html=get_images()
@@ -257,6 +279,8 @@ with gr.Blocks() as app:
257
  html_raw=gr.HTML()
258
  links=gr.JSON()
259
  with gr.Tab("NASA"):
 
 
260
  with gr.Tab("SOHO Images"):
261
  soho_btn=gr.Button("Load")
262
  html_nasa=gr.HTML()
@@ -265,6 +289,7 @@ with gr.Blocks() as app:
265
  html_vid_nasa=gr.HTML()
266
 
267
  ###### NASA Images ##########
 
268
  soho_btn.click(make_nasa_soho_image_trigger,None,html_nasa)
269
  soho_vid_btn.click(make_nasa_soho_videos,None,html_vid_nasa)
270
  ###### NOAA Images ##########
 
5
  from PIL import Image
6
  import moviepy.video.io.ImageSequenceClip as ic
7
  from pathlib import Path
8
+ import bs4
9
 
10
  import urllib.request
11
  import uuid
12
  main_directory = "https://services.swpc.noaa.gov/"
13
+ sdo_source = "https://sdo.gsfc.nasa.gov/assets/img/browse/"
14
+ sdo_source_format = "https://sdo.gsfc.nasa.gov/assets/img/browse/YEAR/MONTH/DAY/DATE_IDENT_SIZE_TOOL.jpg"
15
  sdo_aia_latest=[
16
  {"name":"Fe18 94A", "source":"https://umbra.nascom.nasa.gov/images/latest_aia_94.gif"},
17
  {"name":"Fe20 131A", "source":"https://umbra.nascom.nasa.gov/images/latest_aia_131.gif"},
 
235
  #html_in+= make_nasa_soho_videos()
236
  html_in+="</div>"
237
  return html_in
238
+
239
+ def nasa_sdo_images():
240
+ html_out=""
241
+ in_year="2024"
242
+ in_month="3"
243
+ in_day="24"
244
+ file_name="DATE_IDENT_SIZE_TOOL.jpg"
245
+ sdo_source_format = f"https://sdo.gsfc.nasa.gov/assets/img/browse/{in_year}/{in_month}/{in_day}/"
246
+ get_url=sdo_source_format
247
+ feed1 = requests.get(get_url)
248
+
249
+ link_box=[]
250
+ # Parse the HTML content using BeautifulSoup
251
+ soup = BeautifulSoup(feed1, 'html.parser')
252
+ anchor_elements = soup.find_all('a')
253
+ for element in anchor_elements:
254
+ href=element.get('href')
255
+ print(href)
256
+ link_box.append(href)
257
+ html_out+=f'<div class="img_class"><a href="{get_url}{spl2}" target="_blank">{spl2}</a><br><img src={get_url}{spl2}></div>'
258
+
259
  def run():
260
  out=make_tree()
261
  im_html=get_images()
 
279
  html_raw=gr.HTML()
280
  links=gr.JSON()
281
  with gr.Tab("NASA"):
282
+ with gr.Tab("SDO Images"):
283
+ sdo_btn=gr.Button("Load")
284
  with gr.Tab("SOHO Images"):
285
  soho_btn=gr.Button("Load")
286
  html_nasa=gr.HTML()
 
289
  html_vid_nasa=gr.HTML()
290
 
291
  ###### NASA Images ##########
292
+ sdo_btn.click(nasa_sdo_images,None,None)
293
  soho_btn.click(make_nasa_soho_image_trigger,None,html_nasa)
294
  soho_vid_btn.click(make_nasa_soho_videos,None,html_vid_nasa)
295
  ###### NOAA Images ##########