Preprocess

In this notebook we will preprocess the observations and simulations (UNSEEN).

##Load pacakages
import xarray as xr
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
##This is so variables get printed within jupyter
from IPython.core.interactiveshell import InteractiveShell 
InteractiveShell.ast_node_interactivity = "all"

Observations

Let’s download the observations. We do this using the CABra dataset and tools. See Almagro et al. (2021). Using the shiny app you can explore the available observation stations. We select them and download them into this repository using the wget command

# !wget -O ../Data/Obidos_record_CABra.txt https://thecabradataset.shinyapps.io/CABra/_w_dc7ddebc/session/f594ed5c6efaa6a6431e2fcdc0b525ee/download/downloadData?w=dc7ddebc
# !wget -O ../Data/Xingu_record_CABra.txt https://thecabradataset.shinyapps.io/CABra/_w_d75db33b/session/9854b2d5ed51bb88a3fe58c9cae6392c/download/downloadData?w=d75db33b
# !wget -O ../Data/Tapajos_record_CABra.txt https://thecabradataset.shinyapps.io/CABra/_w_d75db33b/session/9854b2d5ed51bb88a3fe58c9cae6392c/download/downloadData?w=d75db33b

Here we load the downloaded datasets. We skip the first rows that provide additional information

Obidos_record = pd.read_csv('../Data/Obidos_record_CABra.txt', sep='\t',skiprows = 8)#, header=[0,1]) # Downloaded from BACra. Skip the header
# Obidos_record

Xingu_record = pd.read_csv('../Data/Xingu_record_CABra.txt', sep='\t',skiprows = 8)#, header=[0,1]) # Downloaded from BACra. Skip the header
# Xingu_record

Tapajos_record = pd.read_csv('../Data/Tapajos_record_CABra.txt', sep='\t',skiprows = 8)#, header=[0,1]) # Downloaded from BACra. Skip the header
# Tapajos_record

Then we need to do some pre-processing. First we name the columns so they can be used to create a datetime format. Then we remove the first row because that provides the units (m3/s) and not values. Third we create the datetime format and set it as index. Finally, we set the streamflow value type to float.

Obidos_record.columns = ['Year', 'Month', 'Day', 'Streamflow', 'Quality']
Obidos_record = Obidos_record[1:]
date = pd.to_datetime(Obidos_record[['Year', 'Month', 'Day']])
Obidos_record.index = date
Obidos_record['Streamflow'] = Obidos_record['Streamflow'].astype(float)
Obidos_record

Xingu_record.columns = ['Year', 'Month', 'Day', 'Streamflow', 'Quality']
Xingu_record = Xingu_record[1:]
Xingu_record.index = date #same date as Obidos
Xingu_record['Streamflow'] = Xingu_record['Streamflow'].astype(float)
Xingu_record

Tapajos_record.columns = ['Year', 'Month', 'Day', 'Streamflow', 'Quality']
Tapajos_record = Tapajos_record[1:]
Tapajos_record.index = date #same date as Obidos
Tapajos_record['Streamflow'] = Tapajos_record['Streamflow'].astype(float)
Tapajos_record
Year Month Day Streamflow Quality
1980-10-01 1980 10 1 94579.891 2
1980-10-02 1980 10 2 94057.414 2
1980-10-03 1980 10 3 93189.023 2
1980-10-04 1980 10 4 92669.445 2
1980-10-05 1980 10 5 91805.898 2
... ... ... ... ... ...
2010-09-26 2010 9 26 97208.531 2
2010-09-27 2010 9 27 95978.469 2
2010-09-28 2010 9 28 94405.609 2
2010-09-29 2010 9 29 92323.664 2
2010-09-30 2010 9 30 90259.180 2

10957 rows × 5 columns

Year Month Day Streamflow Quality
1980-10-01 1980 10 1 995.854 2
1980-10-02 1980 10 2 1011.401 2
1980-10-03 1980 10 3 1011.401 2
1980-10-04 1980 10 4 1027.081 2
1980-10-05 1980 10 5 1027.081 2
... ... ... ... ... ...
2010-09-26 2010 9 26 896.103 2
2010-09-27 2010 9 27 881.573 2
2010-09-28 2010 9 28 881.573 2
2010-09-29 2010 9 29 867.188 2
2010-09-30 2010 9 30 852.945 2

10957 rows × 5 columns

Year Month Day Streamflow Quality
1980-10-01 1980 10 1 2653.697 2
1980-10-02 1980 10 2 2626.756 2
1980-10-03 1980 10 3 2599.999 2
1980-10-04 1980 10 4 2560.203 2
1980-10-05 1980 10 5 2599.999 2
... ... ... ... ... ...
2010-09-26 2010 9 26 2367.308 2
2010-09-27 2010 9 27 2305.231 2
2010-09-28 2010 9 28 2244.249 2
2010-09-29 2010 9 29 2196.246 2
2010-09-30 2010 9 30 2172.502 2

10957 rows × 5 columns

Obidos_record_monthly = Obidos_record['Streamflow'].resample('M').mean()
Obidos_record_monthly = Obidos_record_monthly.to_xarray()
Obidos_record_annual = Obidos_record_monthly.groupby("index.year").max(dim="index")

Xingu_record_monthly = Xingu_record['Streamflow'].resample('M').mean()
Xingu_record_monthly = Xingu_record_monthly.to_xarray()
Xingu_record_annual = Xingu_record_monthly.groupby("index.year").max(dim="index")

Tapajos_record_monthly = Tapajos_record['Streamflow'].resample('M').mean()
Tapajos_record_monthly = Tapajos_record_monthly.to_xarray()
Tapajos_record_annual = Tapajos_record_monthly.groupby("index.year").max(dim="index")

We want observations representative of streamflow at the mouth of the Amazon. Obidos is the observation station closest to the outlet. The rivers Xingu and Tapajos still join the Amazon river downstream of Obidos. We therefore pool Obidos, Xingu and Tapajos together to represent total streamflow at the river mouth. We sum the monthly streamflow values:

Observations_pooled_monthly = Obidos_record_monthly + Xingu_record_monthly + Tapajos_record_monthly
Observations_pooled_annual = Observations_pooled_monthly.groupby("index.year").max(dim="index")

Let’s store these annual maxima streamflow values. We remove the values for the year 1980 because the series starts in October 1980 and the annual maximum flood peak (somewhere in March-May) was not recorded.

Obidos_record_annual_df = Obidos_record_annual.to_dataframe()
Obidos_record_annual_df[1:].to_csv('../Data/Obidos_CABra_record_annual_df.csv')

Xingu_record_annual_df = Xingu_record_annual.to_dataframe()
Xingu_record_annual_df[1:].to_csv('../Data/Xingu_CABra_record_annual_df.csv')

Tapajos_record_annual_df = Tapajos_record_annual.to_dataframe()
Tapajos_record_annual_df[1:].to_csv('../Data/Tapajos_CABra_record_annual_df.csv')

Observations_pooled_annual_df = Observations_pooled_annual.to_dataframe()
Observations_pooled_annual_df[1:].to_csv('../Data/Observations_pooled_annual_df.csv')
Observations_pooled_monthly.to_netcdf('../Data/Observations_pooled_monthly.nc')

Show observed streamflow timeseries

Some functions to create the figure for publication:

plt.rcParams["font.family"] = "sans-serif" ##change font
plt.rcParams['font.size'] = 7  ## change font size
# plt.rcParams['svg.fonttype'] = 'none' ## so inkscape recognized texts in svg file
plt.rcParams['pdf.fonttype'] = 42 ## so illustrator can recognize text
plt.figure(figsize=(80/25.4, 60/25.4))
(Observations_pooled_monthly/1000).plot(label = 'Pooled', color = 'blue', linestyle = '--', alpha=0.7)
(Obidos_record['Streamflow']/1000).plot(label = 'Obidos', color = 'brown')
(Xingu_record['Streamflow']/1000).plot(label = 'Xingu', color = 'black')
(Tapajos_record['Streamflow']/1000).plot(label = 'Tapajos', color = 'grey')
plt.legend()
plt.ylabel('Discharge [1000 m3/s] ')
plt.xlabel('')
# plt.savefig('../Graphs/Discharge_subcatchments.pdf',
#             bbox_inches='tight', 
#             dpi =300)
# plt.xlim('2008', '2010')
<Figure size 226.772x170.079 with 0 Axes>
[<matplotlib.lines.Line2D at 0x2ae87c931d90>]
<matplotlib.axes._subplots.AxesSubplot at 0x2ae87bedd880>
<matplotlib.axes._subplots.AxesSubplot at 0x2ae87bedd880>
<matplotlib.axes._subplots.AxesSubplot at 0x2ae87bedd880>
<matplotlib.legend.Legend at 0x2ae87c98bbb0>
Text(0, 0.5, 'Discharge [1000 m3/s] ')
Text(0.5, 0, '')
../_images/Preprocess_20_8.png
plt.figure(figsize=(90/25.4, 40/25.4))
(Observations_pooled_monthly.to_dataframe()['Streamflow']/1000).plot(label = 'Pooled', marker='o',
                                                markersize = 3,color = 'blue')
(Obidos_record_monthly.to_dataframe()['Streamflow']/1000).plot(label = 'Obidos',marker='o',
                                                markersize = 3, color = 'brown')
(Xingu_record_monthly.to_dataframe()['Streamflow']/1000).plot(label = 'Xingu',marker='o',
                                                markersize = 3, color = 'black')
(Tapajos_record_monthly.to_dataframe()['Streamflow']/1000).plot(label = 'Tapajos',marker='o',
                                                markersize = 3, color = 'grey')
plt.legend()
plt.ylabel('Discharge [1000 m3/s] ')
plt.xlabel('')
plt.xlim('2008', '2010')
# plt.savefig('../Graphs/Discharge_subcatchments_2009.pdf',
#             bbox_inches='tight', 
#             dpi =300)
<Figure size 255.118x113.386 with 0 Axes>
<matplotlib.axes._subplots.AxesSubplot at 0x2ae87ee641f0>
<matplotlib.axes._subplots.AxesSubplot at 0x2ae87ee641f0>
<matplotlib.axes._subplots.AxesSubplot at 0x2ae87ee641f0>
<matplotlib.axes._subplots.AxesSubplot at 0x2ae87ee641f0>
<matplotlib.legend.Legend at 0x2ae87eedd0d0>
Text(0, 0.5, 'Discharge [1000 m3/s] ')
Text(0.5, 0, '')
(456.0, 480.0)
../_images/Preprocess_21_9.png

Longer Obidos record

Alternatively from CABra, a longer Obidos record can be downloaded from Hybam. We use the dataset from CABra because it contains quality-controlled data over a homogenous period for all three stations. We plot the daily, monthly and annual maximum streamflow values from the longer Obidos record here just for reference.

