aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/image.c
AgeCommit message (Collapse)Author
2024-02-06Julia: MM semantics for Image.crystalsThomas White
2024-02-06Julia: Image/PeakList memory semantics (again)Thomas White
Previous commit a6462e1f0 was still not right. If the image gets freed, the PeakList can be left with a dangling reference. If the peak list gets replaced at the C level (e.g. by running a new peak search), Julia will have no way of knowing about it. Instead of having the PeakList know if it's associated with an image, it's better to have the Image know (at the C level) if it's responsible for freeing the ImageFeatureList. As soon as the ImageFeatureList is exposed to the Julia GC via a PeakList object, it becomes Julia's responsibility to free it. The Julia Image structure contains a reference to the Julia PeakList, to prevent this from happening until either the image is freed or a new PeakList is substituted. The two references (Julia image.peaklist and C image->features) have to be kept in sync, and we check image->features every time the peaklist is requested.
2024-02-06Fix incorrect uses of cell_freeThomas White
This also gets rid of crystal_copy_deep. From now on, all crystal_copy calls also copy the UnitCell.
2024-02-06Crystals shouldn't own RefLists (part 2)Thomas White
This commit replaces image.crystals with an array of small structs, each consisting of a Crystal-RefList pair. index.c and stream.c are updated, more to follow.
2024-02-06Crystals shouldn't own RefLists (part 1)Thomas White
This is a terrible bit of API. A Crystal contains both the parameters for a calculation (e.g. prediction) and the results. Just look at post-refinement.c for an example of the mess this makes when trying to do calculations. This commit removes the reflection list from the Crystal structure. Future commits in this series will fix the resulting build carnage. This also gets rid of vestigial field pr_dud, and adds initialisers for all (remaining) fields.
2024-02-06Use libcrystfel memory allocation routines everywhereThomas White
2024-02-06image_add_feature: Remove "image" argumentThomas White
It hasn't been needed for ages.
2023-09-23indexamajig: Re-use the image data arraysThomas White
We noticed that constant freeing and re-allocating the (potentially quite large) arrays resulted in much lower performance. Since we know that all images have the same data layout, we can safely re-use the arrays. This gives a large speedup.
2023-09-23image_create_dp_bad_sat: Don't worry about "sat"Thomas White
The saturation array is created by create_satmap when needed, which takes care that all panels get an array (so we only have to check image->sat != NULL). The array created by image_create_dp_bad_sat was actually leaked! In any case, saturation maps are rarely used. We can do without the extra allocations. The routine name has been changed accordingly, to prevent future confusion.
2023-07-26Fix memory leaks in header cachingThomas White
2023-05-05Move is_{hdf5,cbf,cbfgz}_file() to image.cThomas White
This also improves is_hdf5_file() to use the proper file signature, not just the extension. See 9040220452a9cc02706159c21c78e43b374446cf.
2023-05-02Remove image_write() and image_hdf5_write()Thomas White
This code isn't needed any more, now that we don't simulate images. It never worked very well - although we can read almost any sensible format, writing images that match an arbitrary schema is very difficult. See 41ed47a931e4c162c9a501981b6f19cd725f6e43 and https://gitlab.desy.de/thomas.white/crystfel/-/issues/81
2023-02-17image_read_peaks: Fix a typoThomas White
2022-09-22Implement data_template_get_2d_detgeom_if_possibleThomas White
It is horrible. But it's contained inside the DataTemplate module.
2022-09-21create_detgeom: Return detgeom structure rather than altering image argumentThomas White
2022-09-21Move create_detgeom to DataTemplate moduleThomas White
It seems to make more sense here, because it's all about interpreting the contents of the DataTemplate structure.
2022-08-22image_create_dp_bad_sat: Initialise saturation array to infinityThomas White
2022-08-18Restructure image data array creationThomas White
This adds a central procedure (image_create_dp_bad_sat) to create all the arrays. Then it's up to the loading procedure to put the values into the arrays. This also makes the loading procedures responsible for marking NaN/inf pixels in the bad pixel map. This avoids an additional sweep through the image data, and makes it possible to skip the NaN/inf check altogether if the image data comes, as it often does, in format which can't represent NaN/inf anyway. Finally, it removes quite a lot of duplicated code.
2022-06-02Add profiling for bad region generationThomas White
2022-06-02Use isfinite() instead of isnan() || isinf()Thomas White
These FP calls seem to be slower than expected. Using only one doubles the speed.
2022-06-02Seedee deserializationThomas White
2022-06-02indexamajig: Track metadata (e.g. for ASAP::O)Thomas White
2022-06-02Generate placeholder filename/event earlierThomas White
Previously, a placeholder was put in the queue ("ZMQdata //" or "ASAPOdata //"), and replaced by image_read_data_block. Instead, the "final" placeholder can be put in the queue already. Note that ASAP::O, at least, will replace this placeholder with a filename delivered by the data transport.
2022-05-04Add improved profilingThomas White
Improvements: - Recursive, so we can see how things are working at different levels - Everything is profiled, even if not explicitly labelled - No possibility of losing time - Detects mistakes if routines aren't wrapped correctly
2022-05-03Strip out time-accountsThomas White
2022-04-05indexamajig: Fix profiling when using streamed dataThomas White
2022-03-09Meson: enable building without HDF5Thomas White
2022-03-07Add image_read_with_time_accounting for fine-grained data load profilingThomas White
2022-03-02Move file_exists() check to right before opening the HDF5Thomas White
No other code path under image_expand_frames() actually opens the file, because HDF5s are currently the only format supporting multiple frames. The aim of the existence check is to give a better error message (compared to the HDF5 backtrace splurge), but it doesn't need to be done so early. In fact, checking so early had the side-effect of breaking indexamajig --wait-for-file. Fixes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/65
2021-10-28Add 'mask_panel_edges' to geometry fileThomas White
Closes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/27
2021-10-26create_detgeom: Factorise panel templateThomas White
2021-09-17Avoid pointless passing of image/eventThomas White
2021-07-21Reduce variable scope where possibleThomas White
2021-07-21Add missing cleanup on error pathsThomas White
2021-07-16Rename DST_* to DATA_SOURCE_TYPE_*Thomas White
On some systems, this conflicts with DST_NONE in sys/time.h.
2021-06-21image_cache_header_str: Reject strings containing newlinesThomas White
2021-06-16Add DST_NONE for 'no data source' (e.g. image came from stream)Thomas White
2021-05-28Pass errors back when retrieving values for wavelength etcThomas White
Big improvement on just sending NAN back. Fixes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/37
2021-05-17Resolve FIXMEs and TODOsThomas White
Prompted by the article linked below, for each FIXME/TODO I've either referenced an issue in the tracker, or removed it if it's not worth fixing. https://schleiss.io/plotting-source-code-todos-for-open-source-projects
2021-05-12Don't assume that headers to be copied are floatsThomas White
2021-05-12FussinessThomas White
2021-05-12Rework header caching layerThomas White
This clears up multiple layering violations which were starting to get in the way. It enables "string" headers to be stored directly, and it will make it much simpler to add new header types in the future. Along the way, this changes all the floating point header stuff to use double precision. This is needed for EuXFEL event IDs. Closes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/34
2021-04-27Rename libcrystfel's config.h to libcrystfel-config.hThomas White
This removes the big potential for confusion, which has happened several times (see e.g. 095cbebaf6). It also fixes in-tree builds with CMake (but seriously, always use out-of-tree builds). Fixes #2.
2021-04-23indexamajig: Generate a unique filename for ZMQ dataThomas White
The unique filename is needed by the GUI for looking up results in a stream. Otherwise, the filename is "(null)" for everything and the lookup just returns the first chunk in the stream. The filename is generated based on the unique serial number for each chunk, and is therefore unique across one run of indexamajig regardless of the number of worker processes (-j). This might have to change in future to accommodate jobs run across multiple nodes, if there is any demand for looking at results in one big concatenated stream. This also changes the condition for deciding when to look for a 'real' file, to take into account that there is always a non-NULL filename.
2021-04-23Clarify some error messagesThomas White
2021-04-20image_read_data_block: Warn user if things go wrongThomas White
2021-04-20image_read_data_block: Set the correct data typeThomas White
2021-04-19Unify loading of image data and header valuesThomas White
This moves the entry point for loading MsgPack data to a new function, image_read_data_block. Inside image.c, the image structure can be created using exactly the same functions as for data files.
2021-04-19Move file_exists to utils (and eliminate several duplicates)Thomas White
2021-04-01Implement loading of saturation mapThomas White