minor: exflate/pump is now wither.
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -19,4 +19,6 @@ build/
|
||||
build.fsx.lock
|
||||
_*.yaml
|
||||
NuGet.Config
|
||||
*.sif
|
||||
*.sif
|
||||
*.nc
|
||||
*.out
|
||||
@@ -17,6 +17,7 @@ mkShell {
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/sz3/lib64"
|
||||
export PATH="$PWD/src/bin/Debug/net9.0:$PATH"
|
||||
# export S3_URL="https://s3.ob-ceph.local"
|
||||
# export S3_URL="http://10.255.241.30:30080"
|
||||
|
||||
@@ -18,7 +18,7 @@ type GridArgs = { Archive: Uri[] }
|
||||
type CopyArgs = {
|
||||
Compress: bool
|
||||
Decompress: bool
|
||||
Pump: bool
|
||||
Wither: bool
|
||||
Sz3: float option
|
||||
Zfp: float option
|
||||
Source: Uri
|
||||
@@ -111,7 +111,7 @@ let argParser: Arg<Command * int> =
|
||||
| CmdType.CopyCmd ->
|
||||
let! compress = flag "compress" null "Compress data"
|
||||
and! decompress = flag "decompress" null "Decompress data"
|
||||
and! pump = flag "pump" null "Compress/decompress"
|
||||
and! wither = flag "wither" null "Compress/decompress"
|
||||
and! sz3 =
|
||||
opt "sz3" null "ratio" "SZ3 compression tolerance"
|
||||
|> optParse (fun s ->
|
||||
@@ -132,7 +132,7 @@ let argParser: Arg<Command * int> =
|
||||
Dest = dst
|
||||
Compress = compress
|
||||
Decompress = decompress
|
||||
Pump = pump
|
||||
Wither = wither
|
||||
Sz3 = sz3
|
||||
Zfp = zfp
|
||||
},
|
||||
|
||||
71
src/Copy.fs
71
src/Copy.fs
@@ -8,22 +8,22 @@ open Types
|
||||
open Tzar.Cli
|
||||
open Fvcom
|
||||
|
||||
let private pumpZfp tol x =
|
||||
// Log.Debug $"Pumping data with ZFP@{tol}"
|
||||
let private witherZfp tol x =
|
||||
// Log.Debug $"Witherign data with ZFP@{tol}"
|
||||
let z = Zfp.Single.zfpCompress tol x
|
||||
// printfn $"comp -> %A{z}"
|
||||
let data = Zfp.Single.zfpDecompress z
|
||||
printfn $"%A{data[0 .. 2]}"
|
||||
printfn $"%A{data[x.Length - 3 .. x.Length - 1]}"
|
||||
// printfn $"%A{data[0 .. 2]}"
|
||||
// printfn $"%A{data[x.Length - 3 .. x.Length - 1]}"
|
||||
data
|
||||
|
||||
let private pumpSz3 tol x =
|
||||
// Log.Debug $"Pumping data with SZ3@{tol}"
|
||||
let private witherSz3 tol x =
|
||||
// Log.Debug $"Witherign data with SZ3@{tol}"
|
||||
let z = Sz3.Single.sz3Compress tol x
|
||||
// printfn $"comp -> %A{z}"
|
||||
let data = Sz3.Single.sz3Decompress x.Length z
|
||||
printfn $"%A{data[0 .. 2]}"
|
||||
printfn $"%A{data[x.Length - 3 .. x.Length - 1]}"
|
||||
// printfn $"%A{data[0 .. 2]}"
|
||||
// printfn $"%A{data[x.Length - 3 .. x.Length - 1]}"
|
||||
data
|
||||
|
||||
let private readSourceProps (src: Uri) =
|
||||
@@ -31,9 +31,7 @@ let private readSourceProps (src: Uri) =
|
||||
match src.Scheme with
|
||||
| "file" ->
|
||||
if src.LocalPath.EndsWith ".nc" then
|
||||
let time = readFvcomTime src.LocalPath
|
||||
printfn $"%A{time}"
|
||||
time
|
||||
readFvcomTime src.LocalPath
|
||||
|> Seq.mapi (fun i t -> t, asyncReadFvcomProps src.LocalPath fvcomProps.Keys i)
|
||||
elif src.LocalPath.EndsWith ".zarr" then
|
||||
// getZarrFiies src.LocalPath
|
||||
@@ -93,30 +91,7 @@ let private writeToDest (dst: Uri) (transform: single[] -> single[]) (source: (i
|
||||
notImplemented "rados/r3"
|
||||
| _ -> failwith "Invalid source URI"
|
||||
|
||||
let copyAction (a: CopyArgs) =
|
||||
let src = a.Source
|
||||
let dst = a.Dest
|
||||
|
||||
let pogonotomizer =
|
||||
if a.Pump then
|
||||
match a.Sz3 with
|
||||
| Some tol -> pumpSz3 tol
|
||||
| None ->
|
||||
match a.Zfp with
|
||||
| Some tol -> pumpZfp tol
|
||||
| None ->
|
||||
let tol = 1e-4
|
||||
pumpZfp tol
|
||||
elif a.Compress then
|
||||
failwith "not implemented"
|
||||
elif a.Decompress then
|
||||
failwith "not implemented"
|
||||
else
|
||||
id
|
||||
|
||||
printfn $"copy {src} -> {dst}"
|
||||
printfn $" {src.Scheme} {src.Host} | {src.LocalPath} | %A{src.Segments}"
|
||||
let sources = readSourceProps src
|
||||
let private peekaBoo sources=
|
||||
sources
|
||||
|> Seq.iter (fun (t, y) ->
|
||||
y
|
||||
@@ -129,4 +104,30 @@ let copyAction (a: CopyArgs) =
|
||||
| W p -> Async.RunSynchronously (p) |> fun k -> Log.Verbose $"W({t}): %A{k[0][0]}"
|
||||
| Z p -> Async.RunSynchronously (p) |> fun k -> Log.Verbose $"Z({t}): %A{k[0]}"
|
||||
| _ -> ()))
|
||||
|
||||
let copyAction (a: CopyArgs) =
|
||||
let src = a.Source
|
||||
let dst = a.Dest
|
||||
|
||||
let pogonotomizer =
|
||||
if a.Wither then
|
||||
match a.Sz3 with
|
||||
| Some tol -> witherSz3 tol
|
||||
| None ->
|
||||
match a.Zfp with
|
||||
| Some tol -> witherZfp tol
|
||||
| None ->
|
||||
let tol = 1e-4
|
||||
witherZfp tol
|
||||
elif a.Compress then
|
||||
failwith "not implemented"
|
||||
elif a.Decompress then
|
||||
failwith "not implemented"
|
||||
else
|
||||
id
|
||||
|
||||
printfn $"copy {src} -> {dst}"
|
||||
// printfn $" {src.Scheme} {src.Host} | {src.LocalPath} | %A{src.Segments}"
|
||||
let sources = readSourceProps src
|
||||
// peekaBoo sources
|
||||
writeToDest dst pogonotomizer sources
|
||||
@@ -12,9 +12,7 @@ let private readSourceProps (src: Uri) =
|
||||
match src.Scheme with
|
||||
| "file" ->
|
||||
if src.LocalPath.EndsWith ".nc" then
|
||||
let time = readFvcomTime src.LocalPath
|
||||
printfn $"%A{time}"
|
||||
time
|
||||
readFvcomTime src.LocalPath
|
||||
|> Seq.mapi (fun i t -> t, asyncReadFvcomProps src.LocalPath fvcomProps.Keys i)
|
||||
elif src.LocalPath.EndsWith ".zarr" then
|
||||
// getZarrFiies src.LocalPath
|
||||
@@ -53,7 +51,6 @@ let private to3D (aa: Async<single[][]>) =
|
||||
let a = aa |> Async.RunSynchronously
|
||||
let n = a.Length
|
||||
let m = a[0].Length
|
||||
printfn $"// {n} - {m}"
|
||||
let a3 = Array3D.zeroCreate 1 n m
|
||||
try
|
||||
for i = 0 to n - 1 do
|
||||
|
||||
@@ -109,7 +109,7 @@ module Single =
|
||||
0UL,
|
||||
n
|
||||
)
|
||||
printfn $"sz3 size: {size}"
|
||||
printfn $"sz3 size: {data.Length * 4} -> {size}"
|
||||
let compressed: byte[] = Array.zeroCreate (int size)
|
||||
Marshal.Copy (p, compressed, 0, int size)
|
||||
Marshal.FreeHGlobal p
|
||||
|
||||
@@ -147,7 +147,7 @@ module private Internal =
|
||||
failwith "zfp_write_header failed!"
|
||||
|
||||
let size = Native.zfp_compress (zstream, field) |> int
|
||||
printfn $"zfp size: {size}"
|
||||
printfn $"zfp size: {int field.nx * 4} -> {size}"
|
||||
|
||||
Native.zfp_stream_close zstream
|
||||
Native.stream_close stream
|
||||
@@ -213,7 +213,7 @@ module Double =
|
||||
|
||||
let zfpDecompress (data: byte[]) : double[] = Internal.decompress<double> data
|
||||
|
||||
module private NativeStruct =
|
||||
module private NativeStructExperimentsProbablyNotWorkingCurrentlyButFeelFreeToImprove =
|
||||
[<StructLayout(LayoutKind.Sequential)>]
|
||||
type ZfpField =
|
||||
struct
|
||||
|
||||
Reference in New Issue
Block a user