Choose images_per_file from the acquisition when it is not given

The value means three different things at once. It is the unit of writer
parallelism - whole files go round-robin to the writers,
(image_number / images_per_file) % socket.size() in ZMQStream2Pusher::SendImage
and TCPStreamPusher - it multiplies writer memory linearly, since every data-file
plugin reserves per file, and it decides whether a legacy master is readable at
all, because dxtbx follows only the first data file of one.

That last point is what makes a flat default wrong. Measured with DIALS on a
2500-image rotation sweep written as legacy: split into five files it reports
2500 images and then raises IndexError beyond image 499, so it half-works
silently; in one file all 2500 read. AutoPROC does not read VDS, so legacy has to
stay the default, which leaves the file count as the only lever.

So make it optional and resolve it from the acquisition. A rotation sweep of at
most 20000 images goes into one data file - rotation datasets are small enough,
and one writer keeps up with them. A grid scan splits on whole fast-axis rows, so
a file is a meaningful piece of the grid. Stills and serial keep 1000, where the
image count far exceeds it and the parallelism and the bounded writer memory are
what matter. An explicit value is always taken literally.

GetImagesPerFile is the single place this is resolved, and it must always return
a fixed non-zero number, because everything downstream - receiver, pusher, puller,
writer - requires one. That was already true of the old 0 = "one file" spelling;
0 is now gone from the API and omitting the field says the same thing better.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
leonarski_fandClaude Opus 5 committed 2026-08-22 21:57:12 +02:00
1 parent 259b43154e
commit 1f4f77fe42
15 files changed
+133 -30

No files matched your search

