Last active
June 27, 2018 09:00
-
-
Save matteodefelice/c324f9c72005db8bbb867da658ec6066 to your computer and use it in GitHub Desktop.
Another CDS Toolbox app to visualise the PV Power Potential ERA5 reanalyses #CDSToolbox. To test the application add a new application in your toolbox workspace and copy & paste the following code. NOTE: the units in the colorbar are wrong (the potential is dimensionless) but I couldn't find a way to remove it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cdstoolbox as ct | |
@ct.application(title='PV Power Potential', | |
description = 'Computation of PV Power potential for a specific day using the dimensionless described in Mavromatakis et al. https://doi.org/10.1016/j.renene.2009.11.010', | |
abstract = 'Lorem Ipsum') | |
@ct.input.dropdown('show_year', values=range(2010, 2017)) | |
@ct.input.dropdown('region', values=['Europe', 'China']) | |
@ct.input.text('month', type = int, label='Month', default=7) | |
@ct.input.text('day', type = int, label='Day', default=1) | |
@ct.output.figure() | |
def plot_map(show_year, region, month, day): | |
ssr = ct.catalogue.retrieve( | |
'reanalysis-era5-single-levels', | |
{ | |
'variable': 'surface_solar_radiation_downwards', | |
'grid': ['0.5', '0.5'], | |
'area': '65/-20/30/45' if (region == 'Europe') else '60/75/15/135', | |
'product_type': 'reanalysis', | |
'year': show_year, | |
'month': month, | |
'day': day, | |
'time': ['06:00', '08:00', '10:00', '12:00','14:00','16:00', '18:00'], | |
}) | |
t2m = ct.catalogue.retrieve( | |
'reanalysis-era5-single-levels', | |
{ | |
'variable': '2m_temperature', | |
'grid': ['0.5', '0.5'], | |
'area': '65/-20/30/45' if (region == 'Europe') else '60/75/15/135', | |
'product_type': 'reanalysis', | |
'year': show_year, | |
'month': month, | |
'day': day, | |
'time': ['06:00', '08:00', '10:00', '12:00','14:00','16:00', '18:00'], | |
}) | |
tcell = ct.operator.add(ct.climate.daily_mean(t2m), ct.operator.mul(ct.climate.daily_mean(ssr), 1e-5)) | |
eta = ct.operator.add(ct.operator.mul(ct.operator.sub(tcell, 273.15+25), 0.0045), 1) | |
pvpot = ct.operator.mul(eta, ct.operator.div(ct.climate.daily_mean(ssr), 1000*3600)) | |
fig = ct.cdsplot.geomap(pvpot, pcolormesh_kwargs={'cmap': 'YlOrRd', 'levels':8, 'cbar_kwargs': {'label': 'PV Potential'}}) | |
return fig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment