diff --git a/azmp_genReport2024.py b/azmp_genReport2024.py index 9488a12..b3b614e 100644 --- a/azmp_genReport2024.py +++ b/azmp_genReport2024.py @@ -65,8 +65,16 @@ ## ---- 2023 update ---- ## # 0. Update CASTS and CABOTS. -# (separate scripts) - +# (separate scripts) + +# Update CASTS from FRDR if wanted +print('Would you like to update CASTS? [yes/no]') +CASTS_up = input() +if CASTS_up == 'yes': + azgen.CASTS_update(years=np.arange(1912,int(yoi)).astype(str),version='CASTS_2023') +elif 'no': + print('No update to CASTS made.') + # 1. NAO, AO, AMO azgen.nao(int(yoi),'~/data/AZMP/climate_indices/nao_data.csv') diff --git a/azmp_modules/azmp_genreport.py b/azmp_modules/azmp_genreport.py index 9fd8341..d05208a 100644 --- a/azmp_modules/azmp_genreport.py +++ b/azmp_modules/azmp_genreport.py @@ -23,6 +23,7 @@ __version__ = '0.1' import os +import wget import re import numpy as np import pandas as pd @@ -44,7 +45,26 @@ os.environ['PROJ_LIB'] = '/home/cyrf0006/anaconda3/share/proj' #from mpl_toolkits.basemap import Basemap - + + +def CASTS_update( + years, + version, + out_path='~/data/CASTS/', + url='https://g-772fa5.cd4fe.0ec8.data.globus.org/1/published/publication_734/submitted_data/',): + ''' + Update CASTS using wget directly from FRDR. + Dowloads the yearly files for specified years. + ''' + for year in years: + if os.path.exists(os.path.expanduser(out_path+year+'.nc')): + os.remove(url+version+'/'+year+'.nc') + wget.download( + url+version+'/'+year+'.nc', + os.path.expanduser(out_path)) + print(year+' CASTS files updated.') + + def nao( YEAR, nao_file_loc, diff --git a/azmp_modules/azmp_report_tools.py b/azmp_modules/azmp_report_tools.py index e7ce0f2..fde3a6d 100644 --- a/azmp_modules/azmp_report_tools.py +++ b/azmp_modules/azmp_report_tools.py @@ -3927,6 +3927,9 @@ def bottomS_scorecards(path, years, clim_year=[2006, 2021]): df = df[(df.index.year>=years[0]) & (df.index.year<=years[-1])] percent_coverage = df.S_percent_coverage.values.copy().round(0) # Flag bad years (no or weak sampling): + bad_years = np.array([1981, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 2020, 2023]) + for i in bad_years: + df[df.index.year==i]=np.nan bad_years = df.index.year.values[percent_coverage < 80] for i in bad_years: df[df.index.year==i]=np.nan