85 support output to binary files#97
Conversation
Bring 85 up to date with main
…o-raw' into 85-support-output-to-raw
|
@rogerkuou I don't know what I did wrong with this PR and why it doesn't run the checks and I can just merge it directly already. Could you have a look? |
|
Hi @Simon-van-Diepen , I tried close and reopened this PR and GitHub actions were triggered. It fails on linting and test coverage. Can you fix? Thanks! |
|
Great, thanks @rogerkuou ! I'll fix the failed checks and then re-request the review |
|
Hi @rogerkuou I have added unit tests for all the ways the new function |
|
Hi @Simon-van-Diepen, |
…path add output file test for to_binary
There was a problem hiding this comment.
Hi @Simon-van-Diepen , thanks for this nice implementation!
I would propose one small thing on controlling the behavior of overwriting. Since these raw files can be big, this can avoid users accidentally overwriting some results.
Implementing this means you will need to add 1-2 more unit tests. Thanks in advance for this!
| memmap = np.memmap( | ||
| output_path, | ||
| dtype=datalayer.dtype, | ||
| mode="w+", |
There was a problem hiding this comment.
Here we are always overwriting the existing file. I propose we either add an input arg in the function to control the behavior (default to non-overwriting is safer.) Or at least document this behavior in the function.
I would prefer the first actually.
There was a problem hiding this comment.
I have added an input argument allow_overwrite in 0cdc6ed, and added three unit tests, including one to ensure that the default will remain False.
There unfortunately is no way to address this in np.memmap directly, as w+ is the only mode allowing the creation of new files. The new input argument therefore is the best way to resolve this
rogerkuou
left a comment
There was a problem hiding this comment.
Thanks @Simon-van-Diepen! Please go ahead and merge.
|



Adds:
sarxarray._io.to_binary, allowing the writing of one data variable contained in anxarray.Datasetorxarray.DataArrayto a binary file, preserving the input dtype and shape.to_binaryandcropare now top-level functions, accessible throughsarxarray.to_binaryandsarxarray.crop