Commit 5384a664 authored by Beatriz Recinos's avatar Beatriz Recinos
Browse files

generalising animation

parent e2f26730
......@@ -37,6 +37,12 @@ start_day = int(sys.argv[3])
month = int(sys.argv[4])
day_to_plot = int(sys.argv[5]) # From SLURM ARRAY
lat_bnds = [-50, -25]
lon_bnds = [100, 180]
extent = np.append(lon_bnds, lat_bnds)
print(extent)
# Define date arrays to process buoy data
start_date = datetime(year=year, month=start_month, day=start_day)
end_date = datetime(year=year, month=month, day=day_to_plot,
......@@ -105,14 +111,15 @@ for hour in hours_list_to_plot:
plot_end_date,
age_dic,
sst,
zonal_means)
zonal_means,
extent=extent)
# Plotting
f = plt.figure(figsize=(10, 16))
f = plt.figure(figsize=(10, 7))
sns.set_style("white")
ax = plt.axes(projection=crs.Mercator())
ax.set_extent([-90, -30, -65, -25], crs=crs.PlateCarree())
ax.set_extent(extent, crs=crs.PlateCarree())
# Plot cci sst day
cci_to_plot = daily_sst_zonal_mean.isel(time=len(sst.time)-1)
......@@ -143,7 +150,8 @@ for hour in hours_list_to_plot:
# \n ''cci-sst at buoy coords - cci-sst avg in a 2x2 gridbox \n '
weight='bold')
ax.set_title(plot_end_date)
f.suptitle(plot_end_date)
#ax.set_title()
plot_name = str(int(year)) + '_' + f"{str(int(month)):0>2}" \
+ f"{str(int(day_to_plot)):0>2}" + f"{str(int(hour)):0>2}"
......
......@@ -30,7 +30,8 @@ def process_hour_drift_from_start_to_end(df,
end_date,
age,
cci_data,
cci_zonal_mean):
cci_zonal_mean,
extent=None):
""" Gets buoy hourly data for selected dates, groups the data by date
and prepares extra sst averages for plotting.
......@@ -40,9 +41,11 @@ def process_hour_drift_from_start_to_end(df,
start_date: start days to plot (datetime.obj)
end_date: end days and hours to plot (datetime.obj)
age: dictionary of dates to plot with the corresponding ages
(marker sizes) for the scatter plot.
(marker sizes) for the scatter plot.
cci_data: xarray containing cci sst temperature
cci_zonal_mean: xarray containing cci sst temperature zonal mean
extent: let and lat coordinates for the extension of the map array of four
[lon_w, lon_e, lat_s, lat_n]
Returns
-------
......@@ -76,8 +79,16 @@ def process_hour_drift_from_start_to_end(df,
# Crop to plot lat and lon extend, this is not needed but is good for
# a speedy plot
day_df = day_df[day_df['lon'].between(-90, -30) &
day_df['lat'].between(-65, -25)]
if extent is None:
day_df = day_df
else:
assert len(extent) == 4
lon_w = extent[0]
lon_e = extent[1]
lat_s = extent[2]
lat_n = extent[3]
day_df = day_df[day_df['lon'].between(lon_w, lon_e) & day_df['lat'].between(lat_s, lat_n)]
# It is important when using interp that you convert to xarray!
yy = xr.DataArray(day_df.lat.values, dims='z')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment