Skip to content
Snippets Groups Projects
Commit d1249cef authored by Aiko Voigt's avatar Aiko Voigt
Browse files

Adds analysis plots of temperature and precipitation

parent 6e315993
No related branches found
No related tags found
No related merge requests found
......@@ -2,4 +2,7 @@ runs/amip/logfiles/
runs/slab4x-sun/logfiles/
runs/slab4x-vap/logfiles/
runs/slab4x/logfiles/
runs/slabctr/logfiles/
\ No newline at end of file
runs/slabctr/logfiles/
analysis/.ipynb_checkpoints/
analysis/__pycache__/
import xarray as xr
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# load yearly mean dataset
def load_yearmean_dataset(file: str, startdate: str):
ds = xr.load_dataset(file)
ds["time"] = pd.date_range(startdate, freq="ME", periods=ds.time.size)
return ds.groupby(ds.time.dt.year).mean()
# compute global mean
def globalmean(ds):
weights = np.cos(np.deg2rad(ds.lat))
weights.name = "weights"
ds_weighted = ds.weighted(weights)
return ds_weighted.mean(("lon", "lat"))
def beautify_timeseries(ax, yaxis0):
""" Makes plots of time series nicer in terms of axes and labeling"""
# adjust spines
ax = plt.gca()
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',yaxis0))
\ No newline at end of file
File added
File added
This diff is collapsed.
File added
File added
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment