Web application to explore carbon budgets
The web application is written with SveltKit.
Warning
This repo has been transferred to https://github.com/pbl-nl/ (private repo) where it was further tailored for production. A hosted instance is available at https://carbonbudgetexplorer.nl/.
Should have the following data files:
data/xr_dataread.nc
- NetCDF filedata/xr_policyscen.nc
- NetCDF filedata/xr_allow_<3 letter ISO countr code>.nc
- NetCDF file for each countrydata/xr_allow_<2030|2040|FC>.nc
- NetCDF filedata/ne_110m_admin_0_countries.geojson
- can be downloaded withnpm run download:borders
The API web service reads the NetCDF file and returns the data as JSON which is used in the web application.
It is written in Python using Flask and xarray.
Python dependencies can be installed with
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
The web service can be started with
gunicorn --bind 0.0.0.0:5000 --workers 4 'ws:app'
(Add --reload
argumment to reload on Python file changes)
In Windows gunicorn might not work. Then use waitress.
pip install waitress
waitress-serve --listen=127.0.0.1:5000 ws:app
You'll need node.js to run a local development server.
Once you've created a project and installed dependencies with npm install
(or pnpm install
or yarn
), start a development server:
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
The code is formatted with Prettier using
npm run format
The code can be linted, using Prettier and eslint, with
npm run lint
The code can be checked with
npm run check
The unit test can be run with
npm run test:unit
For coverage, run
npm run test:unit -- run --coverage
To create a production version of your app:
npm run build
You can the production build with
node build/index.js
To deploy your app, you may need to install an adapter for your target environment.
If the Python webservice is not running on http://127.0.0.1:5000
then set CABE_API_URL
environment variable to right URL.