Amazon_observed = pd.read_csv(dirname + 'Obs/17050001_debits_Obidos.csv', skiprows = [1]) # Downloaded from Hybam. Skip the empty row after the header
Amazon_observed = Amazon_observed.set_index(['date'])
Amazon_observed['valeur'] = Amazon_observed['valeur'].astype(float)
Amazon_observed['valeur'].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x2ac6e48f2e80>
../_images/Preprocess_23_1.png
Amazon_observed.index = pd.to_datetime(Amazon_observed.index)
Amazon_observed_monthly = Amazon_observed['valeur'].resample('M').mean()
Amazon_observed_monthly = Amazon_observed_monthly.to_xarray()
Amazon_observed_monthly
Amazon_observed_monthly.plot()
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'valeur'
  • date: 624
  • 1.6e+05 1.534e+05 1.594e+05 ... 1.425e+05 1.482e+05 1.858e+05
    array([159990.        , 153405.88235294, 159358.62068966, 173232.14285714,
           193017.24137931, 184639.28571429, 171041.37931034, 155737.93103448,
           145192.85714286, 138806.89655172, 133157.14285714, 135989.65517241,
           144501.61290323, 152991.78571429, 162802.58064516, 181400.        ,
           194876.77419355, 182585.33333333, 170936.4516129 , 152741.29032258,
           135668.        , 118927.09677419, 117201.33333333, 120705.48387097,
           137167.74193548, 153639.28571429, 173793.5483871 , 191043.33333333,
           204845.16129032, 201914.33333333, 194100.32258065, 177725.48387097,
           155331.66666667, 136926.4516129 , 124593.66666667, 123500.32258065,
           145848.38709677, 169921.42857143, 189409.67741935, 213793.33333333,
           223687.09677419, 225710.        , 217416.12903226, 198635.48387097,
           174693.33333333, 153025.80645161, 149393.33333333, 151693.5483871 ,
           154351.61290323, 178810.34482759, 198719.35483871, 209243.33333333,
           220783.87096774, 218426.66666667, 208100.        , 188761.29032258,
           169500.        , 150912.90322581, 140270.        , 146758.06451613,
           156967.74193548, 165350.        , 177645.16129032, 192883.33333333,
           211667.74193548, 215596.66666667, 209987.09677419, 196945.16129032,
           178903.33333333, 162919.35483871, 152030.        , 158661.29032258,
           171141.93548387, 190014.28571429, 205212.90322581, 219370.        ,
           229090.32258065, 225310.        , 216412.90322581, 200948.38709677,
           180566.66666667, 162448.38709677, 157523.33333333, 158809.67741935,
           169022.58064516, 187225.        , 203522.58064516, 222570.        ,
           233161.29032258, 233406.66666667, 224990.32258065, 209525.80645161,
           187910.        , 162722.58064516, 144666.66666667, 148509.67741935,
           161806.4516129 , 183182.75862069, 200280.64516129, 223366.66666667,
           236377.41935484, 233306.66666667, 222522.58064516, 196570.96774194,
           166903.33333333, 140332.25806452, 134112.        , 141894.83870968,
           153912.90322581, 159728.57142857, 174170.96774194, 195820.        ,
           216290.32258065, 216980.        , 207625.80645161, 184416.12903226,
           158160.        , 143174.19354839, 148663.33333333, 155793.5483871 ,
           174129.03225806, 176889.28571429, 191780.64516129, 204383.33333333,
           216806.4516129 , 213470.        , 203364.51612903, 182277.41935484,
           158106.66666667, 141816.12903226, 141893.33333333, 148538.70967742,
           164000.32258065, 170758.57142857, 182020.64516129, 201146.        ,
           215718.06451613, 214013.33333333, 198412.90322581, 168658.06451613,
           142146.66666667, 123460.64516129, 126044.        , 131620.        ,
           136812.58064516, 145015.17241379, 149498.70967742, 162299.66666667,
           168711.29032258, 170154.66666667, 162796.12903226, 144518.06451613,
           121857.33333333, 114687.74193548, 125565.33333333, 130495.16129032,
           141596.77419355, 153765.        , 166471.29032258, 180551.33333333,
           183706.12903226, 180671.66666667, 175157.41935484, 159779.67741935,
           135669.33333333, 117346.12903226, 118027.        , 126136.4516129 ,
           162183.87096774, 183653.57142857, 198848.38709677, 215070.        ,
           229500.        , 225903.33333333, 212058.06451613, 186519.35483871,
           160593.33333333, 137196.77419355, 135790.        , 147161.29032258,
           144690.32258065, 151403.92857143, 154640.96774194, 166844.66666667,
           173078.06451613, 171604.66666667, 158617.74193548, 133749.67741935,
           118146.33333333, 110291.93548387, 115783.33333333, 125234.19354839,
           155216.12903226, 169324.13793103, 188167.74193548, 203726.66666667,
           216577.41935484, 210246.66666667, 200974.19354839, 180803.22580645,
           158903.33333333, 138687.09677419, 138736.66666667, 144512.90322581,
           160816.12903226, 172792.85714286, 175183.87096774, 175723.33333333,
           187064.51612903, 186546.66666667, 178922.58064516, 165554.83870968,
           152156.66666667, 137290.32258065, 136126.66666667, 146677.41935484,
           163445.16129032, 174442.85714286, 191148.38709677, 207290.        ,
           214938.70967742, 213923.33333333, 211664.51612903, 193651.61290323,
           166033.33333333, 151409.67741935, 155783.33333333, 161629.03225806,
           163149.03225806, 172997.14285714, 188775.80645161, 199710.33333333,
           206354.19354839, 199661.66666667, 184520.        , 162041.29032258,
           140093.33333333, 123817.41935484, 125252.        , 135171.29032258,
           150896.77419355, 167005.17241379, 184938.06451613, 190921.33333333,
           204007.41935484, 203726.33333333, 194710.96774194, 172976.77419355,
           142157.33333333, 123654.83870968, 128414.33333333, 145727.74193548,
           168693.5483871 , 191200.        , 215167.74193548, 232133.33333333,
           242161.29032258, 241496.66666667, 232438.70967742, 211806.4516129 ,
           183190.        , 156074.19354839, 159243.33333333, 155912.90322581,
           142030.        , 163491.42857143, 188228.38709677, 198844.        ,
           207087.41935484, 204731.66666667, 196745.48387097, 179346.12903226,
           154155.        , 123973.5483871 , 124111.        , 141002.90322581,
           162230.32258065, 175321.42857143, 180266.12903226, 198963.33333333,
           211352.58064516, 211513.33333333, 200843.22580645, 184580.32258065,
           156218.66666667, 126294.19354839, 120911.66666667, 128217.09677419,
           123825.80645161, 131867.24137931, 147475.80645161, 167947.66666667,
           170802.25806452, 160388.        , 147620.64516129, 134309.35483871,
           124250.        , 117393.5483871 , 113687.66666667, 129579.35483871,
           163096.77419355, 176657.14285714, 196606.4516129 , 213066.66666667,
           219858.06451613, 214733.33333333, 203861.29032258, 181938.70967742,
           158683.33333333, 140480.64516129, 143673.33333333, 159051.61290323,
           185187.09677419, 200853.57142857, 217022.58064516, 226426.66666667,
           232941.93548387, 231390.        , 224377.41935484, 203893.5483871 ,
           180130.        , 157925.80645161, 145620.        , 152058.06451613,
           150042.58064516, 154928.21428571, 161921.61290323, 179091.        ,
           195296.4516129 , 194992.        , 183491.61290323, 160557.41935484,
           122615.33333333, 107430.32258065, 114322.66666667, 133936.4516129 ,
           158506.4516129 , 173765.51724138, 197551.61290323, 214376.66666667,
           222306.4516129 , 219183.33333333, 207396.77419355, 185370.96774194,
           158843.33333333, 137006.4516129 , 140616.66666667, 147164.51612903,
           155704.19354839, 167337.5       , 190723.22580645, 215615.66666667,
           227680.        , 217498.        , 198920.32258065, 171635.80645161,
           136804.        , 113224.83870968, 114868.33333333, 126282.90322581,
           132720.        , 141332.14285714, 154368.70967742, 167472.33333333,
           183548.70967742, 185866.        , 182069.03225806, 161955.16129032,
           131511.        , 107265.80645161, 116008.66666667, 130903.87096774,
           157685.48387097, 179518.57142857, 204841.93548387, 217696.        ,
           232756.12903226, 233121.        , 222678.70967742, 203346.4516129 ,
           174129.33333333, 142250.32258065, 130017.33333333, 133642.58064516,
           153687.09677419, 168531.03448276, 187735.48387097, 209240.        ,
           225093.5483871 , 220770.        , 214709.67741935, 197680.64516129,
           172570.        , 149845.16129032, 142913.33333333, 140841.93548387,
           153865.80645161, 175410.        , 195322.90322581, 215774.33333333,
           218854.83870968, 214689.33333333, 202696.77419355, 179495.16129032,
           153604.66666667, 129823.87096774, 127428.        , 137232.25806452,
           162026.4516129 , 168710.71428571, 185858.70967742, 202931.66666667,
           212483.22580645, 216822.66666667, 210545.16129032, 192482.90322581,
           167656.33333333, 136548.06451613, 133883.33333333, 145234.83870968,
           153135.48387097, 162914.28571429, 172335.48387097, 194616.66666667,
           205812.90322581, 207393.33333333, 199445.16129032, 184132.25806452,
           161760.        , 136606.4516129 , 133133.33333333, 134096.77419355,
           147745.16129032, 161437.93103448, 174722.58064516, 191656.66666667,
           200106.4516129 , 192553.33333333, 180912.90322581, 167948.38709677,
           150356.66666667, 135158.06451613, 131036.66666667, 138129.03225806,
           147398.06451613, 157749.64285714, 186830.96774194, 204369.        ,
           213724.51612903, 201741.66666667, 183395.48387097, 154392.90322581,
           124483.66666667, 109595.80645161, 120522.        , 136406.77419355,
           166021.61290323, 187329.28571429, 211292.25806452, 223593.33333333,
           240700.64516129, 232577.33333333, 211487.41935484, 180836.12903226,
           150470.66666667, 128098.70967742, 133381.33333333, 148725.16129032,
           159992.90322581, 172859.28571429, 183024.83870968, 198079.66666667,
           215370.96774194, 216587.33333333, 203909.03225806, 181683.87096774,
           149543.66666667, 128128.06451613, 132560.33333333, 145751.61290323,
           180690.32258065, 198544.82758621, 214406.4516129 , 221700.        ,
           225629.03225806, 230763.33333333, 229022.58064516, 203406.4516129 ,
           163803.33333333, 140361.29032258, 143526.66666667, 161583.87096774,
           189352.25806452, 211859.28571429, 225068.38709677, 225309.33333333,
           225533.5483871 , 230320.        , 235092.58064516, 230592.58064516,
           192166.33333333, 143407.74193548, 130934.        , 141044.51612903,
           154912.25806452, 168668.57142857, 178728.06451613, 203335.66666667,
           219332.25806452, 218130.66666667, 207869.03225806, 178834.83870968,
           131336.        , 100585.48387097, 105920.33333333, 124484.19354839,
           147180.        , 169073.57142857, 192771.93548387, 208831.33333333,
           219251.61290323, 224297.        , 222512.90322581, 198161.93548387,
           145980.33333333, 123462.58064516, 124918.66666667, 139176.4516129 ,
           170761.93548387, 198367.5862069 , 215769.67741935, 219950.33333333,
           224648.70967742, 228148.66666667, 229854.19354839, 206959.67741935,
           159179.33333333, 124828.38709677, 121630.33333333, 131487.09677419,
           161041.93548387, 182385.71428571, 209870.96774194, 218096.66666667,
           224183.87096774, 228973.33333333, 228990.32258065, 209925.80645161,
           184420.        , 153238.70967742, 151423.33333333, 163387.09677419,
           177458.06451613, 191432.14285714, 210151.61290323, 217743.33333333,
           222870.96774194, 226630.        , 229683.87096774, 224922.58064516,
           192666.66666667, 157038.70967742, 151176.66666667, 159619.35483871,
           169440.64516129, 185877.5       , 206551.29032258, 216025.33333333,
           220146.77419355, 224027.        , 226647.09677419, 220963.87096774,
           191105.        , 131321.61290323, 122400.66666667, 124959.35483871,
           129328.33333333, 137817.5       , 158168.33333333, 181599.31034483,
           198211.        , 198985.51724138, 193301.33333333, 177075.        ,
           145862.75862069, 118326.33333333, 145490.71428571, 159520.        ,
           164965.48387097, 187271.78571429, 208632.25806452, 212934.        ,
           219757.74193548, 221421.33333333, 217095.16129032, 190022.90322581,
           143501.        , 124655.80645161, 133603.66666667, 143294.83870968,
           162214.19354839, 180397.85714286, 191146.12903226, 203585.        ,
           216165.16129032, 219578.33333333, 218352.58064516, 201040.64516129,
           177149.66666667, 133309.67741935, 127903.        , 159911.93548387,
           185796.77419355, 202632.14285714, 214106.4516129 , 218686.66666667,
           225622.58064516, 229726.66666667, 230964.51612903, 218274.19354839,
           185626.66666667, 142461.29032258, 148210.        , 185806.66666667])
    • date
      (date)
      datetime64[ns]
      1968-01-31 ... 2019-12-31
      array(['1968-01-31T00:00:00.000000000', '1968-02-29T00:00:00.000000000',
             '1968-03-31T00:00:00.000000000', ..., '2019-10-31T00:00:00.000000000',
             '2019-11-30T00:00:00.000000000', '2019-12-31T00:00:00.000000000'],
            dtype='datetime64[ns]')
