Skip to content

Function for downloading zenodo calibration#135

Merged
ameligrana merged 6 commits intobancaditalia:mainfrom
ViennaInstitute:function-for-downloading-zenodo-calibration
Mar 10, 2026
Merged

Function for downloading zenodo calibration#135
ameligrana merged 6 commits intobancaditalia:mainfrom
ViennaInstitute:function-for-downloading-zenodo-calibration

Conversation

@zauster
Copy link
Contributor

@zauster zauster commented Feb 19, 2026

Builds on PR #134

Usage:

at = download_zenodo_calibration_object("AT");
import BeforeIT as Bit
parameters, initial_conditions = Bit.get_params_and_initial_conditions(at, Bit.DateTime(2020, 03, 31);
    scale = 1 / 1000)
model = Bit.Model(parameters, initial_conditions)

SGHoekstra and others added 4 commits February 19, 2026 13:54
Also includes the utility function 'get_valid_calibration_quarters' that
can be used to retrieve a list of all (YEAR, QUARTER) pairs for which
this calibration object can be used.
Adds comprehensive unit tests for the integration between
download_zenodo_calibration_object and get_params_and_initial_conditions.
Tests cover basic functionality, data validation, error handling,
and multi-country support.
Fixes compatibility issues between ITALY_CALIBRATION (old format) and Zenodo calibration (new format):

1. Fixed CartesianIndex extraction: findall() returns CartesianIndex objects that need
   to be converted to integers before use as array indices.

2. Fixed capital_consumption calculation: Zenodo format has pre-computed sectoral data,
   but ITALY_CALIBRATION requires runtime calculation from scalar inputs using the
   original formula: nace64_capital_consumption ./ nominal_nace64_output .* output

3. Fixed employers_social_contributions calculation: Handles both sectoral wages
   (Zenodo format) and scalar wages (ITALY_CALIBRATION format) by estimating sectoral
   contributions from scalar data when needed.

These changes ensure backward compatibility with existing ITALY_CALIBRATION while
maintaining support for the new Zenodo calibration format.
@zauster zauster force-pushed the function-for-downloading-zenodo-calibration branch from 4a1b4d2 to 43f1fe2 Compare February 24, 2026 14:26
@zauster
Copy link
Contributor Author

zauster commented Feb 25, 2026

@aldoglielmo @ameligrana reviewable now

@ameligrana
Copy link
Collaborator

ameligrana commented Mar 1, 2026

Very nice! It seems to work pretty well.

I found some issues though when using with "LU" and "MT" with the code

import BeforeIT as Bit

for country in Bit.AVAILABLE_COUNTRIES
	try
		co = Bit.download_zenodo_calibration_object(country)
		parameters, initial_conditions = Bit.get_params_and_initial_conditions(co, Bit.DateTime(2020, 03, 31);
		    scale = 1 / 1000)
		model = Bit.Model(parameters, initial_conditions)
		Bit.step!(model)
	catch e
		println(country)
		println(e)
	end
end

the stepping throws with InexactError(:Int64, (Int64, NaN)). I did some brief debugging and I found that parameters["alpha_s"] has some zeroes, and this is in turn due to output in get_params_and_initial_conditions being 0 for some sectors, which is strange. Maybe though this is actually a problem in the model, not the calibration, which can't deal with this initial conditions, given that those countries are very small, they could be true zeroes.

@ameligrana ameligrana merged commit 4e08397 into bancaditalia:main Mar 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants