cetk 0.0.4.dev0__tar.gz → 0.0.6.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/.pre-commit-config.yaml +9 -11
  2. cetk-0.0.6.dev0/MANIFEST.in +3 -0
  3. cetk-0.0.6.dev0/PKG-INFO +93 -0
  4. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/README.md +8 -9
  5. cetk-0.0.6.dev0/constraints-lowest.txt +99 -0
  6. cetk-0.0.6.dev0/flatpak_install.sh +16 -0
  7. cetk-0.0.6.dev0/noxfile.py +97 -0
  8. cetk-0.0.6.dev0/pyproject.toml +67 -0
  9. cetk-0.0.6.dev0/requirements-dev.in +13 -0
  10. cetk-0.0.6.dev0/requirements-dev.txt +87 -0
  11. cetk-0.0.6.dev0/setup.cfg +4 -0
  12. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/__init__.py +5 -4
  13. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/db.py +1 -1
  14. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/cache.py +0 -1
  15. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/exporters.py +3 -3
  16. cetk-0.0.6.dev0/src/cetk/edb/fixtures/edb-ref.json +637 -0
  17. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/importers/codeset_import.py +14 -1
  18. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/importers/roadsource_import.py +20 -20
  19. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/importers/source_import.py +28 -0
  20. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/importers/timevar_import.py +2 -2
  21. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/importers/utils.py +1 -1
  22. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/migrations/0001_initial.py +7 -7
  23. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/models/base.py +0 -1
  24. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/models/common_models.py +14 -16
  25. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/models/gridsource_models.py +1 -2
  26. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/models/road_classes.py +1 -1
  27. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/models/road_models.py +1 -46
  28. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/models/source_models.py +0 -1
  29. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/rasterize/rasterizer.py +127 -99
  30. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/units.py +0 -1
  31. cetk-0.0.6.dev0/src/cetk/edb/utils.py +17 -0
  32. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/calc.py +6 -1
  33. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/filters.py +47 -71
  34. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/queries.py +21 -17
  35. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/views.py +2 -2
  36. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/logging.py +0 -1
  37. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/settings.py +3 -6
  38. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/tools/cetk_command.py +113 -29
  39. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/tools/utils.py +9 -2
  40. cetk-0.0.6.dev0/src/cetk.egg-info/PKG-INFO +93 -0
  41. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk.egg-info/SOURCES.txt +42 -5
  42. cetk-0.0.6.dev0/src/cetk.egg-info/requires.txt +11 -0
  43. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/conftest.py +215 -24
  44. cetk-0.0.6.dev0/tests/edb/data/TrafficImportFormat.xlsx +0 -0
  45. cetk-0.0.6.dev0/tests/edb/data/all_sources.xlsx +0 -0
  46. cetk-0.0.6.dev0/tests/edb/data/areasourceactivities.xlsx +0 -0
  47. cetk-0.0.6.dev0/tests/edb/data/areasources.xlsx +0 -0
  48. cetk-0.0.6.dev0/tests/edb/data/congestion_profiles.json +58 -0
  49. cetk-0.0.6.dev0/tests/edb/data/fleets.json +41 -0
  50. cetk-0.0.6.dev0/tests/edb/data/fleets.xlsx +0 -0
  51. cetk-0.0.6.dev0/tests/edb/data/gridsource_rasters/vasterbotten_conc_NOx_1990010100_1991010100.tif +0 -0
  52. cetk-0.0.6.dev0/tests/edb/data/gridsource_rasters/vasterbotten_conc_PM25_1990010100_1991010100.tif +0 -0
  53. cetk-0.0.6.dev0/tests/edb/data/gridsource_rasters/vasterbotten_conc_PM25_2000010100_2001010100.tif +0 -0
  54. cetk-0.0.6.dev0/tests/edb/data/gridsource_rasters/vasterbotten_conc_PM25_2011010100_2012010100.tif +0 -0
  55. cetk-0.0.6.dev0/tests/edb/data/gridsources.xlsx +0 -0
  56. cetk-0.0.6.dev0/tests/edb/data/gridsources_tmp.xlsx +0 -0
  57. cetk-0.0.6.dev0/tests/edb/data/pointsourceactivities.xlsx +0 -0
  58. cetk-0.0.6.dev0/tests/edb/data/pointsources.csv +6 -0
  59. cetk-0.0.6.dev0/tests/edb/data/pointsources.xlsx +0 -0
  60. cetk-0.0.6.dev0/tests/edb/data/roadclass_settings.xlsx +0 -0
  61. cetk-0.0.6.dev0/tests/edb/data/roadclasses.csv +3 -0
  62. cetk-0.0.6.dev0/tests/edb/data/roadclasses.json +22 -0
  63. cetk-0.0.6.dev0/tests/edb/data/roadclasses_1attr.csv +3 -0
  64. cetk-0.0.6.dev0/tests/edb/data/roadclasses_1attr.json +12 -0
  65. cetk-0.0.6.dev0/tests/edb/data/roaddata.gpkg +0 -0
  66. cetk-0.0.6.dev0/tests/edb/data/roads.json +16 -0
  67. cetk-0.0.6.dev0/tests/edb/data/roads.xlsx +0 -0
  68. cetk-0.0.6.dev0/tests/edb/data/sinuous_road.geojson +3 -0
  69. cetk-0.0.6.dev0/tests/edb/data/timevars.json +124 -0
  70. cetk-0.0.6.dev0/tests/edb/data/vehicle_settings.xlsx +0 -0
  71. cetk-0.0.6.dev0/tests/edb/data/vehicles.csv +9 -0
  72. cetk-0.0.6.dev0/tests/edb/data/vehicles.json +36 -0
  73. cetk-0.0.6.dev0/tests/edb/data/vehicles.xlsx +0 -0
  74. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/test_gridsource_models.py +31 -31
  75. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/test_importers.py +5 -13
  76. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/test_ltreefield.py +2 -1
  77. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/test_rasterize.py +29 -26
  78. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/test_road_classes.py +1 -2
  79. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/test_road_importers.py +21 -24
  80. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/test_road_models.py +0 -34
  81. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/emissions/test_aggregate_emissions.py +18 -7
  82. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/emissions/test_custom_sqlite_functions.py +0 -1
  83. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/emissions/test_gridsource_emissions.py +3 -3
  84. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/emissions/test_utils.py +0 -1
  85. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/test_db.py +2 -2
  86. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/tools/conftest.py +3 -3
  87. cetk-0.0.6.dev0/tests/tools/data/inventory.xlsx +0 -0
  88. cetk-0.0.6.dev0/tests/tools/data/validation.xlsx +0 -0
  89. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/tools/test_calculate.py +23 -30
  90. cetk-0.0.6.dev0/tests/tools/test_create.py +27 -0
  91. cetk-0.0.6.dev0/tests/tools/test_delete.py +25 -0
  92. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/tools/test_exports.py +1 -2
  93. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/tools/test_imports.py +1 -1
  94. cetk-0.0.6.dev0/windows_find_gdal.py +13 -0
  95. cetk-0.0.4.dev0/MANIFEST.in +0 -12
  96. cetk-0.0.4.dev0/PKG-INFO +0 -297
  97. cetk-0.0.4.dev0/compilereqs +0 -14
  98. cetk-0.0.4.dev0/pyproject.toml +0 -72
  99. cetk-0.0.4.dev0/requirements.txt +0 -488
  100. cetk-0.0.4.dev0/setup.cfg +0 -64
  101. cetk-0.0.4.dev0/src/cetk.egg-info/PKG-INFO +0 -297
  102. cetk-0.0.4.dev0/src/cetk.egg-info/not-zip-safe +0 -0
  103. cetk-0.0.4.dev0/src/cetk.egg-info/requires.txt +0 -15
  104. cetk-0.0.4.dev0/tests/tools/test_create.py +0 -9
  105. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/CONTRIBUTING.md +0 -0
  106. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/LICENSE +0 -0
  107. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/manage.py +0 -0
  108. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/__init__.py +0 -0
  109. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/apps.py +0 -0
  110. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/const.py +0 -0
  111. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/copy.py +0 -0
  112. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/importers/__init__.py +0 -0
  113. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/importers/activity_import.py +0 -0
  114. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/importers/gridsource_import.py +0 -0
  115. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/importers/validation.py +0 -0
  116. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/ltreefield.py +0 -0
  117. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/migrations/0002_data.py +0 -0
  118. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/migrations/0003_create_gpkg_tables.py +0 -0
  119. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/migrations/__init__.py +0 -0
  120. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/models/__init__.py +0 -0
  121. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/models/fleets.py +0 -0
  122. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/models/timevar_models.py +0 -0
  123. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/rasterize/__init__.py +0 -0
  124. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/signals.py +0 -0
  125. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/edb/traffic.py +0 -0
  126. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/__init__.py +0 -0
  127. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/aggregate_emissions.sql +0 -0
  128. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/areasource_emissions.sql +0 -0
  129. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/gridsource_emissions.sql +0 -0
  130. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/pointsource_emissions.sql +0 -0
  131. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/roadsource_emissions.sql +0 -0
  132. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/emissions/used_substances.sql +0 -0
  133. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/tools/__init__.py +0 -0
  134. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/tools/manage.py +0 -0
  135. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk/utils.py +0 -0
  136. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk.egg-info/dependency_links.txt +0 -0
  137. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk.egg-info/entry_points.txt +0 -0
  138. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/src/cetk.egg-info/top_level.txt +0 -0
  139. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/data/__init__.py +0 -0
  140. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/test_common_models.py +0 -0
  141. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/edb/test_fleets.py +0 -0
  142. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/emissions/__init__.py +0 -0
  143. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/emissions/test_areasource_emissions.py +0 -0
  144. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/emissions/test_pointsource_emissions.py +0 -0
  145. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/emissions/test_roadsource_emissions.py +0 -0
  146. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/tools/data/__init__.py +0 -0
  147. {cetk-0.0.4.dev0 → cetk-0.0.6.dev0}/tests/tools/test_info.py +0 -0
