Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -419,7 +419,6 @@ def count_days_og(date1,date2):
|
|
| 419 |
|
| 420 |
|
| 421 |
def nasa_sdo_images(obj,size,date1,date2):
|
| 422 |
-
print(generate_sdo_urls(date1,date2))
|
| 423 |
url_box=[]
|
| 424 |
html_in=f"<style>{css}</style><div class='img_box_soho'>"
|
| 425 |
print(date1 + " - " + date2)
|
|
@@ -433,8 +432,10 @@ def nasa_sdo_images(obj,size,date1,date2):
|
|
| 433 |
end_month=f"{date2[4:6]}"
|
| 434 |
end_day=f"{date2[6:8]}"
|
| 435 |
|
|
|
|
|
|
|
| 436 |
|
| 437 |
-
years_rem,months_rem,days_rem=(0,0,0)
|
| 438 |
og_days_rem=days_rem
|
| 439 |
i_in_year,i_in_month,i_in_day,i_end_year,i_end_month,i_end_day=int(in_year),int(in_month),int(in_day),int(end_year),int(end_month),int(end_day)
|
| 440 |
days_json={"year": 0, "month": 0, "day": 0}
|
|
@@ -472,43 +473,45 @@ def nasa_sdo_images(obj,size,date1,date2):
|
|
| 472 |
days_rem += io
|
| 473 |
out_url=f"https://sdo.gsfc.nasa.gov/assets/img/browse/{end_year}/{end_month}/{io}/"
|
| 474 |
print(out_url)
|
| 475 |
-
url_box.append(out_url)
|
| 476 |
|
| 477 |
file_name="DATE_TIME_SIZE_TOOL.jpg"
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
#
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
if
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
|
|
|
|
|
|
| 512 |
return html_in, out_box
|
| 513 |
|
| 514 |
def get_concat_h_cut(in1, in2):
|
|
|
|
| 419 |
|
| 420 |
|
| 421 |
def nasa_sdo_images(obj,size,date1,date2):
|
|
|
|
| 422 |
url_box=[]
|
| 423 |
html_in=f"<style>{css}</style><div class='img_box_soho'>"
|
| 424 |
print(date1 + " - " + date2)
|
|
|
|
| 432 |
end_month=f"{date2[4:6]}"
|
| 433 |
end_day=f"{date2[6:8]}"
|
| 434 |
|
| 435 |
+
sdo_urls = generate_sdo_urls(date1,date2)
|
| 436 |
+
print(sdo_urls)
|
| 437 |
|
| 438 |
+
'''years_rem,months_rem,days_rem=(0,0,0)
|
| 439 |
og_days_rem=days_rem
|
| 440 |
i_in_year,i_in_month,i_in_day,i_end_year,i_end_month,i_end_day=int(in_year),int(in_month),int(in_day),int(end_year),int(end_month),int(end_day)
|
| 441 |
days_json={"year": 0, "month": 0, "day": 0}
|
|
|
|
| 473 |
days_rem += io
|
| 474 |
out_url=f"https://sdo.gsfc.nasa.gov/assets/img/browse/{end_year}/{end_month}/{io}/"
|
| 475 |
print(out_url)
|
| 476 |
+
url_box.append(out_url)'''
|
| 477 |
|
| 478 |
file_name="DATE_TIME_SIZE_TOOL.jpg"
|
| 479 |
+
for link in sdo_urls:
|
| 480 |
+
#sdo_source_format = f"https://sdo.gsfc.nasa.gov/assets/img/browse/{in_year}/{in_month}/{in_day}/"
|
| 481 |
+
sdo_source_format = link
|
| 482 |
+
#get_url=sdo_source_format
|
| 483 |
+
feed1 = requests.get(link)
|
| 484 |
+
#print(get_url)
|
| 485 |
+
if "All" in size:
|
| 486 |
+
size = sdo_size
|
| 487 |
+
if "All" in obj:
|
| 488 |
+
obj = sdo_obj
|
| 489 |
+
link_box=[]
|
| 490 |
+
out_box=[]
|
| 491 |
+
# Parse the HTML content using BeautifulSoup
|
| 492 |
+
soup = bs4.BeautifulSoup(feed1.content, 'html.parser')
|
| 493 |
+
#print(soup)
|
| 494 |
+
anchor_elements = soup.find_all('a')
|
| 495 |
+
for element in anchor_elements:
|
| 496 |
+
link_box.append(element.get('href'))
|
| 497 |
+
|
| 498 |
+
link_box.sort(reverse=True)
|
| 499 |
+
#for element in anchor_elements:
|
| 500 |
+
for href in link_box:
|
| 501 |
+
#href=element.get('href')
|
| 502 |
+
if href.endswith('.jpg'):
|
| 503 |
+
for o in obj:
|
| 504 |
+
for s in size:
|
| 505 |
+
ls=href.split("_")
|
| 506 |
+
#print(ls[1][0:4])
|
| 507 |
+
#print(date1[8:13])
|
| 508 |
+
if ls[1][0:4]>=date1[8:13]:
|
| 509 |
+
src_obj=ls[3].split('.jpg')[0]
|
| 510 |
+
if src_obj == o:
|
| 511 |
+
if int(ls[2]) == int(s):
|
| 512 |
+
out_box.append(f'{sdo_source_format}{href}')
|
| 513 |
+
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>'
|
| 514 |
+
html_in+="</div>"
|
| 515 |
return html_in, out_box
|
| 516 |
|
| 517 |
def get_concat_h_cut(in1, in2):
|