Skip to main content

A Python wrapper for the FAPEC data compressor.

Project description

FaPyc

A Python wrapper for the FAPEC data compressor. (C) DAPCOM Data Services S.L. - https://www.dapcom.es

The full FAPEC compression and decompression library is included in this package, but a valid license file must be available to properly use it. Without a license, you can still use the decompressor (yet with some limitations, such as the maximum number of threads and the recovery of corrupted files). You can get free evaluation licenses at https://www.dapcom.es/get-fapec/ to test the compressor. For full licenses, please contact us at fapec@dapcom.es Once a valid license is obtained (either full or evaluation), you must define a FAPEC_HOME environment variable pointing at the path where you have stored the fapeclic.dat license file.

Usage

There are 3 main execution modes:

  • File: When invoking Fapyc or Unfapyc on a filename, it will (de)compress it directly into another file.
  • Buffer: You can load the whole file to (de)compress on e.g. a byte array, and then invoke Fapyc/Unfapyc which will leave the result in the output buffer. Obviously, you should be careful with large files, as it may use a lot of RAM!
  • File-to-buffer decompression: You can directly decompress a file (without having to load it beforehand) and leave its decompressed output in a buffer, which you can use afterwards.
  • Chunk: FAPEC internally works in 'chunks' of data, typically 1-8 MB each (and up to 384MB each), which allows to progressively (de)compress a huge file while keeping memory usage under control. For now, this feature is only available in the FAPEC CLI, in WinFAPEC and in the C API, not in Fapyc/Unfapyc yet.

Examples

Compress and decompress a file

In this example we use the kmall option of FAPEC, suitable for this kind of geomaritime data files from Kongsberg Maritime:

from fapyc import Fapyc, Unfapyc

filename = input("Path to KMALL file: ")

print("Preparing to compress %s" % (filename))
# Here we invoke FAPEC to directly run on files,
# so the memory usage will be small (just 10MB or so)
# although it won't allow us to directly access the
# (de)compressed buffers.
f = Fapyc(filename, chunksize = 2048576, blen = 512)
f.compress_kmall()

print("Preparing to decompress %s" % (filename + ".fapec"))
uf = Unfapyc(filename + ".fapec")
uf.decompress(output=filename+".dec")

Compress and decompress a buffer

In this example we use the tab option of FAPEC, which typically outperforms gzip and bzip2 on tabulated text/numerical data such as point clouds or certain scientific data files:

from fapyc import Fapyc, Unfapyc

filename = input("Path to file: ")
file = open(filename, "rb")
# Beware - Load the whole file to memory
data = file.read()
f = Fapyc(buffer = data)
# Invoke our tabulated-text compression algorithm
# indicating a comma separator
f.compress_tabtxt(sep1=',')
print("Ratio =", round(float(len(data))/len(f.outputBuffer), 4))

# Now we decompress the buffer
uf = Unfapyc(buffer = f.outputBuffer)
uf.decompress()

Decompress a file into a buffer, and do some operations on it

Here we provide a quite specific use case, based on ESA/DPAC Gaia (E)DR3 bulk catalogue (which is publicly available as FAPEC-compressed CSVs). In this example, we decompress one of the files, get its CSV-formatted contents with Pandas, apply some filtering conditions, and generate a histogram.

from fapyc import Unfapyc
from io import BytesIO
import pandas as pd
import matplotlib.pyplot as plt

filename = input("Path to CSV-FAPEC file: ")

### Option 1: open the file, load it to memory (beware!), and decompress the buffer:
#file = open(filename, "rb")
#data = file.read()
#uf = Unfapyc(buffer = data)

### Option 2: directly decompress from the file into a buffer:
uf = Unfapyc(filename = filename)

# Actual decompressor invocation - same for both options
uf.decompress()

# Regenerate the CSV from the bytes buffer
df = pd.read_csv(BytesIO(uf.outputBuffer), comment="#")

print("Info from the full CSV:")
print(df.info())
# Prepare some nice histograms for all data
plt.subplot(2,2,1)
plt.title("Full CSV: skymap (%d sources)" % df.shape[0])
plt.xlabel("RA")
plt.ylabel("DEC")
print("Getting 2D histogram...")
plt.hist2d(df.ra, df.dec, bins=(100, 100), cmap=plt.cm.jet)
plt.colorbar()
plt.subplot(2,2,2)
plt.title("Full CSV: G dist")
plt.xlabel("G magnitude")
plt.ylabel("Counts")
plt.yscale("log")
print("Getting histogram...")
plt.hist(df.phot_g_mean_mag, bins=(50))

# Now let's repeat, but doing the histogram from only the values that fulfil
# some conditions on some of the CSV fields
print("Loading+filtering CSV...")
iter_csv = pd.read_csv(BytesIO(uf.outputBuffer), comment="#", iterator=True, chunksize=1000)
df = pd.concat((x.query("ra_error < 0.1 & dec_error < 0.1 & ruwe > 0 & ruwe < 5") for x in iter_csv))
print("Info from the filtered CSV:")
print(df.info())
plt.subplot(2,2,3)
plt.title("Filtered CSV: skymap (%d sources)" % df.shape[0])
plt.xlabel("RA")
plt.ylabel("DEC")
print("Getting 2D histogram...")
plt.hist2d(df.ra, df.dec, bins=(100, 100), cmap=plt.cm.jet)
plt.colorbar()
plt.subplot(2,2,4)
plt.title("Filtered CSV: G dist")
plt.xlabel("G magnitude")
plt.ylabel("Counts")
plt.yscale("log")
print("Getting histogram...")
plt.hist(df.phot_g_mean_mag, bins=(50))

