Web application to explore carbon budgets
The web application is written with SveltKit.
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.txtThe 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:appYou'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 -- --openThe code is formatted with Prettier using
npm run formatThe code can be linted, using Prettier and eslint, with
npm run lintThe code can be checked with
npm run checkThe unit test can be run with
npm run test:unitFor coverage, run
npm run test:unit -- run --coverageTo create a production version of your app:
npm run buildYou can the production build with
node build/index.jsTo 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.