Skip to content

Commit

Permalink
added the ability to update CASTS from FRDR
Browse files Browse the repository at this point in the history
  • Loading branch information
jn533213 committed Oct 23, 2024
1 parent ce330f3 commit 5179fbe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
12 changes: 10 additions & 2 deletions azmp_genReport2024.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
22 changes: 21 additions & 1 deletion azmp_modules/azmp_genreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
__version__ = '0.1'

import os
import wget
import re
import numpy as np
import pandas as pd
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions azmp_modules/azmp_report_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5179fbe

Please sign in to comment.