Skip to content
Snippets Groups Projects
Commit 1d0837f3 authored by Fraser William Goldsworth's avatar Fraser William Goldsworth Committed by Fraser William Goldsworth
Browse files

epdates to allow ccrs projection objects

parent 9a6469c4
No related branches found
No related tags found
No related merge requests found
......@@ -5,20 +5,6 @@ import numpy as np
# --- reading data
from netCDF4 import Dataset, num2date
import datetime
<<<<<<< HEAD
=======
# --- plotting
import matplotlib.pyplot as plt
import matplotlib
from matplotlib import ticker
#import my_toolbox as my
import cartopy
import cartopy.crs as ccrs
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
import cmocean
# --- debugging
from ipdb import set_trace as mybreak
>>>>>>> 190700b (pyicon_quickplots.py: Allow for saving timeseries data with dates outside of 1678 - 2262 date range by converting the time coordinates which is used for saving netcdf data to a cftime object.)
import pyicon as pyic
import xarray as xr
import cftime
......@@ -380,7 +366,6 @@ def qp_timeseries(IcD, fname, vars_plot,
omit_last_file=True,
use_tave_int_for_ts=False,
fpath_ref_data_atm='',
do_plot_atm_ref_ts=False,
do_djf=False,
do_jja=False,
mode_ave=['mean'],
......@@ -427,7 +412,7 @@ def qp_timeseries(IcD, fname, vars_plot,
# --- prepare time averaging
times_plot = np.copy(times)
if do_plot_atm_ref_ts and fpath_ref_data_atm!='':
if fpath_ref_data_atm != '':
# save times for validation with ERA5/CERES/GPM
times_exp = np.copy(times)
if ave_freq>0:
......@@ -435,7 +420,7 @@ def qp_timeseries(IcD, fname, vars_plot,
nskip = times.size%ave_freq
if nskip>0:
times = times[:-nskip]
if do_plot_atm_ref_ts and fpath_ref_data_atm!='':
if fpath_ref_data_atm != '':
# save times for validation with ERA5/CERES/GPM
times_exp = times_exp[:-nskip]
# define time bounds for correct time averaging
......@@ -534,7 +519,7 @@ def qp_timeseries(IcD, fname, vars_plot,
data = data.max(axis=0)
# --- read corresponding ERA5/CERES/GPM data
if do_plot_atm_ref_ts and fpath_ref_data_atm!='':
if fpath_ref_data_atm != '':
# get name of reference data set
if 'era5' in fpath_ref_data_atm:
refname = 'ERA5'
......@@ -670,7 +655,7 @@ def qp_timeseries(IcD, fname, vars_plot,
# --- modify data if var_fac or var_add are given
data *= var_fac
data += var_add
if do_plot_atm_ref_ts and fpath_ref_data_atm!='':
if fpath_ref_data_atm != '':
data_ref *= var_fac
data_ref += var_add
......@@ -678,11 +663,11 @@ def qp_timeseries(IcD, fname, vars_plot,
times_plot = times_plot[slice(lstart,lend)]
data = data[slice(lstart,lend)]
dtsum = dtsum[slice(lstart,lend)]
if do_plot_atm_ref_ts and fpath_ref_data_atm!='':
if fpath_ref_data_atm != '':
data_ref = data_ref[slice(lstart,lend)]
# --- define labels
if do_plot_atm_ref_ts and fpath_ref_data_atm!='':
if fpath_ref_data_atm != '':
label1 = 'exp'
label2 = 'era5'
if 'ceres' in fpath_ref_data_atm:
......@@ -696,7 +681,7 @@ def qp_timeseries(IcD, fname, vars_plot,
label = labels[mm]
# --- finally plotting
if do_plot_atm_ref_ts and fpath_ref_data_atm!='':
if fpath_ref_data_atm != '':
hl1, = ax.plot(times_plot, data, color='blue', label=label1)
hl2, = ax.plot(times_plot, data_ref, color='black', label=label2)
else:
......@@ -726,7 +711,7 @@ def qp_timeseries(IcD, fname, vars_plot,
ax.set_title(title)
# --- legend
if len(vars_plot)>1 or (do_plot_atm_ref_ts and fpath_ref_data_atm!=''):
if len(vars_plot)>1 or fpath_ref_data_atm != '':
ax.legend()
# --- vertical lines indicating time frame
......@@ -739,7 +724,7 @@ def qp_timeseries(IcD, fname, vars_plot,
if do_write_data_range:
ind = (times_plot>=t1) & (times_plot<=t2)
data_mean = (data[ind]*dtsum[ind]).sum()/dtsum[ind].sum()
if do_plot_atm_ref_ts and fpath_ref_data_atm!='':
if fpath_ref_data_atm != '':
data_ref_mean = (data_ref[ind]*dtsum[ind]).sum()/dtsum[ind].sum()
try:
refname = 'era5'
......@@ -768,7 +753,7 @@ def qp_timeseries(IcD, fname, vars_plot,
FigInf = dict()
Dhandles = dict()
Dhandles['ax'] = ax
if do_plot_atm_ref_ts and fpath_ref_data_atm!='':
if fpath_ref_data_atm != '':
Dhandles['hl1'] = hl1
Dhandles['hl2'] = hl2
else:
......
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