@@ -1,18 +1,16 @@
1
1
  repos:
2
- - repo: https://github.com/ambv/black
3
- rev: "22.8.0"
2
+ - repo: https://github.com/adamchainz/django-upgrade
3
+ rev: "1.25.0"
4
4
  hooks:
5
- - id: black
6
- - repo: https://github.com/pycqa/isort
7
- rev: "5.12.0"
5
+ - id: django-upgrade
6
+ - repo: https://github.com/astral-sh/ruff-pre-commit
7
+ rev: v0.11.11
8
8
  hooks:
9
- - id: isort
10
- - repo: https://github.com/pycqa/flake8
11
- rev: "5.0.4"
12
- hooks:
13
- - id: flake8
9
+ - id: ruff
10
+ args: [ --fix ]
11
+ - id: ruff-format
14
12
  - repo: https://github.com/pre-commit/pre-commit-hooks
15
- rev: "v4.3.0"
13
+ rev: "v5.0.0"
16
14
  hooks:
17
15
  - id: check-added-large-files
18
16
  args: ["--maxkb=600", "--enforce-all"]
@@ -0,0 +1,3 @@
1
+ prune .github
2
+ exclude .gitignore
3
+ exclude .gitlab-ci.yml
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: cetk
3
+ Version: 0.0.6.dev0
4
+ Summary: CLAIRs Emission ToolKit cetk
5
+ Author: Christian Asker, Mattias Jakobsson, David Segersson, Eef van Dongen
6
+ Maintainer-email: FO Luft <foluftadmin@smhi.se>
7
+ License-Expression: Apache-2.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: django<6,>=4.2
14
+ Requires-Dist: fiona>=1.8.18
15
+ Requires-Dist: geopandas>=0.12
16
+ Requires-Dist: netCDF4>=1.5.4
17
+ Requires-Dist: numpy>=1.20.3
18
+ Requires-Dist: openpyxl>=3.0.7
19
+ Requires-Dist: pandas>=2.0
20
+ Requires-Dist: pyogrio>=0.4.2
21
+ Requires-Dist: rastafari>=0.4
22
+ Requires-Dist: rasterio>=1.3
23
+ Requires-Dist: shapely>=2.0
24
+ Dynamic: license-file
25
+
26
+ # Emission ToolKit cetk
27
+
28
+ Emission toolkit for command line to import, validate, edit and analyse emissions.
29
+ Used in QGIS Plugin Eclair. This package is maintained by [Eef van Dongen][] at SMHI.
30
+
31
+ [Eef van Dongen]: mailto:eef.vandongen@smhi.se
32
+
33
+ ## Installation
34
+ ```
35
+ python3 -m venv --prompt cetk .venv
36
+ . .venv/bin/activate
37
+ python -m pip install -e .
38
+ ```
39
+ Check that installation was successful and receive information on how to use the toolkit:
40
+ ```
41
+ cetk -h
42
+ ```
43
+
44
+ Before using the toolkit, initialize the template database by:
45
+ ```
46
+ cetkmanage migrate
47
+ ```
48
+
49
+ If you did not change the default path, this should create
50
+ `~/.config/eclair/eclair.gpkg`
51
+
52
+ New databases can now be created by copying the template database. This is easiest done using the cetk command:
53
+ ```
54
+ cetk create /home/myuser/mydatabase.gpkg
55
+ ```
56
+
57
+ To use a specific database, set environment variable "CETK_DATABASE_PATH".
58
+ ```
59
+ export CETK_DATABASE_PATH="/home/myuser/mydatabase.gpkg"
60
+ ```
61
+
62
+ For more verbose logging, set environment variable CETK_DEBUG=1:
63
+ ```
64
+ export CETK_DEBUG=1
65
+ ```
66
+
67
+ ## Contributing
68
+
69
+ ### Environment
70
+ Install pre-commit hooks:
71
+
72
+ ```
73
+ . .venv/bin/activate
74
+ pip install -r requirements-dev.txt
75
+ pre-commit install
76
+ ```
77
+
78
+ ### Testing
79
+
80
+ Run tests with
81
+ ```
82
+ nox
83
+ ```
84
+
85
+ ### Update requirements
86
+
87
+ If any new development requirements are added to
88
+ [requirements-dev.in](requirements-dev.in), update
89
+ [requirements-dev.txt](requirements-dev.txt) by running
90
+
91
+ ```
92
+ nox -s requirements
93
+ ```
@@ -9,7 +9,6 @@ Used in QGIS Plugin Eclair. This package is maintained by [Eef van Dongen][] at
9
9
  ```
10
10
  python3 -m venv --prompt cetk .venv
11
11
  . .venv/bin/activate
12
- python -m pip install -r ./requirements.txt
13
12
  python -m pip install -e .
14
13
  ```
15
14
  Check that installation was successful and receive information on how to use the toolkit:
@@ -53,17 +52,17 @@ pre-commit install
53
52
 
54
53
  ### Testing
55
54
 
56
- Run tests by
55
+ Run tests with
57
56
  ```
58
- pytest
57
+ nox
59
58
  ```
59
+
60
60
  ### Update requirements
61
61
 
62
- Install pip-tools:
63
- ```
64
- pip install pip-tools
65
- ```
66
- Update requirements.txt and requirements-dev.txt by:
62
+ If any new development requirements are added to
63
+ [requirements-dev.in](requirements-dev.in), update
64
+ [requirements-dev.txt](requirements-dev.txt) by running
65
+
67
66
  ```
68
- ./compilereqs
67
+ nox -s requirements
69
68
  ```
@@ -0,0 +1,99 @@
1
+ # This file was autogenerated by uv via the following command:
2
+ # nox -s constraints-lowest
3
+ affine==2.4.0
4
+ # via rasterio
5
+ asgiref==3.8.1
6
+ # via django
7
+ attrs==25.3.0
8
+ # via
9
+ # fiona
10
+ # rasterio
11
+ certifi==2025.4.26
12
+ # via
13
+ # fiona
14
+ # pyogrio
15
+ # pyproj
16
+ # rasterio
17
+ cftime==1.6.4.post1
18
+ # via netcdf4
19
+ click==7.1.2
20
+ # via
21
+ # click-plugins
22
+ # cligj
23
+ # fiona
24
+ # rasterio
25
+ click-plugins==1.1.1
26
+ # via
27
+ # fiona
28
+ # rasterio
29
+ cligj==0.7.2
30
+ # via
31
+ # fiona
32
+ # rasterio
33
+ django==4.2
34
+ # via cetk (pyproject.toml)
35
+ et-xmlfile==2.0.0
36
+ # via openpyxl
37
+ fiona==1.8.18
38
+ # via
39
+ # cetk (pyproject.toml)
40
+ # geopandas
41
+ geopandas==0.12.1
42
+ # via cetk (pyproject.toml)
43
+ munch==4.0.0
44
+ # via fiona
45
+ netcdf4==1.5.4
46
+ # via cetk (pyproject.toml)
47
+ numpy==1.20.3
48
+ # via
49
+ # cetk (pyproject.toml)
50
+ # cftime
51
+ # netcdf4
52
+ # pandas
53
+ # pyogrio
54
+ # rastafari
55
+ # rasterio
56
+ # shapely
57
+ # snuggs
58
+ openpyxl==3.0.7
59
+ # via cetk (pyproject.toml)
60
+ packaging==25.0
61
+ # via geopandas
62
+ pandas==2.0.0
63
+ # via
64
+ # cetk (pyproject.toml)
65
+ # geopandas
66
+ pyogrio==0.4.2
67
+ # via cetk (pyproject.toml)
68
+ pyparsing==3.2.3
69
+ # via snuggs
70
+ pyproj==3.6.1
71
+ # via
72
+ # geopandas
73
+ # rastafari
74
+ python-dateutil==2.9.0.post0
75
+ # via pandas
76
+ pytz==2025.2
77
+ # via pandas
78
+ rastafari==0.4.0
79
+ # via cetk (pyproject.toml)
80
+ rasterio==1.3.0
81
+ # via cetk (pyproject.toml)
82
+ setuptools==80.9.0
83
+ # via rasterio
84
+ shapely==2.0.0
85
+ # via
86
+ # cetk (pyproject.toml)
87
+ # geopandas
88
+ six==1.17.0
89
+ # via
90
+ # fiona
91
+ # python-dateutil
92
+ snuggs==1.4.7
93
+ # via rasterio
94
+ sqlparse==0.5.3
95
+ # via django
96
+ typing-extensions==4.14.0
97
+ # via asgiref
98
+ tzdata==2025.2
99
+ # via pandas
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+ FLATPAK="org.qgis.qgis"
3
+
4
+ if [ ! $(flatpak run --command=python $FLATPAK -m pip --version | cut -d " " -f1) = "pip" ]; then
5
+ echo "downloading get-pip.py"
6
+ flatpak run --command=wget $FLATPAK https://bootstrap.pypa.io/get-pip.py
7
+ echo "installing pip"
8
+ flatpak run --command=python $FLATPAK get-pip.py --user
9
+ else
10
+ echo "found pip"
11
+ fi
12
+ flatpak run --command=python $FLATPAK -m pip install -r ./requirements-dev.txt
13
+ flatpak run --command=python $FLATPAK -m pip install -e .
14
+ flatpak override --env=PATH="/app/bin:/usr/bin:/var/data/python/bin" $FLATPAK --user
15
+ version=$(flatpak run --command=cetk $FLATPAK --version | cut -d " " -f2)
16
+ echo "successfully installed pip and cetk ${version} into flatpak"
@@ -0,0 +1,97 @@
1
+ """Nox configuration for cetk."""
2
+
3
+ import os
4
+ from pathlib import Path
5
+
6
+ import nox
7
+
8
+ nox.needs_version = ">=2024.03.02"
9
+ nox.options.default_venv_backend = "uv|virtualenv"
10
+ nox.options.sessions = ["django", "migrations", "test", "test-lowest"]
11
+
12
+ TEST_REQUIREMENTS = ["pytest", "pytest-cov", "pytest-django"]
13
+
14
+
15
+ @nox.session(name="requirements-dev")
16
+ def requirements_dev(session):
17
+ """Re-compile the development requirements"""
18
+ session.install("-c", "requirements-dev.txt", "uv")
19
+ pip_compile(session, "requirements-dev.txt", "requirements-dev.in")
20
+
21
+
22
+ @nox.session(name="constraints-lowest", python="3.9")
23
+ def constraints_lowest(session):
24
+ """Re-compile the constraints for the lowest allowed dependency versions"""
25
+ session.install("-c", "requirements-dev.txt", "uv")
26
+ session.run("rm", "-f", "constraints-lowest.txt", external=True)
27
+ pip_compile(
28
+ session,
29
+ "constraints-lowest.txt",
30
+ "pyproject.toml",
31
+ "--resolution",
32
+ "lowest-direct",
33
+ )
34
+
35
+
36
+ @nox.session
37
+ def django(session):
38
+ """Run Django's system checks"""
39
+ install_cetk(session)
40
+ session.run(
41
+ "python", "manage.py", "check", "--fail-level=WARNING", *session.posargs
42
+ )
43
+
44
+
45
+ @nox.session
46
+ def migrations(session):
47
+ """Check that the database migrations are up-to-date"""
48
+ install_cetk(session)
49
+ args = session.posargs or ["--check"]
50
+ session.run("python", "manage.py", "makemigrations", "--skip-checks", *args)
51
+
52
+
53
+ @nox.session
54
+ def test(session):
55
+ """Run the unit and regression tests"""
56
+ session.install("-c", "requirements-dev.txt", *TEST_REQUIREMENTS)
57
+ install_cetk(session)
58
+ session.run("pytest", *session.posargs)
59
+
60
+
61
+ @nox.session(name="test-lowest", python="3.9")
62
+ def test_lowest(session):
63
+ """Run the unit and regression tests with the lowest allowed versions."""
64
+ session.install("-c", "requirements-dev.txt", *TEST_REQUIREMENTS)
65
+ install_cetk(session, lowest_versions=True)
66
+ session.run(
67
+ "pytest",
68
+ "-Wdefault",
69
+ "-Wignore::DeprecationWarning",
70
+ "-Wignore::FutureWarning",
71
+ "-Wignore::PendingDeprecationWarning",
72
+ "-Wignore:numpy.ndarray size changed:RuntimeWarning",
73
+ *session.posargs,
74
+ )
75
+
76
+
77
+ def install_cetk(session, *, lowest_versions=False, use_wheel_in_ci=True):
78
+ constraints = ("-c", "constraints-lowest.txt") if lowest_versions else ()
79
+ if use_wheel_in_ci and "CI" in os.environ:
80
+ # in CI we install cetk from the built wheel
81
+ wheel = next(Path("./dist").glob("*.whl"))
82
+ session.install(*constraints, wheel)
83
+ else:
84
+ # otherwise cetk is installed in editable mode to allow `nox -R`
85
+ session.install(*constraints, "-e", ".")
86
+
87
+
88
+ def pip_compile(session, outputfile, *extra_args):
89
+ # fmt: off
90
+ session.run(
91
+ "uv", "pip", "compile",
92
+ "--quiet",
93
+ "--output-file", outputfile,
94
+ "--custom-compile-command", f"nox -s {session.name}",
95
+ *session.posargs, *extra_args,
96
+ )
97
+ # fmt: on
@@ -0,0 +1,67 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3", "setuptools-scm >= 8"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cetk"
7
+ authors = [
8
+ { name = "Christian Asker" },
9
+ { name = "Mattias Jakobsson" },
10
+ { name = "David Segersson" },
11
+ { name = "Eef van Dongen" },
12
+ ]
13
+ maintainers = [
14
+ { name = "FO Luft", email = "foluftadmin@smhi.se" },
15
+ ]
16
+ description = "CLAIRs Emission ToolKit cetk"
17
+ readme = "README.md"
18
+ requires-python = ">=3.9"
19
+ license = "Apache-2.0"
20
+ license-files = ["LICENSE"]
21
+ classifiers = [
22
+ "Programming Language :: Python :: 3",
23
+ "Topic :: Scientific/Engineering :: Atmospheric Science",
24
+ ]
25
+ dependencies = [ # Release date Comment
26
+ "django >=4.2,<6", # 2023-04-03 current LTS
27
+ "fiona >=1.8.18", # 2020-11-17 first version with cp39 wheel
28
+ "geopandas >=0.12", # 2022-10-24 first version with shapely 2 support
29
+ "netCDF4 >=1.5.4", # 2020-07-23 first version with cp39 wheel
30
+ "numpy >=1.20.3", # 2021-05-10 required by pandas 2.0.0
31
+ "openpyxl >=3.0.7", # 2021-03-09 required by pandas 2.0.0
32
+ "pandas >=2.0", # 2023-04-03 cetk import test fails with earlier versions
33
+ "pyogrio >=0.4.2", # 2022-10-06 cetk export test fails with earlier versions
34
+ "rastafari >=0.4",
35
+ "rasterio >=1.3", # 2022-07-06 rasterio.CRS is missing in earlier versions
36
+ "shapely >=2.0", # 2022-12-12 cetk calc --rasterize fails with earlier versions
37
+ ]
38
+ dynamic = ["version"]
39
+
40
+ [project.scripts]
41
+ cetk = "cetk.tools.cetk_command:main"
42
+ cetkmanage = "cetk.tools.manage:main"
43
+
44
+ [tool.coverage.run]
45
+ source = ["cetk"]
46
+ branch = true
47
+ omit = [
48
+ ]
49
+
50
+ [tool.mypy]
51
+ ignore_missing_imports = true
52
+
53
+ [tool.pytest.ini_options]
54
+ pythonpath = "tests"
55
+ DJANGO_SETTINGS_MODULE = "cetk.settings"
56
+ filterwarnings = [
57
+ "error",
58
+ "ignore:numpy\\.ndarray size changed:RuntimeWarning",
59
+ "ignore:CheckConstraint\\.check is deprecated:DeprecationWarning",
60
+ "ignore:coord_dim setter is deprecated:DeprecationWarning",
61
+ ]
62
+
63
+ [tool.ruff.lint]
64
+ extend-select = ["I", "RUF100"]
65
+
66
+ [tool.setuptools.dynamic]
67
+ version = { attr = "cetk.__version__" }
@@ -0,0 +1,13 @@
1
+ # CI/CD and development requirements for the Gadget
2
+ build
3
+ coverage[toml]
4
+ django >=4.2,<6
5
+ nox
6
+ pip-tools
7
+ pre-commit
8
+ pytest
9
+ pytest-cov
10
+ pytest-django
11
+ ruff
12
+ setuptools-scm
13
+ uv
@@ -0,0 +1,87 @@
1
+ # This file was autogenerated by uv via the following command:
2
+ # nox -s requirements-dev
3
+ argcomplete==3.6.2
4
+ # via nox
5
+ asgiref==3.8.1
6
+ # via django
7
+ attrs==25.3.0
8
+ # via nox
9
+ build==0.10.0
10
+ # via
11
+ # -r requirements-dev.in
12
+ # pip-tools
13
+ cfgv==3.4.0
14
+ # via pre-commit
15
+ click==8.1.7
16
+ # via pip-tools
17
+ colorlog==6.9.0
18
+ # via nox
19
+ coverage==7.3.0
20
+ # via
21
+ # -r requirements-dev.in
22
+ # pytest-cov
23
+ dependency-groups==1.3.1
24
+ # via nox
25
+ distlib==0.3.7
26
+ # via virtualenv
27
+ django==5.2.1
28
+ # via -r requirements-dev.in
29
+ filelock==3.12.3
30
+ # via virtualenv
31
+ identify==2.5.27
32
+ # via pre-commit
33
+ iniconfig==2.0.0
34
+ # via pytest
35
+ nodeenv==1.8.0
36
+ # via pre-commit
37
+ nox==2025.5.1
38
+ # via -r requirements-dev.in
39
+ packaging==24.1
40
+ # via
41
+ # build
42
+ # dependency-groups
43
+ # nox
44
+ # pytest
45
+ # setuptools-scm
46
+ pip==23.2.1
47
+ # via pip-tools
48
+ pip-tools==7.3.0
49
+ # via -r requirements-dev.in
50
+ platformdirs==3.10.0
51
+ # via virtualenv
52
+ pluggy==1.3.0
53
+ # via pytest
54
+ pre-commit==3.3.3
55
+ # via -r requirements-dev.in
56
+ pyproject-hooks==1.0.0
57
+ # via build
58
+ pytest==7.4.0
59
+ # via
60
+ # -r requirements-dev.in
61
+ # pytest-cov
62
+ # pytest-django
63
+ pytest-cov==4.1.0
64
+ # via -r requirements-dev.in
65
+ pytest-django==4.5.2
66
+ # via -r requirements-dev.in
67
+ pyyaml==6.0.1
68
+ # via pre-commit
69
+ ruff==0.11.11
70
+ # via -r requirements-dev.in
71
+ setuptools==69.1.1
72
+ # via
73
+ # nodeenv
74
+ # pip-tools
75
+ # setuptools-scm
76
+ setuptools-scm==8.3.1
77
+ # via -r requirements-dev.in
78
+ sqlparse==0.4.3
79
+ # via django
80
+ uv==0.7.9
81
+ # via -r requirements-dev.in
82
+ virtualenv==20.24.3
83
+ # via
84
+ # nox
85
+ # pre-commit
86
+ wheel==0.41.2
87
+ # via pip-tools
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,6 +1,6 @@
1
1
  """cetk, a python library for editing Clair emission inventories offline."""
