View Issue Details

IDProjectCategoryView StatusLast Update
0002936CCdcielGeneralpublic26-07-20 22:02
ReporterHan Assigned ToPatrick Chevalley  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status resolvedResolutionfixed 
Summary0002936: Rice compression in native Pascal code.
DescriptionHi Patrick,

I have just finished for my ASTAP program the reading and writing rice compressed files using native Pascal code. This makes the utility program fpack and funpack redundant. The implementation is as follows:

Read 16 bit and floating point fits files. Format rice only. Not gzip;
Write 16 bit fits files.

I skipped writing floating point fits files since rice is an compression for integer files and compression of floating point is always lossy. It is also not relevant for CCDCiel.

Compression for my 16 bit images is identical to fpack to about 40%. Compression is lossless so nothing is lost.

The question would you be interested in adding native rice compression/decompression to CCdCiel? If so I can start working on it.

cs, Han
TagsNo tags attached.

Activities

Patrick Chevalley

26-07-17 20:37

administrator   ~0009901

Han, I think this is interesting to remove the fpack dependency in CCDciel.

This require some change to remove the temporary file both in direct and async (threaded) save.

For reading it is also in function TFits.LoadHeaderFromFile, it is good if you can unpack only the header but at the moment this is not the case. This is used only in TAstrometry.StartAstrometry

Han

26-07-17 21:07

reporter   ~0009903

I will have look how far I get this implemented. I have both a multi-threaded variant and single threaded variant which are interchangeable.

Patrick Chevalley

26-07-18 11:03

administrator   ~0009904

At the moment there is a PackFits and UnPackFits function in cu_fits but they are not part of TFits classs.

If you want you can add the new functions in the TFits class, then I can change all the small details to use them instead of the temporary file.

Han

26-07-18 19:02

reporter   ~0009905

I have implemented it with significant help by Claude.ai, so it was a pretty easy modification.
Instead of make cu_fits larger, the new procedures are in a new unit_ricecomp_fits.pas. You could easily move them to cu_fits.pas and delete this unit.
The rice decoding and encoding is done in unit_ricecomp.pas
The unit_mtpcpu is for the number of cpu's available. I did not investigate how it is done normally in CCDCiel.
There is also function NativeReadFzHeader() to read the header from a fits.fz file. It is called in cu_fits.pas from function TFits.LoadHeaderFromFile() as soon the file extension is fits.fz. Currently that will never happen and it requires changes in TAstrometry.StartAstrometry.
Renaming the units I leave to you.
For me the job is completed. :)
rice compression_v2.zip (88,884 bytes)

Patrick Chevalley

26-07-18 20:10

administrator   ~0009906

Thank you Han.
I am at a star party this weekend and I will look at that when I return on Monday.

Patrick Chevalley

26-07-20 22:02

administrator   ~0009908

This work fine, about two or three time faster than using the external binary.
It is fine for me to have the code in separate units, this is clearer this way.

There is already a variable MaxThreadCount in the u_global that is set in the program initialization.
I make the change to use it and do the same in the tiff unit.

Yes, I remark now that despite I have added packed file support in LoadHeaderFromFile() it is never used because this concern only locally saved temporary files that are never compressed. Sorry to not have checked that before, but now it is done I will keep it for the case we need it later.

The code change:
https://github.com/pchev/ccdciel/commit/6515deb68ea19a28c113bf063e4f9a85f2d8f973

Then I also remove the cfitsio library and binaries from the packages for Windows and Mac:
https://github.com/pchev/ccdciel/commit/ada560d76dbfaecfa8d224fe86aa7858987067e6

Issue History

Date Modified Username Field Change
26-07-15 11:54 Han New Issue
26-07-17 20:37 Patrick Chevalley Note Added: 0009901
26-07-17 21:07 Han Note Added: 0009903
26-07-18 11:03 Patrick Chevalley Note Added: 0009904
26-07-18 19:02 Han Note Added: 0009905
26-07-18 19:02 Han File Added: rice compression_v2.zip
26-07-18 20:10 Patrick Chevalley Note Added: 0009906
26-07-20 22:02 Patrick Chevalley Note Added: 0009908
26-07-20 22:02 Patrick Chevalley Assigned To => Patrick Chevalley
26-07-20 22:02 Patrick Chevalley Status new => resolved
26-07-20 22:02 Patrick Chevalley Resolution open => fixed