Comments (2)
This version might be a better representation:
Code
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
df = pd.DataFrame(columns=['value','source','target'])
df.index.name = 'label'
df.loc['SMB:in'] = [400, 'SMB in', 'SMB gain']
df.loc['rain:freeze'] = [40, 'rain', 'SMB in'] # Alexander 2019
df.loc['snow:fall'] = [750, 'snow fall', 'SMB in'] # fudge from A2019
df.loc['condensation'] = [10, 'condensation', 'SMB in']
# df.loc['drifting_out'] = [100, 'SMB in', 'drift']
# df.loc['drifting_in'] = [100, 'drift', 'SMB in']
df.loc['refreeze1'] = [250, 'refreeze','SMB in']
df.loc['Melt'] = [650, 'SMB in', 'Melt']
df.loc['refreeze'] = [250, 'Melt','refreeze']
df.loc['SMB:out'] = [400, 'Melt', 'runoff']
df.loc['MB:in'] = [400, 'SMB gain', 'MB']
df.loc['MB:D'] = [500, 'MB', 'dynamics']
df.loc['MB:BMB'] = [25, 'MB', 'basal melt']
df.loc['liquid_1'] = [25, 'basal melt', 'liquid']
df.loc['liquid_2'] = [25, 'rain', 'runoff']
df.loc['liquid_3'] = [425, 'runoff', 'liquid']
df.loc['liquid_4'] = [250, 'dynamics', 'liquid']
df.loc['iceberg'] = [250, 'dynamics', 'iceberg']
df.loc['DEFICIT'] = [125, 'DEFICIT', 'MB']
# QC Check
for s in df['source'].unique():
if s in df['target'].unique():
sv = df[df['source'] == s]['value'].sum()
tv = df[df['target'] == s]['value'].sum()
if( sv != tv ):
print(f"Error: {s} inputs != outputs [{sv} != {tv}]")
# # Add numeric values in parentheses
for t in np.unique(df['source'].values.astype(str)):
v = (df[df["source"] == t]["value"].sum()).round().astype(int).astype(str)
df = df.replace(to_replace=t, value=f'{t} ({v})')
for t in np.unique(df['target'].values.astype(str)):
if t[-1] == ')': continue
v = (df[df["target"] == t]["value"].sum()).round().astype(int).astype(str)
df = df.replace(to_replace=t, value=f'{t} ({v})')
# print(df)
## Plotly
# uniqify columns: Convert strings to numbers. Sequential. Across columns
keys = np.unique(df[['source','target']].values.flatten().astype(str))
df = df.replace(to_replace=keys, value=np.arange(len(keys)))
fig = go.Figure(go.Sankey(
arrangement = "snap",
node = {
"label": keys,
'color': "#666666",
'pad':10}, # 10 Pixels
link = {
"source": df['source'].values,
"target": df['target'].values,
# "color": "#DDDDDD",
"value": df['value'].values}))
# fig.show()
fig.write_image("plotly.png")
# interactive HTML: drag to re-arrange and clean up, then screenshot.
fig.write_html("plotly.html")
from mass_balance.
Related Issues (20)
- Lag term for negative SMB and BMB HOT 1
- Multi-time-scale initial figure
- Make reproducible
- Include peripheral glaciers HOT 1
- Distinguish between random and systematic uncertainty
- Upgrade to BedMachine v4
- Rename marine mass balance (MMB) to discharge (D).
- Separate SMB terms
- RAMCO SMB is 0 from 1986 through 1989 HOT 2
- SMB uncertainty is >> 9 % (Table 3) HOT 1
- Sectors & regions disagree when summed. HOT 1
- SMB uncertainty is not fixed at 9 %
- Update to BedMachine V5
- Provide THREDDS interface HOT 1
- Improve daily summary graphic HOT 3
- Treatment for peripheral glaciers (SMB & D)
- Treatment for different domains
- Near Realtime (NRT)
- Compare with IMBIE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mass_balance.