[<matplotlib.lines.Line2D at 0x2ac6e4a9b400>]
../_images/Preprocess_24_2.png
Obidos_record = Amazon_observed_monthly
Obidos_record
Obidos_record_annual = Obidos_record.groupby("date.year").max(dim="date")
Obidos_record_annual
Obidos_record_annual.plot()
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'valeur'
  • date: 624
  • 1.6e+05 1.534e+05 1.594e+05 ... 1.425e+05 1.482e+05 1.858e+05
    array([159990.        , 153405.88235294, 159358.62068966, 173232.14285714,
           193017.24137931, 184639.28571429, 171041.37931034, 155737.93103448,
           145192.85714286, 138806.89655172, 133157.14285714, 135989.65517241,
           144501.61290323, 152991.78571429, 162802.58064516, 181400.        ,
           194876.77419355, 182585.33333333, 170936.4516129 , 152741.29032258,
           135668.        , 118927.09677419, 117201.33333333, 120705.48387097,
           137167.74193548, 153639.28571429, 173793.5483871 , 191043.33333333,
           204845.16129032, 201914.33333333, 194100.32258065, 177725.48387097,
           155331.66666667, 136926.4516129 , 124593.66666667, 123500.32258065,
           145848.38709677, 169921.42857143, 189409.67741935, 213793.33333333,
           223687.09677419, 225710.        , 217416.12903226, 198635.48387097,
           174693.33333333, 153025.80645161, 149393.33333333, 151693.5483871 ,
           154351.61290323, 178810.34482759, 198719.35483871, 209243.33333333,
           220783.87096774, 218426.66666667, 208100.        , 188761.29032258,
           169500.        , 150912.90322581, 140270.        , 146758.06451613,
           156967.74193548, 165350.        , 177645.16129032, 192883.33333333,
           211667.74193548, 215596.66666667, 209987.09677419, 196945.16129032,
           178903.33333333, 162919.35483871, 152030.        , 158661.29032258,
           171141.93548387, 190014.28571429, 205212.90322581, 219370.        ,
           229090.32258065, 225310.        , 216412.90322581, 200948.38709677,
           180566.66666667, 162448.38709677, 157523.33333333, 158809.67741935,
           169022.58064516, 187225.        , 203522.58064516, 222570.        ,
           233161.29032258, 233406.66666667, 224990.32258065, 209525.80645161,
           187910.        , 162722.58064516, 144666.66666667, 148509.67741935,
           161806.4516129 , 183182.75862069, 200280.64516129, 223366.66666667,
           236377.41935484, 233306.66666667, 222522.58064516, 196570.96774194,
           166903.33333333, 140332.25806452, 134112.        , 141894.83870968,
           153912.90322581, 159728.57142857, 174170.96774194, 195820.        ,
           216290.32258065, 216980.        , 207625.80645161, 184416.12903226,
           158160.        , 143174.19354839, 148663.33333333, 155793.5483871 ,
           174129.03225806, 176889.28571429, 191780.64516129, 204383.33333333,
           216806.4516129 , 213470.        , 203364.51612903, 182277.41935484,
           158106.66666667, 141816.12903226, 141893.33333333, 148538.70967742,
           164000.32258065, 170758.57142857, 182020.64516129, 201146.        ,
           215718.06451613, 214013.33333333, 198412.90322581, 168658.06451613,
           142146.66666667, 123460.64516129, 126044.        , 131620.        ,
           136812.58064516, 145015.17241379, 149498.70967742, 162299.66666667,
           168711.29032258, 170154.66666667, 162796.12903226, 144518.06451613,
           121857.33333333, 114687.74193548, 125565.33333333, 130495.16129032,
           141596.77419355, 153765.        , 166471.29032258, 180551.33333333,
           183706.12903226, 180671.66666667, 175157.41935484, 159779.67741935,
           135669.33333333, 117346.12903226, 118027.        , 126136.4516129 ,
           162183.87096774, 183653.57142857, 198848.38709677, 215070.        ,
           229500.        , 225903.33333333, 212058.06451613, 186519.35483871,
           160593.33333333, 137196.77419355, 135790.        , 147161.29032258,
           144690.32258065, 151403.92857143, 154640.96774194, 166844.66666667,
           173078.06451613, 171604.66666667, 158617.74193548, 133749.67741935,
           118146.33333333, 110291.93548387, 115783.33333333, 125234.19354839,
           155216.12903226, 169324.13793103, 188167.74193548, 203726.66666667,
           216577.41935484, 210246.66666667, 200974.19354839, 180803.22580645,
           158903.33333333, 138687.09677419, 138736.66666667, 144512.90322581,
           160816.12903226, 172792.85714286, 175183.87096774, 175723.33333333,
           187064.51612903, 186546.66666667, 178922.58064516, 165554.83870968,
           152156.66666667, 137290.32258065, 136126.66666667, 146677.41935484,
           163445.16129032, 174442.85714286, 191148.38709677, 207290.        ,
           214938.70967742, 213923.33333333, 211664.51612903, 193651.61290323,
           166033.33333333, 151409.67741935, 155783.33333333, 161629.03225806,
           163149.03225806, 172997.14285714, 188775.80645161, 199710.33333333,
           206354.19354839, 199661.66666667, 184520.        , 162041.29032258,
           140093.33333333, 123817.41935484, 125252.        , 135171.29032258,
           150896.77419355, 167005.17241379, 184938.06451613, 190921.33333333,
           204007.41935484, 203726.33333333, 194710.96774194, 172976.77419355,
           142157.33333333, 123654.83870968, 128414.33333333, 145727.74193548,
           168693.5483871 , 191200.        , 215167.74193548, 232133.33333333,
           242161.29032258, 241496.66666667, 232438.70967742, 211806.4516129 ,
           183190.        , 156074.19354839, 159243.33333333, 155912.90322581,
           142030.        , 163491.42857143, 188228.38709677, 198844.        ,
           207087.41935484, 204731.66666667, 196745.48387097, 179346.12903226,
           154155.        , 123973.5483871 , 124111.        , 141002.90322581,
           162230.32258065, 175321.42857143, 180266.12903226, 198963.33333333,
           211352.58064516, 211513.33333333, 200843.22580645, 184580.32258065,
           156218.66666667, 126294.19354839, 120911.66666667, 128217.09677419,
           123825.80645161, 131867.24137931, 147475.80645161, 167947.66666667,
           170802.25806452, 160388.        , 147620.64516129, 134309.35483871,
           124250.        , 117393.5483871 , 113687.66666667, 129579.35483871,
           163096.77419355, 176657.14285714, 196606.4516129 , 213066.66666667,
           219858.06451613, 214733.33333333, 203861.29032258, 181938.70967742,
           158683.33333333, 140480.64516129, 143673.33333333, 159051.61290323,
           185187.09677419, 200853.57142857, 217022.58064516, 226426.66666667,
           232941.93548387, 231390.        , 224377.41935484, 203893.5483871 ,
           180130.        , 157925.80645161, 145620.        , 152058.06451613,
           150042.58064516, 154928.21428571, 161921.61290323, 179091.        ,
           195296.4516129 , 194992.        , 183491.61290323, 160557.41935484,
           122615.33333333, 107430.32258065, 114322.66666667, 133936.4516129 ,
           158506.4516129 , 173765.51724138, 197551.61290323, 214376.66666667,
           222306.4516129 , 219183.33333333, 207396.77419355, 185370.96774194,
           158843.33333333, 137006.4516129 , 140616.66666667, 147164.51612903,
           155704.19354839, 167337.5       , 190723.22580645, 215615.66666667,
           227680.        , 217498.        , 198920.32258065, 171635.80645161,
           136804.        , 113224.83870968, 114868.33333333, 126282.90322581,
           132720.        , 141332.14285714, 154368.70967742, 167472.33333333,
           183548.70967742, 185866.        , 182069.03225806, 161955.16129032,
           131511.        , 107265.80645161, 116008.66666667, 130903.87096774,
           157685.48387097, 179518.57142857, 204841.93548387, 217696.        ,
           232756.12903226, 233121.        , 222678.70967742, 203346.4516129 ,
           174129.33333333, 142250.32258065, 130017.33333333, 133642.58064516,
           153687.09677419, 168531.03448276, 187735.48387097, 209240.        ,
           225093.5483871 , 220770.        , 214709.67741935, 197680.64516129,
           172570.        , 149845.16129032, 142913.33333333, 140841.93548387,
           153865.80645161, 175410.        , 195322.90322581, 215774.33333333,
           218854.83870968, 214689.33333333, 202696.77419355, 179495.16129032,
           153604.66666667, 129823.87096774, 127428.        , 137232.25806452,
           162026.4516129 , 168710.71428571, 185858.70967742, 202931.66666667,
           212483.22580645, 216822.66666667, 210545.16129032, 192482.90322581,
           167656.33333333, 136548.06451613, 133883.33333333, 145234.83870968,
           153135.48387097, 162914.28571429, 172335.48387097, 194616.66666667,
           205812.90322581, 207393.33333333, 199445.16129032, 184132.25806452,
           161760.        , 136606.4516129 , 133133.33333333, 134096.77419355,
           147745.16129032, 161437.93103448, 174722.58064516, 191656.66666667,
           200106.4516129 , 192553.33333333, 180912.90322581, 167948.38709677,
           150356.66666667, 135158.06451613, 131036.66666667, 138129.03225806,
           147398.06451613, 157749.64285714, 186830.96774194, 204369.        ,
           213724.51612903, 201741.66666667, 183395.48387097, 154392.90322581,
           124483.66666667, 109595.80645161, 120522.        , 136406.77419355,
           166021.61290323, 187329.28571429, 211292.25806452, 223593.33333333,
           240700.64516129, 232577.33333333, 211487.41935484, 180836.12903226,
           150470.66666667, 128098.70967742, 133381.33333333, 148725.16129032,
           159992.90322581, 172859.28571429, 183024.83870968, 198079.66666667,
           215370.96774194, 216587.33333333, 203909.03225806, 181683.87096774,
           149543.66666667, 128128.06451613, 132560.33333333, 145751.61290323,
           180690.32258065, 198544.82758621, 214406.4516129 , 221700.        ,
           225629.03225806, 230763.33333333, 229022.58064516, 203406.4516129 ,
           163803.33333333, 140361.29032258, 143526.66666667, 161583.87096774,
           189352.25806452, 211859.28571429, 225068.38709677, 225309.33333333,
           225533.5483871 , 230320.        , 235092.58064516, 230592.58064516,
           192166.33333333, 143407.74193548, 130934.        , 141044.51612903,
           154912.25806452, 168668.57142857, 178728.06451613, 203335.66666667,
           219332.25806452, 218130.66666667, 207869.03225806, 178834.83870968,
           131336.        , 100585.48387097, 105920.33333333, 124484.19354839,
           147180.        , 169073.57142857, 192771.93548387, 208831.33333333,
           219251.61290323, 224297.        , 222512.90322581, 198161.93548387,
           145980.33333333, 123462.58064516, 124918.66666667, 139176.4516129 ,
           170761.93548387, 198367.5862069 , 215769.67741935, 219950.33333333,
           224648.70967742, 228148.66666667, 229854.19354839, 206959.67741935,
           159179.33333333, 124828.38709677, 121630.33333333, 131487.09677419,
           161041.93548387, 182385.71428571, 209870.96774194, 218096.66666667,
           224183.87096774, 228973.33333333, 228990.32258065, 209925.80645161,
           184420.        , 153238.70967742, 151423.33333333, 163387.09677419,
           177458.06451613, 191432.14285714, 210151.61290323, 217743.33333333,
           222870.96774194, 226630.        , 229683.87096774, 224922.58064516,
           192666.66666667, 157038.70967742, 151176.66666667, 159619.35483871,
           169440.64516129, 185877.5       , 206551.29032258, 216025.33333333,
           220146.77419355, 224027.        , 226647.09677419, 220963.87096774,
           191105.        , 131321.61290323, 122400.66666667, 124959.35483871,
           129328.33333333, 137817.5       , 158168.33333333, 181599.31034483,
           198211.        , 198985.51724138, 193301.33333333, 177075.        ,
           145862.75862069, 118326.33333333, 145490.71428571, 159520.        ,
           164965.48387097, 187271.78571429, 208632.25806452, 212934.        ,
           219757.74193548, 221421.33333333, 217095.16129032, 190022.90322581,
           143501.        , 124655.80645161, 133603.66666667, 143294.83870968,
           162214.19354839, 180397.85714286, 191146.12903226, 203585.        ,
           216165.16129032, 219578.33333333, 218352.58064516, 201040.64516129,
           177149.66666667, 133309.67741935, 127903.        , 159911.93548387,
           185796.77419355, 202632.14285714, 214106.4516129 , 218686.66666667,
           225622.58064516, 229726.66666667, 230964.51612903, 218274.19354839,
           185626.66666667, 142461.29032258, 148210.        , 185806.66666667])
    • date
      (date)
      datetime64[ns]
      1968-01-31 ... 2019-12-31
      array(['1968-01-31T00:00:00.000000000', '1968-02-29T00:00:00.000000000',
             '1968-03-31T00:00:00.000000000', ..., '2019-10-31T00:00:00.000000000',
             '2019-11-30T00:00:00.000000000', '2019-12-31T00:00:00.000000000'],
            dtype='datetime64[ns]')
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'valeur'
  • year: 52
  • 1.93e+05 1.949e+05 2.048e+05 ... 2.214e+05 2.196e+05 2.31e+05
    array([193017.24137931, 194876.77419355, 204845.16129032, 225710.        ,
           220783.87096774, 215596.66666667, 229090.32258065, 233406.66666667,
           236377.41935484, 216980.        , 216806.4516129 , 215718.06451613,
           170154.66666667, 183706.12903226, 229500.        , 173078.06451613,
           216577.41935484, 187064.51612903, 214938.70967742, 206354.19354839,
           204007.41935484, 242161.29032258, 207087.41935484, 211513.33333333,
           170802.25806452, 219858.06451613, 232941.93548387, 195296.4516129 ,
           222306.4516129 , 227680.        , 185866.        , 233121.        ,
           225093.5483871 , 218854.83870968, 216822.66666667, 207393.33333333,
           200106.4516129 , 213724.51612903, 240700.64516129, 216587.33333333,
           230763.33333333, 235092.58064516, 219332.25806452, 224297.        ,
           229854.19354839, 228990.32258065, 229683.87096774, 226647.09677419,
           198985.51724138, 221421.33333333, 219578.33333333, 230964.51612903])
    • year
      (year)
      int64
      1968 1969 1970 ... 2017 2018 2019
      array([1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979,
             1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,
             1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
             2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015,
             2016, 2017, 2018, 2019])
[<matplotlib.lines.Line2D at 0x2ac6e4bc9b80>]
../_images/Preprocess_25_3.png

UNSEEN floods

Load the simulations (discharge_monthAvg_presentDay.nc) available at https://doi.org/10.5281/zenodo.4585400 or download them in the ../Data directory by uncommenting and running the following line:

!wget -O ../Data/discharge_monthAvg_presentDay.nc https://zenodo.org/record/4585400/files/discharge_monthAvg_presentDay.nc
--2021-10-07 13:09:36--  https://zenodo.org/record/4585400/files/discharge_monthAvg_presentDay.nc
Resolving zenodo.org (zenodo.org)... 137.138.76.77
Connecting to zenodo.org (zenodo.org)|137.138.76.77|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 247755472 (236M) [application/octet-stream]
Saving to: ‘../Data/discharge_monthAvg_presentDay.nc’

100%[======================================>] 247,755,472 40.7MB/s   in 5.8s   

2021-10-07 13:09:42 (40.7 MB/s) - ‘../Data/discharge_monthAvg_presentDay.nc’ saved [247755472/247755472]
Amazon_simulated = xr.open_dataset('../Data/discharge_monthAvg_presentDay.nc')
Amazon_simulated #to show
/home/tike/miniconda3/envs/exp/lib/python3.8/site-packages/xarray/coding/times.py:426: SerializationWarning: Unable to decode time axis into full numpy.datetime64 objects, continuing using cftime.datetime objects instead, reason: dates out of range
  dtype = _decode_cf_datetime_dtype(data, units, calendar, self.use_cftime)
