Skip to content

Cast the image ID in ConfigData before formatting the image name - #142

Merged
kriboe90 merged 1 commit into
FireDynamics:masterfrom
ManuelOsburg:fix/img-name-format-in-config
Oct 26, 2026
Merged

kriboe90 merged 1 commit into
FireDynamics:masterfrom
ManuelOsburg:fix/img-name-format-in-config

Conversation

@ManuelOsburg

Copy link
Copy Markdown
Contributor

Problem

The ConfigData docstring and the prompt for the image names recommend a format spec such as img{:04d}.jpg for the zero padded IDs most cameras write (DSC_0001.CR3). init_functions and DataExtractor cast the ID to int before formatting. ConfigData.get_start_time and ConfigData.in_time_diff_to_img_time pass the ID as read from config.ini, which is a string. With a format spec they fail:

ValueError: Unknown format code 'd' for object of type 'str'

get_start_time is called whenever start_time is None, i.e. it is taken from the first image, which is the default. So step 3 stops for every padded template unless start_time is set by hand. in_time_diff_to_img_time fails in the same way when the clock offset is computed from a time reference image given by time_ref_img_id.

Change

int(...) on the ID in both places, as in init_functions and DataExtractor.

For a plain {} template the name only changes if the ID in config.ini is written with leading zeros (0001). It is then img1.jpg instead of img0001.jpg. That is the name init_functions already uses for all experiment images, so this combination did not work before either, and no working setup changes.

Tests

New suite 09_test_image_names.robot. The test images are renamed to test_img_0001.jpg … and img_name_string = test_img_{:04d}.jpg is used. Two cases:

  • the start time is taken from the first image;
  • the clock offset comes from a time reference image given by its ID (time_ref_img_id = 1, time_ref_img_time = 12:00:00). The offset comes out as 0.0, computed from test_img_0001.jpg.

Both run S1–S3, check that the four padded images are analysed and that the linear extinction coefficients match the ground truth (rmse 0.014 / 0.016 / 0.022 < 0.05).

Observation, not changed here

The second test sets time_ref_img_id explicitly, because the config template writes the option as time_img_id, while the code reads time_ref_img_id. As a consequence:

  • time_img_id set in config.ini, as the template suggests, is ignored. If exif_time_infront_real_time is not set, the user is asked for the ID instead.
  • If the time reference image is given by time_ref_img_file and the config has no time_ref_img_id, in_time_diff_to_img_time raises KeyError: 'time_ref_img_id', because it indexes the option directly.

Both are the same on master; I reproduced them there. A fix would write time_ref_img_id into the template, read the option with a fallback, and still accept time_img_id from existing configs. I left it out to keep this PR small; happy to add it here or open a separate PR, whichever you prefer.

The config documents a format spec such as img{:04d}.jpg for the zero
padded IDs most cameras write, and init_functions and DataExtractor cast
the ID to int before formatting. get_start_time and
in_time_diff_to_img_time passed the ID as read from config.ini, a
string, so with a format spec they failed with "ValueError: Unknown
format code 'd' for object of type 'str'" - get_start_time whenever the
start time is taken from the first image, which is the default. Cast
the ID there as well.

New acceptance suite 09 runs the workflow with zero padded test images
and img_name_string = test_img_{:04d}.jpg, once with the start time from
the first image and once with the clock offset from a time reference
image given by its ID. Without the fix both stop with the ValueError
above.
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.

2 participants