is it possible to write mSEED records without specifying their length or defaulting to 4096 bytes?

I would like to evaluate the compression ratio for noisy records when saving samples as 32-bits integers and when using steim1/2.

To do this, I split a trace into 100 samples, and saved each new trace as a miniSEED file using the write method of Obspy. Then I used the recordAnalyser script to get the data record length for each miniSEED file I create, but since the write method either requires me to set a data length or defaults to 4096, this method doesn’t give me any meaningful result (I assume it zero pads the file to reach the specified length?)

Is it possible to save a miniSEED file without specifying the length of the file? Or maybe to obtain the steim encoded data directly in obspy?

MSEED records by definition have to be of a length that has to be a power of 2 with smallest possible value of 2**8 = 256 bytes (see page 127 of SEED manual). Remaining unused space in a record is left empty indeed to reach the used record length.

If you want to test compression rates, I would recommend a realistic real world record length like 4096 bytes and use longer noise samples, so that you have a multitude of records and the empty space is negligible. 100 samples is way too short to judge compression rate, imo. Compression rate is massively dependent on what the signal/noise looks like, so if you want realistic estimates, you would need to average across a large set of different stations and timespans, tbh.