/home/tike/miniconda3/envs/exp/lib/python3.8/site-packages/numpy/core/_asarray.py:85: SerializationWarning: Unable to decode time axis into full numpy.datetime64 objects, continuing using cftime.datetime objects instead, reason: dates out of range
  return array(a, dtype, copy=False, order=order)
Show/Hide data repr Show/Hide attributes
xarray.Dataset
    • lat: 44
    • lon: 70
    • time: 24000
    • time
      (time)
      object
      0001-01-03 00:00:00 ... 2055-01-01 00:00:00
      standard_name :
      time
      long_name :
      Days since 1901-01-01
      array([cftime.DatetimeGregorian(0001-01-03 00:00:00),
             cftime.DatetimeGregorian(0002-01-03 00:00:00),
             cftime.DatetimeGregorian(0003-01-03 00:00:00), ...,
             cftime.DatetimeGregorian(2053-01-01 00:00:00),
             cftime.DatetimeGregorian(2054-01-01 00:00:00),
             cftime.DatetimeGregorian(2055-01-01 00:00:00)], dtype=object)
    • lat
      (lat)
      float32
      4.75 4.25 3.75 ... -16.25 -16.75
      long_name :
      latitude
      units :
      degrees_north
      standard_name :
      latitude
      array([  4.75,   4.25,   3.75,   3.25,   2.75,   2.25,   1.75,   1.25,   0.75,
               0.25,  -0.25,  -0.75,  -1.25,  -1.75,  -2.25,  -2.75,  -3.25,  -3.75,
              -4.25,  -4.75,  -5.25,  -5.75,  -6.25,  -6.75,  -7.25,  -7.75,  -8.25,
              -8.75,  -9.25,  -9.75, -10.25, -10.75, -11.25, -11.75, -12.25, -12.75,
             -13.25, -13.75, -14.25, -14.75, -15.25, -15.75, -16.25, -16.75],
            dtype=float32)
    • lon
      (lon)
      float32
      -79.75 -79.25 ... -45.75 -45.25
      standard_name :
      longitude
      long_name :
      longitude
      units :
      degrees_east
      array([-79.75, -79.25, -78.75, -78.25, -77.75, -77.25, -76.75, -76.25, -75.75,
             -75.25, -74.75, -74.25, -73.75, -73.25, -72.75, -72.25, -71.75, -71.25,
             -70.75, -70.25, -69.75, -69.25, -68.75, -68.25, -67.75, -67.25, -66.75,
             -66.25, -65.75, -65.25, -64.75, -64.25, -63.75, -63.25, -62.75, -62.25,
             -61.75, -61.25, -60.75, -60.25, -59.75, -59.25, -58.75, -58.25, -57.75,
             -57.25, -56.75, -56.25, -55.75, -55.25, -54.75, -54.25, -53.75, -53.25,
             -52.75, -52.25, -51.75, -51.25, -50.75, -50.25, -49.75, -49.25, -48.75,
             -48.25, -47.75, -47.25, -46.75, -46.25, -45.75, -45.25], dtype=float32)
    • discharge
      (time, lat, lon)
      float32
      ...
      standard_name :
      discharge
      long_name :
      discharge
      units :
      m3s-1
      [73920000 values with dtype=float32]

