Skip to content

Commit

Permalink
Use of fill algorithm to merge disputed territories in water demand h…
Browse files Browse the repository at this point in the history
…istoric maps. Extended MSWX dataset to 1975
  • Loading branch information
doc78 committed Nov 19, 2024
1 parent a519236 commit 26cdc24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']))
Expand Down
4 changes: 2 additions & 2 deletions src/lisfloodutilities/water-demand-historic/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 26cdc24

Please sign in to comment.