Sea level
Tags: #naas #opendata #snippet
Sea level rise is caused primarily by two factors related to global warming: the added water from melting ice sheets and glaciers and the expansion of seawater as it warms. The first graph tracks the change in sea level since 1993 as observed by satellites.
The second graph, derived from coastal tide gauge and satellite data, shows how much sea level changed from about 1900 to 2018. Items with pluses (+) are factors that cause global mean sea level to increase, while minuses (-) are variables that cause sea levels to decrease. These items are displayed at the time they were affecting sea level.
The data shown are the latest available, with a four- to five-month lag needed for processing.
  • You now need to create an Earthdata account to access NASA's sea level data. Register for free by clicking on 'Get data : http'. Once logged in you will access the data.
Website : https://climate.nasa.gov/vital-signs/sea-level/
Data source: Satellite sea level observations. Credit: NASA's Goddard Space Flight Center

Input

Import libraries

1
import pandas
2
import plotly.graph_objects as go
Copied!

Path of the source

Data source : nasa_sea_levels.txt downloaded earlier
1
uri_nasa_sea_level = "nasa-sea-level-data.txt"
Copied!

Model

Read the csv and create the table

1
df = pandas.read_csv(uri_nasa_sea_level, engine="python", comment='HDR',delim_whitespace=True, names=["A","B","Year + Fraction","D","E","F","G", "H","I","J","K","Smoothed GMSL (mm)",])
2
3
df.head(10)
Copied!
Now lets only get the information we want and convert year + fraction to date
1
new_df = pandas.DataFrame(df, columns=['Year + Fraction', 'Smoothed GMSL (mm)'])
2
3
dates = []
4
values = []
5
6
ref = 0
7
8
for i, row in new_df.iterrows():
9
#date formating
10
date_split = str(row['Year + Fraction']).split('.')
11
year = date_split[0]
12
fraction = '0.' + date_split[1]
13
float_fraction = float(fraction)
14
date = year + "-1-1"
15
date_delta = 365 * float_fraction
16
value = pandas.to_datetime(date) + pandas.to_timedelta(date_delta, unit='D')
17
dates.append(value)
18
19
#value formating
20
#to stay inline with the graph visible on nasa's website, we need to have 0 as our first value
21
if i == 0:
22
ref = row['Smoothed GMSL (mm)']
23
24
val = row['Smoothed GMSL (mm)'] - ref
25
values.append(val)
26
27
28
29
30
new_df['Date'] = dates
31
new_df['Value'] = values
32
33
new_df.head()
Copied!

Output

Land-Ocean Temperature Index - Visualization

1
fig = go.Figure(layout_title="<b>Sea Level variation since 1993 (mm)</b>")
2
fig.add_trace(go.Scatter(
3
x = new_df["Date"],
4
y = new_df["Value"],
5
name="Delta",
6
))
7
8
fig.update_layout(
9
autosize=False,
10
width=1300,
11
height=700,
12
plot_bgcolor='rgb(250,250,250)',
13
)
14
15
16
fig.add_annotation(y=6, x='2020-1-1',
17
text="Data source: Satellite sea level observations.<br> Credit: NASA's Goddard Space Flight Center",
18
showarrow=False,
19
)
20
21
fig.update_yaxes(title_text="Sea Height Variation (mm)")
22
fig.update_xaxes(title_text="Year", tickangle=60)
23
fig.add_hline(y=0.0)
24
fig.update_layout(title_x=0.5)
25
26
fig.show()
Copied!
Last modified 2mo ago
Copy link
Edit on GitHub