+2 -1
View File
@@ -675,7 +675,8 @@ DatasetSettings Convert(const org::openapitools::server::model::Dataset_settings
ret.SampleName(input.getSampleName());
ret.HeaderAppendix(input.getHeaderAppendix());
ret.ImageAppendix(input.getImageAppendix());
ret.ImagesPerFile(input.getImagesPerFile());
if (input.imagesPerFileIsSet())
ret.ImagesPerFile(input.getImagesPerFile());
if (input.dataReductionFactorSerialmxIsSet())
ret.LossyCompressionSerialMX(input.getDataReductionFactorSerialmx());
+3 -3
View File
@@ -33,7 +33,7 @@ Dataset_settings::Dataset_settings()
m_Incident_energy_keV = 0.0f;
m_File_prefix = "";
m_File_prefixIsSet = false;
m_Images_per_file = 1000L;
m_Images_per_file = 0L;
m_Images_per_fileIsSet = false;
m_Space_group_number = 0L;
m_Space_group_numberIsSet = false;
@@ -192,10 +192,10 @@ bool Dataset_settings::validate(std::stringstream& msg, const std::string& pathP
const std::string currentValuePath = _pathPrefix + ".imagesPerFile";
if (value < 0ll)
if (value < 1ll)
{
success = false;
msg << currentValuePath << ": must be greater than or equal to 0;";
msg << currentValuePath << ": must be greater than or equal to 1;";
}
}
+1 -1
View File
@@ -113,7 +113,7 @@ public:
bool filePrefixIsSet() const;
void unsetFile_prefix();
/// <summary>
/// Number of files in a single HDF5 data file (0 &#x3D; write all images to a single data file).
/// Number of images in a single HDF5 data file, taken literally when given. If omitted, it is chosen from the acquisition: a rotation sweep of at most 20000 images goes into a single data file, so the dataset stays readable by programs that follow only the first data file of a legacy master; a grid scan is split on a whole number of fast-axis rows; anything else (stills, serial) uses 1000.
/// </summary>
int64_t getImagesPerFile() const;
void setImagesPerFile(int64_t const value);
+7 -3
View File
@@ -429,9 +429,13 @@ components:
images_per_file:
type: integer
format: int64
minimum: 0
default: 1000
description: Number of files in a single HDF5 data file (0 = write all images to a single data file).
minimum: 1
description: |
Number of images in a single HDF5 data file, taken literally when given.
If omitted, it is chosen from the acquisition: a rotation sweep of at most 20000 images
goes into a single data file, so the dataset stays readable by programs that follow only
the first data file of a legacy master; a grid scan is split on a whole number of fast-axis
rows; anything else (stills, serial) uses 1000.
space_group_number:
type: integer
format: int64
+7 -3
View File
@@ -453,7 +453,11 @@ Beam center in X direction [pixels]</p>
</div></div></div></td></tr><tr class=""><td class="sc-dLMFU sc-eldPxv hZbWKe jXkfaY" kind="field" title="incident_energy_keV"><span class="sc-gFqAkR eRqgPI"></span><span class="property-name">incident_energy_keV</span><div class="sc-Nxspf sc-hRJfrW cXxAXt kYVhSL">required</div></td><td class="sc-fPXMVe bAXEAa"><div><div><span class="sc-Nxspf sc-cfxfcM cXxAXt jrGEaR"></span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr">number</span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr"> <!-- -->&lt;<!-- -->float<!-- -->&gt;<!-- --> </span><span> <span class="sc-Nxspf sc-fxwrCY cXxAXt eMVOei"> <!-- -->[ 0.001 .. 500 ]<!-- --> </span></span></div> <div><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Used to calculate /entry/beam/incident_wavelength in NXmx
Incident particle (photon, electron) energy in keV</p>
</div></div></div></td></tr><tr class=""><td class="sc-dLMFU sc-eldPxv hZbWKe jXkfaY" kind="field" title="file_prefix"><span class="sc-gFqAkR eRqgPI"></span><span class="property-name">file_prefix</span></td><td class="sc-fPXMVe bAXEAa"><div><div><span class="sc-Nxspf sc-cfxfcM cXxAXt jrGEaR"></span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr">string</span></div><div><span class="sc-Nxspf cXxAXt"> <!-- -->Default:<!-- --> </span> <span class="sc-Nxspf sc-ddjGPC cXxAXt jZOCAW">&quot;&quot;</span></div> <div><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Prefix for filenames. If left empty, no file will be saved.</p>
</div></div></div></td></tr><tr class=""><td class="sc-dLMFU sc-eldPxv hZbWKe jXkfaY" kind="field" title="images_per_file"><span class="sc-gFqAkR eRqgPI"></span><span class="property-name">images_per_file</span></td><td class="sc-fPXMVe bAXEAa"><div><div><span class="sc-Nxspf sc-cfxfcM cXxAXt jrGEaR"></span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr">integer</span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr"> <!-- -->&lt;<!-- -->int64<!-- -->&gt;<!-- --> </span><span> <span class="sc-Nxspf sc-fxwrCY cXxAXt eMVOei"> <!-- -->&gt;= 0<!-- --> </span></span></div><div><span class="sc-Nxspf cXxAXt"> <!-- -->Default:<!-- --> </span> <span class="sc-Nxspf sc-ddjGPC cXxAXt jZOCAW">1000</span></div> <div><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Number of files in a single HDF5 data file (0 = write all images to a single data file).</p>
</div></div></div></td></tr><tr class=""><td class="sc-dLMFU sc-eldPxv hZbWKe jXkfaY" kind="field" title="images_per_file"><span class="sc-gFqAkR eRqgPI"></span><span class="property-name">images_per_file</span></td><td class="sc-fPXMVe bAXEAa"><div><div><span class="sc-Nxspf sc-cfxfcM cXxAXt jrGEaR"></span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr">integer</span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr"> <!-- -->&lt;<!-- -->int64<!-- -->&gt;<!-- --> </span><span> <span class="sc-Nxspf sc-fxwrCY cXxAXt eMVOei"> <!-- -->&gt;= 1<!-- --> </span></span></div> <div><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Number of images in a single HDF5 data file, taken literally when given.
If omitted, it is chosen from the acquisition: a rotation sweep of at most 20000 images
goes into a single data file, so the dataset stays readable by programs that follow only
the first data file of a legacy master; a grid scan is split on a whole number of fast-axis
rows; anything else (stills, serial) uses 1000.</p>
</div></div></div></td></tr><tr class=""><td class="sc-dLMFU sc-eldPxv hZbWKe jXkfaY" kind="field" title="space_group_number"><span class="sc-gFqAkR eRqgPI"></span><span class="property-name">space_group_number</span></td><td class="sc-fPXMVe bAXEAa"><div><div><span class="sc-Nxspf sc-cfxfcM cXxAXt jrGEaR"></span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr">integer</span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr"> <!-- -->&lt;<!-- -->int64<!-- -->&gt;<!-- --> </span><span> <span class="sc-Nxspf sc-fxwrCY cXxAXt eMVOei"> <!-- -->[ 1 .. 194 ]<!-- --> </span></span></div> <div><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Number of space group for the crystal. Currently used solely as metadata, not relevant for image processing done in Jungfraujoch.</p>
</div></div></div></td></tr><tr class=""><td class="sc-dLMFU sc-eldPxv hZbWKe jXkfaY" kind="field" title="sample_name"><span class="sc-gFqAkR eRqgPI"></span><span class="property-name">sample_name</span></td><td class="sc-fPXMVe bAXEAa"><div><div><span class="sc-Nxspf sc-cfxfcM cXxAXt jrGEaR"></span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr">string</span></div><div><span class="sc-Nxspf cXxAXt"> <!-- -->Default:<!-- --> </span> <span class="sc-Nxspf sc-ddjGPC cXxAXt jZOCAW">&quot;&quot;</span></div> <div><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>/entry/sample/name in NXmx
Sample name</p>
@@ -512,7 +516,7 @@ Assuming that Smargon is used as static positioner and not moving during the sca
</div></button></div><div><button class="sc-kzqdkY bXzzUN"><svg class="sc-cwHptR cSkZlF" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg><strong class="sc-dSIIpw bpEYcE">400<!-- --> </strong><div class="sc-eeDRCY sc-eBMEME sc-dCFHLb gTGgei kekOtA kCaLQd"><p>Input parsing or validation error</p>
</div></button></div><div><button class="sc-kzqdkY bXzzUN"><svg class="sc-cwHptR cSkZlF" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg><strong class="sc-dSIIpw bpEYcE">500<!-- --> </strong><div class="sc-eeDRCY sc-eBMEME sc-dCFHLb gTGgei kekOtA kCaLQd"><p>Error within Jungfraujoch code - see output message.</p>
</div></button></div></div></div><div class="sc-iGgWBj sc-gsFSXq ibAZSi eDeKjd"><div class="sc-ejfMa-d bNUPQg"><button class="sc-EgOXT cFEcOl"><span type="post" class="sc-eZYNyq fPdOXD http-verb post">post</span><span class="sc-iEXKAA gUNSDu">/start</span><svg class="sc-cwHptR iVFMLx" style="margin-right:-25px" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg></button><div aria-hidden="true" class="sc-dlWCHZ kWacYr"><div class="sc-hHOBiw cndTNO"><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Test Jungfraujoch system</p>
</div><div tabindex="0" role="button"><div class="sc-kWtpeL gEncxT"><span>http://localhost:5232</span>/start</div></div></div></div></div><div><h3 class="sc-kpDqfm eBBgSB"> <!-- -->Request samples<!-- --> </h3><div class="sc-bXCLTC dHowgL" data-rttabs="true"><ul class="react-tabs__tab-list" role="tablist"><li class="react-tabs__tab react-tabs__tab--selected" role="tab" id="tab_R_ii2a_0" aria-selected="true" aria-disabled="false" aria-controls="panel_R_ii2a_0" tabindex="0" data-rttab="true">Payload</li></ul><div class="react-tabs__tab-panel react-tabs__tab-panel--selected" role="tabpanel" id="panel_R_ii2a_0" aria-labelledby="tab_R_ii2a_0"><div><div class="sc-bbSZdi gCVTxk"><span class="sc-fjvvzt jWReSk">Content type</span><div class="sc-JrDLc iTKzPJ">application/json</div></div><div class="sc-uVWWZ gQROPU"><div class="sc-esYiGF dWQNJI"><div class="sc-koXPp efufqz"><button><div class="sc-fhzFiK kwZDms">Copy</div></button><button> Expand all </button><button> Collapse all </button></div><div tabindex="0" class="sc-eeDRCY gTGgei sc-fXSgeo bnrBiz"><div class="redoc-json"><code><button class="collapser" aria-label="collapse"></button><span class="token punctuation">{</span><span class="ellipsis"></span><ul class="obj collapsible"><li><div class="hoverable "><span class="property token string">"images_per_trigger"</span>: <span class="token number">1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"ntrigger"</span>: <span class="token number">1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"image_time_us"</span>: <span class="token number">0</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"beam_x_pxl"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"beam_y_pxl"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"detector_distance_mm"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"incident_energy_keV"</span>: <span class="token number">0.001</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"file_prefix"</span>: <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"images_per_file"</span>: <span class="token number">1000</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"space_group_number"</span>: <span class="token number">1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"sample_name"</span>: <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"compression"</span>: <span class="token string">&quot;bslz4&quot;</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"total_flux"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"transmission"</span>: <span class="token number">1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"goniometer"</span>: <button class="collapser" aria-label="collapse"></button><span class="token punctuation">{</span><span class="ellipsis"></span><ul class="obj collapsible"><li><div class="hoverable collapsed"><span class="property token string">"name"</span>: <span class="token string">&quot;omega&quot;</span><span class="token punctuation">,</span></div></li><li><div class="hoverable collapsed"><span class="property token string">"step"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable collapsed"><span class="property token string">"start"</span>: <span class="token number">50</span><span class="token punctuation">,</span></div></li><li><div class="hoverable collapsed"><span class="property token string">"vector"</span>: <button class="collapser" aria-label="expand"></button><span class="token punctuation">[</span><span class="ellipsis"></span><ul class="array collapsible"><li><div class="hoverable collapsed"><span class="token number">1</span>,</div></li><li><div class="hoverable collapsed"><span class="token number">0</span>,</div></li><li><div class="hoverable collapsed"><span class="token number">0</Line truncated
</div><div tabindex="0" role="button"><div class="sc-kWtpeL gEncxT"><span>http://localhost:5232</span>/start</div></div></div></div></div><div><h3 class="sc-kpDqfm eBBgSB"> <!-- -->Request samples<!-- --> </h3><div class="sc-bXCLTC dHowgL" data-rttabs="true"><ul class="react-tabs__tab-list" role="tablist"><li class="react-tabs__tab react-tabs__tab--selected" role="tab" id="tab_R_ii2a_0" aria-selected="true" aria-disabled="false" aria-controls="panel_R_ii2a_0" tabindex="0" data-rttab="true">Payload</li></ul><div class="react-tabs__tab-panel react-tabs__tab-panel--selected" role="tabpanel" id="panel_R_ii2a_0" aria-labelledby="tab_R_ii2a_0"><div><div class="sc-bbSZdi gCVTxk"><span class="sc-fjvvzt jWReSk">Content type</span><div class="sc-JrDLc iTKzPJ">application/json</div></div><div class="sc-uVWWZ gQROPU"><div class="sc-esYiGF dWQNJI"><div class="sc-koXPp efufqz"><button><div class="sc-fhzFiK kwZDms">Copy</div></button><button> Expand all </button><button> Collapse all </button></div><div tabindex="0" class="sc-eeDRCY gTGgei sc-fXSgeo bnrBiz"><div class="redoc-json"><code><button class="collapser" aria-label="collapse"></button><span class="token punctuation">{</span><span class="ellipsis"></span><ul class="obj collapsible"><li><div class="hoverable "><span class="property token string">"images_per_trigger"</span>: <span class="token number">1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"ntrigger"</span>: <span class="token number">1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"image_time_us"</span>: <span class="token number">0</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"beam_x_pxl"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"beam_y_pxl"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"detector_distance_mm"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"incident_energy_keV"</span>: <span class="token number">0.001</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"file_prefix"</span>: <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"images_per_file"</span>: <span class="token number">1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"space_group_number"</span>: <span class="token number">1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"sample_name"</span>: <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"compression"</span>: <span class="token string">&quot;bslz4&quot;</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"total_flux"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"transmission"</span>: <span class="token number">1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable "><span class="property token string">"goniometer"</span>: <button class="collapser" aria-label="collapse"></button><span class="token punctuation">{</span><span class="ellipsis"></span><ul class="obj collapsible"><li><div class="hoverable collapsed"><span class="property token string">"name"</span>: <span class="token string">&quot;omega&quot;</span><span class="token punctuation">,</span></div></li><li><div class="hoverable collapsed"><span class="property token string">"step"</span>: <span class="token number">0.1</span><span class="token punctuation">,</span></div></li><li><div class="hoverable collapsed"><span class="property token string">"start"</span>: <span class="token number">50</span><span class="token punctuation">,</span></div></li><li><div class="hoverable collapsed"><span class="property token string">"vector"</span>: <button class="collapser" aria-label="expand"></button><span class="token punctuation">[</span><span class="ellipsis"></span><ul class="array collapsible"><li><div class="hoverable collapsed"><span class="token number">1</span>,</div></li><li><div class="hoverable collapsed"><span class="token number">0</span>,</div></li><li><div class="hoverable collapsed"><span class="token number">0</spaLine truncated
To not block web server for a indefinite period of time, the procedure is provided with a timeout.
Extending timeout is possible, but requires to ensure safety that client will not close the connection and retry the connection.</p>
</div></div><div><h5 class="sc-dAlyuH jbQuod">query<!-- --> Parameters</h5><table class="sc-dAbbOL ccPhmY"><tbody><tr class="last "><td class="sc-dLMFU sc-eldPxv hZbWKe jXkfaY" kind="field" title="timeout"><span class="sc-gFqAkR eRqgPI"></span><span class="property-name">timeout</span></td><td class="sc-fPXMVe bAXEAa"><div><div><span class="sc-Nxspf sc-cfxfcM cXxAXt jrGEaR"></span><span class="sc-Nxspf sc-gFAWRd cXxAXt dYzdDr">integer</span><span> <span class="sc-Nxspf sc-fxwrCY cXxAXt eMVOei"> <!-- -->[ 0 .. 3600 ]<!-- --> </span></span></div><div><span class="sc-Nxspf cXxAXt"> <!-- -->Default:<!-- --> </span> <span class="sc-Nxspf sc-ddjGPC cXxAXt jZOCAW">60</span></div> <div><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Timeout in seconds (0 == immediate response)</p>
@@ -977,7 +981,7 @@ then image might be replaced in the buffer between calling /images and /image.cb
</div></button></div></div></div><div class="sc-iGgWBj sc-gsFSXq ibAZSi eDeKjd"><div class="sc-ejfMa-d bNUPQg"><button class="sc-EgOXT cFEcOl"><span type="get" class="sc-eZYNyq qGfV http-verb get">get</span><span class="sc-iEXKAA gUNSDu">/version</span><svg class="sc-cwHptR iVFMLx" style="margin-right:-25px" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg></button><div aria-hidden="true" class="sc-dlWCHZ kWacYr"><div class="sc-hHOBiw cndTNO"><div class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"><p>Test Jungfraujoch system</p>
</div><div tabindex="0" role="button"><div class="sc-kWtpeL gEncxT"><span>http://localhost:5232</span>/version</div></div></div></div></div></div></div></div></div><div class="sc-dExYaf gZbfaQ"></div></div></div>
<script>
const __redoc_state = {"menu":{"activeItemIdx":-1},"spec":{"data":{"openapi":"3.0.3","info":{"title":"Jungfraujoch","description":"API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland).\nJungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU.\nJungfraujoch uses FPGA boards to acquire data at high data rates.\n\n# License Clarification\n\nWhile this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply**\nwhen this file is used solely to generate OpenAPI clients or when implementing applications that\ninteract with the API. Generated client code and applications using this API definition are not\nsubject to the GPL license requirements and may be distributed under terms of your choosing.\n\nThis exception is similar in spirit to the Linux Kernel's approach to userspace API headers and\nthe GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that\nuser programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not\nderivative works of the kernel and are not subject to the terms of the GPL.\n\nThis exception is intended to allow wider use of this API specification without imposing GPL\nrequirements on applications that merely interact with the API, regardless of whether they\ncommunicate through network calls or other mechanisms.\n","version":"1.0.0-rc.162","contact":{"name":"Filip Leonarski (Paul Scherrer Institute)","email":"filip.leonarski@psi.ch"},"license":{"name":"GPL-3.0","url":"https://www.gnu.org/licenses/gpl-3.0.html"}},"servers":[{"url":"http://localhost:5232","description":"Test Jungfraujoch system"}],"components":{"parameters":{"binning":{"in":"query","name":"binning","required":false,"schema":{"default":1,"type":"integer"},"description":"Binning of frames for the plot (0 = default binning)"},"experimental_coord":{"in":"query","name":"experimental_coord","required":false,"schema":{"type":"boolean","default":false},"description":"If measurement has goniometer axis defined, plot X-axis will represent rotation angle\nIf measurement has grid scan defined, plot X-axis and Y-axis will represent grid position, Z will be used as the final value\nFor still measurement the number is ignored\n"},"azint_unit":{"in":"query","name":"azint_unit","required":false,"schema":{"type":"string","enum":["Q_recipA","d_A","two_theta_deg"],"default":"Q_recipA"},"description":"Unit used for azim int.\n"},"fill_value":{"in":"query","name":"fill","required":false,"schema":{"type":"number","format":"float"},"description":"Fill value for elements that were missed during data collection\n"},"plot_type":{"in":"query","name":"type","required":true,"description":"Type of requested plot","schema":{"type":"string","enum":["bkg_estimate","azint","azint_1d","spot_count","spot_count_low_res","spot_count_indexed","spot_count_ice","indexing_rate","indexing_lattice_count","indexing_unit_cell_length","indexing_unit_cell_angle","profile_radius","mosaicity","b_factor","error_pixels","saturated_pixels","image_collection_efficiency","receiver_delay","receiver_free_send_buf","strong_pixels","roi_sum","roi_mean","roi_max_count","roi_pixels","roi_weighted_x","roi_weighted_y","packets_received","max_pixel_value","resolution_estimate","pixel_sum","processing_time","beam_center_x","beam_center_y","integrated_reflections","image_scale_factor","image_scale_cc","compression_ratio","ice_ring_score"]}},"roi":{"in":"query","name":"roi","required":false,"schema":{"type":"string","minLength":1},"description":"Name of ROI for which plot is requested"},"image_id":{"in":"query","name":"id","required":false,"schema":{"type":"integer","format":"int64","default":-1,"minimum":-2},"description":"Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer"},"saturation":{"in":"query","name":"saturation","required":false,"schema":{"type":"number","format":"float","minimum":-32767,"maximum":32767},"description":"Saturation value to set contrast in the preview image; if not provided, then autocontrast procedure is used"},"background":{"in":"query","name":"background","required":false,"schema":{"type":"number","format":"float","default":0,"minimum":-32767,"maximum":32767},"description":"Background value to set contrast in the preview image"},"show_spots":{"in":"query","name":"show_spots","schema":{"type":"boolean","default":true},"description":"Show spot finding results on the image"},"show_predictions":{"in":"query","name":"show_predictions","schema":{"type":"boolean","default":false},"description":"Show Bragg spot predictions on the image (if available for the image)"},"show_beam_center":{"in":"query","name":"show_beam_center","schema":{"type":"boolean","default":true},"description":"Show beam center on the image"},"show_roi":{"in":"query","name":"show_roi","schema":{"type":"boolean","default":false},"description":"Show ROI areas on the image"},Line truncated
const __redoc_state = {"menu":{"activeItemIdx":-1},"spec":{"data":{"openapi":"3.0.3","info":{"title":"Jungfraujoch","description":"API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland).\nJungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU.\nJungfraujoch uses FPGA boards to acquire data at high data rates.\n\n# License Clarification\n\nWhile this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply**\nwhen this file is used solely to generate OpenAPI clients or when implementing applications that\ninteract with the API. Generated client code and applications using this API definition are not\nsubject to the GPL license requirements and may be distributed under terms of your choosing.\n\nThis exception is similar in spirit to the Linux Kernel's approach to userspace API headers and\nthe GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that\nuser programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not\nderivative works of the kernel and are not subject to the terms of the GPL.\n\nThis exception is intended to allow wider use of this API specification without imposing GPL\nrequirements on applications that merely interact with the API, regardless of whether they\ncommunicate through network calls or other mechanisms.\n","version":"1.0.0-rc.162","contact":{"name":"Filip Leonarski (Paul Scherrer Institute)","email":"filip.leonarski@psi.ch"},"license":{"name":"GPL-3.0","url":"https://www.gnu.org/licenses/gpl-3.0.html"}},"servers":[{"url":"http://localhost:5232","description":"Test Jungfraujoch system"}],"components":{"parameters":{"binning":{"in":"query","name":"binning","required":false,"schema":{"default":1,"type":"integer"},"description":"Binning of frames for the plot (0 = default binning)"},"experimental_coord":{"in":"query","name":"experimental_coord","required":false,"schema":{"type":"boolean","default":false},"description":"If measurement has goniometer axis defined, plot X-axis will represent rotation angle\nIf measurement has grid scan defined, plot X-axis and Y-axis will represent grid position, Z will be used as the final value\nFor still measurement the number is ignored\n"},"azint_unit":{"in":"query","name":"azint_unit","required":false,"schema":{"type":"string","enum":["Q_recipA","d_A","two_theta_deg"],"default":"Q_recipA"},"description":"Unit used for azim int.\n"},"fill_value":{"in":"query","name":"fill","required":false,"schema":{"type":"number","format":"float"},"description":"Fill value for elements that were missed during data collection\n"},"plot_type":{"in":"query","name":"type","required":true,"description":"Type of requested plot","schema":{"type":"string","enum":["bkg_estimate","azint","azint_1d","spot_count","spot_count_low_res","spot_count_indexed","spot_count_ice","indexing_rate","indexing_lattice_count","indexing_unit_cell_length","indexing_unit_cell_angle","profile_radius","mosaicity","b_factor","error_pixels","saturated_pixels","image_collection_efficiency","receiver_delay","receiver_free_send_buf","strong_pixels","roi_sum","roi_mean","roi_max_count","roi_pixels","roi_weighted_x","roi_weighted_y","packets_received","max_pixel_value","resolution_estimate","pixel_sum","processing_time","beam_center_x","beam_center_y","integrated_reflections","image_scale_factor","image_scale_cc","compression_ratio","ice_ring_score"]}},"roi":{"in":"query","name":"roi","required":false,"schema":{"type":"string","minLength":1},"description":"Name of ROI for which plot is requested"},"image_id":{"in":"query","name":"id","required":false,"schema":{"type":"integer","format":"int64","default":-1,"minimum":-2},"description":"Image ID in the image buffer. Special values: -1 - last image in the buffer, -2: last indexed image in the buffer"},"saturation":{"in":"query","name":"saturation","required":false,"schema":{"type":"number","format":"float","minimum":-32767,"maximum":32767},"description":"Saturation value to set contrast in the preview image; if not provided, then autocontrast procedure is used"},"background":{"in":"query","name":"background","required":false,"schema":{"type":"number","format":"float","default":0,"minimum":-32767,"maximum":32767},"description":"Background value to set contrast in the preview image"},"show_spots":{"in":"query","name":"show_spots","schema":{"type":"boolean","default":true},"description":"Show spot finding results on the image"},"show_predictions":{"in":"query","name":"show_predictions","schema":{"type":"boolean","default":false},"description":"Show Bragg spot predictions on the image (if available for the image)"},"show_beam_center":{"in":"query","name":"show_beam_center","schema":{"type":"boolean","default":true},"description":"Show beam center on the image"},"show_roi":{"in":"query","name":"show_roi","schema":{"type":"boolean","default":false},"description":"Show ROI areas on the image"},Line truncated
var container = document.getElementById('redoc');
Redoc.hydrate(__redoc_state, container);
+4 -4
View File
@@ -21,7 +21,6 @@ DatasetSettings::DatasetSettings() {
ntrigger = 1;
images_per_trigger = 1;
compression = CompressionAlgorithm::BSHUF_LZ4;
images_per_file = 1000;
data_reduction_factor_serialmx = 1.0;
write_nxmx_hdf5_master = true;
spot_finding_enable = true;
@@ -249,13 +248,14 @@ int64_t DatasetSettings::GetImageNumPerTrigger() const {
return images_per_trigger;
}
DatasetSettings &DatasetSettings::ImagesPerFile(int64_t input) {
check_min("Images per file", input, 0);
DatasetSettings &DatasetSettings::ImagesPerFile(const std::optional<int64_t> &input) {
if (input.has_value())
check_min("Images per file", input.value(), 1);
images_per_file = input;
return *this;
}
int64_t DatasetSettings::GetImagesPerFile() const {
std::optional<int64_t> DatasetSettings::GetImagesPerFile() const {
return images_per_file;
}
+3 -3
View File
@@ -23,7 +23,7 @@ class DatasetSettings {
float photon_energy_keV;
std::string file_prefix;
int64_t images_per_file;
std::optional<int64_t> images_per_file;
CompressionAlgorithm compression;
@@ -89,7 +89,7 @@ public:
DatasetSettings& GridScan(const std::optional<GridScanSettings>& input);
DatasetSettings& HeaderAppendix(const nlohmann::json& input);
DatasetSettings& ImageAppendix(const nlohmann::json& input);
DatasetSettings& ImagesPerFile(int64_t input);
DatasetSettings& ImagesPerFile(const std::optional<int64_t> &input);
DatasetSettings& RunNumber(const std::optional<uint64_t> &run_number);
DatasetSettings& RunName(const std::optional<std::string> &input);
DatasetSettings& ExperimentGroup(const std::string &group);
@@ -139,7 +139,7 @@ public:
CompressionAlgorithm GetCompressionAlgorithm() const;
int64_t GetNumTriggers() const;
int64_t GetImageNumPerTrigger() const;
int64_t GetImagesPerFile() const;
std::optional<int64_t> GetImagesPerFile() const;
std::optional<uint64_t> GetRunNumber() const;
std::optional<std::string> GetRunName() const;
+6
View File
@@ -20,6 +20,12 @@ constexpr size_t JUNGFRAU_PACKET_SIZE_BYTES = 8192;
constexpr int MAX_IMAGE_NUMBER = 2*1024*1024;
// Defaults for images_per_file when the acquisition does not ask for a particular number; see
// DiffractionExperiment::GetImagesPerFile.
constexpr int64_t DEFAULT_IMAGES_PER_FILE = 1000;
// Above this, a rotation sweep is split rather than written to one file.
constexpr int64_t ROTATION_SINGLE_FILE_IMAGE_LIMIT = 20000;
constexpr std::chrono::nanoseconds MIN_COUNT_TIME = std::chrono::microseconds(3);
constexpr std::chrono::nanoseconds MIN_STORAGE_CELL_DELAY = std::chrono::nanoseconds(2100);
constexpr std::chrono::nanoseconds MIN_FRAME_TIME_JUNGFRAU_HALF_SPEED = std::chrono::microseconds(1000);
+31 -7
View File
@@ -1113,19 +1113,43 @@ std::vector<uint16_t> DiffractionExperiment::ExportROIMap() const {
return roi_mask.GetROIMap(GetDiffractionGeometry(), GetXPixelsNumConv(), GetYPixelsNumConv());
}
DiffractionExperiment &DiffractionExperiment::ImagesPerFile(int64_t input) {
DiffractionExperiment &DiffractionExperiment::ImagesPerFile(const std::optional<int64_t> &input) {
dataset.ImagesPerFile(input);
return *this;
}
// Images per file is optional in the settings, because at setup time the acquisition it should suit
// is not necessarily known yet. Everything downstream of here - receiver, pusher, puller, writer -
// requires a fixed, non-zero number, so this is the one place that resolves it and it must always
// return one.
int64_t DiffractionExperiment::GetImagesPerFile() const {
auto tmp = dataset.GetImagesPerFile();
// A single self-contained file holds the whole run whatever the setting says.
if (file_writer.GetFileFormat() == FileWriterFormat::NXmxIntegrated)
return std::max<int64_t>(GetImageNum(), 1);
if (tmp == 0
|| file_writer.GetFileFormat() == FileWriterFormat::NXmxIntegrated)
return GetImageNum();
else
return tmp;
if (const auto requested = dataset.GetImagesPerFile())
return requested.value(); // taken literally
const int64_t image_num = GetImageNum();
// Rotation: keep the sweep in one data file. A legacy master splits over several files is read
// by some programs as only its first one, and a rotation dataset is small enough that the file
// is not a problem - past the limit the writer parallelism is worth more, one file going to one
// writer (see ZMQStream2Pusher::SendImage).
const auto goniometer = GetGoniometer();
if (goniometer.has_value() && (goniometer->GetIncrement_deg() != 0.0f)
&& (image_num > 0) && (image_num <= ROTATION_SINGLE_FILE_IMAGE_LIMIT))
return image_num;
// Grid scan: split on whole rows of the fast axis, so a file is a meaningful piece of the grid
// rather than an arbitrary cut across it.
if (const auto grid_scan = GetGridScan()) {
const int64_t n_fast = grid_scan->GetNFast();
if (n_fast > 0)
return ((DEFAULT_IMAGES_PER_FILE + n_fast - 1) / n_fast) * n_fast;
}
return DEFAULT_IMAGES_PER_FILE; // stills, serial
}
int64_t DiffractionExperiment::GetImageBufferLocationSize() const {
+1 -1
View File
@@ -137,7 +137,7 @@ public:
DiffractionExperiment& ImageAppendix(const nlohmann::json& input);
DiffractionExperiment& Summation(int64_t input);
DiffractionExperiment& MaxSpotCount(int64_t input);
DiffractionExperiment& ImagesPerFile(int64_t input);
DiffractionExperiment& ImagesPerFile(const std::optional<int64_t> &input);
DiffractionExperiment& LossyCompressionSerialMX(float input);
DiffractionExperiment& LossyCompressionPoisson(const std::optional<int64_t> &input);
DiffractionExperiment& SaveCalibration(const std::optional<bool> &input);
+4
View File
@@ -15,6 +15,10 @@ This is an UNSTABLE release. It includes many experimental features, as well as
* rugnux: the detector geometry is also logged in XDS's convention (`ORGX`/`ORGY`, detector axis vectors, rotation axis), so it can be compared directly with an XDS refinement.
* HDF5: a data file missing next to a VDS master now reads as the error-pixel marker instead of zero counts, so those frames are masked rather than silently integrated as blank.
* The writer refuses a stream whose start message declares a different pixel format than its images carry, instead of writing a master that does not describe its own data.
* `images_per_file` is now chosen from the acquisition when it is not given: a rotation sweep of at most 20000 images goes into a single data file, a grid scan splits on whole fast-axis rows, and stills and serial keep 1000.
**Breaking change to OpenAPI** - regenerate the client (`jfjoch-client` 1.0.0-rc.162, `frontend/src/client`):
* `dataset_settings.images_per_file` is no longer `default: 1000` and no longer accepts `0`; it is optional, and its minimum is 1. A client sending `0` (previously "one file for the whole run") is now rejected - omit the field instead, which for a rotation sweep gives the same single file.
### 1.0.0-rc.161
This is an UNSTABLE release. It includes many experimental features, as well as many AI generated fixes. We recommend using rc.152 for production use.
+1 -1
View File
@@ -13,7 +13,7 @@ Name | Type | Description | Notes
**detector_distance_mm** | **float** | /entry/detector/distance in NXmx Detector distance [mm] |
**incident_energy_ke_v** | **float** | Used to calculate /entry/beam/incident_wavelength in NXmx Incident particle (photon, electron) energy in keV |
**file_prefix** | **str** | Prefix for filenames. If left empty, no file will be saved. | [optional] [default to '']
**images_per_file** | **int** | Number of files in a single HDF5 data file (0 &#x3D; write all images to a single data file). | [optional] [default to 1000]
**images_per_file** | **int** | Number of images in a single HDF5 data file, taken literally when given. If omitted, it is chosen from the acquisition: a rotation sweep of at most 20000 images goes into a single data file, so the dataset stays readable by programs that follow only the first data file of a legacy master; a grid scan is split on a whole number of fast-axis rows; anything else (stills, serial) uses 1000. | [optional]
**space_group_number** | **int** | Number of space group for the crystal. Currently used solely as metadata, not relevant for image processing done in Jungfraujoch. | [optional]
**sample_name** | **str** | /entry/sample/name in NXmx Sample name | [optional] [default to '']
**compression** | **str** | Compression type for the images transferred over ZeroMQ and saved to HDF5 file. | [optional] [default to 'bslz4']
+6 -1
View File
@@ -191,7 +191,12 @@ export type dataset_settings = {
*/
file_prefix?: string;
/**
* Number of files in a single HDF5 data file (0 = write all images to a single data file).
* Number of images in a single HDF5 data file, taken literally when given.
* If omitted, it is chosen from the acquisition: a rotation sweep of at most 20000 images
* goes into a single data file, so the dataset stays readable by programs that follow only
* the first data file of a legacy master; a grid scan is split on a whole number of fast-axis
* rows; anything else (stills, serial) uses 1000.
*
*/
images_per_file?: number;
/**
+1 -1
View File
@@ -111,7 +111,7 @@ export const zDatasetSettings = z.object({
detector_distance_mm: z.number().gte(0),
incident_energy_keV: z.number().gte(0.001).lte(500),
file_prefix: z.string().optional().default(''),
images_per_file: z.coerce.bigint().gte(BigInt(0)).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).optional().default(BigInt(1000)),
images_per_file: z.coerce.bigint().gte(BigInt(1)).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).optional(),
space_group_number: z.coerce.bigint().gte(BigInt(1)).lte(BigInt(194)).optional(),
sample_name: z.string().optional().default(''),
compression: z.enum([
+56 -1
View File
@@ -1077,4 +1077,59 @@ TEST_CASE("DiffractionExperiment_PedestalRun","[DiffractionExperiment]") {
x.Mode(DetectorMode::PedestalG2);
REQUIRE(x.IsPedestalRun());
REQUIRE(!x.IsApplyPixelMask());
}
}
TEST_CASE("DiffractionExperiment_ImagesPerFile_Defaults", "[DiffractionExperiment]") {
// images_per_file is optional in the settings, because at setup time the acquisition it should
// suit is not necessarily known. GetImagesPerFile() is the single place that resolves it, and
// everything downstream (receiver, pusher, puller, writer) requires the answer to be a fixed
// non-zero number - so every branch below must produce one.
const GoniometerAxis rotation("omega", 0.0f, 0.1f, {-1, 0, 0}, {});
const GoniometerAxis stationary("omega", 0.0f, 0.0f, {-1, 0, 0}, {});
SECTION("taken literally when given") {
DiffractionExperiment x(DetJF4M());
x.ImagesPerTrigger(5000).NumTriggers(1).Goniometer(rotation).ImagesPerFile(250);
CHECK(x.GetImagesPerFile() == 250);
}
SECTION("stills default to 1000") {
DiffractionExperiment x(DetJF4M());
x.ImagesPerTrigger(50000).NumTriggers(1);
CHECK(x.GetImagesPerFile() == DEFAULT_IMAGES_PER_FILE);
}
SECTION("a rotation sweep goes into one file") {
DiffractionExperiment x(DetJF4M());
x.ImagesPerTrigger(3600).NumTriggers(1).Goniometer(rotation);
CHECK(x.GetImagesPerFile() == 3600);
}
SECTION("a long rotation sweep is split again") {
DiffractionExperiment x(DetJF4M());
x.ImagesPerTrigger(ROTATION_SINGLE_FILE_IMAGE_LIMIT + 1).NumTriggers(1).Goniometer(rotation);
CHECK(x.GetImagesPerFile() == DEFAULT_IMAGES_PER_FILE);
}
SECTION("a goniometer that does not turn is not a rotation sweep") {
DiffractionExperiment x(DetJF4M());
x.ImagesPerTrigger(3600).NumTriggers(1).Goniometer(stationary);
CHECK(x.GetImagesPerFile() == DEFAULT_IMAGES_PER_FILE);
}
SECTION("a grid scan splits on whole fast-axis rows") {
DiffractionExperiment x(DetJF4M());
x.ImagesPerTrigger(10000).NumTriggers(1)
.GridScan(GridScanSettings(30, 10.0f, 10.0f, false, false));
const int64_t images_per_file = x.GetImagesPerFile();
CHECK(images_per_file % 30 == 0);
CHECK(images_per_file >= DEFAULT_IMAGES_PER_FILE);
CHECK(images_per_file < DEFAULT_IMAGES_PER_FILE + 30);
}
SECTION("a single self-contained file holds the whole run") {
DiffractionExperiment x(DetJF4M());
x.ImagesPerTrigger(5000).NumTriggers(1)
.SetFileWriterFormat(FileWriterFormat::NXmxIntegrated).ImagesPerFile(250);
CHECK(x.GetImagesPerFile() == 5000);
}
}