2
2
 
3
- __version__ = "0.0.4.dev"
3
+ __version__ = "0.0.6.dev"
4
4
 
5
5
  import os
6
6
 
@@ -16,6 +16,7 @@ DEFAULT_SETTINGS = {
16
16
  "TIME_ZONE": "UTC",
17
17
  "USE_I18N": True,
18
18
  "USE_TZ": True,
19
+ "MAX_ERROR_MESSAGES": 10,
19
20
  }
20
21
 
21
22
  log = logging.getLogger(__name__)
@@ -67,10 +68,10 @@ def configure():
67
68
  "version": 1,
68
69
  "disable_existing_loggers": False,
69
70
  "formatters": {
70
- "cetk": {"format": "%(levelname)s: %(message)s"}, # noqa
71
+ "cetk": {"format": "%(levelname)s: %(message)s"},
71
72
  "cetk_debug": {
72
73
  "format": "%(asctime)s %(levelname)s: %(name)s %(message)s"
73
- }, # noqa
74
+ },
74
75
  },
75
76
  "handlers": {
76
77
  "console": {"class": "logging.StreamHandler", "formatter": "cetk"},
@@ -80,7 +81,7 @@ def configure():
80
81
  },
81
82
  },
82
83
  "loggers": {"cetk": cetk_logger},
83
- }
84
+ },
84
85
  )
85
86
  django.setup()
86
87
  log.debug("configured django")
@@ -23,7 +23,7 @@ def run_migrate(db_path=None):
23
23
  "cetkmanage",
24
24
  "shell",
25
25
  "-c",
26
- "import django;django.db.connection.cursor().execute('SELECT InitSpatialMetaData(1);')", # noqa: E501
26
+ "import django;django.db.connection.cursor().execute('SELECT InitSpatialMetaData(1);')",
27
27
  ],
28
28
  stdout=subprocess.PIPE,
29
29
  stderr=subprocess.PIPE,
@@ -38,7 +38,6 @@ class NotInCacheError(Exception):
38
38
 
39
39
 
40
40
  class EmissionCache:
41
-
42
41
  """An emission out-of-memory cache."""
43
42
 
44
43
  def __init__(self, querysets):
@@ -534,9 +534,9 @@ def create_source_sheet(
534
534
  for act in source.activities.all():
535
535
  activity_unit = Activity.objects.get(id=act.activity_id).unit
536
536
  activity_rate = activity_rate_unit_from_si(act.rate, activity_unit)
537
- source_activity_rates[
538
- Activity.objects.get(id=act.activity_id).name
539
- ] = activity_rate
537
+ source_activity_rates[Activity.objects.get(id=act.activity_id).name] = (
538
+ activity_rate
539
+ )
540
540
  act_row = [
541
541
  source_activity_rates[name] if name in source_activities else 0
542
542
  for name in activity_names