From 6ae9e5f9483d5a83c15476bfc5baa86d50840b5b Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Thu, 28 Nov 2024 23:46:32 +0100 Subject: [PATCH] Update get_parameters_and_initial_conditions.jl --- .../get_parameters_and_initial_conditions.jl | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/examples/get_parameters_and_initial_conditions.jl b/examples/get_parameters_and_initial_conditions.jl index e0a20e3..cc946ce 100644 --- a/examples/get_parameters_and_initial_conditions.jl +++ b/examples/get_parameters_and_initial_conditions.jl @@ -3,21 +3,23 @@ import BeforeIT as Bit using Dates, FileIO - -# We start from loading the calibration oject for italy, which contains 4 datasets: calibration_data, figaro, data, and ea -# These are saved within BeforeIT for the Italian case, and would need to be appropriately generated for other countries +# We start from loading the calibration object for italy, which contains +# 4 datasets: `calibration_data`, `figaro`, `data`, and `ea`. These are +# saved within `BeforeIT.jl` for the Italian case, and would need to be +# appropriately generated for other countries. cal = Bit.ITALY_CALIBRATION - fieldnames(typeof(cal)) -# These are essentually 4 dictionaries with well defined keys, such as +# These are essentially 4 dictionaries with well defined keys, such as + println(keys(cal.calibration)) println(keys(cal.figaro)) println(keys(cal.data)) println(keys(cal.ea)) # The object also contains two time variables related to the data + println(cal.max_calibration_date) println(cal.estimation_date) @@ -26,19 +28,18 @@ println(cal.estimation_date) calibration_date = DateTime(2010, 03, 31) parameters, initial_conditions = Bit.get_params_and_initial_conditions(cal, calibration_date; scale = 0.01) -# In sgeneral, we might want to repeat this operation for multiple quarters. -# In the following, we loop over all quarters from 2010Q1 to 2019Q4 +# In general, we might want to repeat this operation for multiple quarters. +# In the following, we loop over all quarters from `2010Q1` to `2019Q4` # and save the parameters and initial conditions in separate files. # We can then load these files later to run the model for each quarter. + start_calibration_date = DateTime(2010, 03, 31) end_calibration_date = DateTime(2019, 12, 31) for calibration_date in collect(start_calibration_date:Dates.Month(3):end_calibration_date) params, init_conds = Bit.get_params_and_initial_conditions(cal, calibration_date; scale = 0.0005) save( - "data/" * - "italy/" * - "/parameters/" * + "data/italy/parameters/" * string(year(calibration_date)) * "Q" * string(Dates.quarterofyear(calibration_date)) * @@ -46,9 +47,7 @@ for calibration_date in collect(start_calibration_date:Dates.Month(3):end_calibr params, ) save( - "data/" * - "italy/" * - "/initial_conditions/" * + "data/italy/initial_conditions/" * string(year(calibration_date)) * "Q" * string(Dates.quarterofyear(calibration_date)) *