And select grid cells corresponding to (sub)catchment outlets

Amazon = Amazon_simulated['discharge'].sel(lon=-51.75,lat=-1.25)#.sel(lon=-50.25,lat=0.25)  ## Select the timeseries in the gridcell at the mouth of the river
Manaus = Amazon_simulated['discharge'].sel(lon=-59.75,lat=-3.25)  
Obidos = Amazon_simulated['discharge'].sel(lon=-55.75,lat=-2.25)  
Tapajos = Amazon_simulated['discharge'].sel(lon=-55.25,lat=-2.75)  
Xingu = Amazon_simulated['discharge'].sel(lon=-52.25,lat=-1.75)

Now we will select the annual monthly streamflow maxima.

I couldnt assign 2000 years of data to the time dimension of xarray. Hence, I assigned a new coordinate with the years 0-1999.

Amazon = Amazon.assign_coords({'year': ('time', np.repeat(np.arange(2000),12))} )
Amazon
Amazon_annual = Amazon.groupby("year").max(dim="time")
Amazon_annual

Obidos = Obidos.assign_coords({'year': ('time', np.repeat(np.arange(2000),12))} )
Obidos
Obidos_annual = Obidos.groupby("year").max(dim="time")
Obidos_annual
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'discharge'
  • time: 24000
  • 185345.83 211996.66 241979.86 ... 153125.78 144078.7 152582.12
    array([185345.83, 211996.66, 241979.86, ..., 153125.78, 144078.7 , 152582.12],
          dtype=float32)
    • time
      (time)
      object
      0001-01-03 00:00:00 ... 2055-01-01 00:00:00
      standard_name :
      time
      long_name :
      Days since 1901-01-01
      array([cftime.DatetimeGregorian(0001-01-03 00:00:00),
             cftime.DatetimeGregorian(0002-01-03 00:00:00),
             cftime.DatetimeGregorian(0003-01-03 00:00:00), ...,
             cftime.DatetimeGregorian(2053-01-01 00:00:00),
             cftime.DatetimeGregorian(2054-01-01 00:00:00),
             cftime.DatetimeGregorian(2055-01-01 00:00:00)], dtype=object)
    • lat
      ()
      float32
      -1.25
      long_name :
      latitude
      units :
      degrees_north
      standard_name :
      latitude
      array(-1.25, dtype=float32)
    • lon
      ()
      float32
      -51.75
      standard_name :
      longitude
      long_name :
      longitude
      units :
      degrees_east
      array(-51.75, dtype=float32)
    • year
      (time)
      int64
      0 0 0 0 0 ... 1999 1999 1999 1999
      array([   0,    0,    0, ..., 1999, 1999, 1999])
  • standard_name :
    discharge
    long_name :
    discharge
    units :
    m3s-1
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'discharge'
  • year: 2000
  • 287012.72 301987.78 358596.53 ... 407820.25 378064.0 341684.56
    array([287012.72, 301987.78, 358596.53, ..., 407820.25, 378064.  ,
           341684.56], dtype=float32)
    • lat
      ()
      float32
      -1.25
      long_name :
      latitude
      units :
      degrees_north
      standard_name :
      latitude
      array(-1.25, dtype=float32)
    • lon
      ()
      float32
      -51.75
      standard_name :
      longitude
      long_name :
      longitude
      units :
      degrees_east
      array(-51.75, dtype=float32)
    • year
      (year)
      int64
      0 1 2 3 4 ... 1996 1997 1998 1999
      array([   0,    1,    2, ..., 1997, 1998, 1999])
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'discharge'
  • time: 24000
  • 152280.95 175300.23 192076.03 ... 126738.73 118734.34 128958.37
    array([152280.95, 175300.23, 192076.03, ..., 126738.73, 118734.34, 128958.37],
          dtype=float32)
    • time
      (time)
      object
      0001-01-03 00:00:00 ... 2055-01-01 00:00:00
      standard_name :
      time
      long_name :
      Days since 1901-01-01
      array([cftime.DatetimeGregorian(0001-01-03 00:00:00),
             cftime.DatetimeGregorian(0002-01-03 00:00:00),
             cftime.DatetimeGregorian(0003-01-03 00:00:00), ...,
             cftime.DatetimeGregorian(2053-01-01 00:00:00),
             cftime.DatetimeGregorian(2054-01-01 00:00:00),
             cftime.DatetimeGregorian(2055-01-01 00:00:00)], dtype=object)
    • lat
      ()
      float32
      -2.25
      long_name :
      latitude
      units :
      degrees_north
      standard_name :
      latitude
      array(-2.25, dtype=float32)
    • lon
      ()
      float32
      -55.75
      standard_name :
      longitude
      long_name :
      longitude
      units :
      degrees_east
      array(-55.75, dtype=float32)
    • year
      (time)
      int64
      0 0 0 0 0 ... 1999 1999 1999 1999
      array([   0,    0,    0, ..., 1999, 1999, 1999])
  • standard_name :
    discharge
    long_name :
    discharge
    units :
    m3s-1
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'discharge'
  • year: 2000
  • 237567.19 241490.0 267892.1 286408.94 ... 337493.94 296771.4 278421.6
    array([237567.19, 241490.  , 267892.1 , ..., 337493.94, 296771.4 ,
           278421.6 ], dtype=float32)
    • lat
      ()
      float32
      -2.25
      long_name :
      latitude
      units :
      degrees_north
      standard_name :
      latitude
      array(-2.25, dtype=float32)
    • lon
      ()
      float32
      -55.75
      standard_name :
      longitude
      long_name :
      longitude
      units :
      degrees_east
      array(-55.75, dtype=float32)
    • year
      (year)
      int64
      0 1 2 3 4 ... 1996 1997 1998 1999
      array([   0,    1,    2, ..., 1997, 1998, 1999])

