Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/updates waterdemhist #67

Open
wants to merge 18 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use of fill algorithm to merge disputed territories in water demand h…
…istoric maps. Extended MSWX dataset to 1975
doc78 committed Nov 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 26cdc248e2ebe9142a0fb1c95151b71d55164c55
Original file line number Diff line number Diff line change
@@ -340,7 +340,10 @@ def main():
# Load MSWX air temperature data
mswx_monthly = np.zeros((mapsize_global[0],mapsize_global[1],12),dtype=np.single)*np.NaN
for month in np.arange(1,13):
dset = Dataset(os.path.join(config['mswx_folder'],'Past','Temp','Monthly',str(year)+str(month).zfill(2)+'.nc'))
if year<1979: #MSWX dataset starts from 1979
dset = Dataset(os.path.join(config['mswx_folder'],'Past','Temp','Monthly',str(1979)+str(month).zfill(2)+'.nc'))
else:
dset = Dataset(os.path.join(config['mswx_folder'],'Past','Temp','Monthly',str(year)+str(month).zfill(2)+'.nc'))
data = np.squeeze(np.array(dset.variables['air_temperature']))
mswx_monthly[:,:,month-1] = imresize_mean(data,mapsize_global)
mswx_avg = np.mean(mswx_monthly,axis=2)
Original file line number Diff line number Diff line change
@@ -731,7 +731,10 @@ def main():
ndays = monthrange(year,month)[1]
mswx_month = np.zeros((1800,3600,ndays),dtype=np.single)*np.NaN
for day in np.arange(1,ndays+1):
filepath = os.path.join(config['mswx_folder'],'Past','Temp','Daily',datetime(year,month,day).strftime('%Y%j')+'.nc')
if year<1979: #MSWX dataset starts from 1979
filepath = os.path.join(config['mswx_folder'],'Past','Temp','Daily',datetime(1979,month,day).strftime('%Y%j')+'.nc')
else:
filepath = os.path.join(config['mswx_folder'],'Past','Temp','Daily',datetime(year,month,day).strftime('%Y%j')+'.nc')
if os.path.isfile(filepath):
dset = Dataset(filepath)
mswx_month[:,:,day-1] = np.squeeze(np.array(dset.variables['air_temperature']))
4 changes: 2 additions & 2 deletions src/lisfloodutilities/water-demand-historic/tools.py
Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@ def load_country_code_map(filepath,mapsize):
assert (country_code_map_refmatrix[0]==-180) & (country_code_map_refmatrix[3]==90)

country_code_map = resize(country_code_map,mapsize,order=0,mode='edge',anti_aliasing=False)
country_code_map[country_code_map==158] = 156 # Add Taiwan to China
country_code_map[country_code_map==736] = 729 # South Sudan missing from map
# apply the fill algorithm to fill the gaps of the Disputed Territories (code>1000), so that the fill algorithm will set each pixel value to their nearest neighbour
country_code_map = fill(country_code_map, country_code_map>1000) # CR: check here: the fill algorithm includes also zero as a neighbour country code, so that isles and some land area will be replaced by ocean
country_code_map[country_code_map==0] = np.NaN

return country_code_map