print("Plotting!")
plt.show()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

fapyc-0.3.2-cp312-cp312-win_amd64.whl (794.3 kB view details)

Uploaded CPython 3.12 Windows x86-64

fapyc-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (904.1 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

fapyc-0.3.2-cp312-cp312-macosx_13_0_arm64.whl (452.7 kB view details)

Uploaded CPython 3.12 macOS 13.0+ ARM64

fapyc-0.3.2-cp311-cp311-win_amd64.whl (794.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

fapyc-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (898.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

fapyc-0.3.2-cp311-cp311-macosx_13_0_arm64.whl (452.0 kB view details)

Uploaded CPython 3.11 macOS 13.0+ ARM64

fapyc-0.3.2-cp310-cp310-win_amd64.whl (794.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

fapyc-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (867.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

fapyc-0.3.2-cp310-cp310-macosx_13_0_arm64.whl (451.5 kB view details)

Uploaded CPython 3.10 macOS 13.0+ ARM64

fapyc-0.3.2-cp39-cp39-win_amd64.whl (801.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

fapyc-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (870.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

fapyc-0.3.2-cp39-cp39-macosx_13_0_arm64.whl (452.1 kB view details)

Uploaded CPython 3.9 macOS 13.0+ ARM64

fapyc-0.3.2-cp38-cp38-win_amd64.whl (801.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

fapyc-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (874.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

fapyc-0.3.2-cp38-cp38-macosx_13_0_arm64.whl (452.5 kB view details)

Uploaded CPython 3.8 macOS 13.0+ ARM64

fapyc-0.3.2-cp37-cp37m-win_amd64.whl (801.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

fapyc-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (848.0 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

fapyc-0.3.2-cp37-cp37m-macosx_13_0_arm64.whl (451.7 kB view details)

Uploaded CPython 3.7m macOS 13.0+ ARM64

fapyc-0.3.2-cp36-cp36m-win_amd64.whl (805.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

fapyc-0.3.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (833.9 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

fapyc-0.3.2-cp36-cp36m-macosx_13_0_arm64.whl (448.4 kB view details)

Uploaded CPython 3.6m macOS 13.0+ ARM64

File details

Details for the file fapyc-0.3.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fapyc-0.3.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 794.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for fapyc-0.3.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cb7afdc4245d8fe613beddf79b21f2c22843a01cd5bc72a6dc25b6ce8b6c6e7c
MD5 849028feaad568a707ee597c375d1ae0
BLAKE2b-256 47933fa1917554b1a33ae7a542852a79d652c4ff01cd05c563ee6ac3dff7ea1d

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 880495102ea2c9573f02cd41369d66bf876e5e6c5f89bda759f1027cf8e0e365
MD5 112bfea3fb25c19f2568ef47e61082cf
BLAKE2b-256 6e4e48df14f76ee807e224d46a579d1762c4ee952a0bdc91a6a4e24c360b5e2f

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp312-cp312-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp312-cp312-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 c3d35a8a95fc23aa32bbb3fcaec8c3bfa4bb39f63d01a6ae864e062164fc945c
MD5 67890ec4b203f1a3c52bdb6ba3b629b3
BLAKE2b-256 9dfb4d896653a60542f3851a6eb939b22257ff40a09c52ec21ae7e15f9611ce1

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: fapyc-0.3.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 794.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for fapyc-0.3.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4cae46ae1e9cf8c1e768d89f295f4095493547d818ff30367ac2fb5aba91125e
MD5 be5a1ca03ca2118ffc31d217365a049d
BLAKE2b-256 f5e5836a5a6fe8f50da409aaf60c181940071cefbf1489b0c2ea7bbe772bdf82

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b4d8bddb4d144f94848bf13f746e54cce33ee12a3afe533b1adedfb3d5972af
MD5 07958a9ef98fd41391470251f7790bbe
BLAKE2b-256 8afde74ad6a05663cb14835712c208efef9b306c8c244158e4847b984ecc1030

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp311-cp311-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp311-cp311-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 379810f3ad5dffadbc620d193d8f785f6c82f0135e5ef27eecc82aa29beec56b
MD5 e3f2bfb41c41d7f7e58e5e88edbbb26b
BLAKE2b-256 788d295c68c275d7ae5dd63aa391268f4a6cc79b2dc5eb0bca478e64ee2b3abb

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: fapyc-0.3.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 794.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for fapyc-0.3.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 57a0a90c161f4adc23de60e406ec7f240d5e3efb63eb497e20dbfcf269c13e98
MD5 9e202dd1b52d358cc761bc2b578871b4
BLAKE2b-256 3c8f6af83da39d4870d2fc6586acab23bb84a58919a6ac65c028bcf71caedfaa

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bf8e7105dbdafdec4922ea8b184ee713ebb4d513952230f3036c1af1bb4e3d04
MD5 e80725b1987f29625f075cf6a8dbbd91
BLAKE2b-256 0555db616a921866d8da8b823fe6f216b6f7c244087349c36f8526cb3bec69f4

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp310-cp310-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp310-cp310-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 2fd0437c27265b9dcca3d064d2c6ac4d228e35358f39d28c046629233d66e444
MD5 8c4a16b075d8cc0512a21bfb6ac81a61
BLAKE2b-256 960eeb8f311ce827359087b9584550160e17994fb9779aa375727ce5d7c4db30

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: fapyc-0.3.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 801.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for fapyc-0.3.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e9beb53bdf2eba0a38efa74acd86758ee553259d4a9e167395162a1dadc35c07
MD5 a56d6c5843ad5a43a86cd2273dc2860d
BLAKE2b-256 99570a48ae8ef8cc58d08073be959a4269f6db64e96c19addb8fd95c01e6e2cb

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e49adb57703e828a3aa36388e7c5f0d697b8d7aa471a9d840e9caa2c1c664008
MD5 f7b62294b7244a704cffb0f0b8ec2adb
BLAKE2b-256 7f6669c9a264f3592eb1e071b46c58ddc5e6ce017cbf7b106aa1f2f070a9d483

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp39-cp39-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp39-cp39-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 1af63b1c5f56601350c88b3dc4343e6e0cb6d2c1f61873a9eaca378c28840312
MD5 179376392d87a44413d462e74f199519
BLAKE2b-256 f327871663a0e0f0ad02e053dfd6883452c5167d7f01ceb8d3f4802bf11ef90f

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: fapyc-0.3.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 801.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for fapyc-0.3.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e1ac2cda12d1dfbc2a3d3e63256f441a58ee63e673635604615d1f959ecdc6ff
MD5 84cead9b3a49a49b98e49cd062c1adf1
BLAKE2b-256 8201d1b13e463cb23350eaaa807adeebd607f73f6efa0cd94b6eb6dc83a72eb1

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a4bc329489e5e116dc17ec440e71224c332e16e7454c619e6cf2e27e63662e92
MD5 a3a52a56c200416fa1a8a2401434b654
BLAKE2b-256 1987e2722bcf8d4f7e44e58e473c42040ce2958fd9f06d0aa4225f522d279925

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp38-cp38-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp38-cp38-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 098bd9d4973a391057c15f58f17ccb555e8153518ec4ade2eadf29b919788109
MD5 4aaee5e9c35f4bdd9a8a74cc51519e69
BLAKE2b-256 c11df95db60e2d35b8d03c71046c19d7ee96fa7ef2edf926131c8e3425bf2d6c

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: fapyc-0.3.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 801.2 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for fapyc-0.3.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 09c2a71cb9b9ba2cc874f8c3bcf32110c1a9e7ac1a9b1c34d948bf0dc6d29098
MD5 7661ae6fe4b71f38c1da0af257c054dd
BLAKE2b-256 ead1e16dd26d3025bcf60ad5fac9cce55df4ba1ce9be03e0f25aefe6117a5d6b

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cab396aef7cdb60ae0519a66d6c9d9294ce3cb04889bdf75107e36d3b52b9620
MD5 4a30ed00c8e82af9826aaf3ef0853631
BLAKE2b-256 0a23f6dc206e290546bd459ca0b4ed9e5578d2c5d5505d2a55e4515d97609e2a

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp37-cp37m-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp37-cp37m-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 12924aa281d6e89329f47ca97b3abc765269bd5d13537be1a5b54a5d3548fc73
MD5 5bf300e5a05ab63d19a13b8333d51304
BLAKE2b-256 d2321b6f18b4327fa8b360fd3863adb2ab379300b780be3ecb01c182f579e06c

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: fapyc-0.3.2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 805.5 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for fapyc-0.3.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 326dae92c76035f07dbe33fd5c6b9ad26da93f8d414f033150521a31ffc2ea74
MD5 43c5591b1509c7f87d990a73840f2a9a
BLAKE2b-256 12a9b1d93e05a6935ba7ff084de92d587caff41c7e40e015fa3d452ece1d91f5

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ad7279ac5e5b89cdf396596fac1643ead3bcadc510044124ed93236606c1060b
MD5 5b172851dbccaaad801daf1a806eae53
BLAKE2b-256 743d1b8f4b91177f906a8b421bc2c8305905ea96b24cebc4c80e86295b7b368f

See more details on using hashes here.

File details

Details for the file fapyc-0.3.2-cp36-cp36m-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for fapyc-0.3.2-cp36-cp36m-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 4a5cee6a615a92d99a3028956307b7e89503b5aa04f065e3e37007533dad97bf
MD5 c79a3380dbf9ead157aef02291aa0889
BLAKE2b-256 332a8af64d29d2be13b80458d6793bc8e6445aa859f412a9f7e6695f60a15a9b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page