Store the datasets to be used in R

Amazon_annual
Obidos_annual
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'discharge'
  • year: 2000
  • 287012.72 301987.78 358596.53 ... 407820.25 378064.0 341684.56
    array([287012.72, 301987.78, 358596.53, ..., 407820.25, 378064.  ,
           341684.56], dtype=float32)
    • lat
      ()
      float32
      -1.25
      long_name :
      latitude
      units :
      degrees_north
      standard_name :
      latitude
      array(-1.25, dtype=float32)
    • lon
      ()
      float32
      -51.75
      standard_name :
      longitude
      long_name :
      longitude
      units :
      degrees_east
      array(-51.75, dtype=float32)
    • year
      (year)
      int64
      0 1 2 3 4 ... 1996 1997 1998 1999
      array([   0,    1,    2, ..., 1997, 1998, 1999])
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'discharge'
  • year: 2000
  • 237567.19 241490.0 267892.1 286408.94 ... 337493.94 296771.4 278421.6
    array([237567.19, 241490.  , 267892.1 , ..., 337493.94, 296771.4 ,
           278421.6 ], dtype=float32)
    • lat
      ()
      float32
      -2.25
      long_name :
      latitude
      units :
      degrees_north
      standard_name :
      latitude
      array(-2.25, dtype=float32)
    • lon
      ()
      float32
      -55.75
      standard_name :
      longitude
      long_name :
      longitude
      units :
      degrees_east
      array(-55.75, dtype=float32)
    • year
      (year)
      int64
      0 1 2 3 4 ... 1996 1997 1998 1999
      array([   0,    1,    2, ..., 1997, 1998, 1999])
Amazon_simulated_annual_df = Amazon_annual.drop(['lat','lon']).to_dataframe()
Amazon_simulated_annual_df.head()
Amazon_simulated_annual_df.to_csv('../Data/Amazon_annual_df.csv')

Obidos_simulated_annual_df = Obidos_annual.drop(['lat','lon']).to_dataframe()
Obidos_simulated_annual_df.head()
Obidos_simulated_annual_df.to_csv('../Data/Obidos_annual_df.csv')
discharge
year
0 287012.71875
1 301987.78125
2 358596.53125
3 349216.28125
4 295950.96875
discharge
year
0 237567.187500
1 241490.000000
2 267892.093750
3 286408.937500
4 234192.484375